export default {
  data() {
    return {
      total: 20,
      loading: false,
      tableData: [

      ],
      tableOptions: {
        sortTable: true,
        maxHeight: 'calc(100vh - 406px)',
        height: 'calc(100vh - 406px)'
      },
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '验收单编号',
          prop: 'moduleNumber',
          showTooltip: true
        },
        {
          label: '业务编号',
          prop: 'businessNumber',
          showTooltip: true
        },
        {
          label: '项目名称',
          showTooltip: true,
          prop: 'projectName'
        },
        {
          label: '主企业名称',
          showTooltip: true,
          prop: 'supplierName'
        },
        {
          label: '核心企业名称',
          showTooltip: true,
          prop: 'customerName'
        },
        {
          label: '贸易平台',
          prop: 'platformName',
          showTooltip: true
        },
        {
          label: '当前阶段',
          prop: 'taskName',
          showTooltip: true
        },
        {
          label: '执行人',
          prop: 'assigneeName',
          showTooltip: true
        },
        {
          label: '状态',
          prop: 'status',
          showTooltip: true,
          render: (h, row) => {
            let statusStr = ''
            switch (row.statusStr) {
              case 'project_init_processing': statusStr = '处理中'
                break
              case 'project_init_completed': statusStr = '已完成'
                break
              case 'project_init_terminated': statusStr = '已终止'
                break
              case 'project_init_cancelled': statusStr = '已解除'
                break
            }
            return <span>{ statusStr }</span>
          }
        },
        {
          label: '操作',
          show: true,
          render: (h, row) => {
            const btnList = [
              {
                msg: '时间进度轴',
                icon: 'iconfont icon-timeAxis',
                tabPower: ['all', 'pending'],
                category: 'timeAxis'
              },
              {
                msg: '处理',
                icon: 'iconfont icon-xiugai',
                tabPower: ['pending'],
                category: 'edit'
              },
              {
                msg: '查看',
                icon: 'iconfont icon-Magnifier',
                tabPower: ['all'],
                power: 'showAcceptance',
                category: 'see'
              },
              { msg: '下载', icon: 'iconfont icon-xiazai', power: 'downloadAllAcceptanceFile', tabPower: ['all'], category: 'download' },
              { msg: '下载出证文件', icon: 'iconfont icon-xiazai', power: 'downloadAcceptanceFileCertificate', tabPower: ['all'], category: 'downloadBook' }
            ]
            const options = btnList.map(item => {
              return (
                this.tablePower({ item, tab: this.activeName, row }) &&
                <el-tooltip class='item' effect='dark' content={item.msg} placement='top' >
                  <span class='table-icon-box'>
                    <i class={item.icon} onClick={() => { this.handlerOperate(item.category, row) }}></i>
                  </span>
                </el-tooltip>
              )
            })
            return <div>{ options }</div>
          },
          width: 160
        }
      ]
    }
  },
  computed: {
    tablePower() {
      return ({ item, tab, row }) => {
        const { tabPower, power } = item
        if (power) {
          if (tabPower.includes(tab) && JSON.parse(sessionStorage.getItem('buttons')).includes(power)) {
            return true
          }
        } else {
          if (tabPower.includes(tab)) {
            return true
          }
        }
      }
    },
    getTableOptions() {
      if (this.activeName === 'all') {
        return {
          sortTable: true,
          maxHeight: 'calc(100vh - 406px)',
          height: 'calc(100vh - 406px)'
        }
      }
      if (this.total > 0) {
        return {
          sortTable: true,
          maxHeight: 'calc(100vh - 360px)',
          height: 'calc(100vh - 360px)'
        }
      }
      return {
        sortTable: true,
        maxHeight: 'calc(100vh - 306px)',
        height: 'calc(100vh - 306px)'
      }
    }
  }
}
