import React, { useRef } from 'react'; import Table, { ProColumns, ActionType } from '@/components/Table'; import { Image } from 'antd'; import DeleteButton from '@/components/Table/DeleteButton'; import { history, Link } from 'umi'; import RoutePath from '@/routes/routePath'; import { queryWorkList, deleteWork } from '@/services/work'; import { fetchTableData } from '@/utils/table'; import TimeText from '@/components/Typography/TimeText'; const WorkList = () => { const tableRef = useRef(); const handleDelete = async (id) => { await deleteWork({ id }); tableRef.current?.reload(); }; const columns: ProColumns[] = [ { title: 'ID', dataIndex: 'id', width: '10%', hideInSearch: true, }, { title: '封面', dataIndex: 'url', valueType: 'image', hideInSearch: true, width: '20%', render: (_, row) => { return ; }, }, { title: '标题', dataIndex: 'title', ellipsis: true, }, { title: '系列', dataIndex: 'series', width: '10%', hideInSearch: true, }, { title: '等级', dataIndex: 'rarity_name', width: '10%', hideInSearch: true, }, { title: '创建时间', dataIndex: 'created_at', valueType: 'dateRange', width: '20%', hideInSearch: true, render: (_, row) => { return ; }, }, { title: '操作', valueType: 'option', width: 150, render: (_, row) => [ 详情, { handleDelete(row.id); }} />, ], }, ]; return ( { history.push(RoutePath.WORK.EDIT); }, }, ]} request={async (params) => { return fetchTableData(queryWorkList, params); }} /> ); }; export default WorkList;