<template>
  <!--发件箱详情 只查不改-->
  <div class="box">
    <input hidden="hidden" id="keys" v-model="mailGuid"></input>
    <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.createTime | format('yyyy-MM-dd hh:mm:ss')}}</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" target="_blank">{{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";
  import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo } from "@/api/system/email/info";

  export default {
    name: 'senddetails',
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        // 【请填写功能名称】表格数据
        infoList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        open1: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          senderName: undefined,
          senderAccount: undefined,
          receiverName: undefined,
          receiverAccount: undefined,
          mailTheme: undefined,
          mailContent: undefined,
          status: undefined,
          deleteTime: undefined
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        fujianpath:'',
        fujianName:'',
        fujian:[],
        devapi:'',
        mailGuid:this.$route.query.id
      };
    },
    created() {
      this.info();
      this.getList();
    },
    methods: {
      info(row){
        getInfo(this.mailGuid).then(response => {
          this.form = response.data;
          console.log(response.data)
          this.fujianpath =response.data.filePath.split(',')
          this.fujianName =response.data.fileName.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
          // this.open = true;
          // this.title = "修改【请填写功能名称】";
        });
      },
      openda(){
        this.open1 = false;
      },
      /** 查询【请填写功能名称】列表 */
      getList() {
        this.loading = true;
        listInfo(this.queryParams).then(response => {
          this.infoList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          mailGuid: undefined,
          senderName: undefined,
          senderAccount: undefined,
          receiverName: undefined,
          receiverAccount: undefined,
          mailTheme: undefined,
          mailContent: undefined,
          createTime: 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.mailGuid)
        this.single = selection.length!=1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加【请填写功能名称】";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const mailGuid = row.mailGuid || this.ids
        getInfo(mailGuid).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "邮件详情";
        });
      },
      handleUpdate1(row) {
        this.reset();
        const mailGuid = row.mailGuid || this.ids
        // this.$router.push({path:'/Emile/receiveList/senddetails',query: {id:mailGuid }})
        getInfo(mailGuid).then(response => {
          this.form = response.data;
          // this.open1 = true;
          this.title = "修改【请填写功能名称】";
        });
      },

    },
    watch: {
      // 监听相同路由下参数变化的时候，从而实现异步刷新
      '$route':function(newUrl,oldUrl){
          this.fujian = [];
        this.mailGuid=this.$route.query.id
      },
      mailGuid: 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{

    padding: 0 20px;
    overflow: auto;
  }
  .fujian{
  padding-right: 10px;
   }
</style>
