import React, { useState } from 'react'; import { Divider, Switch, Tag } from 'antd'; import ProTable, { ProColumns } from '@ant-design/pro-table'; import { EditOutlined, PlusOutlined } from '@ant-design/icons'; import CreateDocument from './components/CreateDocument'; export interface Status { color: string; text: string; } const statusMap = { 0: { color: '', text: '未归档', }, 1: { color: 'green', text: '已归档', }, }; export interface TableListItem { key: number; name: string; containers: number; creator: string; status: Status; createdAt: number; } 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)], status: statusMap[Math.floor(Math.random() * 10) % 5], createdAt: Date.now() - Math.floor(Math.random() * 100000), }); } const onChange = (value: any) => { console.log(value) } const expandedRowRender = () => { const data = []; for (let i = 0; i < 3; i += 1) { data.push({ key: i, id: i+1, to: "项目建档", upgradeNum: 'Upgraded: 56', name: 'This is production name', is: "有", ispaper: 1, state:statusMap[ i == 0 || i == 1 ? 0 : 1 ] }); } return ( }, { title: '状态', dataIndex: 'state', key: 'state', render: (_, record) => {record.state.text},}, { title: '操作', dataIndex: 'operation', key: 'operation', valueType: 'option', render: () => [移除, 编辑, 详情], }, ]} headerTitle={false} search={false} options={false} dataSource={data} // pagination={false} /> ); }; const ProjectArchive: React.FC<{}> = () => { //新增档案文件弹出参数 const [addDocument, setAddDocument] = useState(false) const columns: ProColumns[] = [ { title: '业务编号', dataIndex: 'name', key: 'name', width: 120, render: (_) => {_}, }, { title: '标段名称', dataIndex: 'containers', key: 'containers', width: 120, }, { title: '操作', key: 'option', valueType: 'option', width: 164, render: (_,record) => [ setAddDocument(true)}>新增, 归档 ] }, ]; 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, }} expandable={{ expandedRowRender }} search={false} dateFormatter="string" options={false} /> setAddDocument(false)} modalVisible={addDocument} /> ); } export default ProjectArchive