<template>
    <div class="box">
      <el-card class="box-card">
        <el-row class="title">
          编号为1的邮件
        </el-row>
        <el-row :gutter="80">
          <el-col :span="1">
            <el-tag>发件人</el-tag>
          </el-col >
          <el-col :span="22"><span class="hg">{{form.senderName}}</span></el-col>
        </el-row>
        <el-row :gutter="80">
          <el-col :span="1">
            <el-tag>时 间</el-tag>
          </el-col >
          <el-col :span="22"><span class="hg">{{form.readTime}}</span></el-col>
        </el-row>
        <el-row :gutter="80">
          <el-col :span="1">
            <el-tag>收件人</el-tag>
          </el-col >
          <el-col :span="22"><span class="hg">{{form.receiverName}}</span></el-col>
        </el-row>
        <el-row :gutter="80">
          <el-col :span="1">
            <el-tag>邮件主题</el-tag>
          </el-col >
          <el-col :span="22"><span class="hg">{{form.mailTheme}}</span></el-col>
        </el-row>
        <!--<el-row :gutter="80">-->
          <!--<el-col :span="1">-->
            <!--<el-tag>附件</el-tag>-->
          <!--</el-col >-->
          <!--<el-col :span="22">-->
            <!--<span class="hg" v-for="site in fujianpath">-->
            <!--<img  :src="devapi + site" alt="">-->
          <!--</span></el-col>-->
        <!--</el-row>-->
      </el-card>
      <el-row>
        <p class="text">
          <el-row>
            <span class="hg" v-for="site in fujianpath">
            <img  :src="devapi + site" alt="">
          </span>
          </el-row>
          <el-row>
            {{form.mailContent}}
          </el-row>


        </p>
      </el-row>

    </div>
</template>

<script>
  import { listDetail, getDetail, delDetail, addDetail, updateDetail, exportDetail } from "@/api/system/email/detail";

  export default {
    name: 'receiptdetails',
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        names:[],
        // 非单个禁用
        single: true,
        single1: true,
        // 非多个禁用
        multiple: true,
        multiple1: true,
        // 总条数
        total: 0,
        // 【请填写功能名称】表格数据
        detailList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          mailGuid: undefined,
          receiverName: undefined,
          receiverAccount: undefined,
          readFlag: undefined,
          readTime: undefined,
          status: undefined,
          deleteTime: undefined,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        },
        fujianpath:'',
        devapi:'',
      };
    },
    created() {
      this.info()
      this.getList();
      this.asd();


    },
    methods: {
      info(row){
        // console.log(this.$route.params)
        // console.log(senderName);
        // this.$route.params
        // console.log(this.$route.query.senderName[0])
        // this.username = this.$route.params;
        // this.receiverName = this.$route.params
        console.log(this.$route.query.id);
        // console.log(this.$route.params);
        const mailDetailGuid = this.$route.query.id
        getDetail(mailDetailGuid).then(response => {
          // this.form = response.data;
          this.form = response.data[0];
          this.fujianpath = this.form.filePath;
          // console.log(response.data);
          this.fujianpath =this.fujianpath.split(',')
          this.devapi = process.env.VUE_APP_BASE_API
          // this.open = true;
          // this.title = "修改【请填写功能名称】";
        });
      },
      asd(){
        var str = this.path;
        var res = str.split(',')
        console.log(res);
      },


      /** 查询【请填写功能名称】列表 */
      getList() {
        this.loading = true;
        listDetail(this.queryParams).then(response => {
          this.detailList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
        this.getList();
      },
      // 表单重置
      reset() {
        this.form = {
          mailDetailGuid: undefined,
          mailGuid: undefined,
          receiverName: undefined,
          receiverAccount: undefined,
          readFlag: undefined,
          readTime: undefined,
          status: "0",
          deleteTime: undefined
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.mailDetailGuid)
        this.names = selection.map(item => item.senderName)
        this.single = selection.length!=1
        this.single1 = selection.length!=1
        this.multiple = !selection.length
        this.multiple1 = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加【请填写功能名称】";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {



        // this.reset();
        const mailDetailGuid = row.mailDetailGuid || this.ids
        console.log(mailDetailGuid);
        this.$router.push({path:'/Emile/receiveList/xiangqing',query: {id:mailDetailGuid[0] }})

        getDetail(mailDetailGuid).then(response => {
          // this.form = response.data;
          this.form = response.data[0];
          console.log(response.data);
          // this.open = true;
          this.title = "修改【请填写功能名称】";
        });
      },
      /** 提交按钮 */
      submitForm: function() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.mailDetailGuid != undefined) {
              updateDetail(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                }
              });
            } else {
              addDetail(this.form).then(response => {
                if (response.code === 200) {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
                }
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const mailDetailGuids = row.mailDetailGuid || this.ids;
        console.log(mailDetailGuids);
        this.$confirm('是否确认删除【请填写功能名称】编号为"' + mailDetailGuids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delDetail(mailDetailGuids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有【请填写功能名称】数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportDetail(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
      }
    }
  }
</script>

<style lang="less" scoped>
  .box{
    margin: 10px;
    background: #eff2f7;
  }
  .box-card{
    background: #eff2f7;
  }
  .el-row{
    margin-bottom: 8px;
  }
  .el-tag{
    margin-right: 10px;
  }
  .title{
    font-size: 20px;
  }
  .hg{
    line-height: 30px;
  }
  .text{
    span{
      margin: 20px;
    }
    padding: 0 20px;
  }

</style>
