export default {
  data() {
    return {
      tableOptions: {
        sortTable: true,
        maxHeight: 'calc(100vh - 280px)',
        height: 'calc(100vh - 280px)'
      },
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '业务编号',
          prop: 'businessNumber',
          showTooltip: true,
          width: 150
        },
        {
          label: '项目名称',
          showTooltip: true,
          prop: 'projectName',
          width: 150
        },
        {
          label: '主企业名称',
          prop: 'mainEnterprise',
          width: 120,
          showTooltip: true
        },
        {
          label: '核心企业名称',
          prop: 'enterprise',
          width: 120,
          showTooltip: true
        },
        {
          label: '贸易平台',
          prop: 'platform',
          showTooltip: true
        },
        {
          label: '当前阶段',
          prop: 'stage',
          showTooltip: true
        },
        {
          label: '状态',
          prop: 'status',
          showTooltip: true
        },
        {
          label: '操作',
          show: true,
          render: (h, row) => {
            const btnList = [
              {
                msg: '查看',
                icon: 'iconfont icon-orange icon-a-Group957',
                power: 'projectNumber:delete',
                category: 'see'
              },
              {
                msg: '编辑',
                icon: 'iconfont icon-orange icon-a-Group8151',
                power: 'projectNumber:delete',
                category: 'edit',
                rowPower: ['业务创建']
              }
            ]
            const options = btnList.map(item => {
              return (
                this.tablePower({ item, 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: 200
        }
      ]
    }
  },
  computed: {
    tablePower() {
      return ({ item, row }) => {
        const { rowPower } = item
        if (rowPower) {
          if (rowPower.includes(row.stage)) {
            return true
          }
        } else {
          return true
        }
      }
    }
  }
}
