export default {
  data() {
    return {
      total: 0,
      loading: false,
      tableData: [],
      tableOptions: {
        sortTable: true,
        maxHeight: 'calc(100vh - 406px)',
        height: 'calc(100vh - 406px)'
      },
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '业务编号',
          prop: 'businessNumber',
          showTooltip: true,
          width: 150
        },
        {
          label: '项目名称',
          showTooltip: true,
          prop: 'projectName',
          width: 150
        },
        {
          label: '主企业名称',
          prop: 'supplierName',
          showTooltip: true,
          width: 120
        },
        {
          label: '核心企业名称',
          prop: 'customerName',
          showTooltip: true,
          width: 120
        },
        {
          label: '贸易平台',
          prop: 'platformName',
          showTooltip: true
        },
        {
          label: '当前阶段',
          prop: 'taskName',
          showTooltip: true
        },
        {
          label: '执行人',
          prop: 'executor',
          showTooltip: true
        },
        {
          label: '状态',
          prop: 'status.name',
          showTooltip: true
        },
        {
          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',
                power: 'viewBiddingBasicInfo',
                tabPower: ['pending', 'all'],
                category: 'see'
              }
            ]
            const options = btnList.map(item => {
              return (
                this.tablePower({ item, tab: this.activeName }) &&
                <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: 200
        }
      ]
    }
  },
  computed: {
    tablePower() {
      return ({ item, tab }) => {
        const { tabPower, power } = item
        if (power && !this.btnPermission.includes(power)) {
          return false
        }
        if (tabPower && !tabPower.includes(tab)) {
          return false
        }
        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)'
      }
    }
  }
}
