Blame view

src/pages/Invoice/index.tsx 29.6 KB
zhongnanhuang authored
1
import ButtonConfirm from '@/components/ButtomConfirm';
zhongnanhuang authored
2
import EllipsisDiv from '@/components/Div/EllipsisDiv';
zhongnanhuang authored
3
import { RESPONSE_CODE } from '@/constants/enum';
曾国涛 authored
4
import AddInvoiceDrawerForm from '@/pages/Invoice/components/AddInvoiceDrawerForm';
曾国涛 authored
5
6
import InvoiceModal from '@/pages/Invoice/components/InvoiceModal';
import InvoiceRecordDetailModal from '@/pages/Invoice/components/InvoiceRecordDetailModal';
曾国涛 authored
7
import InvoicingModal from '@/pages/Invoice/components/InvoicingModal';
8
import ManualInvoicingModal from '@/pages/Invoice/components/ManualInvoicingModal';
zhongnanhuang authored
9
import {
zhongnanhuang authored
10
11
12
13
14
15
  BANK_STATEMENT_COLUMNS,
  INVOICE_COLUMNS,
  INVOICE_STATUS,
} from '@/pages/Invoice/constant';
import {
  postServiceBankStatementDeleteBankStatement,
zhongnanhuang authored
16
  postServiceBankStatementEditBankStatement,
zhongnanhuang authored
17
  postServiceBankStatementQueryBankStatement,
曾国涛 authored
18
  postServiceConstAfterInvoicingInvoiceRecordStatus,
曾国涛 authored
19
  postServiceConstBeforeInvoicingInvoiceRecordStatus,
曾国涛 authored
20
21
  postServiceConstInvoiceType,
  postServiceConstInvoicingType,
zhongnanhuang authored
22
  postServiceInvoiceDeleteInvoice,
曾国涛 authored
23
  postServiceInvoiceInvoicing,
zhongnanhuang authored
24
  postServiceInvoiceQueryInvoice,
曾国涛 authored
25
26
  postServiceInvoiceQueryInvoiceRecordList,
  postServiceOrderQuerySalesCode,
zhongnanhuang authored
27
} from '@/services';
曾国涛 authored
28
import { excelExport } from '@/services/exportRequest';
曾国涛 authored
29
30
import {
  enumToProTableEnumValue,
曾国涛 authored
31
  enumToSelect,
曾国涛 authored
32
33
34
  enumValueToLabel,
  formatDateTime,
} from '@/utils';
35
import { formatDate } from '@/utils/time';
36
import { PlusOutlined } from '@ant-design/icons';
曾国涛 authored
37
import { ActionType, ModalForm, ProTable } from '@ant-design/pro-components';
曾国涛 authored
38
import { Button, Space, Table, Tabs, message } from 'antd';
曾国涛 authored
39
import { useEffect, useRef, useState } from 'react';
40
import { INVOCING_STATUS, PAYEE_OPTIONS } from '../Order/constant';
41
import BankImportModal from './components/BankImportModal';
zhongnanhuang authored
42
import InvoiceVerificationModal from './components/InvoiceVerificationModal';
43
import './index.less';
曾国涛 authored
44
45
46
47
const InvoicePage = () => {
  const invoiceActionRef = useRef<ActionType>();
  const bankActionRef = useRef<ActionType>();
曾国涛 authored
48
  const waitDealrecordActionRef = useRef<ActionType>();
曾国涛 authored
49
  const processedRecordRef = useRef<ActionType>();
曾国涛 authored
50
51
52
  const [invoiceTypeValueEnum, setInvoiceTypeValueEnum] = useState({});
  const [invoicingTypeValueEnum, setInvoicingTypeValueEnum] = useState({});
  const [salesCodeValueEnum, setSalesCodeValueEnum] = useState({});
53
  const [bankImportModalVisible, setBankImportModalVisible] = useState(false);
zhongnanhuang authored
54
55
56
  const [invoiceVerificationVisible, setInvoiceVerificationVisible] =
    useState(false);
  const [invoiceId, setInvoiceId] = useState(undefined);
曾国涛 authored
57
58
59
  const [invoiceRecordDetailVisible, setInvoiceRecordDetailVisible] =
    useState(false);
  const [invoiceRecord, setInvoiceRecord] = useState({});
曾国涛 authored
60
  const [messageApi, contextHolder] = message.useMessage();
61
曾国涛 authored
62
63
64
65
66
  useEffect(() => {
    async function extracted() {
      let invoiceTypeRet = await postServiceConstInvoiceType();
      setInvoiceTypeValueEnum(invoiceTypeRet.data);
    }
67
曾国涛 authored
68
69
70
71
72
73
74
75
    extracted().catch(console.error);
  }, []);

  useEffect(() => {
    async function extracted() {
      let invoicingTypeRet = await postServiceConstInvoicingType();
      setInvoicingTypeValueEnum(invoicingTypeRet.data);
    }
76
曾国涛 authored
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    extracted().catch(console.error);
  }, []);

  useEffect(() => {
    async function extracted() {
      const res = await postServiceOrderQuerySalesCode();
      let map = {};
      res.data?.forEach((item) => {
        map[item.userName] = {
          text: item.userName,
          status: item.userName,
        };
      });
      setSalesCodeValueEnum(map);
    }

    extracted().catch(console.error);
曾国涛 authored
94
95
  }, []);
zhongnanhuang authored
96
97
98
99
100
101
  const reloadInvoiceTable = () => {
    invoiceActionRef.current?.reload();
  };

  const reloadBankStatementTable = () => {
    bankActionRef.current?.reload();
102
  };
曾国涛 authored
103
104
105
106
  const reloadRecordTable = () => {
    waitDealrecordActionRef.current?.reload();
    processedRecordRef.current?.reload();
  };
107
108
109
110
111
  const getTableCellText = (target: any) => {
    if (!target) {
      return '';
    }
112
113
114
115
    if (target.props) {
      return target.props.text;
    }
116
117
118
    return target;
  };
119
曾国涛 authored
120
121
122
123
  const waitDealRecordColumns = [
    {
      dataIndex: 'index',
      valueType: 'indexBorder',
曾国涛 authored
124
      hideInSearch: true,
曾国涛 authored
125
      ellipsis: true,
曾国涛 authored
126
127
128
      width: 48,
    },
    {
曾国涛 authored
129
      title: '开票编号',
曾国涛 authored
130
131
132
      valueType: 'text',
      dataIndex: 'id',
      copyable: true,
曾国涛 authored
133
      hideInSearch: true,
曾国涛 authored
134
135
      ellipsis: true,
      width: 100,
曾国涛 authored
136
137
    },
    {
曾国涛 authored
138
139
140
      title: '发票状态',
      valueType: 'Text',
      dataIndex: 'statusText',
曾国涛 authored
141
      ellipsis: true,
曾国涛 authored
142
143
144
      hideInSearch: true,
    },
    {
曾国涛 authored
145
146
147
148
      title: '申请开票时间',
      dataIndex: 'createTime',
      valueType: 'dateTime',
      hideInSearch: true,
曾国涛 authored
149
      ellipsis: true,
曾国涛 authored
150
151
    },
    {
曾国涛 authored
152
      title: '销售代表',
曾国涛 authored
153
      valueType: 'text',
曾国涛 authored
154
      hideInSearch: true,
曾国涛 authored
155
      ellipsis: true,
曾国涛 authored
156
      dataIndex: 'createByName',
曾国涛 authored
157
158
159
160
161
    },
    {
      title: '购方名称',
      valueType: 'text',
      dataIndex: 'partyAName',
曾国涛 authored
162
      hideInSearch: true,
曾国涛 authored
163
      ellipsis: true,
曾国涛 authored
164
165
166
167
    },
    {
      title: '购方税号',
      valueType: 'text',
曾国涛 authored
168
      hideInSearch: true,
曾国涛 authored
169
      dataIndex: 'partyATaxid',
曾国涛 authored
170
      ellipsis: true,
曾国涛 authored
171
172
173
174
    },
    {
      title: '收款单位',
      valueType: 'text',
曾国涛 authored
175
      hideInSearch: true,
曾国涛 authored
176
      dataIndex: 'partyBName',
曾国涛 authored
177
      ellipsis: true,
曾国涛 authored
178
179
180
181
182
    },
    {
      title: '开票金额',
      valueType: 'money',
      dataIndex: 'price',
曾国涛 authored
183
      hideInSearch: true,
曾国涛 authored
184
      ellipsis: true,
曾国涛 authored
185
186
187
188
189
190
    },
    {
      title: '开具类型',
      valueType: 'Text',
      dataIndex: 'invoicingTypeText',
      hideInSearch: true,
曾国涛 authored
191
      ellipsis: true,
曾国涛 authored
192
193
194
195
196
    },
    {
      title: '发票类型',
      valueType: 'Text',
      dataIndex: 'typeText',
曾国涛 authored
197
      hideInSearch: true,
曾国涛 authored
198
      ellipsis: true,
曾国涛 authored
199
200
201
202
203
204
    },
    {
      title: '是否加急',
      valueType: 'Text',
      dataIndex: 'isUrgentText',
      hideInSearch: true,
曾国涛 authored
205
      ellipsis: true,
曾国涛 authored
206
    },
曾国涛 authored
207
208
209
210
211
212
213
    {
      title: '申请备注',
      valueType: 'text',
      dataIndex: 'applyInvoicingNotes',
      hideInSearch: true,
      ellipsis: true,
    },
曾国涛 authored
214
    {
曾国涛 authored
215
216
217
218
219
220
221
      title: '购方名称',
      valueType: 'Text',
      dataIndex: 'partyANameLike',
      hideInTable: true,
    },
    {
      title: '收款单位',
曾国涛 authored
222
      valueType: 'select',
曾国涛 authored
223
      dataIndex: 'partyB',
曾国涛 authored
224
225
226
      filters: true,
      onFilter: true,
      hideInTable: true,
曾国涛 authored
227
      valueEnum: enumToProTableEnumValue(PAYEE_OPTIONS),
曾国涛 authored
228
229
    },
    {
曾国涛 authored
230
231
232
233
234
235
236
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
      title: '主订单号',
      valueType: 'Text',
      dataIndex: 'mainOrderId',
      hideInTable: true,
    },
    {
      title: '子订单号',
      valueType: 'Text',
      dataIndex: 'subOrderId',
      hideInTable: true,
    },
    {
      title: '销售代表',
      valueType: 'select',
      dataIndex: 'salesCode',
      filters: true,
      onFilter: true,
      hideInTable: true,
      valueEnum: salesCodeValueEnum,
    },
    {
      title: '发票类型',
      valueType: 'select',
      dataIndex: 'type',
      filters: true,
      onFilter: true,
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(invoiceTypeValueEnum),
    },
    {
      title: '开具类型',
      valueType: 'select',
      dataIndex: 'invoicingType',
      filters: true,
      onFilter: true,
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(invoicingTypeValueEnum),
    },
    {
曾国涛 authored
269
270
271
272
273
274
275
276
277
278
279
280
      title: '开票状态',
      valueType: 'select',
      dataIndex: 'status',
      filters: true,
      onFilter: true,
      hideInTable: true,
      request: async () => {
        const res = await postServiceConstBeforeInvoicingInvoiceRecordStatus();
        return enumToSelect(res.data);
      },
    },
    {
曾国涛 authored
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
      title: '是否加急',
      valueType: 'select',
      dataIndex: 'isUrgent',
      filters: true,
      onFilter: true,
      hideInTable: true,
      valueEnum: {
        true: {
          text: '是',
          status: true,
        },
        false: {
          text: '否',
          status: false,
        },
      },
    },
    {
      title: '申请开票时间',
      dataIndex: 'createTime',
      valueType: 'dateRange',
      width: 200,
      hideInTable: true,
      search: {
        transform: (value) => {
          if (value) {
            return {
              createTimeGe: value[0],
              createTimeLe: value[1],
            };
          }
        },
      },
    },
曾国涛 authored
315
    {
曾国涛 authored
316
317
318
      title: '操作',
      valueType: 'option',
      key: 'option',
曾国涛 authored
319
320
      render: (text, record) => {
        return [
曾国涛 authored
321
          /*<InvoiceRecordDetailModal
322
323
324
325
326
327
328
329
                      key="detail"
                      id={record.id}
                      subOrderIds={record.subOrderIds}
                      onClose={()=>{
                        waitDealrecordActionRef.current?.reload();
                      }
                      }
                    />*/
曾国涛 authored
330
331
332
333
334
335
336
337
338
          <a
            key="detail"
            onClick={() => {
              setInvoiceRecordDetailVisible(true);
              setInvoiceRecord(record);
            }}
          >
            详情
          </a>,
曾国涛 authored
339
          <InvoiceModal key="invoiceModal" recordId={record.id} />,
340
341
342
343
344
345
346
347
          <>
            {record.paths.includes('INVOICING') && (
              <ManualInvoicingModal
                key={'ManualInvoicingModal'}
                record={record}
              ></ManualInvoicingModal>
            )}
          </>,
曾国涛 authored
348
349
        ];
      },
曾国涛 authored
350
351
352
353
354
355
356
357
358
    },
  ];

  const processedRecordColumns = [
    {
      dataIndex: 'index',
      valueType: 'indexBorder',
    },
    {
曾国涛 authored
359
      title: '开票编号',
曾国涛 authored
360
361
362
      valueType: 'text',
      dataIndex: 'id',
      copyable: true,
曾国涛 authored
363
      ellipsis: true,
曾国涛 authored
364
365
366
367
    },
    {
      title: '发票号码',
      valueType: 'text',
曾国涛 authored
368
      dataIndex: 'invoiceNumber',
曾国涛 authored
369
      copyable: true,
曾国涛 authored
370
      ellipsis: true,
曾国涛 authored
371
372
373
374
375
376
    },
    {
      title: '开票日期',
      dataIndex: 'invoicingTime',
      valueType: 'dateTime',
      hideInSearch: true,
曾国涛 authored
377
      ellipsis: true,
曾国涛 authored
378
379
380
381
382
    },
    {
      title: '发票类型',
      valueType: 'Text',
      dataIndex: 'typeText',
曾国涛 authored
383
      hideInSearch: true,
曾国涛 authored
384
      ellipsis: true,
曾国涛 authored
385
386
387
388
389
390
    },
    {
      title: '发票状态',
      valueType: 'Text',
      dataIndex: 'statusText',
      hideInSearch: true,
曾国涛 authored
391
      ellipsis: true,
曾国涛 authored
392
393
394
395
396
    },
    {
      title: '购方名称',
      valueType: 'text',
      dataIndex: 'partyAName',
曾国涛 authored
397
      hideInSearch: true,
曾国涛 authored
398
      ellipsis: true,
曾国涛 authored
399
400
401
402
403
    },
    {
      title: '购方税号',
      valueType: 'text',
      dataIndex: 'partyATaxid',
曾国涛 authored
404
      ellipsis: true,
曾国涛 authored
405
406
407
408
409
    },
    {
      title: '收款单位',
      valueType: 'text',
      dataIndex: 'partyBName',
曾国涛 authored
410
      hideInSearch: true,
曾国涛 authored
411
      ellipsis: true,
曾国涛 authored
412
413
414
415
416
    },
    {
      title: '联系人',
      valueType: 'text',
      dataIndex: 'contacts',
曾国涛 authored
417
      hideInSearch: true,
曾国涛 authored
418
      ellipsis: true,
曾国涛 authored
419
420
421
422
423
424
    },
    {
      title: '申请人',
      valueType: 'text',
      dataIndex: 'createByName',
      hideInSearch: true,
曾国涛 authored
425
      ellipsis: true,
曾国涛 authored
426
427
428
429
430
    },
    {
      title: '开票金额(元)',
      valueType: 'money',
      dataIndex: 'price',
曾国涛 authored
431
      hideInSearch: true,
曾国涛 authored
432
      ellipsis: true,
曾国涛 authored
433
434
435
436
437
    },
    {
      title: '备注',
      valueType: 'text',
      dataIndex: 'contacts',
曾国涛 authored
438
      hideInSearch: true,
曾国涛 authored
439
      ellipsis: true,
曾国涛 authored
440
    },
曾国涛 authored
441
442
443
444
445
446
447
    {
      title: '失败原因',
      valueType: 'text',
      dataIndex: 'failureReason',
      hideInSearch: true,
      ellipsis: true,
    },
曾国涛 authored
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471

    {
      title: '购方名称',
      valueType: 'text',
      dataIndex: 'partyANameLike',
      hideInTable: true,
    },
    {
      title: '发票类型',
      valueType: 'select',
      dataIndex: 'type',
      filters: true,
      onFilter: true,
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(invoiceTypeValueEnum),
    },

    {
      title: '开票状态',
      valueType: 'select',
      dataIndex: 'status',
      filters: true,
      onFilter: true,
      hideInTable: true,
曾国涛 authored
472
473
474
      request: async () => {
        const res = await postServiceConstAfterInvoicingInvoiceRecordStatus();
        return enumToSelect(res.data);
曾国涛 authored
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
      },
    },
    {
      title: '销售代表',
      valueType: 'select',
      dataIndex: 'salesCode',
      filters: true,
      onFilter: true,
      hideInTable: true,
      valueEnum: salesCodeValueEnum,
    },
    {
      title: '联系人',
      valueType: 'text',
      dataIndex: 'contactsLike',
      hideInTable: true,
    },
    {
      title: '开票日期',
      dataIndex: 'invoicingTime',
      valueType: 'dateRange',
      hideInTable: true,
      search: {
        transform: (value) => {
          if (value) {
            return {
              invoicingTimeGe: value[0],
              invoicingTimeLe: value[1],
            };
          }
        },
      },
曾国涛 authored
507
508
    },
    {
曾国涛 authored
509
510
511
512
513
514
515
516
517
      title: '收款单位',
      valueType: 'select',
      dataIndex: 'partyB',
      filters: true,
      onFilter: true,
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(PAYEE_OPTIONS),
    },
    {
曾国涛 authored
518
519
520
      title: '操作',
      valueType: 'option',
      key: 'option',
曾国涛 authored
521
      render: (text, record) => [
曾国涛 authored
522
        <a
曾国涛 authored
523
          key="detail"
曾国涛 authored
524
525
526
527
528
529
530
          onClick={() => {
            setInvoiceRecordDetailVisible(true);
            setInvoiceRecord(record);
          }}
        >
          详情
        </a>,
曾国涛 authored
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
560
561
562
563
564
565
566
567
568
569
570
571
572
        <>
          {record.status === 'SUCCESS' && (
            <>
              {record.status === 'SUCCESS' && (
                <a href={record.invoiceAddress} download>
                  下载发票
                </a>
              )}
            </>
          )}
        </>,
        <>
          {record.status === 'FAIL' && (
            <ModalForm
              title="提示"
              trigger={
                <Button type="link" danger>
                  重试
                </Button>
              }
              autoFocusFirstInput
              modalProps={{
                destroyOnClose: true,
              }}
              submitTimeout={2000}
              onFinish={async () => {
                const res = await postServiceInvoiceInvoicing({
                  data: {
                    invoiceRecordIds: [record.id],
                  },
                });
                if (res) {
                  message.success(res.message);
                  processedRecordRef?.current?.reload();
                }
                return true;
              }}
            >
              确定重试订单信息吗?
            </ModalForm>
          )}
        </>,
573
574
575
576
577
578
579
580
        <>
          {record.paths.includes('INVOICING') && (
            <ManualInvoicingModal
              key={'ManualInvoicingModal'}
              record={record}
            ></ManualInvoicingModal>
          )}
        </>,
曾国涛 authored
581
582
583
      ],
    },
  ];
584
585
586
587
588
589
590
591
592
593
594
595
  /**
   * 加载发票列表表格的各个列格式
   */
  const invoicecColumnsInit = () => {
    let columns = INVOICE_COLUMNS.map((item) => {
      let newItem = { ...item };
      let dataIndex = item.dataIndex;
      let dataType = item.valueType;

      newItem.render = (text, record) => {
        let textValue = record[dataIndex];
zhongnanhuang authored
596
        if (dataType === 'dateRange' || dataType === 'date') {
597
598
599
600
601
602
603
604
605
606
607
608
609
610
          textValue = formatDate(textValue);
        }

        if (dataType === 'dateTime') {
          textValue = formatDateTime(textValue);
        }

        if (dataType === 'money') {
          textValue = '¥' + textValue;
        }

        switch (dataIndex) {
          case 'invoiceStatus':
            return (
zhongnanhuang authored
611
              <EllipsisDiv
612
613
614
615
616
617
618
619
620
                text={enumValueToLabel(
                  getTableCellText(textValue),
                  INVOCING_STATUS,
                )}
              />
            );

          case 'status':
            return (
zhongnanhuang authored
621
              <EllipsisDiv
622
623
624
625
626
627
628
629
630
                text={enumValueToLabel(
                  getTableCellText(textValue),
                  INVOICE_STATUS,
                )}
              />
            );

          case 'payee':
            return (
zhongnanhuang authored
631
              <EllipsisDiv
632
633
634
635
636
637
638
639
                text={enumValueToLabel(
                  getTableCellText(textValue),
                  PAYEE_OPTIONS,
                )}
              />
            );

          default:
zhongnanhuang authored
640
            return <EllipsisDiv text={getTableCellText(textValue)} />;
641
642
643
644
645
646
647
648
649
650
651
652
        }
      };

      return newItem;
    });

    columns.push({
      title: '操作',
      valueType: 'option',
      key: 'option',
      fixed: 'right',
      width: 120,
zhongnanhuang authored
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
      render: (text, record) => {
        let btns = [];
        if (record.path?.includes('writeOff')) {
          btns.push(
            <a
              key="editable"
              onClick={() => {
                setInvoiceVerificationVisible(true);
                setInvoiceId(record.invoiceId);
              }}
            >
              核销
            </a>,
          );
        }

        if (record.path?.includes('queryInvoiceDetails')) {
          btns.push(
            <Button
              className="p-0"
              key="view"
              type="link"
              onClick={() => {
                setInvoiceVerificationVisible(true);
                setInvoiceId(record.invoiceId);
              }}
            >
              查看
            </Button>,
          );
        }

        if (record.path?.includes('deleteInvoice')) {
          btns.push(
            <ButtonConfirm
              key="delete"
              className="p-0"
              title={
                '确认删除发票号码为[ ' + record.invoiceNumber + ' ]的发票吗?'
              }
              text="删除"
              onConfirm={async () => {
                let res = await postServiceInvoiceDeleteInvoice({
                  data: { invoiceId: record.invoiceId },
                });
                if (res) {
                  message.success(res.message);
                  reloadInvoiceTable();
                }
              }}
            />,
          );
        }
        return btns;
      },
zhongnanhuang authored
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
    });

    return columns;
  };

  const bankStatemetColumnsInit = () => {
    let columns = BANK_STATEMENT_COLUMNS.map((item) => {
      let newItem = { ...item };
      let dataIndex = item.dataIndex;
      let dataType = item.valueType;

      newItem.render = (text, record) => {
        let textValue = record[dataIndex];

        if (dataType === 'date') {
          textValue = formatDate(textValue);
        }

        if (dataType === 'dateTime') {
          textValue = formatDateTime(textValue);
        }

        if (dataType === 'money') {
zhongnanhuang authored
731
732
733
734
735
          if (textValue === null || textValue === undefined) {
            textValue = '';
          } else {
            textValue = '¥' + textValue;
          }
zhongnanhuang authored
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
        }

        switch (dataIndex) {
          case 'invoiceStatus':
            return (
              <EllipsisDiv
                text={enumValueToLabel(
                  getTableCellText(textValue),
                  INVOCING_STATUS,
                )}
              />
            );

          case 'status':
            return (
              <EllipsisDiv
                text={enumValueToLabel(
                  getTableCellText(textValue),
                  INVOICE_STATUS,
                )}
              />
            );

          case 'payee':
            return (
              <EllipsisDiv
                text={enumValueToLabel(
                  getTableCellText(textValue),
                  PAYEE_OPTIONS,
                )}
              />
            );

          default:
            return <EllipsisDiv text={getTableCellText(textValue)} />;
        }
      };

      return newItem;
    });

    columns.push({
      title: '操作',
      valueType: 'option',
      key: 'option',
      fixed: 'right',
      width: 120,
zhongnanhuang authored
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
      render: (text, record, _, action) => {
        let btns = [];
        if (record.path?.includes('editBankStatement')) {
          btns.push(
            <a
              key="editable"
              onClick={() => {
                action?.startEditable?.(record.id);
              }}
            >
              编辑
            </a>,
          );
        }

        if (record.path?.includes('deleteBankStatement')) {
          btns.push(
            <ButtonConfirm
              key="delete"
              className="p-0"
              title={'是否删除该银行流水记录?'}
              text="删除"
              onConfirm={async () => {
                let res = await postServiceBankStatementDeleteBankStatement({
                  data: { id: record.id },
                });
                if (res.result === RESPONSE_CODE.SUCCESS) {
                  message.success(res.message);
                  reloadBankStatementTable();
                }
              }}
            />,
          );
        }
        return btns;
      },
819
820
821
822
823
824
825
826
    });

    return columns;
  };

  const tabsItems = [
    {
      key: 1,
曾国涛 authored
827
828
829
830
831
832
833
834
835
      label: '待处理',
      children: (
        <ProTable
          columns={waitDealRecordColumns}
          actionRef={waitDealrecordActionRef}
          cardBordered
          pagination={{
            pageSize: 10,
          }}
曾国涛 authored
836
837
          rowSelection={{
            selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
曾国涛 authored
838
            alwaysShowAlert: true,
曾国涛 authored
839
840
841
842
843
844
845
          }}
          tableAlertOptionRender={({ selectedRowKeys, selectedRows }) => {
            console.log(selectedRows);
            console.log(selectedRowKeys);
            return (
              <Space size={16}>
                <InvoicingModal
曾国涛 authored
846
                  reloadRecordTable={reloadRecordTable}
曾国涛 authored
847
848
849
850
851
852
                  key="button"
                  selectedRowKeys={selectedRowKeys}
                />
              </Space>
            );
          }}
曾国涛 authored
853
854
          request={async (params) => {
            let res = await postServiceInvoiceQueryInvoiceRecordList({
曾国涛 authored
855
              data: {
曾国涛 authored
856
                ...params,
曾国涛 authored
857
858
859
860
                statusIn: [
                  'WAITING_FOR_INVOICING',
                  'AUDITING',
                  'AUDITING_NOT_PASSED',
曾国涛 authored
861
                  'CANCELED',
曾国涛 authored
862
                ],
863
                needBuildDetails: true,
曾国涛 authored
864
                needBuildSubOrders: true,
曾国涛 authored
865
              },
曾国涛 authored
866
            });
曾国涛 authored
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
            return {
              data: res?.data?.data,
              total: res?.data?.total || 0,
            };
          }}
          columnsState={{
            persistenceKey: 'pro-table-singe-demos',
            persistenceType: 'localStorage',
            defaultValue: {
              option: { fixed: 'right', disable: true },
            },
            onChange(value) {
              console.log('value: ', value);
            },
          }}
          rowKey="id"
          search={{
            labelWidth: 'auto',
          }}
          options={{
            setting: {
              listsHeight: 400,
            },
          }}
          form={{}}
          dateFormatter="string"
          headerTitle="待开票列表"
          scroll={{ x: 1400, y: 360 }}
        />
      ),
    },
    {
      key: 2,
      label: '开票记录',
      children: (
        <ProTable
          columns={processedRecordColumns}
曾国涛 authored
904
          actionRef={processedRecordRef}
曾国涛 authored
905
906
907
908
909
910
911
912
913
914
915
916
917
918
          cardBordered
          pagination={{
            pageSize: 10,
          }}
          editable={{
            type: 'multiple',
            onSave: async (rowKey, data) => {
              await postServiceBankStatementEditBankStatement({ data: data });
            },
            actionRender: (row, config, defaultDom) => [
              defaultDom.save,
              defaultDom.cancel,
            ],
          }}
曾国涛 authored
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
          search={{
            labelWidth: 'auto',
            defaultCollapsed: false,
            optionRender: (searchConfig, formProps, dom) => [
              ...dom,
              <Button
                key="out"
                onClick={() => {
                  const values = searchConfig?.form?.getFieldsValue();
                  console.log(values);
                  messageApi.open({
                    type: 'loading',
                    content: '正在导出文件...',
                  });
                  excelExport(
                    '/api/service/invoice/exportInvoiceRecords',
                    {
                      ...values,
                      statusIn: ['INVOICING', 'SUCCESS', 'FAIL'],
                    },
                    () => {
                      messageApi.destroy();
                    },
                  );
                }}
              >
                导出
              </Button>,
            ],
          }}
曾国涛 authored
949
950
          request={async (params) => {
            let res = await postServiceInvoiceQueryInvoiceRecordList({
曾国涛 authored
951
              data: {
曾国涛 authored
952
                ...params,
曾国涛 authored
953
                statusIn: ['INVOICING', 'SUCCESS', 'FAIL'],
曾国涛 authored
954
              },
曾国涛 authored
955
            });
曾国涛 authored
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
            return {
              data: res?.data?.data,
              total: res?.data?.total || 0,
            };
          }}
          columnsState={{
            persistenceKey: 'pro-table-singe-demos',
            persistenceType: 'localStorage',
            defaultValue: {
              option: { fixed: 'right', disable: true },
            },
            onChange(value) {
              console.log('value: ', value);
            },
          }}
          rowKey="id"
          options={{
            setting: {
              listsHeight: 400,
            },
          }}
          form={{}}
          dateFormatter="string"
          headerTitle="待开票列表"
          scroll={{ x: 1400, y: 360 }}
          toolBarRender={() => []}
        />
      ),
    },
    {
      key: 3,
987
      label: '发票管理',
zhongnanhuang authored
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
      children: (
        <ProTable
          columns={invoicecColumnsInit()}
          actionRef={invoiceActionRef}
          cardBordered
          pagination={{
            pageSize: 10,
          }}
          request={async (params) => {
            const res = await postServiceInvoiceQueryInvoice({
              data: { ...params },
            });
            if (res) {
              return {
                data: res?.data?.data || [],
                total: res?.data?.total || 0,
              };
            }
          }}
          columnsState={{
            persistenceKey: 'pro-table-singe-demos',
            persistenceType: 'localStorage',
            defaultValue: {
              option: { fixed: 'right', disable: true },
            },
            onChange(value) {
              console.log('value: ', value);
            },
          }}
          rowKey="id"
          search={{
            labelWidth: 'auto',
          }}
          options={{
            setting: {
              listsHeight: 400,
            },
          }}
          form={{}}
          dateFormatter="string"
          headerTitle="发票列表"
          scroll={{ x: 1400, y: 360 }}
曾国涛 authored
1030
1031
1032
1033
1034
1035
          toolBarRender={() => [
            <AddInvoiceDrawerForm
              onClose={() => {
                invoiceActionRef.current?.reload();
                bankActionRef.current?.reload();
              }}
曾国涛 authored
1036
              key="add"
曾国涛 authored
1037
1038
            ></AddInvoiceDrawerForm>,
          ]}
zhongnanhuang authored
1039
1040
        />
      ),
1041
1042
    },
    {
曾国涛 authored
1043
      key: 4,
1044
      label: '银行流水',
zhongnanhuang authored
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
      children: (
        <ProTable
          columns={bankStatemetColumnsInit()}
          actionRef={bankActionRef}
          cardBordered
          pagination={{
            pageSize: 10,
          }}
          editable={{
            type: 'multiple',
            onSave: async (rowKey, data) => {
              await postServiceBankStatementEditBankStatement({ data: data });
            },
            actionRender: (row, config, defaultDom) => [
              defaultDom.save,
              defaultDom.cancel,
            ],
          }}
          request={async (params) => {
            const res = await postServiceBankStatementQueryBankStatement({
              data: { ...params },
            });
            if (res) {
              return {
                data: res?.data?.data || [],
                total: res?.data?.total || 0,
              };
            }
          }}
          columnsState={{
            persistenceKey: 'pro-table-singe-demos',
            persistenceType: 'localStorage',
            defaultValue: {
              option: { fixed: 'right', disable: true },
            },
            onChange(value) {
              console.log('value: ', value);
            },
          }}
          rowKey="id"
          search={{
            labelWidth: 'auto',
          }}
          options={{
            setting: {
              listsHeight: 400,
            },
          }}
          form={{}}
          dateFormatter="string"
          headerTitle="银行流水列表"
          scroll={{ x: 1400, y: 360 }}
          toolBarRender={() => [
            <Button
              key="button"
              icon={<PlusOutlined />}
              onClick={() => {
                setBankImportModalVisible(true);
              }}
              type="primary"
            >
              导入
            </Button>,
          ]}
        />
      ),
1111
1112
    },
  ];
1113
  return (
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
    <div className="invoice-index">
      <Tabs
        defaultActiveKey="1"
        items={tabsItems}
        onChange={(value) => {
          if (value === 1) {
            invoiceActionRef.current?.reload();
          } else {
            bankActionRef.current?.reload();
          }
1124
        }}
1125
      />
1126
1127
1128
1129

      {bankImportModalVisible ? (
        <BankImportModal
          setVisible={setBankImportModalVisible}
zhongnanhuang authored
1130
          onClose={() => {
1131
            setBankImportModalVisible(false);
zhongnanhuang authored
1132
1133
1134
            invoiceActionRef.current?.reload();
            bankActionRef.current?.reload();
          }}
1135
1136
1137
1138
        ></BankImportModal>
      ) : (
        ''
      )}
zhongnanhuang authored
1139
1140
1141
1142
1143

      {invoiceVerificationVisible ? (
        <InvoiceVerificationModal
          setVisible={setInvoiceVerificationVisible}
          invoiceId={invoiceId}
zhongnanhuang authored
1144
1145
1146
1147
          onClose={() => {
            invoiceActionRef.current?.reload();
            bankActionRef.current?.reload();
          }}
zhongnanhuang authored
1148
1149
1150
1151
        ></InvoiceVerificationModal>
      ) : (
        ''
      )}
曾国涛 authored
1152
1153
1154
1155
1156
1157
1158
1159
1160
      {invoiceRecordDetailVisible ? (
        <InvoiceRecordDetailModal
          key="detail"
          id={invoiceRecord.id}
          setVisible={setInvoiceRecordDetailVisible}
        />
      ) : (
        ''
      )}
曾国涛 authored
1161
      {contextHolder}
1162
    </div>
1163
1164
1165
1166
  );
};

export default InvoicePage;