export default {
  data() {
    return {
      total: 20,
      loading: false,
      tableData: [

      ],
      tableOptions: {
        sortTable: true,
        maxHeight: 'calc(100vh - 260px)',
        height: 'calc(100vh - 260px)'
      },
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '验收单编号',
          prop: 'acceptanceNumber',
          showTooltip: true,
          width: 120
        },
        {
          label: '业务编号',
          showTooltip: true,
          prop: 'businessNumber'
        },
        {
          label: '项目名称',
          prop: 'projectName',
          showTooltip: true
        },
        {
          label: '主企业名称',
          prop: 'supplierName',
          showTooltip: true
        },
        {
          label: '核心企业名称',
          prop: 'coreEnterpriseName',
          showTooltip: true
        },
        {
          label: '贸易平台',
          prop: 'platformName',
          showTooltip: true
        },
        {
          label: '货物数量',
          prop: 'goodsQuantity',
          showTooltip: true
        },
        {
          label: '预计结算日期',
          prop: 'expectedSettlementDate',
          showTooltip: true,
          render: (h, row) => {
            return <span>{ row.expectedSettlementDate.split(' ')[0] }</span>
          }
        },
        {
          label: '当前阶段',
          prop: 'stage',
          showTooltip: true
        },
        {
          label: '状态',
          prop: 'status',
          showTooltip: true
        },
        {
          label: '操作',
          show: this.$route.query.type !== 'details',
          render: (h, row) => {
            const btnList = []
            if (row.stage === '' && row.status === '' || row.stage === null && row.status === null) { // 暂存和不申请审核  状态为空
              // 申请审核状态/暂存状态的查看
              btnList.push({
                msg: '查看',
                icon: 'iconfont icon-orange icon-a-Group957',
                category: 'view'
              })
              if (row.submitStatus === 0) { // 暂存状态
                btnList.push({
                  msg: '编辑',
                  icon: 'iconfont icon-orange icon-a-Group8151',
                  category: 'edit'
                })
              } else {
                btnList.push({
                  msg: '申请融资',
                  icon: 'iconfont icon-orange icon-a-Group8151',
                  category: 'apply'
                })
              }
            } else if (row.status === '处理中') {
              // 流程节点查看
              btnList.push({
                msg: '查看',
                icon: 'iconfont icon-orange icon-a-Group957',
                category: 'see'
              })
              if (row.stage === '录入验收单' || row.stage === '签署确认') {
                btnList.push({
                  msg: '处理',
                  icon: 'iconfont icon-orange icon-a-Group8151',
                  category: 'edit',
                  rowPower: ['录入验收单', '签署确认']
                })
              } else if (row.stage.includes('单价调整') && row.showPriceChange) {
                btnList.push({
                  msg: '单价调整',
                  icon: 'iconfont icon-orange icon-a-Group990',
                  category: 'change'
                })
              }
            } else if (row.status === '已完成') {
              btnList.push({ msg: '查看', icon: 'iconfont icon-orange icon-a-Group957', category: 'see' })
              if (row.businessApprovalStatus === 1 && row.stage === '业务经理审核通过') {
                btnList.push({
                  msg: '申请融资',
                  icon: 'iconfont icon-orange icon-a-Group8151',
                  category: 'apply'
                })
              }
              if (row.showPriceChange && row.stage !== '业务经理审核通过') {
                btnList.push({ msg: '单价调整', icon: 'iconfont icon-orange icon-a-Group990', category: 'change' })
              }
              if (row.stage !== '业务经理审核通过') {
                btnList.push({ msg: '预览签署附件', icon: 'iconfont icon-orange icon-a-Group8141', category: 'preview' })
                btnList.push({ msg: '下载签署附件', icon: 'iconfont icon-orange icon-Union', category: 'download', style: 'display: inline-block; transform: scale(0.65)' })
              }
            }
            // btnList.push({
            //   msg: '删除',
            //   icon: 'iconfont icon-orange icon-a-Group991',
            //   category: 'delete'
            // })
            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' style={{ 'margin-right': '10px' }}>
                    <i class={item.icon} style={item.style} onClick={() => { this.handlerOperate(item.category, row) }}></i>
                  </span>
                </el-tooltip>
              )
            })
            return <div>{ options }</div>
          },
          width: 160
        }
      ]
    }
  },
  computed: {
    tablePower() {
      return ({ item, row }) => {
        const { rowPower } = item
        if (rowPower) {
          if (rowPower.includes(row.stage)) {
            return true
          }
        } else {
          return true
        }
      }
    }
  }

}
