<template>
  <el-card class="box-card">

    <el-row slot="header" class="clearfix">
      <span>公示公告</span>
      <el-button style="float: right; padding: 5px 0;color: black;" type="text" @click="more">更   多</el-button>
    </el-row>
    <el-table v-loading="loading" :data="mesList" size="small" :show-header="showHeader">
      <el-table-column label="标题"style="color:#1890ff"  prop="tatle" align="left"  :show-header="showHeader">
        <template slot-scope="scope">
          <el-button type="text" @click="handleUpdate(scope.row)" style="color: black">{{scope.row.tatle}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="发布日期" align="right"prop="updateTime" :show-header="showHeader" >
      <template slot-scope="scope">
        <el-button type="text" @click="handleUpdate(scope.row)" style="color: black">{{parseTime(scope.row.updateTime,'{y}-{m}-{d}')}}</el-button>
      </template>
      </el-table-column>
    </el-table>
    <!-- 详情对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="63%" :show-close="true" append-to-body  >
      <el-container>
        <el-form ref="form" :model="form"  style="width: 100%;">
          <el-form-item label="" prop="tatle" >
            <el-header><span>{{this.form.tatle}}</span></el-header>
          </el-form-item>
          <el-form-item label=""prop="updateTime">
            <el-footer><span>{{"发布日期 : "+parseTime(this.form.updateTime,'{y}-{m}-{d}')}}</span></el-footer>
          </el-form-item>
          <el-divider></el-divider>
          <el-form-item label="" prop="fileDetails">
            <el-main><span v-html="this.form.fileDetails"></span></el-main>
          </el-form-item>
        </el-form>
      </el-container>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancel">关    闭</el-button>
      </div>
    </el-dialog>
  </el-card>
</template>
<script>
  import { listMesOne,getMes } from "@/api/information/mes";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  export default {
    components: {},
    data() {
      return {
        showHeader:true,
        //下拉选框
        content: this.value,
        radio: '1',
        fileList: [],
        status:'',
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        // 【请填写功能名称】表格数据
        mesList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize:5,
          tatle: undefined,
          documentType: undefined,
          img: undefined,
          putFilePath: undefined,
          fileDetails: undefined,
          xsState: undefined,
          typeId: undefined,
          flg: undefined,
          submitTime: undefined,
          lastUpdate: undefined
        },
        // 表单参数
        form: {}
      };
    },
    created() {
      this.getList();

    },
    methods: {
      more(){
        this.$router.push({path:'/information/more'})
      },
      getList() {
        this.loading = true;
        listMesOne(this.queryParams).then(response => {
          this.mesList = response.rows;
          this.loading = false;
          console.log(response.rows)
          let result=response.rows;
          for (let i = 0; i <response.rows.length ; i++) {
            if (result[i].tatle.length>10){
              result[i].tatle=result[i].tatle.substring(0,10)+"...";
            }
          }
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          tatle: undefined,
          documentType: [],
          img: undefined,
          putFilePath: undefined,
          fileDetails: undefined,
          xsState: undefined,
          typeId: undefined,
          flg: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          remark: undefined,
        };
        this.resetForm("form");
      },
      /** 详情按钮操作 */
      handleUpdate(row) {
       // alert("111")
        this.reset();
        const id = row.id || this.ids
        getMes(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.form = response.data;
          this.status = response.data.status;
        })
      },

    }
  }
</script>

<style lang="less" scoped>
  .box-card{
    margin-left: 16px;
    height: 400px;
  }
  .el-table{
    color:#1890ff;
  }
  .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;
  }
  .el-header{
    color:red;
    width: 100%;
    text-align: center;
    line-height: 60px;
    font-size: 30px;
    font-weight: bold;
  }
  .el-footer{
    text-align: center;
    height: 40px !important;
    line-height: 40px;
    font-size: 18px;
  }
  .el-form-item{
    margin-bottom: 0 !important;
  }
  .el-divider--horizontal {
    display: block;
    height: 1px;
    width: 90% !important;
    margin: 10px 50px !important;
  }
  .el-main{
    padding: 0 70px !important;
  }
</style>
