<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 fujian">
            <a class="fujian" :href="devapi + site.path">{{site.name}} </a>
          </span></el-col>
        </el-row>
      </el-card>
      <el-row>
        <p class="text">
          <el-row>
            <!--{{form}}-->
            <span v-html="form.mailContent"></span>
          </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:'',
        fujianName:'',
        fujian:[],
        devapi:'',
        mailDetailGuid:this.$route.query.id
      };
    },
    created() {
      this.info()
      this.getList();
      this.asd();


    },
    methods: {
      info(row){
        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;
          this.fujianName = this.form.fileName;
          // console.log(response.data);
          this.fujianpath =this.fujianpath.split(',')
          this.fujianName =this.fujianName.split(',')
          for(var i=0;i< this.fujianName.length;i++){
            this.fujian.push({
              "path": this.fujianpath[i],
              "name":this.fujianName[i]
            });
          }
          this.devapi = process.env.VUE_APP_BASE_API
        });
      },
      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;
        });
      },

      watch: {
        // 监听相同路由下参数变化的时候，从而实现异步刷新
        '$route':function(newUrl,oldUrl){
            this.fujian = [];
          this.mailGuid=this.$route.query.id
        },
        mailDetailGuid: function() {
          this.info()
        }
      }
    }
  }
</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;
    text-align: left;
  }
  .hg{
    line-height: 30px;
  }
  .text{
    span{
      /*margin: 20px;*/
    }
    padding: 0 20px;
  }

</style>
