export default {
  data() {
    return {
      total: 0,
      loading: false,
      tableData: [],
      tableOptions: {
        sortTable: true,
        maxHeight: 'calc(100vh - 260px)',
        height: 'calc(100vh - 260px)'
      },
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '销售合同编号',
          prop: 'contractNumber',
          showTooltip: 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: 'platformName',
          showTooltip: true
        },
        {
          label: '当前阶段',
          prop: 'stage',
          showTooltip: true
        },
        {
          label: '状态',
          prop: 'status',
          showTooltip: true
        },
        {
          label: '操作',
          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: ['销售合同创建', '销售合同录入', '签署确认', '变更合同创建', '变更信息录入', '变更签署确认']
              },
              {
                msg: '变更',
                icon: 'iconfont icon-orange icon-a-Group990',
                power: 'projectNumber:delete',
                category: 'change',
                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) || rowPower.includes(row.status)) {
            return true
          }
        } else {
          return true
        }
      }
    }
  }
}
