Blame view

src/pages/Order/index.tsx 96.1 KB
sanmu authored
1
import ButtonConfirm from '@/components/ButtomConfirm';
zhongnanhuang authored
2
3
import { RESPONSE_CODE } from '@/constants/enum';
import {
4
5
  postKingdeeRepSalBillOutbound,
  postKingdeeRepSalOrderSave,
zhongnanhuang authored
6
  postServiceOrderNoNeedSend,
zhongnanhuang authored
7
  postServiceOrderOrderCancel,
8
  postServiceOrderProcureOrder,
zhongnanhuang authored
9
  postServiceOrderProcurePrint,
zhongnanhuang authored
10
  postServiceOrderQueryServiceOrder,
11
  postServiceOrderSaleCancelInvoicing,
zhongnanhuang authored
12
13
} from '@/services';
import { orderExport } from '@/services/order';
14
15
16
17
18
19
import {
  copyToClipboard,
  enumToProTableEnumValue,
  enumValueToLabel,
  formatDateTime,
} from '@/utils';
zhongnanhuang authored
20
import { getUserInfo } from '@/utils/user';
zhongnanhuang authored
21
import {
zhongnanhuang authored
22
  ClockCircleTwoTone,
zhongnanhuang authored
23
  ContainerTwoTone,
zhongnanhuang authored
24
  CopyTwoTone,
zhongnanhuang authored
25
  DownOutlined,
zhongnanhuang authored
26
  EditTwoTone,
zhongnanhuang authored
27
  EllipsisOutlined,
zhongnanhuang authored
28
  QuestionCircleOutlined,
zhongnanhuang authored
29
} from '@ant-design/icons';
calmound authored
30
import {
zhongnanhuang authored
31
  ActionType,
calmound authored
32
  PageContainer,
sanmu authored
33
  ProColumns,
zhongnanhuang authored
34
  ProFormInstance,
sanmu authored
35
  ProTable,
calmound authored
36
} from '@ant-design/pro-components';
zhongnanhuang authored
37
import { history } from '@umijs/max';
zhongnanhuang authored
38
import {
zhongnanhuang authored
39
  Avatar,
zhongnanhuang authored
40
41
  Button,
  Checkbox,
zhongnanhuang authored
42
  Divider,
zhongnanhuang authored
43
44
  Dropdown,
  Flex,
45
  Image,
zhongnanhuang authored
46
47
48
  MenuProps,
  Space,
  Tag,
zhongnanhuang authored
49
  Tooltip,
zhongnanhuang authored
50
51
52
  message,
} from 'antd';
import { cloneDeep } from 'lodash';
zhongnanhuang authored
53
import React, { Key, useEffect, useRef, useState } from 'react';
zhongnanhuang authored
54
import OrderPrintModal from '../OrderPrint/OrderPrintModal';
zhongnanhuang authored
55
import AfterSalesDrawer from './components/AfterSalesDrawer';
zhongnanhuang authored
56
import ApplyForInvoicingModal from './components/ApplyForInvoicingModal';
zhongnanhuang authored
57
import AttachmentModal from './components/AttachmentModal';
sanmu authored
58
import CheckModal from './components/CheckModal';
zhongnanhuang authored
59
import ConfirmReceiptModal from './components/ConfirmReceiptModal';
zhongnanhuang authored
60
import DeliverInfoDrawer from './components/DeliverInfoDrawer';
sanmu authored
61
import DeliverModal from './components/DeliverModal';
zhongnanhuang authored
62
import FinancialDrawer from './components/FinancialDrawer';
63
import FinancialEditDrawer from './components/FinancialEditDrawer';
64
import FinancialMergeDrawer from './components/FinancialMergeDrawer';
zhongnanhuang authored
65
import FinancialReceiptsModal from './components/FinancialReceiptsModal';
zhongnanhuang authored
66
import HistoryModal from './components/HistoryModal';
zhongnanhuang authored
67
import ImportModal from './components/ImportModal';
sanmu authored
68
import OrderDrawer from './components/OrderDrawer';
zhongnanhuang authored
69
import OrderNotesEditModal from './components/OrderNotesEditModal';
zhongnanhuang authored
70
import ProcureCheckModal from './components/ProcureCheckModal';
71
import ProcureConvertModal from './components/ProcureConvertModal';
zhongnanhuang authored
72
import SubOrderComfirmReceiptImagesModal from './components/SubOrderComfirmReceiptImagesModal';
73
import {
74
  AFTER_INVOICING_STATUS,
zhongnanhuang authored
75
  CHECK_TYPE,
zhongnanhuang authored
76
  LOGISTICS_STATUS_OPTIONS,
77
78
79
80
  MAIN_ORDER_COLUMNS,
  ORDER_STATUS_OPTIONS,
  PAYMENT_CHANNEL_OPTIONS,
  PAYMENT_METHOD_OPTIONS,
81
  PROCURE_ORDER_STATUS,
zhongnanhuang authored
82
  PRODUCT_BELONG_DEPARTMENT_OPTIONS,
zhongnanhuang authored
83
  TAGS_COLOR,
zhongnanhuang authored
84
85
  getInvoicingType,
  getNeedInvoicing,
86
} from './constant';
sanmu authored
87
import './index.less';
sanmu authored
88
import { OrderListItemType, OrderType } from './type.d';
calmound authored
89
sanmu authored
90
const OrderPage = () => {
sanmu authored
91
  const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false);
sanmu authored
92
  const [checkVisible, setCheckVisible] = useState<boolean>(false);
zhongnanhuang authored
93
  const [orderPrintVisible, setOrderPrintVisible] = useState<boolean>(false);
94
  const [allMainChecked, setAllMainChecked] = useState(false);
zhongnanhuang authored
95
96
97
98
  const [
    subOrderConfirmReceiptImagesVisible,
    setSubOrderConfirmReceiptImagesVisible,
  ] = useState<boolean>(false);
99
  const [data, setData] = useState([]); //列表数据
100
  const [notesEditVisible, setNotesEditVisible] = useState<boolean>(false);
101
102
  const [financialMergeDrawerVisible, setFinancialMergeDrawerVisible] =
    useState<boolean>(false);
