|
1
2
3
4
5
6
7
8
9
10
11
12
|
import {
deleteOrderErpOrderStagesDelect,
getOrderErpOrderStagesListAll,
postOrderErpOrderStagesSearch,
} from '@/services';
import { orderExport } from '@/services/order';
import { VerticalAlignTopOutlined } from '@ant-design/icons';
import type { ProColumns } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
import { Button, message } from 'antd';
import { useRef } from 'react';
import Comfire from '../comfire/comfire';
|
|
13
14
|
import AddModel from '../detail/detail';
import EditorModel from '../edit/edit';
|
|
15
|
import ReadModel from '../read/read';
|
|
16
|
import UploadModel from '../upload/uploadModel';
|
|
17
|
import './title.less';
|
|
18
|
export const waitTimePromise = async (time: number = 100) => {
|
|
19
20
21
22
23
|
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
|
|
24
25
26
|
};
export const waitTime = async (time: number = 100) => {
|
|
27
|
await waitTimePromise(time);
|
|
28
29
30
|
};
type OrderStagesItem = {
|
|
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
|
//文件编号
id?: number;
//合同编号
contract?: string;
//供应商名称
vendor?: string;
//签合同日期
dateRange?: Date;
//终端名称
terminal?: string;
//设备编号
dId?: number;
//设备名称
deviceName?: string;
//设备型号
deviceModel?: string;
//数量
count?: number;
//单价
unitPrice?: number;
//总价
price?: number;
//合同总金额
totalPrice?: number;
//付款方式
payWay?: string;
//附件
annex?: string;
//备注
remark?: string;
|
|
61
62
63
|
};
type OrderStagesWithListItem = {
|
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
//文件编号
id: number;
//合同编号
contract: string;
//供应商名称
vendor: string;
//签合同日期
dateRange: Date;
//终端名称
terminal: string;
orderStagesDeviceVoList: orderStagesDevice[];
//合同总金额
totalPrice: number;
//付款方式
payWay: string;
//附件
annex: string;
//备注
remark: string;
|
|
83
84
85
|
};
type orderStagesDevice = {
|
|
86
87
88
89
90
91
92
93
94
95
96
97
98
|
//设备id
dId: number;
//设备名称
deviceName: string;
//设备型号
deviceModel: string;
//数量
count: number;
//单价
unitPrice: number;
//总价
price: number;
};
|
|
99
100
|
export default () => {
|
|
101
102
|
// const actionRef = useRef<ActionType>();
// const [TableItem, setTableItem] = useState([]);
|
|
103
|
|
|
104
105
106
107
108
109
110
111
|
interface ActionType {
reload: (resetPageIndex?: boolean) => void;
reloadAndRest: () => void;
reset: () => void;
clearSelected?: () => void;
startEditable: (rowKey: Key) => boolean;
cancelEditable: (rowKey: Key) => boolean;
}
|
|
112
|
|
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
const ref = useRef<ActionType>({
reload: () => {
// implementation for reload
},
reloadAndRest: () => {
// implementation for reloadAndRest
},
reset: () => {
// implementation for reset
},
startEditable: () => {
// implementation for startEditable
},
cancelEditable: () => {
// implementation for cancelEditable
},
});
|
|
130
|
|
|
131
132
133
|
function reload() {
ref.current.reload();
}
|
|
134
|
|
|
135
136
137
138
139
140
141
142
143
144
145
146
|
async function toDelete(value) {
const res = await deleteOrderErpOrderStagesDelect({
data: {
ids: null,
deviceIds: value,
},
});
if (res) {
message.success('删除成功');
ref.current.reload();
} else {
message.error('删除失败');
|
|
147
|
}
|
|
148
|
}
|
|
149
|
|
|
150
151
152
|
const exportLoadingDestory = () => {
message.success('导出成功');
};
|
|
153
|
|
|
154
155
156
157
158
159
160
161
162
163
|
async function toExport() {
// await getOrderErpOrderStagesExport()
orderExport(
'/api/order/erp/orderStages/export',
'分期订单.xlsx',
'get',
{},
exportLoadingDestory,
);
}
|
|
164
|
|
|
165
166
167
168
|
const columns: ProColumns<OrderStagesItem>[] = [
{
title: '文件编号',
dataIndex: 'id',
|
|
169
170
171
172
|
width: 100,
disable: true,
onFilter: true,
ellipsis: true,
|
|
173
174
175
176
177
178
179
180
181
182
183
184
|
render: (_, record) => {
if (record.id) {
const text = record.id.toString();
const paddedText = '0'.repeat(4 - text.length) + text;
return paddedText;
}
},
},
{
title: '签合同日期',
dataIndex: 'dateRange',
valueType: 'date',
|
|
185
186
|
width: 100,
disable: true,
|
|
187
188
189
190
191
192
|
onFilter: true,
ellipsis: true,
},
{
title: '合同编号',
dataIndex: 'contract',
|
|
193
194
|
width: 200,
disable: true,
|
|
195
196
197
198
199
200
|
onFilter: true,
ellipsis: true,
},
{
title: '供应商名称',
dataIndex: 'vendor',
|
|
201
202
|
width: 200,
disable: true,
|
|
203
204
205
206
207
208
|
onFilter: true,
ellipsis: true,
},
{
title: '终端名称',
dataIndex: 'terminal',
|
|
209
210
|
width: 200,
disable: true,
|
|
211
212
213
214
215
216
|
onFilter: true,
ellipsis: true,
},
{
title: '设备名称',
dataIndex: 'deviceName',
|
|
217
218
|
width: 200,
disable: true,
|
|
219
220
221
222
223
224
225
|
onFilter: true,
ellipsis: true,
},
{
title: '设备型号',
dataIndex: 'deviceModel',
hideInSearch: true,
|
|
226
227
228
|
width: 200,
disable: true,
onFilter: true,
|
|
229
230
231
232
233
234
|
ellipsis: true,
},
{
title: '数量',
dataIndex: 'count',
hideInSearch: true,
|
|
235
236
237
|
width: 100,
disable: true,
onFilter: true,
|
|
238
239
240
241
242
243
|
ellipsis: true,
},
{
title: '单价',
dataIndex: 'unitPrice',
hideInSearch: true,
|
|
244
245
246
|
width: 100,
disable: true,
onFilter: true,
|
|
247
248
249
250
251
252
|
ellipsis: true,
},
{
title: '总价',
dataIndex: 'price',
hideInSearch: true,
|
|
253
254
255
|
width: 100,
disable: true,
onFilter: true,
|
|
256
257
258
259
260
261
|
ellipsis: true,
},
{
title: '合同总金额',
dataIndex: 'totalPrice',
hideInSearch: true,
|
|
262
263
264
|
width: 100,
disable: true,
onFilter: true,
|
|
265
266
267
268
269
270
|
ellipsis: true,
},
{
title: '付款方式',
dataIndex: 'payWay',
hideInSearch: true,
|
|
271
272
273
|
width: 100,
disable: true,
onFilter: true,
|
|
274
275
276
277
278
279
|
ellipsis: true,
},
{
title: '附件',
dataIndex: 'annex',
hideInSearch: true,
|
|
280
281
282
|
width: 100,
disable: true,
onFilter: true,
|
|
283
284
|
ellipsis: true,
render: (_, record) => {
|
|
285
286
|
if (record.id && record.annex !== null) {
return <a href={record.annex}>附件文件</a>;
|
|
287
288
289
290
291
292
293
294
295
296
297
|
}
},
},
{
disable: true,
title: '备注',
dataIndex: 'remark',
filters: true,
hideInSearch: true,
onFilter: false,
ellipsis: true,
|
|
298
299
300
301
|
width: 100,
disable: true,
onFilter: true,
ellipsis: true,
|
|
302
303
304
305
306
|
},
{
title: '操作',
valueType: 'option',
key: 'option',
|
|
307
308
309
310
311
|
fixed: 'right',
width: 120,
disable: true,
onFilter: true,
ellipsis: true,
|
|
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
render: (_text, record) => {
if (record?.id) {
return (
<>
<ReadModel currentContract={record.contract}></ReadModel>
<EditorModel
currentContract={record.contract}
toReload={reload}
></EditorModel>
{/* <a key="delect" target="_blank" rel="noopener noreferrer" onClick={() => { toDelete([record.dId]) }}>
删除
</a> */}
<Comfire currtDid={record.dId} sureDelete={toDelete}></Comfire>
</>
);
}
return null;
},
},
];
|
|
334
|
|
|
335
336
337
338
339
340
|
return (
<ProTable<OrderStagesItem>
className="title-index"
columnEmptyText=""
columns={columns}
cardBordered
|
|
341
342
|
actionRef={ref}
scroll={{ x: 1400, y: 360 }}
|
|
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
request={async (params) => {
if (
params.id !== null ||
params.contract !== null ||
params.vendor !== null ||
params.terminal !== null ||
params.deviceName !== null ||
params.dateRange !== null
) {
let PostOrderErpOrderStagesSearchOption = {
id: params.id,
contract: params.contract,
vendor: params.vendor,
terminal: params.terminal,
deviceName: params.deviceName,
dateRange: params.dateRange,
};
let res = await postOrderErpOrderStagesSearch({
data: { ...PostOrderErpOrderStagesSearchOption },
});
await waitTime(2000);
if (res) {
// setTableItem(res.data)
const orderStagesWithList: OrderStagesWithListItem[] = res?.data;
let orderStagesList: OrderStagesItem[] = [];
for (let ind = 0; ind < orderStagesWithList.length; ind++) {
for (
let index = 0;
index < orderStagesWithList[ind].orderStagesDeviceVoList.length;
index++
) {
let item: OrderStagesItem = {
id: undefined,
contract: undefined,
vendor: undefined,
dateRange: undefined,
terminal: undefined,
dId: undefined,
deviceName: undefined,
deviceModel: undefined,
count: undefined,
unitPrice: undefined,
price: undefined,
totalPrice: undefined,
payWay: undefined,
annex: undefined,
remark: undefined,
};
if (index === 0) {
item.id = orderStagesWithList[ind].id;
item.contract = orderStagesWithList[ind].contract;
item.vendor = orderStagesWithList[ind].vendor;
item.dateRange = orderStagesWithList[ind].dateRange;
item.terminal = orderStagesWithList[ind].terminal;
item.dId =
orderStagesWithList[ind].orderStagesDeviceVoList[index].dId;
item.deviceName =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceName;
item.deviceModel =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceModel;
item.count =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].count;
item.unitPrice =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].unitPrice;
item.price =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].price;
item.totalPrice = orderStagesWithList[ind].totalPrice;
item.payWay = orderStagesWithList[ind].payWay;
item.annex = orderStagesWithList[ind].annex;
item.remark = orderStagesWithList[ind].remark;
orderStagesList.push(item);
} else {
item.id = orderStagesWithList[ind].id;
item.contract = orderStagesWithList[ind].contract;
item.vendor = orderStagesWithList[ind].vendor;
item.dateRange = orderStagesWithList[ind].dateRange;
item.terminal = orderStagesWithList[ind].terminal;
item.dId =
orderStagesWithList[ind].orderStagesDeviceVoList[index].dId;
item.deviceName =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceName;
item.deviceModel =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceModel;
item.count =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].count;
item.unitPrice =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].unitPrice;
item.price =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].price;
item.totalPrice = orderStagesWithList[ind].totalPrice;
item.payWay = orderStagesWithList[ind].payWay;
item.annex = orderStagesWithList[ind].annex;
item.remark = orderStagesWithList[ind].remark;
orderStagesList.push(item);
|
|
457
|
}
|
|
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
}
}
return {
data: orderStagesList || [],
};
}
} else {
let res = await getOrderErpOrderStagesListAll();
await waitTime(2000);
if (res) {
// setTableItem(res.data)
const orderStagesWithList: OrderStagesWithListItem[] = res?.data;
let orderStagesList: OrderStagesItem[] = [];
for (let ind = 0; ind < orderStagesWithList.length; ind++) {
for (
let index = 0;
index < orderStagesWithList[ind].orderStagesDeviceVoList.length;
index++
) {
let item: OrderStagesItem = {
id: undefined,
contract: undefined,
vendor: undefined,
dateRange: undefined,
terminal: undefined,
dId: undefined,
deviceName: undefined,
deviceModel: undefined,
count: undefined,
unitPrice: undefined,
price: undefined,
totalPrice: undefined,
payWay: undefined,
annex: undefined,
remark: undefined,
};
if (index === 0) {
item.id = orderStagesWithList[ind].id;
item.contract = orderStagesWithList[ind].contract;
item.vendor = orderStagesWithList[ind].vendor;
item.dateRange = orderStagesWithList[ind].dateRange;
item.terminal = orderStagesWithList[ind].terminal;
item.dId =
orderStagesWithList[ind].orderStagesDeviceVoList[index].dId;
item.deviceName =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceName;
item.deviceModel =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceModel;
item.count =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].count;
item.unitPrice =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].unitPrice;
item.price =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].price;
item.totalPrice = orderStagesWithList[ind].totalPrice;
item.payWay = orderStagesWithList[ind].payWay;
item.annex = orderStagesWithList[ind].annex;
item.remark = orderStagesWithList[ind].remark;
orderStagesList.push(item);
} else {
item.id = orderStagesWithList[ind].id;
item.contract = orderStagesWithList[ind].contract;
item.vendor = orderStagesWithList[ind].vendor;
item.dateRange = orderStagesWithList[ind].dateRange;
item.terminal = orderStagesWithList[ind].terminal;
item.dId =
orderStagesWithList[ind].orderStagesDeviceVoList[index].dId;
item.deviceName =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceName;
item.deviceModel =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].deviceModel;
item.count =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].count;
item.unitPrice =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].unitPrice;
item.price =
orderStagesWithList[ind].orderStagesDeviceVoList[
index
].price;
item.totalPrice = orderStagesWithList[ind].totalPrice;
item.payWay = orderStagesWithList[ind].payWay;
item.annex = orderStagesWithList[ind].annex;
item.remark = orderStagesWithList[ind].remark;
orderStagesList.push(item);
|
|
560
|
}
|
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
}
}
return {
data: orderStagesList || [],
};
}
}
}}
editable={{
type: 'multiple',
}}
columnsState={{
persistenceKey: 'pro-table-singe-demos',
persistenceType: 'localStorage',
defaultValue: {
option: { fixed: 'right', disable: true },
|
|
577
|
},
|
|
578
579
580
581
582
583
584
585
586
587
|
// onChange(value) {
// },
}}
rowKey="dId"
search={{
labelWidth: 'auto',
}}
options={{
setting: {
listsHeight: 800,
|
|
588
|
},
|
|
589
590
591
592
593
594
595
596
597
598
|
}}
form={{
syncToUrl: (values, type) => {
if (type === 'get') {
return {
...values,
created_at: [values.startTime, values.endTime],
};
}
return values;
|
|
599
|
},
|
|
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
}}
pagination={{
pageSize: 10,
}}
dateFormatter="string"
headerTitle={[]}
toolBarRender={() => [
<>
<AddModel toReload={reload}></AddModel>
<UploadModel toReload={reload}></UploadModel>
<Button
type="primary"
onClick={() => {
toExport();
|
|
614
|
}}
|
|
615
616
617
618
619
620
621
622
623
|
>
<VerticalAlignTopOutlined />
导出
</Button>
</>,
]}
/>
);
};
|