import React from 'react'; import { Button, Tooltip } from 'antd'; import { QuestionCircleOutlined } from '@ant-design/icons'; import type { ProColumns } from '@ant-design/pro-table'; import ProTable, { TableDropdown } from '@ant-design/pro-table'; export type TableListItem = { key: number; name: string; creator: string; createdAt: number; }; const tableListDataSource: TableListItem[] = []; const creators = ['付小小', '曲丽丽', '林东东', '陈帅帅', '兼某某']; for (let i = 0; i < 5; i += 1) { tableListDataSource.push({ key: i, name: 'AppName', creator: creators[Math.floor(Math.random() * creators.length)], createdAt: Date.now() - Math.floor(Math.random() * 100000), }); } const columns: ProColumns[] = [ { title: '应用名称', dataIndex: 'name', render: (_) => {_}, }, { title: '创建者', dataIndex: 'creator', valueType: 'select', valueEnum: { all: { text: '全部' }, 付小小: { text: '付小小' }, 曲丽丽: { text: '曲丽丽' }, 林东东: { text: '林东东' }, 陈帅帅: { text: '陈帅帅' }, 兼某某: { text: '兼某某' }, }, }, { title: ( <> 创建时间 ), key: 'since', dataIndex: 'createdAt', valueType: 'date', sorter: (a, b) => a.createdAt - b.createdAt, }, { title: '操作', width: '164px', key: 'option', valueType: 'option', render: () => [ 链路, 报警, 监控, , ], }, ]; export default () => { return ( columns={columns} request={(params, sorter, filter) => { // 表单搜索项会从 params 传入,传递给后端接口。 console.log(params, sorter, filter); return Promise.resolve({ data: tableListDataSource, success: true, }); }} rowKey="key" pagination={{ showQuickJumper: true, }} search={{ filterType: 'light', }} dateFormatter="string" headerTitle="表格标题" toolBarRender={() => [ , , ]} /> ); };