zhongnanhuang authored
103
104
  const [attachmentModalVisible, setAttachmentModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
105
106
  const [financialReceiptsModalVisible, setFinancialReceiptsModalVisible] =
    useState(false);
zhongnanhuang authored
107
  const [financialVisible, setFinancialVisible] = useState<boolean>(false);
108
109
  const [financialEditVisible, setFinancialEditVisible] =
    useState<boolean>(false);
zhongnanhuang authored
110
111
  const [afterSalesDrawerVisible, setAfterSalesDrawerVisible] =
    useState<boolean>(false);
zhongnanhuang authored
112
113
  const [historyModalVisible, setHistoryModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
114
115
116
  const [isRePrintOrder, setIsRePrintOrder] = useState<boolean>(false);
  const [isSendProduct, setIsSendProduct] = useState<boolean>(false);
  const [isMainOrder, setIsMainOrder] = useState<boolean>(false);
zhongnanhuang authored
117
  const [importModalVisible, setImportModalVisible] = useState<boolean>(false);
zhongnanhuang authored
118
119
  const [applyForInvoicingVisible, setApplyForInvoicingVisible] =
    useState<boolean>(false);
zhongnanhuang authored
120
121
  const [procureCheckModalVisible, setProcureCheckModalVisible] =
    useState<boolean>(false);
122
123
  const [procureConvertModalVisible, setProcureConvertModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
124
125
  const [confirmReceiptVisible, setConfirmReceiptVisible] =
    useState<boolean>(false);
sanmu authored
126
  const [deliverVisible, setDeliverVisible] = useState<boolean>(false);
zhongnanhuang authored
127
128
  const [deliverInfoDrawerVisible, setDeliverInfoDrawerVisible] =
    useState<boolean>(false);
129
  const [orderOptType, setOrderOptType] = useState<string>('');
zhongnanhuang authored
130
  const [isEdit, setIsEdit] = useState<boolean>(false);
131
  const [expandedRowKeys, setExpandedRowKeys] = useState<Key[]>([]);
sanmu authored
132
  const [orderRow, setOrderRow] = useState<Partial<OrderType>>({});
zhongnanhuang authored
133
  const [mainOrderAllItemKeys, setMainOrderAllItemKeys] = useState([]);
zhongnanhuang authored
134
  const [rolePath, setRolePath] = useState([]); //当前角色权限(新增跟打印按钮)
zhongnanhuang authored
135
  const userInfo = getUserInfo();
zhongnanhuang authored
136
  // const [tableHeight, setTableHeight] = useState(200);
sanmu authored
137
138
  const [selectedRows, setSelectedRows] = useState({});
  const [selectedRowObj, setSelectedRowObj] = useState({});
139
  const [selectedItems, setSelectedItems] = useState([]);
zhongnanhuang authored
140
  const [selectedRowKeys, setSelectedRowKeys] = useState([]);
zhongnanhuang authored
141
142
  const [pageSize, setPageSize] = useState(10);
  const [currentPage, setCurrentPage] = useState(1);
zhongnanhuang authored
143
  const [orderCheckType, setOrderCheckType] = useState('');
zhongnanhuang authored
144
  const [onlyShowCancelOrder, setOnlyShowCancelOrder] = useState(false);
zhongnanhuang authored
145
146
  const [onlyShowProcureToBeProcessed, setOnlyShowProcureToBeProcessed] =
    useState(false);
147
  const [mainOrderSelectedMap] = useState(new Map()); //选中的主订单Map
148
  const [mainOrderSelectedRows, setMainOrderSelectedRows] = useState([]); //选中的主订单集合
zhongnanhuang authored
149
150
  const [onlyShowFinancialToBeProcessed, setOnlyShowFinancialToBeProcessed] =
    useState(false);
zhongnanhuang authored
151
152
  const mainTableRef = useRef<ActionType>();
  const mainTableFormRef = useRef<ProFormInstance>();
zhongnanhuang authored
153
  let [searchParams, setSearchParam] = useState(Object); //表格的查询条件存储
zhongnanhuang authored
154
155
  const [messageApi, contextHolder] = message.useMessage();
zhongnanhuang authored
156
157
158
159
160
161
162
163
164
165
166
  // const openCheckNotes = (checkNotes: string) => {
  //   Modal.info({
  //     title: '驳回备注',
  //     content: (
  //       <div>
  //         <p>{checkNotes}</p>
  //       </div>
  //     ),
  //     onOk() { },
  //   });
  // };
zhongnanhuang authored
167
zhongnanhuang authored
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
  const exportLoading = () => {
    messageApi.open({
      type: 'loading',
      content: '正在导出文件...',
      duration: 0,
    });
  };

  const exportLoadingDestory = () => {
    messageApi.destroy();
  };

  const refreshTable = () => {
    mainTableRef.current?.reload();
    //刷新表格数据的时候,取消选中行
    setSelectedRowObj([]);
    setSelectedRows([]);
    setSelectedRowKeys([]);
  };
187
zhongnanhuang authored
188
189
190
191
192
  function changeCancelOrderShow(e: any) {
    setOnlyShowCancelOrder(e.target.checked);
    refreshTable();
  }
zhongnanhuang authored
193
194
195
196
197
198
199
200
201
202
  function changeProcureToBeProcessed(e: any) {
    setOnlyShowProcureToBeProcessed(e.target.checked);
    refreshTable();
  }

  function changeFinancialToBeProcessed(e: any) {
    setOnlyShowFinancialToBeProcessed(e.target.checked);
    refreshTable();
  }
203
204
205
206
207
208
209
  /**
   * 复制订单到剪贴板
   * @param record
   */
  function copyOrderToClipboard(record: any) {
    let text = '';
    text += record?.id;
zhongnanhuang authored
210
    text += ',' + record?.salesCode;
211
212
213
    text += ',' + record?.customerName;
    text += ',' + record?.customerContactNumber;
    text += ',' + record?.customerShippingAddress;
zhongnanhuang authored
214
215
    text += ',' + record?.institutionContactName;
    text += ',' + record?.institution;
216
217
218
219
220
221
222
223
224
225
226
227
228
229
    record?.subOrderInformationLists?.forEach((item) => {
      text += '\n';
      text += item?.productName;
      text += ' ' + item?.parameters;
      text += ' ' + item?.quantity;
      text += ' ' + item?.unit;
    });
    if (copyToClipboard(text)) {
      message.info('已复制到剪贴板');
    } else {
      message.info('无法复制到剪贴板');
    }
  }
zhongnanhuang authored
230
231
232
233
234
235
236
237
238
  // const resize = () => {
  //   // 计算元素底部到视口顶部的距离
  //   let bottomDistance = document
  //     .getElementById('mainTable')
  //     ?.getElementsByClassName('ant-table-thead')[0]
  //     .getBoundingClientRect().bottom;
  //   // 获取屏幕高度
  //   let screenHeight =
  //     window.innerHeight || document.documentElement.clientHeight;
239
zhongnanhuang authored
240
241
  //   // 计算元素底部到屏幕底部的距离
  //   let bottomToScreenBottomDistance = screenHeight - bottomDistance;
242
zhongnanhuang authored
243
244
  //   // //底部分页元素的高度
  //   // var pH = screenHeight - document.getElementById("main-table").getElementsByClassName('ant-table-body')[0].getBoundingClientRect().bottom;
245
zhongnanhuang authored
246
247
  //   setTableHeight(bottomToScreenBottomDistance - 88);
  // };
248
zhongnanhuang authored
249
250
251
252
253
  // useEffect(() => {
  //   resize();
  //   // 添加事件监听器,当窗口大小改变时调用resize方法
  //   window.addEventListener('resize', resize);
  // });
254
zhongnanhuang authored
255
256
257
258
259
260
261
262
263
264
265
266
  const MyToolTip = ({ title, content }) => {
    return (
      <Tooltip
        color="#FFFFFF"
        placement="bottom"
        title={<div className="px-5 py-4 text-black">{title}</div>}
      >
        {content}
      </Tooltip>
    );
  };
zhongnanhuang authored
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
  /**
   * 检查是否可以打印
   * @param paths 按钮集合
   * @returns
   */
  function checkePrintable(paths: any) {
    if (
      !paths?.includes('printOrder') &&
      !paths?.includes('supplierPrint') &&
      !paths?.includes('procurePrint') &&
      !paths?.includes('rePrintOrder')
    ) {
      return false;
    }

    return true;
  }
zhongnanhuang authored
285
286
287
288
289
  const onCheckboxChange = (record: never) => {
    let newSelectedItems = [];
    if (selectedItems.includes(record.id)) {
      newSelectedItems = selectedItems.filter((key) => key !== record.id);
      setSelectedRowKeys([]);
290
      console.log(selectedRowObj);
zhongnanhuang authored
291
292
293
294
295
296
      setSelectedRowObj({
        ...setSelectedRowObj,
        [record.id]: [],
      });
      selectedRowObj[record.id] = [];
      setSelectedRows([]);
297
298
299

      //取消选中主订单
      mainOrderSelectedMap.delete(record.id);
zhongnanhuang authored
300
301
302
303
304
305
306
    } else {
      newSelectedItems = [...selectedItems, record.id];
      //子订单全部自动选中
      let subIds = record.subOrderInformationLists?.map((item) => {
        return item.id;
      });
      setSelectedRowKeys(subIds);
307
zhongnanhuang authored
308
309
310
311
312
313
      setSelectedRowObj({
        ...setSelectedRowObj,
        [record.id]: record.subOrderInformationLists,
      });
      selectedRowObj[record.id] = record.subOrderInformationLists;
      setSelectedRows(record.subOrderInformationLists);
314
315
316

      //选中主订单
      mainOrderSelectedMap.set(record.id, record);
zhongnanhuang authored
317
    }
318
319
    setSelectedItems(newSelectedItems);
  };
zhongnanhuang authored
320
321
322
323
  const handleTableExpand = (mainOrderIds: any) => {
    setExpandedRowKeys(mainOrderIds);
  };
324
325
326
  const allMainCheckBoxChange = () => {
    let checked = !allMainChecked;
    setAllMainChecked(checked);
327
328

    mainOrderSelectedMap.clear();
329
330
    if (checked) {
      let mainOrderIds = data?.map((item) => {
331
        mainOrderSelectedMap.set(item.id, item);
332
333
334
        return item.id;
      });
zhongnanhuang authored
335
336
      let rowObj = {};
      data?.forEach((item) => {
337
338
339
340
341
342
343
344
345
        let id = item.id;
        rowObj[id] = item;
      });
      setSelectedItems(mainOrderIds);
    } else {
      setSelectedItems([]);
    }
  };
zhongnanhuang authored
346
347
348
349
  //表头渲染
  const OrderTableHeader = () => {
    return (
      <Flex className="w-full">
350
351
352
353
354
355
356
        <Flex className="w-[1%] ml-[7px]">
          <Checkbox
            onChange={allMainCheckBoxChange}
            checked={allMainChecked}
          ></Checkbox>
        </Flex>
        <Flex className="w-[30%] ml-[1%]">
zhongnanhuang authored
357
358
          <span className="font-medium">商品信息</span>
        </Flex>
359
        <Flex className="w-[13%]">
zhongnanhuang authored
360
361
362
363
364
          <span className="font-medium">交易金额</span>
        </Flex>
        <Flex className="w-[10%]">
          <span className="font-medium">支付</span>
        </Flex>
365
        <Flex className="w-[12%]">
zhongnanhuang authored
366
367
368
369
370
371
372
373
          <span className="font-medium">其他</span>
        </Flex>
        <Flex className="w-[10%]">
          <span className="font-medium">交易状态</span>
        </Flex>
        <Flex className="w-[17%]">
          <span className="font-medium">操作</span>
        </Flex>
zhongnanhuang authored
374
375
376
377
378
      </Flex>
    );
  };
  //子订单内容渲染
  const SubOderRander = ({ record, optRecord }) => {
zhongnanhuang authored
379
380
381
382
383
384
385
386
387
    /**
     * 获取订单状态标签
     * @param optRecord
     */
    function getOrderStatusTag(optRecord: any): import('react').ReactNode {
      const orderStatus = optRecord.orderStatus;
      if (orderStatus === 'AUDIT_FAILED') {
        return (
          <MyToolTip
388
            key="key"
zhongnanhuang authored
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
            title={optRecord.checkNotes}
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
                  {enumValueToLabel(
                    optRecord.orderStatus,
                    ORDER_STATUS_OPTIONS,
                  )}
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }

      if (
        orderStatus === 'AFTER_SALES_COMPLETION' ||
        orderStatus === 'IN_AFTER_SALES'
      ) {
        return (
zhongnanhuang authored
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
          // <MyToolTip
          //   key="key"
          //   title={
          //     enumValueToLabel(
          //       optRecord.afterSalesPlan,
          //       AFTE_SALES_PLAN_OPTIONS,
          //     ) +
          //     ' ' +
          //     optRecord.afterSalesNotes
          //   }
          //   content={
          //     <>
          //       <Tag
          //         color={TAGS_COLOR.get(optRecord.orderStatus)}
          //         style={{ marginRight: '4px' }}
          //       >
          //         {enumValueToLabel(
          //           optRecord.orderStatus,
          //           ORDER_STATUS_OPTIONS,
          //         )}
          //       </Tag>
          //       <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
          //     </>
          //   }
          // />
          <Tag
            color={TAGS_COLOR.get(optRecord.orderStatus)}
            style={{ marginRight: '4px' }}
          >
            {enumValueToLabel(optRecord.orderStatus, ORDER_STATUS_OPTIONS)}
          </Tag>
zhongnanhuang authored
444
445
446
        );
      }
zhongnanhuang authored
447
448
449
      if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') {
        return (
          <MyToolTip
450
            key="key"
zhongnanhuang authored
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
            title={optRecord.checkNotes}
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
                  {enumValueToLabel(
                    optRecord.orderStatus,
                    ORDER_STATUS_OPTIONS,
                  )}
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }
zhongnanhuang authored
470
      return (
471
        <Tag key="key" color={TAGS_COLOR.get(optRecord.orderStatus)}>
zhongnanhuang authored
472
473
474
475
476
          {enumValueToLabel(optRecord.orderStatus, ORDER_STATUS_OPTIONS)}
        </Tag>
      );
    }
477
478
479
480
481
482
483
484
    //申请开票附件处理
    const getAfterAnnexList = () => {
      let links = [];
      let afterAnnexList = optRecord.afterAnnexList;
      let i = 1;
      if (afterAnnexList?.length > 0) {
        for (let url of afterAnnexList) {
          links.push(
485
            <a key={i} className="pl-2" href={url}>
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
              附件{i++}
            </a>,
          );
        }
      }

      return links;
    };

    //财务审核附件处理
    const getInvoicingCheckAnnexList = () => {
      let invoicingCheckAnnexList = optRecord.invoicingCheckAnnexList;
      return (
        <div>
          <Image.PreviewGroup
            className="mr-10"
            preview={{
              onChange: (current, prev) =>
                console.log(`current index: ${current}, prev index: ${prev}`),
            }}
zhongnanhuang authored
506
          >
507
508
            {invoicingCheckAnnexList.map((url, index) => (
              <React.Fragment key={index}>
509
510
                <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '}
                <Divider type="vertical" />
511
              </React.Fragment>
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
            ))}
          </Image.PreviewGroup>
        </div>
      );
    };

    return (
      <>
        <Flex className="w-full border-b-indigo-500">
          <Flex vertical className="w-[31%]" gap="small">
            {/* 商品名称 */}
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={optRecord.productName}
            >
              <span className="font-medium text-black ">
                {optRecord.productName}
              </span>
            </div>
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={optRecord.parameters}
            >
zhongnanhuang authored
535
              <span className="text-[#8C8C8C]">
536
                参数:{optRecord.parameters}
zhongnanhuang authored
537
              </span>
zhongnanhuang authored
538
            </div>
539
540
541
542
543
544
545
546
547
            <Flex title={optRecord.notes}>
              <div className="max-w-[90%] whitespace-no-wrap overflow-hidden overflow-ellipsis">
                <span className="text-[#8C8C8C]">
                  备注:
                  {optRecord.notes === undefined ? '暂无备注' : optRecord.notes}
                </span>
              </div>
              {/* 编辑备注按钮 */}
              <EditTwoTone
zhongnanhuang authored
548
                className="pl-1 hover:curcor-pointer"
549
550
551
552
553
554
555
                onClick={() => {
                  setNotesEditVisible(true);
                  setOrderRow(optRecord);
                  setIsMainOrder(false);
                }}
              />
            </Flex>
556
557
558
            {/* {optRecord.applyInvoicingNotes !== undefined &&
            optRecord.applyInvoicingNotes !== null ? (
559
560
561
562
563
564
565
566
567
568
            <Flex title={optRecord.notes}>
              <div className="max-w-[90%] whitespace-no-wrap overflow-hidden overflow-ellipsis">
                <span className="text-[#8C8C8C]">
                  开票备注:
                  {optRecord.applyInvoicingNotes}
                </span>
              </div>
            </Flex>
          ) : (
            ''
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
          )} */}
          </Flex>
          <Flex className="w-[13%]" vertical gap="small">
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={optRecord.productPrice}
            >
              <span className="text-[#8C8C8C]">单价:</span>
              <span className="text-slate-700">¥{optRecord.productPrice}</span>
            </div>
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={optRecord.quantity}
            >
              <span className="text-[#8C8C8C]">数量:</span>
584
585
586
587
              <span className="text-slate-700">
                x{optRecord.quantity + ' '}
              </span>
              <span className="text-[#8C8C8C]">{optRecord.unit}</span>
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
            </div>
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={optRecord.subOrderPayment}
            >
              <span className="text-[#8C8C8C]">合计:</span>
              <span className="text-slate-700">
                ¥{optRecord.subOrderPayment}
              </span>
            </div>
          </Flex>
          <Flex className="w-[10%]" vertical gap="small">
            {/* 支付方式 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              <span className="text-slate-700">
                {enumValueToLabel(
                  optRecord.paymentMethod,
                  PAYMENT_METHOD_OPTIONS,
                )}
              </span>
            </div>
            {/* 支付渠道 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              <span className="text-slate-700">
                {enumValueToLabel(
                  optRecord.paymentChannel,
                  PAYMENT_CHANNEL_OPTIONS,
                )}
              </span>
            </div>
          </Flex>
          <Flex className="w-[13%]" vertical gap="small">
            {/* 所属部门 */}
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={enumValueToLabel(
zhongnanhuang authored
624
625
626
                optRecord.productBelongBusiness,
                PRODUCT_BELONG_DEPARTMENT_OPTIONS,
              )}
627
628
629
630
631
632
633
634
            >
              <span className="text-slate-700">
                {enumValueToLabel(
                  optRecord.productBelongBusiness,
                  PRODUCT_BELONG_DEPARTMENT_OPTIONS,
                )}
              </span>
            </div>
zhongnanhuang authored
635
636
637
638
639
640
641
642
643
644
645
646
647
            {/* 开票类型 */}
            {getInvoicingType(optRecord) === undefined ? (
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                <span className="text-slate-700">
                  {getInvoicingType(optRecord)}
                </span>
              </div>
            ) : (
              ''
            )}

            {/* 开票状态 */}
648
649
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              <span className="text-slate-700">
650
651
652
653
                {enumValueToLabel(
                  optRecord.afterInvoicingStatus,
                  AFTER_INVOICING_STATUS,
                )}
654
655
              </span>
            </div>
656
          </Flex>
zhongnanhuang authored
657
658
659
660
661
662
663
664
665
666
          <Flex className="w-[10%]" vertical gap="small">
            {/* 开票状态 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              <Tag
                color={
                  optRecord.invoicingTime === null ||
                  optRecord.invoicingTime === undefined
                    ? TAGS_COLOR.get(optRecord.invoicingStatus)
                    : 'success'
zhongnanhuang authored
667
                }
668
669
670
671
672
673
674
675
676
              >
                {getNeedInvoicing(optRecord)}
              </Tag>
            </div>
            {/* 订单状态 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              {getOrderStatusTag(optRecord)}
            </div>
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
            {/**采购是否已下单状态 */}
            {optRecord.procureOrderStatus !== null &&
            optRecord.procureOrderStatus !== undefined ? (
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                <Tag color="success">
                  {enumValueToLabel(
                    optRecord.procureOrderStatus,
                    PROCURE_ORDER_STATUS,
                  )}
                </Tag>
              </div>
            ) : (
              ''
            )}
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
            {/* 物流信息 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              {optRecord.orderStatus === 'CONFIRM_RECEIPT' ||
              optRecord.orderStatus === 'AFTER_SALES_COMPLETION' ||
              optRecord.orderStatus === 'IN_AFTER_SALES' ||
              optRecord.orderStatus === 'SHIPPED' ? (
                <MyToolTip
                  title={
                    optRecord.serialNumber === undefined
                      ? '暂无物流信息'
                      : enumValueToLabel(
                          optRecord.logisticsMethod,
                          LOGISTICS_STATUS_OPTIONS,
                        ) +
                        '  ' +
                        optRecord.serialNumber
                  }
                  content={
                    <Button type="link" size="small" style={{ padding: 0 }}>
                      物流信息
                    </Button>
                  }
                />
              ) : (
                ''
              )}
            </div>
          </Flex>
          <Flex className="w-[18%]" wrap="wrap" gap="small">
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
            {optRecord.subPath?.includes('saleCancelInvoicing') ? (
              <ButtonConfirm
                className="p-0"
                title="确认取消申请开票?"
                text="取消申请"
                onConfirm={async () => {
                  let res = await postServiceOrderSaleCancelInvoicing({
                    data: {
                      subOrderIds: [optRecord.id],
                    },
                  });

                  if (res && res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
                }}
              />
            ) : (
              ''
            )}
742
743
744
745
746
747
748
            {optRecord.subPath?.includes('noNeedInvoicingEdit') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setFinancialEditVisible(true);
                  setSelectedRows([optRecord]);
749
                  setOrderRow(record);
750
751
752
                  setIsMainOrder(false);
                }}
              >
753
                编辑时间
754
755
756
757
              </Button>
            ) : (
              ''
            )}
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
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
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
            {optRecord.subPath?.includes('sendProduct') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
                  setSelectedRows([cloneDeep(optRecord)]); //克隆一份数据,避免后续修改污染
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.NORMAL);
                }}
              >
                仓库发货
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('supplierSendOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
                  setSelectedRows([cloneDeep(optRecord)]); //克隆一份数据,避免后续修改污染
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.SUPPLIER);
                }}
              >
                供应商发货
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('procureSend') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
                  setSelectedRows([cloneDeep(optRecord)]); //克隆一份数据,避免后续修改污染
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                }}
              >
                采购发货
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('queryAnnex') &&
            optRecord.listAnnex?.length > 0 ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
                  setAttachmentModalVisible(true);
                  setOrderRow(optRecord);
                }}
              >
                附件
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('modifySendInformation') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
                  setSelectedRows([cloneDeep(optRecord)]); //克隆一份数据,避免后续修改污染
                  setDeliverVisible(true);
                  setIsSendProduct(false);
                }}
              >
                修改发货信息
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('printOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
                  setOrderPrintVisible(true);
                  setSelectedRows([optRecord]);
                  setOrderRow(record);
                  setOrderCheckType(CHECK_TYPE.NORMAL);
                }}
              >
                仓库打印
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('supplierPrint') ? (
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
                  setOrderPrintVisible(true);
                  setSelectedRows([optRecord]);
                  setOrderRow(record);
                  setOrderCheckType(CHECK_TYPE.SUPPLIER);
                }}
              >
                供应商打印
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('procurePrint') ? (
zhongnanhuang authored
881
              <ButtonConfirm
882
                className="p-0"
zhongnanhuang authored
883
884
885
886
887
888
889
890
891
892
893
894
895
                title="确认打印?"
                text="采购打印"
                onConfirm={async () => {
                  let res = await postServiceOrderProcurePrint({
                    data: {
                      ids: [optRecord.id],
                    },
                  });

                  if (res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
896
                }}
zhongnanhuang authored
897
              />
898
            ) : (
zhongnanhuang authored
899
900
901
902
903
904
905
906
907
908
909
910
              // <Button
              //   className="p-0"
              //   type="link"
              //   onClick={async () => {
              //     setOrderPrintVisible(true);
              //     setSelectedRows([optRecord]);
              //     setOrderRow(record);
              //     setOrderCheckType(CHECK_TYPE.PROCURE);
              //   }}
              // >
              //   采购打印
              // </Button>
911
912
913
914
915
916
917
918
919
920
921
              ''
            )}

            {optRecord.subPath?.includes('editOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setFinancialVisible(true);
                  setOrderRow(record);
                  setSelectedRows([optRecord]);
zhongnanhuang authored
922
                  setIsEdit(true);
923
924
925
926
927
928
929
                }}
              >
                编辑
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
930
931
932
933
934
935
936
            {optRecord.subPath?.includes('invoicing') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setFinancialVisible(true);
zhongnanhuang authored
937
                  setIsEdit(false);
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
                  setOrderRow(record);
                  setSelectedRows([optRecord]);
                  setIsMainOrder(false);
                }}
              >
                开票
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('applyInvoicing') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setApplyForInvoicingVisible(true);
                  setSelectedRows([optRecord]);
zhongnanhuang authored
956
                  setIsEdit(false);
957
                  setIsMainOrder(false);
958
959
960
961
962
963
964
965
966
967
968
969
970
                }}
              >
                申请开票
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('checkOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
971
                  setOrderRow(record);
972
973
974
975
976
977
978
979
980
981
982
                  setCheckVisible(true);
                  setSelectedRows([optRecord]);
                  setOrderCheckType(CHECK_TYPE.NORMAL);
                }}
              >
                审核
              </Button>
            ) : (
              ''
            )}
983
984
985
986
987
            {optRecord.subPath?.includes('afterSalesCheck') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
988
                  setOrderRow(record);
989
990
991
992
993
994
995
996
997
998
999
                  setCheckVisible(true);
                  setSelectedRows([optRecord]);
                  setOrderCheckType(CHECK_TYPE.AFTER_SALES);
                }}
              >
                售后审核
              </Button>
            ) : (
              ''
            )}
1000
1001
1002
1003
1004
            {optRecord.subPath?.includes('financeCheckOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1005
                  setOrderRow(record);
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
                  setCheckVisible(true);
                  setSelectedRows([optRecord]);
                  setOrderCheckType(CHECK_TYPE.FINALCIAL);
                }}
              >
                财务审核
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('procureCheckOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1022
                  setOrderRow(record);
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
                  setSelectedRows([optRecord]);
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                  setProcureCheckModalVisible(true);
                }}
              >
                采购审核
              </Button>
            ) : (
              ''
            )}
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
            {optRecord.subPath?.includes('procureConvertProcure') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setSelectedRows([optRecord]);
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                  setProcureConvertModalVisible(true);
                }}
              >
                转发
              </Button>
            ) : (
              ''
            )}
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
            {optRecord.subPath?.includes('rePrintOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setOrderPrintVisible(true);
                  setSelectedRows([optRecord]);
                  setOrderRow(record);
                  setIsRePrintOrder(true);
                }}
              >
                重新打印
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('confirmReceipt') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setConfirmReceiptVisible(true);
                  setOrderRow(optRecord);
                }}
              >
                确认收货
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1082
            {optRecord.subPath?.includes('applyAfterSales') ? (
1083
1084
1085
1086
1087
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setSelectedRows([optRecord]);
1088
                  setOrderDrawerVisible(true);
1089
                  setOrderRow(record);
zhongnanhuang authored
1090
                  setOrderOptType('after-sales');
1091
1092
1093
1094
1095
1096
                }}
              >
                申请售后
              </Button>
            ) : (
              ''
zhongnanhuang authored
1097
            )}
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
            {optRecord.subPath?.includes('procureOrder') ? (
              <ButtonConfirm
                className="p-0"
                title="是否已下单?"
                text="下单"
                onConfirm={async () => {
                  let res = await postServiceOrderProcureOrder({
                    data: { subIds: [optRecord.id] },
                  });
                  if (res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                    return true;
                  }
                }}
              />
            ) : (
              ''
            )}
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
            {optRecord.subPath?.includes('noNeedSend') ? (
              <ButtonConfirm
                className="p-0"
                title="此订单是否无需发货?"
                text="无需发货"
                onConfirm={async () => {
                  let res = await postServiceOrderNoNeedSend({
                    data: { ids: [optRecord.id] },
                  });
                  if (res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                    return true;
                  }
                }}
              />
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('viewImages') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setSubOrderConfirmReceiptImagesVisible(true);
                  setOrderRow(optRecord);
                }}
              >
                查看收货凭证
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('orderCancel') ? (
              <ButtonConfirm
                className="p-0"
                title="确认作废?"
                text="作废"
                onConfirm={async () => {
                  let body = { ids: [optRecord.id], checkIsMainOrderId: false };
                  const data = await postServiceOrderOrderCancel({
                    data: body,
                  });
                  if (data.result === RESPONSE_CODE.SUCCESS) {
                    message.success(data.message);
                    refreshTable();
                  }
                }}
              />
            ) : (
              ''
            )}
          </Flex>
zhongnanhuang authored
1174
        </Flex>
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188

        {userInfo?.roleSmallVO?.code === 'admin' ||
        userInfo?.roleSmallVO?.code === 'salesManager' ||
        userInfo?.roleSmallVO?.code === 'salesRepresentative' ||
        userInfo?.roleSmallVO?.code === 'finance' ? (
          <Flex title={optRecord.notes}>
            <div className="flex items-center">
              <div className="flex items-center max-w-[500px]">
                <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <Tooltip
                    title={optRecord.applyInvoicingNotes}
                    placement="topLeft"
                  >
                    <span className="text-[#8C8C8C]">
zhongnanhuang authored
1189
                      申请开票备注:
1190
1191
1192
1193
1194
1195
1196
1197
1198
                      {optRecord.applyInvoicingNotes === undefined ||
                      optRecord.applyInvoicingNotes === null
                        ? '暂无备注'
                        : optRecord.applyInvoicingNotes}
                    </span>
                  </Tooltip>
                </div>

                {getAfterAnnexList()}
zhongnanhuang authored
1199
1200
1201
1202
1203
1204
1205
1206

                <Tooltip title="编辑">
                  <EditTwoTone
                    className="pl-1 hover:curcor-pointer"
                    onClick={() => {
                      setApplyForInvoicingVisible(true);
                      setSelectedRows([optRecord]);
                      setIsEdit(true);
1207
                      setIsMainOrder(false);
zhongnanhuang authored
1208
1209
1210
                    }}
                  />
                </Tooltip>
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
              </div>
              <Divider type="vertical" className="mx-5" />
              <div className="flex items-center max-w-[500px]">
                <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <Tooltip title={optRecord.checkNotes} placement="topLeft">
                    <span className="text-[#8C8C8C] mr-3">
                      财务审核备注:
                      {optRecord.checkNotes === undefined ||
                      optRecord.checkNotes === null
                        ? '暂无备注'
                        : optRecord.checkNotes}
                    </span>
                  </Tooltip>
                </div>

                {getInvoicingCheckAnnexList()}
              </div>
            </div>
          </Flex>
        ) : (
          ''
        )}
      </>
zhongnanhuang authored
1234
    );
zhongnanhuang authored
1235
  };
zhongnanhuang authored
1236
1237
1238
1239
1240
1241
  const expandedRowRender = (record) => {
    let subOrders = record.subOrderInformationLists;

    return (
      <ProTable
        id="sub-table"
zhongnanhuang authored
1242
        className="w-full "
zhongnanhuang authored
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
        showHeader={false}
        columns={[
          {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            render: (text: any, optRecord: any) => {
              return <SubOderRander record={record} optRecord={optRecord} />;
            },
          },
        ]}
        rowSelection={{
          onChange: (selectedRowKeys: any, selectedRows: any) => {
            setSelectedRowKeys(selectedRowKeys);
            setSelectedRowObj({
              ...setSelectedRowObj,
              [record.id]: selectedRows,
            });
            selectedRowObj[record.id] = selectedRows;
            setSelectedRows(selectedRows);
          },
          selectedRowKeys: selectedRowKeys,
          // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
          // 注释该行则默认不显示下拉选项
          // selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
          // defaultSelectedRowKeys: [],
        }}
        rowKey="id"
        headerTitle={false}
        search={false}
        options={false}
        dataSource={subOrders}
        pagination={false}
zhongnanhuang authored
1276
        tableAlertRender={false}
zhongnanhuang authored
1277
1278
1279
1280
      />
    );
  };
1281
  // 主订单内容渲染
sanmu authored
1282
  const MainOrderColumnRender = ({ record }: { record: OrderListItemType }) => {
sanmu authored
1283
1284
1285
    return (
      <Flex vertical={true}>
        {/* 编号、时间、销售信息 */}
zhongnanhuang authored
1286
        <Flex
zhongnanhuang authored
1287
          className="px-4 py-4 bg-white rounded-t-lg"
zhongnanhuang authored
1288
1289
1290
1291
1292
1293
          justify="space-between"
        >
          <Flex wrap="wrap" gap="middle" vertical>
            <Flex>
              <Flex>
                <Checkbox
zhongnanhuang authored
1294
                  onChange={() => onCheckboxChange(record)}
zhongnanhuang authored
1295
1296
                  checked={selectedItems.includes(record.id)}
                >
zhongnanhuang authored
1297
1298
                  <Space split={<Divider type="vertical" />}>
                    <div>
zhongnanhuang authored
1299
                      <span className="text-[#8C8C8C]">订单号:</span>
zhongnanhuang authored
1300
                      <span className="text-slate-700">{record.id}</span>
zhongnanhuang authored
1301
1302
1303
1304
1305
                    </div>
                    <span>{formatDateTime(record.createTime)}</span>
                  </Space>
                </Checkbox>
                <Space split={<Divider type="vertical" />}>
zhongnanhuang authored
1306
                  <div>
zhongnanhuang authored
1307
                    <span className="text-[#8C8C8C]">代表:</span>
zhongnanhuang authored
1308
                    <span className="text-slate-700">{record.salesCode}</span>
zhongnanhuang authored
1309
                  </div>
zhongnanhuang authored
1310
1311
                  <div
                    title={record.institution}
zhongnanhuang authored
1312
                    className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[150px]"
zhongnanhuang authored
1313
                  >
zhongnanhuang authored
1314
                    <span className="text-[#8C8C8C]">单位:</span>
zhongnanhuang authored
1315
                    <span className="text-slate-700">{record.institution}</span>
zhongnanhuang authored
1316
                  </div>
zhongnanhuang authored
1317
                  <span>
zhongnanhuang authored
1318
                    <span className="text-[#8C8C8C]">联系人:</span>
zhongnanhuang authored
1319
                    <span className="text-slate-700">
zhongnanhuang authored
1320
                      {record.institutionContactName + ' '}
zhongnanhuang authored
1321
1322
1323
1324
1325
1326
                    </span>
                  </span>
                  <span>
                    <span className="text-[#8C8C8C]">收货人:</span>
                    <span className="text-slate-700">
                      {record.customerName + ' '}
zhongnanhuang authored
1327
1328
1329
1330
1331
1332
1333
1334
1335
                      <Tooltip className="order-tooltip" title="详情">
                        <ContainerTwoTone
                          className="hover:curcor-pointer"
                          onClick={() => {
                            setDeliverInfoDrawerVisible(true);
                            setOrderRow(record);
                          }}
                        />
                      </Tooltip>
zhongnanhuang authored
1336
                    </span>
zhongnanhuang authored
1337
1338
                  </span>
                </Space>
zhongnanhuang authored
1339
              </Flex>
1340
            </Flex>
zhongnanhuang authored
1341
            <Flex className="pl-6" align="center">
zhongnanhuang authored
1342
              <div title={record.notes}>
zhongnanhuang authored
1343
                <div className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis">
zhongnanhuang authored
1344
1345
1346
1347
                  <span className="text-[#8C8C8C]">备注:</span>
                  <span className="ml-2">
                    {record.notes === undefined ? '暂无备注' : record.notes}
                  </span>
zhongnanhuang authored
1348
                </div>
zhongnanhuang authored
1349
              </div>
zhongnanhuang authored
1350
1351
              <Tooltip title="编辑">
                <EditTwoTone
zhongnanhuang authored
1352
                  className="pl-1 hover:curcor-pointer"
zhongnanhuang authored
1353
1354
1355
1356
1357
1358
1359
                  onClick={() => {
                    setNotesEditVisible(true);
                    setOrderRow(record);
                    setIsMainOrder(true);
                  }}
                />
              </Tooltip>
zhongnanhuang authored
1360
1361
1362
1363
1364
1365
            </Flex>
          </Flex>
          <Flex wrap="wrap" gap="middle" vertical>
            <Flex justify="flex-end">
              <Flex wrap="wrap" gap="middle" align="center">
                <div>
zhongnanhuang authored
1366
                  <span className="text-[#8C8C8C]">总金额:¥</span>
zhongnanhuang authored
1367
1368
1369
                  <span className="text-lg font-medium">
                    {record.totalPayment}
                  </span>
zhongnanhuang authored
1370
1371
                </div>
                {rolePath?.includes('addOrder') ? (
zhongnanhuang authored
1372
1373
1374
1375
                  <Tooltip title="复制">
                    <CopyTwoTone
                      className="hover:cursor-pointer"
                      onClick={() => {
1376
                        copyOrderToClipboard(record);
zhongnanhuang authored
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
                        setOrderOptType('copy');
                        setOrderDrawerVisible(true);
                        let copy = cloneDeep(record);
                        copy.id = undefined;
                        copy.subOrderInformationLists?.forEach((item) => {
                          item.id = undefined;
                        });
                        setOrderRow(copy);
                      }}
                    />
                  </Tooltip>
zhongnanhuang authored
1388
                ) : (
1389
1390
1391
1392
1393
1394
1395
1396
                  <Tooltip title="复制文本">
                    <CopyTwoTone
                      className="hover:cursor-pointer"
                      onClick={() => {
                        copyOrderToClipboard(record);
                      }}
                    />
                  </Tooltip>
zhongnanhuang authored
1397
                )}
zhongnanhuang authored
1398
zhongnanhuang authored
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
                <Tooltip title="历史">
                  <ClockCircleTwoTone
                    className="hover:cursor-pointer"
                    onClick={() => {
                      setHistoryModalVisible(true);
                      if (selectedRowObj[record.id]?.length) {
                        setSelectedRows(selectedRowObj[record.id]);
                      } else {
                        setSelectedRows(record.subOrderInformationLists);
                      }
                    }}
                  />
                </Tooltip>
zhongnanhuang authored
1412
1413
1414
1415
1416
              </Flex>
            </Flex>
            <Flex justify="flex-end">
              <Space.Compact direction="vertical" align="end">
                <Space>
1417
                  {false ? (
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setFinancialReceiptsModalVisible(true);
                        setOrderRow(record);
                        setSelectedRows([record]);
                        setIsEdit(true);
                      }}
                    >
                      收款记录
                    </Button>
                  ) : (
                    ''
                  )}
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
                  {record.mainPath?.includes('procureConvertProcure') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }

                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            !selectedSubOrders[i].subPath.includes(
                              'procureConvertProcure',
                            )
                          ) {
                            message.error('请选择允许转发的子订单进行转发');
                            return;
                          }
                        }
                        setSelectedRows(selectedSubOrders);
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                        setProcureConvertModalVisible(true);
                      }}
                    >
                      转发
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1464
                  {record.mainPath?.includes('sendProduct') ? (
zhongnanhuang authored
1465
1466
1467
1468
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
1469
1470
1471
1472
                        if (!selectedRowObj[record.id]?.length) {
                          return message.error('请选择选择子订单');
                        }
                        setSelectedRows(selectedRowObj[record.id]);
zhongnanhuang authored
1473
                        setDeliverVisible(true);
zhongnanhuang authored
1474
                        setIsSendProduct(true);
zhongnanhuang authored
1475
                        setOrderCheckType(CHECK_TYPE.NORMAL);
zhongnanhuang authored
1476
1477
                      }}
                    >
