import React from 'react'; import { Button } from 'antd'; import { EllipsisOutlined, SettingOutlined, FullscreenOutlined } from '@ant-design/icons'; import { LightFilter, ProFormDatePicker } from '@ant-design/pro-form'; import type { ProColumns } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; export type TableListItem = { key: number; name: string; containers: number; creator: string; }; const tableListDataSource: TableListItem[] = []; const creators = ['付小小', '曲丽丽', '林东东', '陈帅帅', '兼某某']; for (let i = 0; i < 5; i += 1) { tableListDataSource.push({ key: i, name: 'AppName', containers: Math.floor(Math.random() * 20), creator: creators[Math.floor(Math.random() * creators.length)], }); } const columns: ProColumns[] = [ { title: '应用名称', dataIndex: 'name', render: (_) => {_}, }, { title: '容器数量', dataIndex: 'containers', align: 'right', sorter: (a, b) => a.containers - b.containers, }, { title: '创建者', dataIndex: 'creator', valueEnum: { all: { text: '全部' }, 付小小: { text: '付小小' }, 曲丽丽: { text: '曲丽丽' }, 林东东: { text: '林东东' }, 陈帅帅: { text: '陈帅帅' }, 兼某某: { text: '兼某某' }, }, }, { title: '操作', key: 'option', width: 120, 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, }); }} toolbar={{ title: '这里是标题', subTitle: '这里是子标题', tooltip: '这是一个段描述', search: { onSearch: (value: string) => { alert(value); }, }, filter: ( ), actions: [ , ], settings: [ { icon: , tooltip: '设置', }, { icon: , tooltip: '全屏', }, ], }} rowKey="key" search={false} /> ); };