柏杨
authored
|
1
2
|
import ButtonConfirm from '@/components/ButtomConfirm';
import { RESPONSE_CODE } from '@/constants/enum';
|
|
3
|
import {
|
柏杨
authored
|
4
|
postServiceOrderAddWarningOrderWhiteList,
|
柏杨
authored
|
5
|
postServiceOrderAddWarningUserWhiteList,
|
柏杨
authored
|
6
|
postServiceOrderDeleteWarningOrderWhiteList,
|
柏杨
authored
|
7
8
|
postServiceOrderDeleteWarningUserWhiteList,
postServiceOrderWarningOrderWhiteLists,
|
柏杨
authored
|
9
|
postServiceOrderWarningUserWhiteLists,
|
柏杨
authored
|
10
11
|
} from '@/services';
import { PlusOutlined } from '@ant-design/icons';
|
柏杨
authored
|
12
13
14
15
|
import {
ActionType,
ModalForm,
ProColumns,
|
曾国涛
authored
|
16
|
ProFormDateTimePicker,
|
柏杨
authored
|
17
18
19
20
|
ProFormText,
ProTable,
} from '@ant-design/pro-components';
import { Button, Tabs, message } from 'antd';
|
柏杨
authored
|
21
22
23
24
25
26
27
28
|
import { useRef } from 'react';
export const waitTimePromise = async (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
|
|
29
|
|
柏杨
authored
|
30
31
32
|
export const waitTime = async (time: number = 100) => {
await waitTimePromise(time);
};
|
柏杨
authored
|
33
|
const WarningWhitelist = () => {
|
柏杨
authored
|
34
35
36
37
38
39
40
41
42
|
const columnsAccount: ProColumns[] = [
{
title: '序号',
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '销售账号',
|
柏杨
authored
|
43
|
dataIndex: 'userName',
|
柏杨
authored
|
44
|
ellipsis: true,
|
柏杨
authored
|
45
46
47
48
49
50
51
|
hideInSearch: true,
},
{
title: '销售账号',
dataIndex: 'userNameLike',
ellipsis: true,
hideInTable: true,
|
柏杨
authored
|
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
},
{
title: '添加人',
dataIndex: 'createByName',
hideInSearch: true,
ellipsis: true,
},
{
title: '添加时间',
valueType: 'dateTimeRange',
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
createTimeGe: value[0],
createTimeLe: value[1],
};
|
|
70
|
}
|
柏杨
authored
|
71
72
73
74
|
},
},
},
{
|
柏杨
authored
|
75
76
77
78
79
80
|
title: '添加时间',
dataIndex: 'createTime',
hideInSearch: true,
ellipsis: true,
},
{
|
曾国涛
authored
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
title: '到期时间',
dataIndex: 'expireDatetime',
hideInSearch: true,
ellipsis: true,
},
{
title: '到期时间',
valueType: 'dateTimeRange',
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
expireDatetimeGe: value[0],
expireDatetimeLe: value[1],
};
}
},
},
},
{
|
柏杨
authored
|
102
103
104
105
106
107
108
109
110
111
|
title: '操作',
valueType: 'option',
key: 'option',
render: (text, record, _, action) => [
<ButtonConfirm
key="delete"
className="p-0"
title={'确认删除此项吗?'}
text="删除"
onConfirm={async () => {
|
柏杨
authored
|
112
|
await postServiceOrderDeleteWarningUserWhiteList({
|
柏杨
authored
|
113
|
query: {
|
曾国涛
authored
|
114
|
id: record.id,
|
柏杨
authored
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
},
});
action?.reload();
}}
/>,
],
},
];
const columnsInvoice: ProColumns[] = [
{
title: '序号',
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '订单号',
|
柏杨
authored
|
132
|
dataIndex: 'orderId',
|
柏杨
authored
|
133
|
ellipsis: true,
|
柏杨
authored
|
134
135
136
137
|
search: {
transform: (value) => {
if (value) {
return {
|
柏杨
authored
|
138
|
orderId: Number(value),
|
柏杨
authored
|
139
140
141
142
|
};
}
},
},
|
柏杨
authored
|
143
144
145
|
},
{
title: '所属销售',
|
柏杨
authored
|
146
|
dataIndex: 'salesCode',
|
柏杨
authored
|
147
148
149
150
151
152
153
154
155
156
157
|
ellipsis: true,
hideInSearch: true,
},
{
title: '添加人',
dataIndex: 'createByName',
hideInSearch: true,
ellipsis: true,
},
{
title: '添加时间',
|
柏杨
authored
|
158
159
160
161
162
|
dataIndex: 'createTime',
hideInSearch: true,
ellipsis: true,
},
{
|
曾国涛
authored
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
title: '到期时间',
dataIndex: 'expireDatetime',
hideInSearch: true,
ellipsis: true,
},
{
title: '到期时间',
valueType: 'dateTimeRange',
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
expireDatetimeGe: value[0],
expireDatetimeLe: value[1],
};
}
},
},
},
{
|
柏杨
authored
|
184
|
title: '添加时间',
|
柏杨
authored
|
185
186
187
188
189
190
191
192
193
|
valueType: 'dateTimeRange',
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
createTimeGe: value[0],
createTimeLe: value[1],
};
|
|
194
|
}
|
柏杨
authored
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
},
},
},
{
title: '操作',
valueType: 'option',
key: 'option',
render: (text, record, _, action) => [
<ButtonConfirm
key="delete"
className="p-0"
title={'确认删除此项吗?'}
text="删除"
onConfirm={async () => {
|
柏杨
authored
|
209
|
await postServiceOrderDeleteWarningOrderWhiteList({
|
柏杨
authored
|
210
|
query: {
|
曾国涛
authored
|
211
|
orderId: record.orderId,
|
柏杨
authored
|
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
},
});
action?.reload();
}}
/>,
],
},
];
const actionRef = useRef<ActionType>();
const tabsItems = [
{
key: 1,
label: '帐号白名单',
children: (
|
|
226
|
<div>
|
柏杨
authored
|
227
228
229
230
231
|
<ProTable
columns={columnsAccount}
actionRef={actionRef}
cardBordered
request={async (params) => {
|
柏杨
authored
|
232
233
|
const res = await postServiceOrderWarningUserWhiteLists({
data: { ...params },
|
柏杨
authored
|
234
235
|
});
return res.data;
|
|
236
|
}}
|
柏杨
authored
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
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="添加帐号"
width={500}
trigger={
<Button type="primary">
<PlusOutlined />
添加
</Button>
}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => console.log('run'),
}}
submitTimeout={2000}
onFinish={async (values) => {
|
柏杨
authored
|
270
271
|
const res = await postServiceOrderAddWarningUserWhiteList({
data: {
|
曾国涛
authored
|
272
|
...values,
|
柏杨
authored
|
273
274
|
userName: values.orderIdsText,
},
|
曾国涛
authored
|
275
|
});
|
柏杨
authored
|
276
|
if (res.result === RESPONSE_CODE.SUCCESS) {
|
柏杨
authored
|
277
278
279
280
|
// actionRef.current?.reload();
setTimeout(() => {
actionRef.current?.reload();
}, 50);
|
柏杨
authored
|
281
282
|
message.success('添加成功');
return true;
|
曾国涛
authored
|
283
284
|
}
}}
|
|
285
|
>
|
柏杨
authored
|
286
287
288
289
290
291
292
293
|
<ProFormText
name="orderIdsText"
label="销售账号"
placeholder="请输入销售账号"
rules={[
{
required: true,
message: '请输入销售账号',
|
|
294
|
},
|
柏杨
authored
|
295
296
|
]}
></ProFormText>
|
曾国涛
authored
|
297
|
<ProFormDateTimePicker name="expireDatetime" label="到期时间" />
|
柏杨
authored
|
298
299
300
301
|
</ModalForm>,
]}
/>
</div>
|
柏杨
authored
|
302
|
),
|
柏杨
authored
|
303
304
305
306
307
308
309
310
311
312
313
|
},
{
key: 2,
label: '订单白名单',
children: (
<div>
<ProTable
columns={columnsInvoice}
actionRef={actionRef}
cardBordered
request={async (params) => {
|
柏杨
authored
|
314
|
const res = await postServiceOrderWarningOrderWhiteLists({
|
柏杨
authored
|
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
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="添加订单"
width={500}
trigger={
<Button type="primary">
<PlusOutlined />
添加
</Button>
}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => console.log('run'),
}}
submitTimeout={2000}
onFinish={async (values) => {
|
柏杨
authored
|
352
353
|
const res = await postServiceOrderAddWarningOrderWhiteList({
data: {
|
曾国涛
authored
|
354
|
...values,
|
柏杨
authored
|
355
|
orderId: values.orderIdsText,
|
柏杨
authored
|
356
|
},
|
|
357
358
|
});
if (res.result === RESPONSE_CODE.SUCCESS) {
|
柏杨
authored
|
359
360
361
|
setTimeout(() => {
actionRef.current?.reload();
}, 50);
|
柏杨
authored
|
362
363
|
message.success('添加成功');
return true;
|
|
364
|
}
|
|
365
366
|
}}
>
|
柏杨
authored
|
367
368
369
370
371
372
373
374
375
376
377
|
<ProFormText
name="orderIdsText"
label="订单号"
placeholder="请输入订单号"
rules={[
{
required: true,
message: '请输入订单号',
},
]}
></ProFormText>
|
曾国涛
authored
|
378
|
<ProFormDateTimePicker name="expireDatetime" label="到期时间" />
|
柏杨
authored
|
379
380
381
382
|
</ModalForm>,
]}
/>
</div>
|
柏杨
authored
|
383
384
385
|
),
},
];
|
|
386
|
return (
|
柏杨
authored
|
387
|
<div>
|
|
388
|
<Tabs defaultActiveKey="1" items={tabsItems} onChange={() => {}} />
|
|
389
|
</div>
|
柏杨
authored
|
390
391
392
|
);
};
export default WarningWhitelist;
|