zhongnanhuang authored
1478
                      仓库发货
zhongnanhuang authored
1479
1480
1481
1482
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1483
1484

                  {/* 供应商发货 */}
zhongnanhuang authored
1485
                  {record.mainPath?.includes('supplierSendOrder') ? (
zhongnanhuang authored
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        if (!selectedRowObj[record.id]?.length) {
                          return message.error('请选择选择子订单');
                        }
                        setSelectedRows(selectedRowObj[record.id]);
                        setDeliverVisible(true);
                        setIsSendProduct(true);
                        setOrderCheckType(CHECK_TYPE.SUPPLIER);
                      }}
                    >
                      供应商发货
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1504
zhongnanhuang authored
1505
                  {record.mainPath?.includes('procureSend') ? (
zhongnanhuang authored
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        if (!selectedRowObj[record.id]?.length) {
                          return message.error('请选择选择子订单');
                        }
                        setSelectedRows(selectedRowObj[record.id]);
                        setDeliverVisible(true);
                        setIsSendProduct(true);
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                      }}
                    >
                      采购发货
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1525
                  {record.mainPath?.includes('printOrder') ? (
zhongnanhuang authored
1526
1527
1528
1529
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
1530
1531
                        const selectedSubOrders = selectedRowObj[record.id];
                        if (!selectedSubOrders?.length) {
zhongnanhuang authored
1532
1533
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
1534
1535
1536
1537
1538
1539
1540
1541

                        for (let subOrderRecord of selectedSubOrders) {
                          let subPath = subOrderRecord.subPath;
                          if (!checkePrintable(subPath)) {
                            return message.error('请选择可以打印的子订单');
                          }
                        }
                        setSelectedRows(selectedSubOrders);
zhongnanhuang authored
1542
1543
                        setOrderRow(record);
                        setOrderPrintVisible(true);
zhongnanhuang authored
1544
                        setOrderCheckType(CHECK_TYPE.NORMAL);
zhongnanhuang authored
1545
1546
                      }}
                    >
zhongnanhuang authored
1547
                      仓库打印
zhongnanhuang authored
1548
1549
1550
1551
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1552
zhongnanhuang authored
1553
                  {record.mainPath?.includes('supplierPrint') ? (
zhongnanhuang authored
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        if (!selectedRowObj[record.id]?.length) {
                          return message.error('请选择选择子订单');
                        }
                        setSelectedRows(selectedRowObj[record.id]);
                        setOrderRow(record);
                        setOrderPrintVisible(true);
                        setOrderCheckType(CHECK_TYPE.SUPPLIER);
                      }}
                    >
zhongnanhuang authored
1567
                      供应商打印
zhongnanhuang authored
1568
1569
1570
1571
1572
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1573
                  {record.mainPath?.includes('rePrintOrder') ? (
zhongnanhuang authored
1574
1575
1576
1577
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
1578
1579
1580
1581
                        if (!selectedRowObj[record.id]?.length) {
                          return message.error('请选择选择子订单');
                        }
                        setSelectedRows(selectedRowObj[record.id]);
1582
                        setOrderRow(record);
zhongnanhuang authored
1583
1584
                        setOrderPrintVisible(true);
                        setIsRePrintOrder(true);
zhongnanhuang authored
1585
1586
                      }}
                    >
zhongnanhuang authored
1587
                      重新打印
zhongnanhuang authored
1588
1589
1590
1591
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1592
                  {record.mainPath?.includes('modifySendInformation') ? (
zhongnanhuang authored
1593
                    <Button
zhongnanhuang authored
1594
                      className="p-0"
zhongnanhuang authored
1595
1596
                      type="link"
                      onClick={() => {
zhongnanhuang authored
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
                        if (!selectedRowObj[record.id]?.length) {
                          return message.error(
                            '请选择已经发货或者已经确认收货的子订单',
                          );
                        }
                        for (let row of selectedRowObj[record.id]) {
                          if (
                            row.orderStatus !== 'CONFIRM_RECEIPT' &&
                            row.orderStatus !== 'SHIPPED'
                          ) {
                            return message.error(
                              '请选择已经发货或者已经确认收货的子订单',
                            );
                          }
                        }
                        setSelectedRows(selectedRowObj[record.id]);
                        setDeliverVisible(true);
                        setIsSendProduct(false);
zhongnanhuang authored
1615
1616
                      }}
                    >
zhongnanhuang authored
1617
                      修改发货信息
zhongnanhuang authored
1618
                    </Button>
zhongnanhuang authored
1619
1620
1621
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1622
                  {record.mainPath?.includes('invoicing') ? (
zhongnanhuang authored
1623
1624
                    <Button
                      type="link"
zhongnanhuang authored
1625
                      className="p-0"
zhongnanhuang authored
1626
                      onClick={() => {
zhongnanhuang authored
1627
1628
1629
                        let selectedSubOrders = selectedRowObj[record.id];
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
1630
                          setIsMainOrder(true);
zhongnanhuang authored
1631
                          setSelectedRows(record.subOrderInformationLists);
zhongnanhuang authored
1632
1633
                        } else {
                          setIsMainOrder(false);
zhongnanhuang authored
1634
                        }
zhongnanhuang authored
1635
                        setOrderRow(record);
zhongnanhuang authored
1636
                        setFinancialVisible(true);
zhongnanhuang authored
1637
                        setIsEdit(false);
zhongnanhuang authored
1638
1639
                      }}
                    >
zhongnanhuang authored
1640
                      开票
zhongnanhuang authored
1641
1642
1643
1644
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670

                  {record.mainPath?.includes('applyInvoicing') ? (
                    <Button
                      type="link"
                      className="p-0"
                      onClick={() => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }

                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].invoicingStatus ===
                              'UN_INVOICE' ||
                            selectedSubOrders[i].afterInvoicingStatus ===
                              'APPLY_FOR_INVOICING'
                          ) {
                            message.error(
                              '请选择需要开票且未申请开票的子订单进行申请',
                            );
                            return;
                          }
                        }
                        setApplyForInvoicingVisible(true);
zhongnanhuang authored
1671
                        setIsEdit(false);
zhongnanhuang authored
1672
                        setIsMainOrder(false);
zhongnanhuang authored
1673
1674
1675
1676
1677
1678
1679
1680
                      }}
                    >
                      申请开票
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1681
                  {record.mainPath?.includes('updateOrder') ? (
zhongnanhuang authored
1682
1683
1684
1685
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
1686
                        //勾选的子订单:如果有勾选,后面只校验有勾选的
1687
zhongnanhuang authored
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (
                          selectedSubOrders === undefined ||
                          selectedSubOrders.length === 0
                        ) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (
                          let index = 0;
                          index < selectedSubOrders.length;
                          index++
                        ) {
                          let orderStatus =
                            selectedSubOrders[index].orderStatus;
1702
                          //仓库管理员在审核之后的任何时候都可以编辑
zhongnanhuang authored
1703
                          if (
1704
1705
                            userInfo.roleSmallVO.code !== 'warehouseKeeper' &&
                            userInfo.roleSmallVO.code !== 'admin'
zhongnanhuang authored
1706
                          ) {
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
                            //是审核通过及之后的订单
                            if (
                              orderStatus !== 'UNAUDITED' &&
                              orderStatus !== 'AUDIT_FAILED'
                            ) {
                              message.error(
                                '请选择未审核或者审核失败的订单进行编辑',
                              );
                              return;
                            }
                          } else {
                            //仓库管理员只能编辑是还未审核的订单
                            if (
                              userInfo.roleSmallVO.code !== 'admin' &&
                              (orderStatus === 'UNAUDITED' ||
                                orderStatus === 'AUDIT_FAILED')
                            ) {
                              message.error('请选择已审核的订单进行编辑');
                              return;
                            }
zhongnanhuang authored
1727
1728
1729
1730
1731
1732
                          }
                        }
                        setOrderDrawerVisible(true);
                        setOrderRow(record);
                        setSelectedRows(selectedSubOrders);
                        setOrderOptType('edit');
zhongnanhuang authored
1733
1734
                      }}
                    >
zhongnanhuang authored
1735
                      编辑
zhongnanhuang authored
1736
1737
1738
1739
                    </Button>
                  ) : (
                    ''
                  )}
