index.tsx
3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import ButtonConfirm from '@/components/ButtomConfirm';
import { RESPONSE_CODE } from '@/constants/enum';
import {
postOldInvoicingWhiteListBatchAdd,
postOldInvoicingWhiteListPage,
postOldInvoicingWhiteListRemove,
} from '@/services';
import { PlusOutlined } from '@ant-design/icons';
import {
ActionType,
ModalForm,
ProColumns,
ProFormTextArea,
ProTable,
} from '@ant-design/pro-components';
import { Button, message } from 'antd';
import { useRef } from 'react';
export const waitTimePromise = async (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
export const waitTime = async (time: number = 100) => {
await waitTimePromise(time);
};
const columns: ProColumns[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '订单号',
dataIndex: 'mainOrderId',
ellipsis: true,
},
{
title: '添加时间',
dataIndex: 'createTime',
hideInSearch: true,
ellipsis: true,
},
{
title: '添加人',
dataIndex: 'createByName',
hideInSearch: true,
ellipsis: true,
},
{
title: '创建时间',
valueType: 'dateTimeRange',
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
createTimeGe: value[0],
createTimeLe: value[1],
};
}
},
},
},
{
title: '操作',
valueType: 'option',
key: 'option',
render: (text, record, _, action) => [
<ButtonConfirm
key="delete"
className="p-0"
title={'确认删除此项吗?'}
text="删除"
onConfirm={async () => {
await postOldInvoicingWhiteListRemove({
query: {
mainOrderId: record.mainOrderId,
},
});
action?.reload();
}}
/>,
],
},
];
export default () => {
const actionRef = useRef<ActionType>();
return (
<ProTable
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params) => {
const res = await postOldInvoicingWhiteListPage({
data: params,
});
return res.data;
}}
rowKey="id"
search={{
labelWidth: 'auto',
}}
options={{
setting: {
listsHeight: 400,
},
}}
pagination={{
showSizeChanger: true, // 显示可以选择每页显示条数的下拉菜单
pageSizeOptions: ['10', '20', '50', '100'], // 设置可以选择的每页显示条数选项
}}
dateFormatter="string"
headerTitle="白名单"
toolBarRender={() => [
<ModalForm
key="add"
title="添加"
trigger={
<Button type="primary">
<PlusOutlined />
添加
</Button>
}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => console.log('run'),
}}
submitTimeout={2000}
onFinish={async (values) => {
const res = await postOldInvoicingWhiteListBatchAdd({
data: values,
});
if (res.result === RESPONSE_CODE.SUCCESS) {
actionRef.current?.reload();
message.success('添加成功');
return true;
}
}}
>
<ProFormTextArea
name="orderIdsText"
label="订单号"
placeholder="请输入订单号,多个用逗号分割"
rules={[
{
required: true,
message: '请输入订单号,多个用逗号分割',
},
]}
></ProFormTextArea>
</ModalForm>,
]}
/>
);
};