<template>
  <div class="table-wrap">
    <el-table :data="tableData" ref="tableRef" highlight-current-row size="mini" stripe border>

      <el-table-column type="index" label="序号"  width="60" show-overflow-tooltip>
      </el-table-column>

      <el-table-column v-for="(item, index) in colunms" :key="index"
            :prop="item.prop"
            :label="item.label"
            :fixed="item.fixed"
            :formatter="formatter"
            :class-name="item.prop =='status'?'c357F':'' "
            :show-overflow-tooltip="item.tooltip"
            :min-width="item.width"
            >
      </el-table-column>

    </el-table>

  </div>
</template>

<script>
  export default {
    name: 'document-table',
    created() {
      this.doQuery();
    },
    mounted() {

    },
    methods: {
      // 查询数据
      doQuery () {
        let param = {
          busId: this.projectid,
          modelId: 3101,
        };
        this.$ajax.post({
          domain: 'crmUrl',
          url: 'project.listProjectFile',
          data: param,
          requestType: 'body',
          showLoad: true,
          success: function (res) {
            if (res.errorCode === 200) {
                this.tableData = res.data || [];
            }
          }.bind(this),
          error: function (res) {
            this.$message({
              type: 'error',
              message: res.body.msg || res.msg
            })
          }.bind(this)
        })
      },
      formatter(row, column, cellValue, index){
           if(column.property == 'status'){
               if(row.status == 1 ){
                 return '有效';
               }  else {
                 return '无效';
               }
           } else if(column.property == 'fileSize'){
             return row.fileSize  + "KB";
           }  else if(column.property == 'fileIndate'){
             if(row.fileIndate){
               if(this.$common.compareDate(row.fileIndate)){
                 return '生效中';
               } else {
                 return '已失效';
               }
             } else if(row.isFlag){
               if(row.isFlag === 1){
                 return '生效中';
               }
             }
           }
           else {
             return cellValue;
           }
       },

    },
    props: ['projectid'],
    data() {
      return {

        tableData: [],
        //表格列
        colunms: [
           { prop: 'fileName', label: '文件名称',   width: 120, fixed: false,  tooltip: true },
           { prop: 'fileVersion', label: '版本',   width: 100, fixed: false,  tooltip: true },
           { prop: 'fileTypeKey', label: '文件类型',   width: 100, fixed: false,  tooltip: true },
           { prop: 'signMainPartKey', label: '签订主体',   width: 100, fixed: false,  tooltip: true },
           { prop: 'fileIndate', label: '文件有效期',   width: 100, fixed: false,  tooltip: true },
           { prop: 'fileSuffix', label: '附件格式',   width: 100, fixed: false,  tooltip: true },
           { prop: 'fileSize', label: '文件大小',   width: 100, fixed: false,  tooltip: true },
           { prop: 'createTime', label: '上传时间',   width: 100, fixed: false,  tooltip: true },
           { prop: 'updater', label: '上传人员',   width: 100, fixed: false,  tooltip: true },
           { prop: 'status', label: '文件状态',   width: 100, fixed: false,  tooltip: true },
           { prop: 'remark', label: '备注说明',   width: 100, fixed: false,  tooltip: true },
        ],

      }
    },

  }
</script>

<style>
</style>