1740
zhongnanhuang authored
1741
1742
1743
                  {record?.subOrderInformationLists[0].subPath?.includes(
                    'noNeedInvoicingEdit',
                  ) ? (
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        let selectedSubOrders = record.subOrderInformationLists;
                        setFinancialEditVisible(true);
                        setSelectedRows(selectedSubOrders);
                        setOrderRow(record);
                        setIsMainOrder(true);
                      }}
                    >
                      财务编辑
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1761
                  {record.mainPath?.includes('checkOrder') ? (
zhongnanhuang authored
1762
1763
1764
1765
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
1766
1767
1768
                        let selectedSubOrders = selectedRowObj[record.id];
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
1769
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
1770
                        }
zhongnanhuang authored
1771
                        for (let i = 0; i < selectedSubOrders.length; i++) {
zhongnanhuang authored
1772
                          if (
zhongnanhuang authored
1773
1774
1775
                            selectedSubOrders[i].orderStatus !== 'UNAUDITED' &&
                            selectedSubOrders[i].orderStatus !==
                              'FINANCE_PROCESS'
zhongnanhuang authored
1776
1777
1778
1779
1780
1781
1782
                          ) {
                            message.error('请选择未审核的子订单进行审核');
                            return;
                          }
                        }
                        setOrderRow(record);
                        setCheckVisible(true);
zhongnanhuang authored
1783
                        setSelectedRows(selectedSubOrders);
zhongnanhuang authored
1784
1785
1786
1787
1788
1789
1790
1791
1792
                        setOrderCheckType(CHECK_TYPE.NORMAL);
                      }}
                    >
                      审核
                    </Button>
                  ) : (
                    ''
                  )}
