export default {
  data() {
    return {
      total: 0,
      loading: false,
      tableData: [],
      tableOptions: {
        sortTable: true,
        maxHeight: 'calc(100vh - 406px)',
        height: 'calc(100vh - 406px)'
      },
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '贸易平台',
          prop: 'platformName',
          showTooltip: true
        },
        {
          label: '认证状态',
          prop: 'authStatus',
          showTooltip: true,
          render: (h, row) => {
            return <div>{ row.authStatus ? '已认证' : '未认证' }</div>
          }
        },
        {
          label: '自动签署状态',
          showTooltip: true,
          prop: 'autoSignStatus',
          render: (h, row) => {
            return <div>{ row.autoSignStatus ? '已签署' : '未签署' }</div>
          }
        },
        {
          label: '创建时间',
          prop: 'gmtCreate'
        },
        {
          label: '操作',
          show: true,
          render: (h, row) => {
            const btnList = [
              {
                msg: '复制认证链接',
                icon: 'iconfont icon-fuzhi',
                power: 'platformCopyAuthUrl',
                category: 'copyUrl'
              },
              {
                msg: '复制自动签署链接',
                icon: 'iconfont icon-fuzhi',
                power: 'platformCopySignUrl',
                category: 'automaticSigning'
              },
              {
                msg: ' 重新生成认证和签署链接',
                icon: 'thin-icon el-icon-refresh',
                power: 'platformCreateUrl',
                category: 'refreshAuthLink'
              },
              {
                msg: ' 刷新认证状态',
                icon: 'iconfont icon-shuaxin',
                power: 'platformFlushStatus',
                category: 'refreshStatus'
              },
              {
                msg: '开票信息维护',
                icon: 'iconfont icon-xiugai',
                power: 'platformInvoiceInfo',
                category: 'edit'
              },
              {
                msg: '认证详情',
                icon: 'iconfont icon-Magnifier',
                category: 'see',
                rowPower: [1]
              }
            ]
            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: 230
        }
      ]
    }
  },
  computed: {
    tablePower() {
      return ({ item, row }) => {
        const { power } = item
        if (power && !this.btnPermission.includes(power)) {
          return false
        }
        // if(rowPower && (!row.authStatus || !rowPower.includes(row.authStatus))) {
        //   return false
        // }
        return true
      }
    }
  }
}
