搭建表格

main
白封羽 2022-12-28 17:04:39 +08:00
parent e7705bbe65
commit 0d9e429d86
1 changed files with 142 additions and 39 deletions

View File

@ -1,34 +1,86 @@
import { DownOutlined } from '@ant-design/icons'; import { DownOutlined } from '@ant-design/icons';
import type { ProColumns } from '@ant-design/pro-components'; import type { ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components';
import { Button } from 'antd'; import {Button, Dropdown, Input, Space, Typography} from 'antd';
import React from "react";
import Search from "antd/es/input/Search";
const valueEnum = { const valueEnum = {
0: 'close', 0: 'success',
1: 'running', 1: 'wait1',
2: 'online', 2: 'wait2',
3: 'error', 3: 'wait3',
4: 'wait4',
5: 'failure'
}; };
export type TableListItem = { export type TableListItem = {
id:string; id:string;
kind: string; kind: string;
invoiceKind: string;
amount: number; amount: number;
status: string; status: string;
department: string; department: string;
submitDateTime: string; submitDateTime: number;
detail: string;
}; };
const tableListDataSource: TableListItem[] = [ const tableListDataSource: TableListItem[] = [
{ {
id:"123", id:"123",
kind: "string", kind: "string",
invoiceKind: "string", amount: 1200.0,
amount: 1234, status: valueEnum[5],
status: "string",
department: "string", department: "string",
submitDateTime: "string", submitDateTime: Date.now()-100000000,
} detail: "查看详情",
},
{
id:"123",
kind: "string",
detail: "查看详情",
amount: 1200.0,
status: valueEnum[4],
department: "string",
submitDateTime: Date.now()-100000000,
},
{
id:"123",
kind: "string",
detail: "查看详情",
amount: 1200.0,
status: valueEnum[3],
department: "string",
submitDateTime: Date.now()-100000000,
},
{
id:"123",
kind: "string",
detail: "查看详情",
amount: 500,
status: valueEnum[2],
department: "string",
submitDateTime: Date.now(),
},
{
id:"123",
kind: "string",
detail: "查看详情",
amount: 1200.0,
status: valueEnum[1],
department: "string",
submitDateTime: Date.now()-100000000,
},
{
id:"123",
kind: "string",
detail: "查看详情",
amount: 1200.0,
status: valueEnum[0],
department: "string",
submitDateTime: Date.now()-100000000,
},
]; ];
@ -37,43 +89,64 @@ const columns: ProColumns<TableListItem>[] = [
title: '报销单号', title: '报销单号',
width: 80, width: 80,
dataIndex: 'id', dataIndex: 'id',
render: (_) => <a>{_}</a>, search:false,
//render: (_) => <a>{_}</a>,
}, },
{ {
title: '申请事由', title: '报销类型',
width: 80, width: 80,
dataIndex: 'kind', dataIndex: 'kind',
render: (_) => <a>{_}</a>, search:false,
}, //render: (_) => <a>{_}</a>,
{
title: '发票类型',
width: 80,
dataIndex: 'invoiceKind',
render: (_) => <a>{_}</a>,
}, },
{ {
title: '金额', title: '金额',
width: 80, width: 80,
dataIndex: 'amount', dataIndex: 'amount',
render: (_) => <a>{_}</a>, search:false,
//render: (_) => <a>{_}</a>,
sorter:(a,b)=> a.amount - b.amount sorter:(a,b)=> a.amount - b.amount
}, },
{ {
title: '状态', title: '状态',
width: 80, width: 80,
dataIndex: 'status', dataIndex: 'status',
render: (_) => <a>{_}</a>, filters: true,
onFilter: true,
search:false,
valueEnum: {
wait1: { text: '待主管审批', status: 'Processing' },
wait2: { text: '待财务审批', status: 'Processing' },
wait3: { text: '待财务主管审批', status: 'Processing' },
wait4: { text: '待总经理审批', status: 'Processing' },
success: { text: '已报销', status: 'Success' },
failure: { text: '审批未通过', status: 'Error' },
},
//render: (_) => <a>{_}</a>,
}, },
{ {
title: '申请部门', title: '申请部门',
width: 80, width: 80,
search:false,
dataIndex: 'department', dataIndex: 'department',
render: (_) => <a>{_}</a>, //render: (_) => <a>{_}</a>,
}, },
{ {
title: '申请时间', title: '申请时间',
width: 80, width: 80,
dataIndex: 'submitDateTime', dataIndex: 'submitDateTime',
valueType: 'dateTime',
search:false,
sorter:(a,b)=> a.submitDateTime-b.submitDateTime
//render: (_) => <a>{_}</a>,
},
{
title: '申请详情',
width: 80,
dataIndex: 'detail',
search:false,
render: (_) => <a>{_}</a>, render: (_) => <a>{_}</a>,
}, },
]; ];
@ -92,32 +165,62 @@ function makeTable() {
}} }}
rowKey="key" rowKey="key"
pagination={{ pagination={{
pageSize:5,
showQuickJumper: true, showQuickJumper: true,
}} }}
// toolbar={{
// title: '这里是标题',
// subTitle: '这里是子标题',
// tooltip: '这是一个段描述',
// search: {
// onSearch: (value: string) => {
// alert(value);
// },
// },
// }}
search={{ search={{
optionRender: false, defaultCollapsed: false,
collapsed: false, labelWidth: 'auto',
resetText:" ",
optionRender: ({ searchText }, { form }) => {
// console.log(searchConfig, formProps, dom)
return [
<Search className="searchBar"
addonBefore={"报销单号:"}
placeholder={"this.state.searchContent"}
allowClear
onSearch={(value) => {
}}
style={{width: 304,marginLeft:-30}}
enterButton
/>,
<Button key="create" type="primary" onClick={() => console.log(6668)} style={{width:100}}>
</Button>
]
}
}} }}
dateFormatter="string" dateFormatter="string"
headerTitle="表格标题" // toolBarRender={() => [
toolBarRender={() => [ // <Button key="show">查看日志</Button>,
<Button key="show"></Button>, // <Button key="out">
<Button key="out"> // 导出数据
// <DownOutlined />
<DownOutlined /> // </Button>,
</Button>, // <Button type="primary" key="primary">
<Button type="primary" key="primary"> // 创建应用
// </Button>,
</Button>, // ]}
]}
/> />
); );
}; };
function MyReimbursement() { function MyReimbursement() {
return( return(
<div> <>
{makeTable()} {makeTable()}
</div> </>
) )
} }
export default MyReimbursement export default MyReimbursement