1793
                  {record.mainPath?.includes('afterSalesCheck') ? (
1794
1795
1796
1797
1798
1799
1800
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
1801
                          selectedSubOrders = record.subOrderInformationLists;
1802
                        }
zhongnanhuang authored
1803
                        for (let i = 0; i < selectedSubOrders.length; i++) {
1804
                          if (
zhongnanhuang authored
1805
1806
                            selectedSubOrders[i].orderStatus !==
                            'IN_AFTER_SALES'
1807
1808
                          ) {
                            message.error('请选择售后中的子订单进行审核');
1809
1810
1811
1812
1813
                            return;
                          }
                        }
                        setOrderRow(record);
                        setCheckVisible(true);
zhongnanhuang authored
1814
                        setSelectedRows(selectedSubOrders);
1815
1816
1817
1818
1819
1820
1821
1822
1823
                        setOrderCheckType(CHECK_TYPE.AFTER_SALES);
                      }}
                    >
                      售后审核
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
                  {record.mainPath?.includes('noNeedSend') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="此订单是否无需发货?"
                      text="无需发货"
                      onConfirm={async () => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
zhongnanhuang authored
1837
                            selectedSubOrders[i].orderStatus !== 'AUDITED' &&
zhongnanhuang authored
1838
                            selectedSubOrders[i].orderStatus !==
zhongnanhuang authored
1839
1840
1841
1842
1843
1844
1845
1846
                              'PROCURE_PROCESS' &&
                            selectedSubOrders[i].orderStatus !==
                              'PROCURE_PROCESS_FOR_MINE' &&
                            selectedSubOrders[i].orderStatus !==
                              'PROCURE_WAIT_SHIP' &&
                            selectedSubOrders[i].orderStatus !==
                              'SUPPLIER_WAIT_SHIP' &&
                            selectedSubOrders[i].orderStatus !== 'WAIT_SHIP'
zhongnanhuang authored
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
                          ) {
                            message.error(
                              '请选择未发货的子订单进行无需发货操作',
                            );
                            return;
                          }
                        }

                        const data = await postServiceOrderNoNeedSend({
                          data: {
                            ids: selectedSubOrders.map((item) => {
                              return item.id;
                            }),
                          },
                        });
                        if (data.result === RESPONSE_CODE.SUCCESS) {
                          message.success(data.message);
                          refreshTable();
                        }
                      }}
                    />
                  ) : (
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
                    ''
                  )}

                  {record.mainPath?.includes('saleCancelInvoicing') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="确认取消申请开票?"
                      text="取消申请"
                      onConfirm={async () => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].afterInvoicingStatus !==
                            'APPLY_FOR_INVOICING'
                          ) {
                            message.error(
                              '请选择已[申请开票]的子订单进行取消申请',
                            );
                            return;
                          }
                        }
                        let res = await postServiceOrderSaleCancelInvoicing({
                          data: {
                            subOrderIds: selectedSubOrders.map((item) => {
                              return item.id;
                            }),
                          },
                        });

                        if (res && res.result === RESPONSE_CODE.SUCCESS) {
                          message.success(res.message);
                          refreshTable();
                        }
                      }}
                    />
                  ) : (
zhongnanhuang authored
1909
1910
1911
                    ''
                  )}
