import { ElButton, ElPopconfirm } from 'element-plus'

const sendStatusList = ['待发送', '发送中', '已发送', '发送失败']
export default (
  event: { [key: string]: any },
  pageData: any,
): TableColumn[] => [
  {
    label: '排序',
    width: 80,
    render: (h, scope) => {
      return (
        <span>{(pageData.current - 1) * pageData.size + scope.$index + 1}</span>
      )
    },
  },
  {
    label: '邮件主题',
    prop: 'createTime',
    'show-overflow-tooltip': true,
    render: (h, scope) => {
      return <span>{scope.row.userMessageBoxAddMessage.title}</span>
    },
  },
  {
    label: '状态',
    prop: 'createTime',
    render: (h, scope) => {
      return <span>{sendStatusList[scope.row.sendStatus]}</span>
    },
  },
  {
    label: '发送时间',
    prop: 'sendTime',
  },

  {
    label: '操作',
    width: 240,
    fixed: 'right',
    render: (h, scope) => {
      return (
        <div>
          <ElButton
            onClick={() => event.handleClick(scope.row, 0)}
            type="primary"
          >
            查看
          </ElButton>
          <ElPopconfirm
            onConfirm={() => event.handleClick(scope.row, 1)}
            persistent
            title="删除后无法恢复，确定吗？"
            width="220"
          >
            {{
              reference: () => <ElButton type="danger">删除</ElButton>,
            }}
          </ElPopconfirm>
        </div>
      )
    },
  },
]
