/* eslint-disable no-undef */
import { ElButton, ElPopconfirm } from 'element-plus'
import getDict from '#/hooks/useDict'
import { ArrToObj } from '#/utils/tool'
// 词根类型
const ROOT_TYPE: anyObj = ArrToObj(getDict('word_root_type'))
export default (event: { [key: string]: any }): TableColumn[] => [
  {
    label: '排序',
    prop: 'sort',
  },
  {
    label: '词根词缀',
    prop: 'wordRoot',
    'show-overflow-tooltip': true,
  },
  {
    label: '类型',
    prop: 'wordRootType',
    render: (h, scope) => {
      return <span>{ROOT_TYPE[scope.row.wordRootType]}</span>
    },
  },
  {
    label: '词根含义',
    prop: 'wordRootMeaning',
    'show-overflow-tooltip': true,
  },
  {
    label: '同源单词',
    prop: 'sameSourceWords',
    'show-overflow-tooltip': true,
  },
  {
    label: '操作',
    width: 240,
    fixed: 'right',
    render: (h, scope) => {
      return (
        <div>
          <ElButton
            type="primary"
            onClick={() => event.handleClick(scope.row, 0)}
          >
            详情
          </ElButton>
          <ElPopconfirm
            title="删除后无法恢复，确定吗？"
            width="220"
            persistent
            onConfirm={() => event.handleClick(scope.row, 1)}
          >
            {{
              reference: () => <ElButton type="danger">删除</ElButton>,
            }}
          </ElPopconfirm>
        </div>
      )
    },
  },
]