zhongnanhuang authored
1912
                  {/* 财务审核:主订单暂无 */}
zhongnanhuang authored
1913
                  {record.mainPath?.includes('financeCheckOrder') ? (
zhongnanhuang authored
1914
1915
1916
1917
1918
1919
1920
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
1921
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
1922
                        }
zhongnanhuang authored
1923
                        for (let i = 0; i < selectedSubOrders.length; i++) {
zhongnanhuang authored
1924
                          if (
zhongnanhuang authored
1925
1926
1927
                            selectedSubOrders[i].orderStatus !== 'UNAUDITED' &&
                            selectedSubOrders[i].orderStatus !==
                              'FINANCE_PROCESS'
zhongnanhuang authored
1928
                          ) {
zhongnanhuang authored
1929
                            message.error('请选择未审核的子订单进行审核');
zhongnanhuang authored
1930
1931
1932
                            return;
                          }
                        }
zhongnanhuang authored
1933
                        setOrderRow(record);
zhongnanhuang authored
1934
                        setCheckVisible(true);
zhongnanhuang authored
1935
                        setSelectedRows(selectedSubOrders);
zhongnanhuang authored
1936
                        setOrderCheckType(CHECK_TYPE.FINALCIAL);
zhongnanhuang authored
1937
1938
                      }}
                    >
zhongnanhuang authored
1939
1940
1941
1942
1943
1944
1945
                      财务审核
                    </Button>
                  ) : (
                    ''
                  )}

                  {/* 采购审核 */}
zhongnanhuang authored
1946
                  {record.mainPath?.includes('procureCheckOrder') ? (
zhongnanhuang authored
1947
1948
1949
1950
1951
1952
1953
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
1954
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
1955
                        }
zhongnanhuang authored
1956
                        for (let i = 0; i < selectedSubOrders.length; i++) {
zhongnanhuang authored
1957
                          if (
zhongnanhuang authored
1958
1959
                            selectedSubOrders[i].orderStatus !==
                            'PROCURE_UN_PROCESS'
zhongnanhuang authored
1960
1961
1962
1963
1964
1965
1966
                          ) {
                            message.error('请选择未审核的子订单进行审核');
                            return;
                          }
                        }
                        setOrderRow(record);
                        setProcureCheckModalVisible(true);
zhongnanhuang authored
1967
                        setSelectedRows(selectedSubOrders);
zhongnanhuang authored
1968
1969
1970
1971
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                      }}
                    >
                      采购审核
zhongnanhuang authored
1972
1973
1974
1975
1976
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
1977
                  {record.mainPath?.includes('applyAfterSales') ? (
zhongnanhuang authored
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
zhongnanhuang authored
1990
1991
1992
                              'CONFIRM_RECEIPT' &&
                            selectedSubOrders[i].orderStatus !==
                              'AFTER_SALES_FAILURE'
zhongnanhuang authored
1993
1994
1995
1996
1997
                          ) {
                            message.error('请选择确认收货状态的子订单进行售后');
                            return;
                          }
                        }
1998
                        setOrderDrawerVisible(true);
zhongnanhuang authored
1999
                        setOrderRow(record);
2000
                        setOrderOptType('after-sales');
zhongnanhuang authored
2001
2002
2003
2004
2005
2006
2007
2008
                      }}
                    >
                      申请售后
                    </Button>
                  ) : (
                    ''
                  )}
2009
                  {/* {record.mainPath?.includes('afterSalesCompletion') ? (
zhongnanhuang authored
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
                    <ButtonConfirm
                      className="p-0"
                      title="售后是否已完成?"
                      text="完成售后"
                      onConfirm={async () => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
                            'IN_AFTER_SALES'
                          ) {
                            message.error(
                              '请选择售后中状态的子订单进行完成售后',
                            );
                            return false;
                          }
                        }

                        const ids = selectedSubOrders?.map((item) => {
                          return item.id;
                        });

                        let body = {
                          ids: ids,
                        };
                        const data = await postServiceOrderAfterSalesCompletion(
                          {
                            data: body,
                          },
                        );
                        if (data.result === RESPONSE_CODE.SUCCESS) {
                          message.success(data.message);
                          refreshTable();
                        }
                      }}
                    />
                  ) : (
                    ''
2051
                  )} */}
