export default {
  data() {
    return {
      total: 20,
      loading: false,
      tableOptions: {
        maxHeight: 'calc(100vh - 470px)',
        height: 'calc(100vh - 470px)'
      },
      tableData: [

      ],
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '业务编号',
          prop: 'businessNumber',
          showTooltip: true
        },
        {
          label: '项目名称',
          showTooltip: true,
          prop: 'projectName'
        },
        {
          label: '主企业名称',
          showTooltip: true,
          prop: 'ownerName'
        },
        {
          label: '核心企业名称',
          showTooltip: true,
          prop: 'customerName'
        },
        {
          label: '项目准入结果',
          prop: 'projectStatusStr',
          showTooltip: true
        },
        {
          label: '核心企业准入结果',
          prop: 'coreStatusStr'
        },
        {
          label: '执行人',
          prop: 'assigneeName'
        },
        // {
        //   label: '状态',
        //   prop: 'inDate'
        // },
        {
          label: '最近提交时间',
          prop: 'gmtModified'
        },
        {
          label: '操作',
          render: (h, row) => {
            const btnList = [
              {
                msg: '时间进度轴',
                icon: 'iconfont icon-timeAxis',
                category: 'timeAxis'
              },
              { msg: '尽调审核', icon: 'iconfont icon-xiugai', category: 'edit' }
              // {
              //   msg: '查看',
              //   icon: 'iconfont icon-Magnifier',
              //   power: 'viewProjectCoreEnterprise',
              //   category: 'view'
              // }
            ]
            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) }} />
                  </span>
                </el-tooltip>
              )
            })
            return <div>{ options }</div>
          },
          width: 150
        }
      ],
      columnsAll: [
        {
          label: '序号',
          index: true
        },
        {
          label: '业务编号',
          prop: 'businessNumber',
          showTooltip: true
        },
        {
          label: '项目名称',
          showTooltip: true,
          prop: 'projectName'
        },
        {
          label: '主企业名称',
          showTooltip: true,
          prop: 'supplierName'
        },
        {
          label: '核心企业名称',
          showTooltip: true,
          prop: 'customerName'
        },
        {
          label: '项目准入结果',
          prop: 'projectStatusStr',
          showTooltip: true
        },
        {
          label: '核心企业准入结果',
          prop: 'coreStatusStr'
        },
        {
          label: '未通过原因',
          prop: 'errorsString',
          showTooltip: true
        },
        {
          label: '是否流程授信',
          prop: 'process',
          showTooltip: true,
          render: (h, row) => {
            return <span>{ row.process ? '是' : '否' }</span>
          }
        },
        {
          label: '执行人',
          prop: 'assigneeName'
        },
        {
          label: '最近提交时间',
          prop: 'gmtModified'
        },
        {
          label: '操作',
          render: (h, row) => {
            const btnList = [
              { msg: '时间进度轴', icon: 'iconfont icon-timeAxis', category: 'timeAxis' }
            ]
            if (row.coreStatusStr === '尽调审核' || row.coreStatusStr === '授信成功') {
              btnList.push({ msg: '查看', icon: 'iconfont icon-Magnifier', power: 'viewProjectCoreEnterprise', category: 'view' })
            }
            if (row.coreStatusStr === '授信成功') {
              btnList.push({ msg: '准入报告', icon: 'thin-icon el-icon-notebook-2', power: 'viewProjectCoreEnterprise', category: 'report' })
              btnList.push({ msg: '下载报告', icon: 'iconfont icon-xiazai', power: 'downloadProjectReport', category: 'download' })
            }
            const options = btnList.map(item => {
              return item.category === 'see' ? (
                this.tablePower({ item, row }) &&
                <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>
              ) : (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) }} />
                  </span>
                </el-tooltip>
              )
            })
            return <div>{ options }</div>
          },
          width: 180
        }
      ]
    }
  },
  computed: {
    tablePower() {
      return ({ item, row }) => {
        const { power } = item
        if (power) {
          if (JSON.parse(sessionStorage.getItem('buttons')).includes(power)) {
            return true
          }
        } else {
          return true
        }
      }
    }
  }
}
