import { Popconfirm } from 'ant-design-vue'
import { delVersionById } from '/@/api/sys/manager'
import { VersionItem } from '/@/api/sys/model/managerModel'
import Icon from '/@/components/Icon'
import { BasicColumn } from '/@/components/Table/src/types/table'
export function getTableColumns(fn: (item: VersionItem) => void, reload: () => void): BasicColumn[] {
  async function delConfirm(id: string) {
    await delVersionById({ id })
    reload()
  }
  return [
    {
      dataIndex: 'name',
      title: '名称'
    },
    {
      dataIndex: 'content',
      title: '内容'
    },
    {
      dataIndex: 'opreate',
      title: '操作',
      customRender: ({ record }) => (
        <div class="divide-light-500">
          {/* <span class="text-[#007BFF] hover:text-[#005BB8] cursor-pointer">
            <Icon icon="fluent:edit-32-filled" onClick={() => fn(record)}></Icon>
          </span> */}
          <span class="pl-2">
            <Popconfirm title="确定删除吗?" okText="确认" cancelText="取消" onConfirm={() => delConfirm(record.id)}>
              <span class="text-red-500 hover:text-red-600 cursor-pointer">
                <Icon icon="fluent:delete-20-filled"></Icon>
              </span>
            </Popconfirm>
          </span>
        </div>
      )
    }
  ]
}