zhongnanhuang authored
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
                  {record.mainPath?.includes('salOrderSave') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="是否推送至金蝶ERP?"
                      text="推送ERP"
                      onConfirm={async () => {
                        let res = await postKingdeeRepSalOrderSave({
                          data: {
                            id: record.id,
                          },
                        });

                        if (res && res.result === RESPONSE_CODE.SUCCESS) {
                          message.success('推送成功');
                          mainTableRef.current.reload();
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}

                  {record.mainPath?.includes('salBillOutbound') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="是否下推金蝶ERP出库单?"
                      text="下推出库"
                      onConfirm={async () => {
                        let res = await postKingdeeRepSalBillOutbound({
                          data: {
                            id: record.id,
                          },
                        });

                        if (res && res.result === RESPONSE_CODE.SUCCESS) {
                          message.success('下推成功');
                          mainTableRef.current.reload();
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2097
                  {record.mainPath?.includes('orderCancel') ? (
zhongnanhuang authored
2098
                    <ButtonConfirm
zhongnanhuang authored
2099
                      className="p-0"
zhongnanhuang authored
2100
2101
2102
                      title="确认作废?"
                      text="作废"
                      onConfirm={async () => {
zhongnanhuang authored
2103
2104
2105
2106
                        let body = {
                          ids: [record.id],
                          checkIsMainOrderId: true,
                        };
zhongnanhuang authored
2107
2108
2109
2110
2111
2112
2113
                        const data = await postServiceOrderOrderCancel({
                          data: body,
                        });
                        if (data.result === RESPONSE_CODE.SUCCESS) {
                          message.success(data.message);
                          refreshTable();
                        }
zhongnanhuang authored
2114
                      }}
zhongnanhuang authored
2115
                    />
zhongnanhuang authored
2116
2117
2118
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2119
zhongnanhuang authored
2120
                  {record.mainPath?.includes('procurePrint') ? (
zhongnanhuang authored
2121
                    <ButtonConfirm
zhongnanhuang authored
2122
                      className="p-0"
zhongnanhuang authored
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
                      title="确认打印?"
                      text="采购打印"
                      onConfirm={async () => {
                        let selectedSubOrders = selectedRowObj[record.id];
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
                            'PROCURE_PROCESS_FOR_MINE'
                          ) {
                            message.error(
                              '请选择采购待打印状态的子订单进行打印',
                            );
                            return false;
                          }
                        }

                        const ids = selectedSubOrders?.map((item) => {
                          return item.id;
                        });
                        let res = await postServiceOrderProcurePrint({
                          data: {
                            ids: ids,
                          },
                        });

                        if (res.result === RESPONSE_CODE.SUCCESS) {
                          message.success(res.message);
                          refreshTable();
zhongnanhuang authored
2154
2155
                        }
                      }}
zhongnanhuang authored
2156
                    />
zhongnanhuang authored
2157
                  ) : (
zhongnanhuang authored
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
                    // <Button
                    //   className="p-0"
                    //   type="link"
                    //   onClick={() => {
                    //     if (!selectedRowObj[record.id]?.length) {
                    //       return message.error('请选择选择子订单');
                    //     }
                    //     setSelectedRows(selectedRowObj[record.id]);
                    //     setOrderRow(record);
                    //     setOrderPrintVisible(true);
                    //     setOrderCheckType(CHECK_TYPE.PROCURE);
                    //   }}
                    // >
                    //   采购打印
                    // </Button>
zhongnanhuang authored
2173
2174
                    ''
                  )}
zhongnanhuang authored
2175
2176
2177
2178
2179
2180
                </Space>
              </Space.Compact>
            </Flex>
          </Flex>
        </Flex>
zhongnanhuang authored
2181
        <Flex className="p-0 pb-[24px] pt-[4px] pl-[23px] pr-[5px] bg-white rounded-b-lg">
zhongnanhuang authored
2182
2183
2184
          {expandedRowRender(record)}
        </Flex>
      </Flex>
2185
2186
2187
    );
  };
zhongnanhuang authored
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
  // 主订单列表
  const mainOrdersColumns: ProColumns<OrderType>[] = MAIN_ORDER_COLUMNS.map(
    (item) => {
      if (item.dataIndex === 'name') {
        return {
          ...item,
          title: <OrderTableHeader />,
          render: (text, record) => {
            return <MainOrderColumnRender record={record} />;
          },
        };
      }
      return item;
    },
  );
2204
  //判断是否是采购,是的话新增一个筛选条件
2205
2206
2207
2208
  if (
    userInfo?.roleSmallVO?.code === 'procure' ||
    userInfo?.roleSmallVO?.code === 'admin'
  ) {
2209
2210
2211
2212
2213
2214
2215
2216
2217
    mainOrdersColumns.push({
      title: '采购下单状态',
      dataIndex: 'procureOrderStatus',
      valueType: 'select',
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
    });
  }
zhongnanhuang authored
2218
  function toolBarRender() {
zhongnanhuang authored
2219
    let roleCode = userInfo?.roleSmallVO?.code;
zhongnanhuang authored
2220
2221
    let toolBtns = [];
zhongnanhuang authored
2222
2223
2224
2225
    toolBtns.push(
      <Checkbox onChange={changeCancelOrderShow}>只看作废</Checkbox>,
    );
zhongnanhuang authored
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
    //采购可以筛选出需要处理的订单
    if (roleCode === 'procure') {
      toolBtns.push(
        <Checkbox onChange={changeProcureToBeProcessed}>只看需处理</Checkbox>,
      );
    }

    //财务可以将需要处理的订单排序到前面
    if (roleCode === 'finance') {
      toolBtns.push(
        <Checkbox onChange={changeFinancialToBeProcessed}>排序</Checkbox>,
      );
    }

    if (roleCode === 'admin') {
      toolBtns.push(
        <Checkbox onChange={changeProcureToBeProcessed}>
          只看需处理(采购)
        </Checkbox>,
      );
      toolBtns.push(
        <Checkbox onChange={changeFinancialToBeProcessed}>排序</Checkbox>,
      );
    }
zhongnanhuang authored
2251
2252
2253
    //导出按钮配置
    const items: MenuProps['items'] = [
      {
zhongnanhuang authored
2254
2255
2256
2257
2258
2259
2260
2261
2262
        label: '导出查询结果订单',
        key: '2',
        onClick: async () => {
          let body = { flag: 50, ...searchParams };
          exportLoading();
          orderExport('/api/service/order/export', body, exportLoadingDestory);
        },
      },
      {
zhongnanhuang authored
2263
2264
2265
2266
2267
2268
2269
        label: '导出已选中订单',
        key: '1',
        onClick: async () => {
          if (selectedItems.length === 0) {
            message.error('请选择订单');
            return;
          }
zhongnanhuang authored
2270
          let body = { flag: 30, ids: selectedItems };
zhongnanhuang authored
2271
          exportLoading();
zhongnanhuang authored
2272
          orderExport('/api/service/order/export', body, exportLoadingDestory);
zhongnanhuang authored
2273
2274
        },
      },
zhongnanhuang authored
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
      // {
      //   label: '导出当前页订单',
      //   key: '2',
      //   onClick: async () => {
      //     if (mainOrderAllItemKeys.length === 0) {
      //       message.error('当前没有订单');
      //       return;
      //     }
      //     let body = { flag: 20, ids: mainOrderAllItemKeys };
      //     exportLoading();
      //     orderExport('/api/service/order/export', body, exportLoadingDestory);
      //   },
      // },
zhongnanhuang authored
2288
      {
zhongnanhuang authored
2289
2290
        label: '导出当天订单',
        key: '4',
zhongnanhuang authored
2291
        onClick: async () => {
zhongnanhuang authored
2292
          let body = { flag: 40, ids: [] };
zhongnanhuang authored
2293
          exportLoading();
zhongnanhuang authored
2294
          orderExport('/api/service/order/export', body, exportLoadingDestory);
zhongnanhuang authored
2295
2296
2297
2298
2299
2300
        },
      },
      {
        label: '导出所有订单',
        key: '3',
        onClick: async () => {
zhongnanhuang authored
2301
2302
2303
2304
2305
          let body = { flag: 10, ids: [] };
          exportLoading();
          orderExport('/api/service/order/export', body, exportLoadingDestory);
        },
      },
zhongnanhuang authored
2306
2307
2308
2309
2310
2311
2312
    ];

    const menuProps = {
      items,
      onClick: () => {},
    };
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
    if (rolePath?.includes('mergeApplyInvoicing')) {
      toolBtns.push(
        <Button
          type="primary"
          key="out"
          onClick={() => {
            setApplyForInvoicingVisible(true);
            //选中订单
            setIsEdit(false);
            setIsMainOrder(true);
2323
2324
2325
2326
2327
            let mainOrderList = [];
            for (let order of mainOrderSelectedMap.values()) {
              mainOrderList.push(order);
            }
            setSelectedRows(mainOrderList);
2328
2329
2330
          }}
          disabled={selectedItems?.length === 0}
        >
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
          {userInfo?.roleSmallVO?.code === 'admin' ? '合并(销售)' : '合并开票'}
        </Button>,
      );
    }

    if (rolePath?.includes('mergeInvoicing')) {
      toolBtns.push(
        <Button
          type="primary"
          key="out"
          onClick={() => {
            //检查订单状态是否正确
            // 遍历Map中的键值对
            let errorIds = [];
            let mainOrders = [];
            mainOrderSelectedMap.forEach((value) => {
              mainOrders.push(value);
              for (let subOrder of value.subOrderInformationLists) {
zhongnanhuang authored
2349
2350
2351
2352
                if (
                  subOrder.afterInvoicingStatus !== 'APPLY_FOR_INVOICING' &&
                  subOrder.afterInvoicingStatus !== 'PARTIAL_INVOICING'
                ) {
2353
2354
2355
2356
2357
2358
2359
2360
2361
                  errorIds.push(value.id);
                  return;
                }
              }
            });
            if (errorIds.length > 0) {
              message.error(
                '订单号为:' +
                  errorIds.join(',') +
zhongnanhuang authored
2362
                  '的订单存在不是[申请开票]或者[部分开票]状态的子订单,请检查!',
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
              );
              return;
            }

            setMainOrderSelectedRows(mainOrders);
            setFinancialMergeDrawerVisible(true);
          }}
          disabled={selectedItems?.length === 0}
        >
          {userInfo?.roleSmallVO?.code === 'admin' ? '合并(财务)' : '合并开票'}
2373
2374
2375
2376
        </Button>,
      );
    }
2377
    if (rolePath?.includes('addOrder')) {
zhongnanhuang authored
2378
2379
2380
2381
      toolBtns.push(
        <Button
          type="primary"
          key="out"
zhongnanhuang authored
2382
2383
          onClick={() => {
            setOrderDrawerVisible(true);
2384
            setOrderOptType('add');
zhongnanhuang authored
2385
          }}
zhongnanhuang authored
2386
2387
2388
2389
2390
        >
          新增
        </Button>,
      );
    }
2391
zhongnanhuang authored
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
    if (rolePath?.includes('importExcel')) {
      toolBtns.push(
        <Button
          type="primary"
          key="out"
          onClick={() => {
            setImportModalVisible(true);
          }}
        >
          导入
        </Button>,
      );
    }
zhongnanhuang authored
2405
zhongnanhuang authored
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
    if (rolePath?.includes('export')) {
      toolBtns.push(
        <Dropdown menu={menuProps}>
          <Button>
            <Space>
              导出
              <DownOutlined />
            </Space>
          </Button>
        </Dropdown>,
      );
    }
zhongnanhuang authored
2418
zhongnanhuang authored
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
    // toolBtns.push(
    //   <Button
    //     key="show"
    //     onClick={() => {
    //       handleAllExpand();
    //     }}
    //   >
    //     {mainOrderAllItemKeys?.length !== expandedRowKeys.length
    //       ? '一键展开'
    //       : '一键收起'}
    //   </Button>,
    // );
zhongnanhuang authored
2431
2432
2433
2434

    return toolBtns;
  }
zhongnanhuang authored
2435
2436
2437
2438
2439
2440
2441
2442
2443
  useEffect(() => {
    // 使用URLSearchParams来解析查询参数
    const params = new URLSearchParams(location.search);
    const id = params.get('id');
    if (id) {
      mainTableFormRef.current?.setFieldValue('id', id);
    }
  }, []);
calmound authored
2444
2445
  return (
    <PageContainer
zhongnanhuang authored
2446
      className="order-page-container"
calmound authored
2447
      header={{
sanmu authored
2448
        title: '订单管理',
zhongnanhuang authored
2449
2450
        extra: [
          <Avatar key="0" style={{ verticalAlign: 'middle' }} size="large">
zhongnanhuang authored
2451
            {userInfo?.username}
zhongnanhuang authored
2452
          </Avatar>,
zhongnanhuang authored
2453
          <Tag key="nickName">{userInfo?.nickName}</Tag>,
zhongnanhuang authored
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
          <Dropdown
            key="dropdown"
            trigger={['click']}
            menu={{
              items: [
                {
                  label: '退出登录',
                  key: '1',
                  onClick: () => {
                    localStorage.removeItem('token');
                    history.push('/login');
                  },
                },
2467
2468
2469
2470
                // {
                //   label: '修改密码',
                //   key: '2',
                // },
zhongnanhuang authored
2471
2472
2473
2474
2475
2476
2477
2478
              ],
            }}
          >
            <Button key="4" style={{ padding: '0 8px' }}>
              <EllipsisOutlined />
            </Button>
          </Dropdown>,
        ],
calmound authored
2479
2480
      }}
    >
2481
      <div id="resizeDiv"></div>
2482
      <ProTable
zhongnanhuang authored
2483
2484
2485
        id="main-table"
        // tableStyle={{backgroundColor:'red'}}
2486
        actionRef={mainTableRef}
zhongnanhuang authored
2487
        formRef={mainTableFormRef}
2488
2489
2490
2491
2492
        expandIconColumnIndex={-1}
        columns={mainOrdersColumns}
        rowKey="id"
        pagination={{
          showQuickJumper: true,
zhongnanhuang authored
2493
2494
2495
2496
2497
2498
2499
          pageSize: pageSize,
          current: currentPage,
          showSizeChanger: true,
          onChange: (page, size) => {
            setPageSize(size);
            setCurrentPage(page);
          },
calmound authored
2500
        }}
zhongnanhuang authored
2501
        // showHeader={false}
2502
        expandedRowKeys={expandedRowKeys}
zhongnanhuang authored
2503
        // expandable={{ expandedRowRender }}
2504
2505
        dateFormatter="string"
        options={false}
zhongnanhuang authored
2506
        headerTitle=""
2507
2508
        search={{
          labelWidth: 'auto',
zhongnanhuang authored
2509
          // onCollapse: resize,
2510
2511
2512
2513
        }}
        request={async (
          // 第一个参数 params 查询表单和 params 参数的结合
          // 第一个参数中一定会有 pageSize 和  current ,这两个参数是 antd 的规范
zhongnanhuang authored
2514
          params,
2515
          sorter,
sanmu authored
2516
2517
          filter,
        ) => {
2518
          //订单id处理
zhongnanhuang authored
2519
2520
2521
2522
2523
2524
          /**
           * 以params中的id为主,如果params没id,则取url中的id
           * 第一次进来这个页面,url带有id的话,会自动填充到查询表单中,但是第一次查询params不会带这个id进来
           */
          let orderIds = mainTableFormRef.current?.getFieldValue('id');
          params.id = params.id || orderIds;
2525
          if (params.id !== '') {
2526
            if (params.id?.indexOf(',')) {
2527
2528
2529
2530
2531
2532
              params.id = params.id.split(',');
              params.id = params.id.filter((id) => {
                return id !== '';
              });
            }
          }
zhongnanhuang authored
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
          //采购是否只查看需要自己处理的
          if (onlyShowProcureToBeProcessed) {
            params.condition = 10;
          }

          //财务是否只查看需要自己处理的
          if (onlyShowFinancialToBeProcessed) {
            params.condition = 20;
          }

          //是否只查看已作废
          params.isDeleteQueryOrder = onlyShowCancelOrder;
          //保存这个搜索条件
zhongnanhuang authored
2546
          setSearchParam(params);
2547
          const { data } = await postServiceOrderQueryServiceOrder({
2548
            // ...params,
calmound authored
2549
2550
2551
2552
            // FIXME: remove @ts-ignore
            // @ts-ignore
            sorter,
            filter,
zhongnanhuang authored
2553
            data: { ...params },
calmound authored
2554
          });
zhongnanhuang authored
2555
zhongnanhuang authored
2556
2557
2558
2559
2560
2561
2562
          let mainOrderIds = data?.data?.map((d) => d.id);
          if (mainOrderAllItemKeys === undefined) {
            setMainOrderAllItemKeys([]);
          } else {
            setMainOrderAllItemKeys(mainOrderIds);
          }
          setRolePath(data.specialPath);
zhongnanhuang authored
2563
          handleTableExpand(mainOrderIds);
2564
          setData(data?.data);
calmound authored
2565
          return {
2566
            data: data?.data || [],
zhongnanhuang authored
2567
            total: data?.total || 0,
calmound authored
2568
2569
          };
        }}
2570
2571
2572
        toolbar={{
          multipleLine: true,
        }}
zhongnanhuang authored
2573
2574
2575
        toolBarRender={() => {
          return toolBarRender();
        }}
2576
2577
      />
sanmu authored
2578
      {orderDrawerVisible && (
sanmu authored
2579
        <OrderDrawer
2580
          data={orderRow}
2581
          subOrders={selectedRows}
zhongnanhuang authored
2582
          onClose={(isSuccess: boolean) => {
sanmu authored
2583
            setOrderDrawerVisible(false);
2584
            setOrderRow({});
zhongnanhuang authored
2585
2586
2587
            if (isSuccess) {
              refreshTable();
            }
calmound authored
2588
          }}
2589
          orderOptType={orderOptType}
calmound authored
2590
        />
sanmu authored
2591
      )}
sanmu authored
2592
2593
2594
2595

      {checkVisible && (
        <CheckModal
          setCheckVisible={setCheckVisible}
2596
          data={orderRow}
2597
          subOrders={selectedRows}
zhongnanhuang authored
2598
          orderCheckType={orderCheckType}
zhongnanhuang authored
2599
2600
2601
2602
2603
          openOrderDrawer={(type: any, id: any) => {
            setOrderRow({ id: id });
            setOrderOptType(type);
            setOrderDrawerVisible(true);
          }}
sanmu authored
2604
2605
2606
          onClose={() => {
            setCheckVisible(false);
            setOrderRow({});
2607
            setSelectedRows({});
zhongnanhuang authored
2608
            refreshTable();
2609
2610
2611
2612
          }}
        />
      )}
zhongnanhuang authored
2613
2614
2615
      {applyForInvoicingVisible && (
        <ApplyForInvoicingModal
          setCheckVisible={setApplyForInvoicingVisible}
zhongnanhuang authored
2616
          data={selectedItems}
zhongnanhuang authored
2617
          subOrders={selectedRows}
2618
          isMainOrder={isMainOrder}
zhongnanhuang authored
2619
          isEdit={isEdit}
zhongnanhuang authored
2620
2621
2622
          onClose={() => {
            setApplyForInvoicingVisible(false);
            setSelectedRows({});
zhongnanhuang authored
2623
            setIsMainOrder(false);
zhongnanhuang authored
2624
2625
2626
2627
2628
            refreshTable();
          }}
        />
      )}
2629
      {notesEditVisible && (
zhongnanhuang authored
2630
        <OrderNotesEditModal
2631
2632
          setNotesEditVisible={setNotesEditVisible}
          data={orderRow}
zhongnanhuang authored
2633
          isMianOrder={isMainOrder}
2634
2635
2636
          onClose={() => {
            setNotesEditVisible(false);
            setOrderRow({});
zhongnanhuang authored
2637
            refreshTable();
sanmu authored
2638
2639
2640
2641
2642
2643
2644
          }}
        />
      )}

      {deliverVisible && (
        <DeliverModal
          data={selectedRows}
zhongnanhuang authored
2645
          isSendProduct={isSendProduct}
zhongnanhuang authored
2646
2647
2648
          setVisible={(b: boolean) => {
            setDeliverVisible(b);
          }}
zhongnanhuang authored
2649
          sendType={orderCheckType}
sanmu authored
2650
          onClose={() => {
zhongnanhuang authored
2651
            setDeliverVisible(false);
sanmu authored
2652
            setOrderRow({});
zhongnanhuang authored
2653
2654
            setIsSendProduct(false);
            refreshTable();
sanmu authored
2655
2656
2657
          }}
        />
      )}
zhongnanhuang authored
2658
2659
2660

      {financialVisible && (
        <FinancialDrawer
zhongnanhuang authored
2661
          isEdit={isEdit}
zhongnanhuang authored
2662
2663
          mainOrder={orderRow}
          subOrders={selectedRows}
zhongnanhuang authored
2664
          isMainOrder={isMainOrder}
zhongnanhuang authored
2665
2666
2667
2668
          cancel={() => {
            setFinancialVisible(false);
            setOrderRow({});
            setIsMainOrder(false);
zhongnanhuang authored
2669
            setIsEdit(false);
zhongnanhuang authored
2670
          }}
zhongnanhuang authored
2671
2672
2673
          onClose={() => {
            setFinancialVisible(false);
            setOrderRow({});
zhongnanhuang authored
2674
            refreshTable();
zhongnanhuang authored
2675
            setIsMainOrder(false);
zhongnanhuang authored
2676
            setIsEdit(false);
zhongnanhuang authored
2677
2678
2679
2680
          }}
        />
      )}
2681
2682
      {financialEditVisible && (
        <FinancialEditDrawer
2683
          mainOrder={orderRow}
2684
          subOrders={selectedRows}
2685
          isMainOrder={isMainOrder}
2686
2687
2688
2689
2690
2691
2692
2693
          setVisible={() => {
            setFinancialEditVisible(false);
            setIsMainOrder(false);
          }}
          onClose={() => {
            setFinancialEditVisible(false);
            refreshTable();
            setIsMainOrder(false);
2694
            setOrderRow({});
2695
2696
2697
2698
          }}
        />
      )}
zhongnanhuang authored
2699
2700
2701
2702
      {orderPrintVisible && (
        <OrderPrintModal
          mainOrder={orderRow}
          subOrders={selectedRows}
zhongnanhuang authored
2703
          isRePrint={isRePrintOrder}
zhongnanhuang authored
2704
2705
2706
          setVisible={(b: boolean) => {
            setOrderPrintVisible(b);
          }}
zhongnanhuang authored
2707
          printOptType={orderCheckType}
zhongnanhuang authored
2708
2709
2710
          onClose={() => {
            setOrderPrintVisible(false);
            setOrderRow({});
zhongnanhuang authored
2711
2712
            setIsRePrintOrder(false);
            refreshTable();
zhongnanhuang authored
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
          }}
        />
      )}

      {confirmReceiptVisible && (
        <ConfirmReceiptModal
          data={orderRow}
          onClose={() => {
            setConfirmReceiptVisible(false);
            setOrderRow({});
zhongnanhuang authored
2723
            refreshTable();
zhongnanhuang authored
2724
2725
2726
          }}
        />
      )}
zhongnanhuang authored
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737

      {subOrderConfirmReceiptImagesVisible && (
        <SubOrderComfirmReceiptImagesModal
          setVisible={setSubOrderConfirmReceiptImagesVisible}
          onClose={() => {
            setSubOrderConfirmReceiptImagesVisible(false);
          }}
          orderRow={orderRow}
        />
      )}
zhongnanhuang authored
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
      {importModalVisible && (
        <ImportModal
          onClose={() => {
            setImportModalVisible(false);
            refreshTable();
          }}
        />
      )}

      {attachmentModalVisible && (
        <AttachmentModal
          data={orderRow}
          onClose={() => {
            setAttachmentModalVisible(false);
            setOrderRow({});
          }}
        />
      )}
zhongnanhuang authored
2757
2758
2759
      {historyModalVisible && (
        <HistoryModal
          subOrders={selectedRows}
zhongnanhuang authored
2760
          isCancelledOrder={onlyShowCancelOrder}
zhongnanhuang authored
2761
2762
2763
2764
2765
2766
2767
          onClose={() => {
            setHistoryModalVisible(false);
            setSelectedRows({});
          }}
        />
      )}
zhongnanhuang authored
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
      {deliverInfoDrawerVisible && (
        <DeliverInfoDrawer
          data={orderRow}
          onClose={() => {
            setDeliverInfoDrawerVisible(false);
            setOrderRow({});
          }}
        />
      )}
zhongnanhuang authored
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
      {deliverInfoDrawerVisible && (
        <DeliverInfoDrawer
          data={orderRow}
          onClose={() => {
            setDeliverInfoDrawerVisible(false);
            setOrderRow({});
          }}
        />
      )}

      {procureCheckModalVisible && (
        <ProcureCheckModal
          setCheckVisible={setProcureCheckModalVisible}
          data={orderRow}
          subOrders={selectedRows}
          onClose={() => {
            setProcureCheckModalVisible(false);
            setOrderRow({});
            setSelectedRows({});
            refreshTable();
          }}
        />
      )}
zhongnanhuang authored
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
      {afterSalesDrawerVisible && (
        <AfterSalesDrawer
          setVisible={setAfterSalesDrawerVisible}
          mainOrder={orderRow}
          subOrders={selectedRows}
          onClose={() => {
            setAfterSalesDrawerVisible(false);
            setSelectedRows({});
            setOrderRow({});
            refreshTable();
          }}
        />
      )}
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
      {procureConvertModalVisible && (
        <ProcureConvertModal
          setVisible={setProcureConvertModalVisible}
          subOrders={selectedRows}
          onClose={() => {
            setProcureConvertModalVisible(false);
            setSelectedRows({});
            refreshTable();
          }}
        />
      )}
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
      {financialMergeDrawerVisible && (
        <FinancialMergeDrawer
          setVisible={setFinancialMergeDrawerVisible}
          dataList={mainOrderSelectedRows}
          onClose={() => {
            setFinancialMergeDrawerVisible(false);
            setMainOrderSelectedRows([]);
            refreshTable();
          }}
        />
      )}
zhongnanhuang authored
2840
2841
2842
      {financialReceiptsModalVisible && (
        <FinancialReceiptsModal
          setVisible={setFinancialReceiptsModalVisible}
2843
          datas={selectedRows}
zhongnanhuang authored
2844
2845
2846
2847
2848
2849
2850
2851
          onClose={() => {
            setFinancialReceiptsModalVisible(false);
            setSelectedRows({});
            refreshTable();
          }}
        />
      )}
zhongnanhuang authored
2852
      {contextHolder}
calmound authored
2853
2854
2855
2856
    </PageContainer>
  );
};
sanmu authored
2857
export default OrderPage;