export default {
  data() {
    return {
      total: 20,
      loading: false,
      tableData: [],
      tableOptions: {
        maxHeight: 'calc(100vh - 406px)',
        height: 'calc(100vh - 406px)'
      },
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '业务编号',
          prop: 'businessNumber',
          showTooltip: true
        },
        {
          label: '项目名称',
          showTooltip: true,
          prop: 'projectName'
        },
        {
          label: '主企业名称',
          prop: 'ownerName',
          showTooltip: true
        },
        {
          label: '核心企业名称',
          prop: 'customerName',
          showTooltip: true
        },
        {
          label: '当前阶段',
          prop: 'taskName'
        },
        {
          label: '执行人',
          prop: 'assigneeName'
        },

        {
          label: '状态',
          prop: 'status.name'
        },
        {
          label: '操作',
          render: (h, row) => {
            const btnList = [
              { msg: '时间进度轴', icon: 'iconfont icon-timeAxis', tabPower: ['all', 'pending'], category: 'timeAxis' },
              { msg: '修改', icon: 'iconfont icon-xiugai', category: 'edit' },
              { msg: '查看', icon: 'iconfont icon-Magnifier', power: 'viewCreditResolution', category: 'see' }
            ]
            // if(this.btnPermission.includes('viewCreditResolution')) {
            //   btnList.push({ msg: '查看', icon: 'see', power: 'viewCreditResolution', category: 'see' })
            // }
            const options = btnList.map(item => {
              return (
                this.tablePower({ item }) && (item.icon === 'see' ? (<el-tooltip class='item' effect='dark' content={item.msg} placement='top'>
                  <span class='table-icon-box' onClick={() => { this.handlerOperate(item.category, row) }}>
                    <svg-icon icon-class='see' class='table-svg-icon'></svg-icon>
                  </span>
                </el-tooltip>) : (
                  <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) }} />
                    </span>
                  </el-tooltip>)
                )
              )
            })
            return <div>{ options }</div>
          },
          width: 200
        }
      ],
      columnsAll: [
        {
          label: '序号',
          index: true
        },
        {
          label: '业务编号',
          prop: 'businessNumber',
          showTooltip: true
        },
        {
          label: '项目名称',
          showTooltip: true,
          prop: 'projectName'
        },
        {
          label: '主企业名称',
          prop: 'ownerName',
          showTooltip: true
        },
        {
          label: '核心企业名称',
          prop: 'customerName',
          showTooltip: true
        },
        {
          label: '状态',
          prop: 'statusStr'
        },
        {
          label: '操作',
          render: (h, row) => {
            const btnList = [
              { msg: '时间进度轴', icon: 'iconfont icon-timeAxis', tabPower: ['all', 'pending'], category: 'timeAxis' },
              { msg: '查看', icon: 'iconfont icon-Magnifier', power: 'viewCreditResolution', category: 'see' }
            ]
            const options = btnList.map(item => {
              return (
                this.tablePower({ item }) && (item.icon === 'see' ? (<el-tooltip class='item' effect='dark' content={item.msg} placement='top'>
                  <span class='table-icon-box' onClick={() => { this.handlerOperate(item.category, row) }}>
                    <svg-icon icon-class='see' class='table-svg-icon'></svg-icon>
                  </span>
                </el-tooltip>) : (
                  <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) }} />
                    </span>
                  </el-tooltip>
                ))
              )
            })
            return <div>{ options }</div>
          },
          width: 200
        }
      ]
    }
  },
  computed: {
    tablePower() {
      return ({ item }) => {
        const { power } = item
        if (power && !this.btnPermission.includes(power)) {
          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)'
      }
    }
  }
}
