<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <img src="../../assets/image/sq.png" style="display: block;float: left;margin: 1px 5px 0 0;" height="15" width="17"/>
      <span>我的通知</span>
      <el-button style="float: right; padding: 3px 0;color: #000000;" type="text" @click="more">更多</el-button>
    </div>
    <el-table v-loading="loading" :data="infoList" size="mini"  >
      <el-table-column label="标题"style="color:#1890ff"  prop="tatle" align="left"  :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <el-button type="text" @click="handleUpdate(scope.row)"  style="color: #606266;">{{scope.row.title}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="发布日期" align="right" width="180" prop="updateTime" :show-header="showHeader" >
        <template slot-scope="scope">
          <el-button type="text"  style="color: #606266">{{parseTime(scope.row.sendtime,'{y}-{m}-{d}')}}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 通知详情 -->
    <el-dialog :title="tztitle" :visible.sync="tzshow" width="1000px" append-to-body>
      <el-form :model="form" label-width="100px"  v-loading="xxloading">
        <el-form-item label="通知标题" prop="Title">
          <el-input v-model="form.title" placeholder="请输入通知标题" clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
        <el-form-item label="通知内容" prop="Content" style="height: 240px;">
          <div v-html="form.content" style="border: 1px solid #e5e5e5;border-radius: 4px;"></div>
        </el-form-item>
        <el-form-item label="附件列表：">
          <div v-html="form.fj" style="border: 1px solid #e5e5e5;border-radius: 4px;">{{form.fj}}</div>
        </el-form-item>
        <el-form-item label="发送时间：">{{form.sendtime}}
        </el-form-item>
        <el-form-item label="联系人" prop="contactPerson">
          <el-input v-model="form.contactperson" clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
        <el-form-item label="联系电话" prop="contactTel">
          <el-input v-model="form.contacttel"  clearable :style="{width: '100%'}">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </el-card>
</template>
<script>
  import { listInfo, xxInfo} from "@/api/system/notify_info/mylist";
  import log from '../monitor/job/log'
  export default {
    name: "Info",
    data() {
      return {
        tzshow:false,
        xxloading:true,
        showHeader:true,
// 遮罩层
        loading: true,
// 选中数组
        ids: [],
// 非单个禁用
        single: true,
// 非多个禁用
        multiple: true,
// 总条数
        total: 0,
// 【请填写功能名称】表格数据
        infoList: [],
// 弹出层标题
        title: "",
// 是否显示弹出层
        open: false,
// 查询参数
        queryParams: {
          pageNum: 1,
          pageSize:6,
          orderByColumn:"sendtime",//排序字段
          isAsc:"desc",//排序方式
        },
// 表单参数
        form: {},
// 表单校验
        rules: {
          guid: [
            {required: true, message: "收件人不能为空", trigger: "blur"}
          ],
        },
        tztitle: "通知详情",
      };
    },
    created() {
      this.getList();
    },
    methods: {
      // 取消按钮
      cancel() {
        this.tzshow = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          guid: undefined,
          title: undefined,
          content: undefined,
          sendtime: undefined,
          filename: undefined,
          filepath: undefined,
          contactperson: undefined,
          contacttel: undefined,
          recvperson: undefined
        };
        this.resetForm("form");
      },
      /** 查询【请填写功能名称】列表 */
      getList() {
        this.loading = true;
        listInfo(this.queryParams).then(response => {
          this.infoList = response.rows;
          this.loading = false;
          let result=response.rows;
          this.$emit('getNum','tz',response.total)
        });
      },
      /** 详情按钮操作 */
      handleUpdate(row) {
        /** 详细按钮操作 */
        this.reset();
        this.tzshow=true;
        this.xxloading=true;
        xxInfo(row.id).then(response => {
          this.form.title = response.data.title;
          this.form.content = response.data.content;
          this.form.sendtime = response.data.sendtime;
          this.form.contactperson = response.data.contactperson;
          this.form.contacttel = response.data.contacttel;
          this.form.fj = "";
          let fjname=response.data.filename.split(",");
          let fjpath=response.data.filepath.split(",");
          for (let i = 0; i <fjname.length ; i++) {
            this.form.fj+="<a href='"+process.env.VUE_APP_BASE_API+fjpath[i]+"' target='_blank'>"+fjname[i]+'</a><br/>';
          }
        });
        this.xxloading=false;
      },
      //指定跳转地址
      more(){
        this.$router.replace('/mylist')
      },

    }
  }
</script>
<style lang="less" scoped>
  .box-card {
    margin-left: 6px;
    height: 407px;
  }

  .clearfix {
    color: #1890ff;
  }

  .text {
    font-size: 14px;
  }

  .item {
    height: 44px;
    line-height: 44px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }

  .clearfix:after {
    clear: both
  }

  .el-card__header {
    background: #f5f5f5;
    color: #1890ff;
  }
</style>
