Blame view

src/pages/Order/index.tsx 161 KB
sanmu authored
1
import ButtonConfirm from '@/components/ButtomConfirm';
zhongnanhuang authored
2
import { RESPONSE_CODE } from '@/constants/enum';
3
import ImportExpressBillModal from '@/pages/Order/components/ImportExpressBillModal';
曾国涛 authored
4
import InvoicingDrawerForm from '@/pages/Order/components/InvoicingDrawerForm';
5
import ReissueModal from '@/pages/Order/components/ReissueModal';
zhongnanhuang authored
6
import {
7
8
  postKingdeeRepSalBillOutbound,
  postKingdeeRepSalOrderSave,
zhongnanhuang authored
9
  postServiceOrderCancelSend,
10
  postServiceOrderGetCurrentOptNode,
zhongnanhuang authored
11
  postServiceOrderNoNeedSend,
zhongnanhuang authored
12
  postServiceOrderOrderCancel,
13
  postServiceOrderProcureOrder,
zhongnanhuang authored
14
  postServiceOrderProcurePrint,
zhongnanhuang authored
15
  postServiceOrderProvideProcurementRoles,
zhongnanhuang authored
16
  postServiceOrderQueryServiceOrder,
17
  postServiceOrderSaleCancelInvoicing,
18
  postServiceOrderSalesConfirm,
zhongnanhuang authored
19
20
} from '@/services';
import { orderExport } from '@/services/order';
21
import {
zhongnanhuang authored
22
  FloatAdd,
23
24
25
26
  copyToClipboard,
  enumToProTableEnumValue,
  enumValueToLabel,
  formatDateTime,
27
  formatdate,
zhongnanhuang authored
28
29
  getAliYunOSSFileNameFromUrl,
  isImageName,
30
} from '@/utils';
31
32
import {
  getReceivingCompanyOptions,
33
  isAdmin,
34
  isExaminer,
35
36
37
  isFinance,
  isProcure,
  isSales,
38
  isSupplier,
39
  isWarehousekeeper,
40
} from '@/utils/order';
zhongnanhuang authored
41
import { getUserInfo } from '@/utils/user';
zhongnanhuang authored
42
import {
zhongnanhuang authored
43
  ClockCircleTwoTone,
zhongnanhuang authored
44
  ContainerTwoTone,
zhongnanhuang authored
45
  CopyOutlined,
zhongnanhuang authored
46
  CopyTwoTone,
zhongnanhuang authored
47
  DownOutlined,
zhongnanhuang authored
48
  EditTwoTone,
zhongnanhuang authored
49
  QuestionCircleOutlined,
zhongnanhuang authored
50
} from '@ant-design/icons';
calmound authored
51
import {
zhongnanhuang authored
52
  ActionType,
sanmu authored
53
  ProColumns,
zhongnanhuang authored
54
  ProFormInstance,
sanmu authored
55
  ProTable,
calmound authored
56
} from '@ant-design/pro-components';
zhongnanhuang authored
57
58
59
import {
  Button,
  Checkbox,
zhongnanhuang authored
60
  Divider,
zhongnanhuang authored
61
62
  Dropdown,
  Flex,
63
  FloatButton,
64
  Image,
zhongnanhuang authored
65
  MenuProps,
zhongnanhuang authored
66
67
  Modal,
  Popconfirm,
68
  Radio,
zhongnanhuang authored
69
  Space,
70
  Spin,
zhongnanhuang authored
71
  Tag,
zhongnanhuang authored
72
  Tooltip,
zhongnanhuang authored
73
74
  message,
} from 'antd';
zhongnanhuang authored
75
import Base64 from 'base-64';
zhongnanhuang authored
76
import { cloneDeep } from 'lodash';
zhongnanhuang authored
77
import React, { Key, useEffect, useRef, useState } from 'react';
zhongnanhuang authored
78
import OrderPrintModal from '../OrderPrint/OrderPrintModal';
zhongnanhuang authored
79
import AfterSalesDrawer from './components/AfterSalesDrawer';
zhongnanhuang authored
80
import ApplyForInvoicingModal from './components/ApplyForInvoicingModal';
zhongnanhuang authored
81
import AttachmentModal from './components/AttachmentModal';
sanmu authored
82
import CheckModal from './components/CheckModal';
zhongnanhuang authored
83
import ConfirmReceiptModal from './components/ConfirmReceiptModal';
zhongnanhuang authored
84
import DeliverInfoDrawer from './components/DeliverInfoDrawer';
sanmu authored
85
import DeliverModal from './components/DeliverModal';
zhongnanhuang authored
86
import FinancialDrawer from './components/FinancialDrawer';
87
import FinancialEditDrawer from './components/FinancialEditDrawer';
88
import FinancialMergeDrawer from './components/FinancialMergeDrawer';
zhongnanhuang authored
89
import FinancialReceiptsModal from './components/FinancialReceiptsModal';
zhongnanhuang authored
90
import HistoryModal from './components/HistoryModal';
91
import ImagesViewerModal from './components/ImagesViewerModal';
zhongnanhuang authored
92
import ImportModal from './components/ImportModal';
zhongnanhuang authored
93
import ModifiedDiffModal from './components/ModifiedDiffModal';
sanmu authored
94
import OrderDrawer from './components/OrderDrawer';
zhongnanhuang authored
95
import OrderNotesEditModal from './components/OrderNotesEditModal';
zhongnanhuang authored
96
import ProcureCheckModal from './components/ProcureCheckModal';
97
import ProcureConvertModal from './components/ProcureConvertModal';
zhongnanhuang authored
98
import ProductionTimeModal from './components/ProductionTimeModal';
zhongnanhuang authored
99
import ShippingWarehouseChangeModal from './components/ShippingWarehouseChangeModal';
100
import UploadPayBillModal from './components/UploadPayBillModal';
101
import {
102
  AFTER_INVOICING_STATUS,
zhongnanhuang authored
103
  CHECK_TYPE,
zhongnanhuang authored
104
  LOGISTICS_STATUS_OPTIONS,
105
  MAIN_ORDER_COLUMNS,
106
  MODIFIED_AUDIT_STATUS_OPTIONS,
107
  ORDER_STATUS_OPTIONS,
zhongnanhuang authored
108
  PAYEE_OPTIONS,
109
  PAYMENT_CHANNEL_OPTIONS,
zhongnanhuang authored
110
  PAYMENT_RECEIPTS_STATUS_OPTIONS,
zhongnanhuang authored
111
  POST_AUDIT_OPTIONS,
112
  PROCURE_ORDER_STATUS,
zhongnanhuang authored
113
  PROCURE_PRIMARY_ORDER_STATUS_OPTIONS,
zhongnanhuang authored
114
  PRODUCT_BELONG_DEPARTMENT_OPTIONS,
zhongnanhuang authored
115
  SHIPPING_WAREHOUSE_OPTIONS,
zhongnanhuang authored
116
  TAGS_COLOR,
zhongnanhuang authored
117
118
  getInvoicingType,
  getNeedInvoicing,
119
} from './constant';
sanmu authored
120
import './index.less';
sanmu authored
121
import { OrderListItemType, OrderType } from './type.d';
calmound authored
122
sanmu authored
123
const OrderPage = () => {
sanmu authored
124
  const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false);
sanmu authored
125
  const [checkVisible, setCheckVisible] = useState<boolean>(false);
zhongnanhuang authored
126
  const [orderPrintVisible, setOrderPrintVisible] = useState<boolean>(false);
127
  const [allMainChecked, setAllMainChecked] = useState(false);
128
129
  const [imagesViewerModalVisible, setImagesViewerModalVisible] =
    useState<boolean>(false);
曾国涛 authored
130
131
  const [InvoicingDrawerFormVisible, setInvoicingDrawerFormVisible] =
    useState<boolean>(false);
132
  const [data, setData] = useState([]); //列表数据
133
  const [notesEditVisible, setNotesEditVisible] = useState<boolean>(false);
134
135
  const [financialMergeDrawerVisible, setFinancialMergeDrawerVisible] =
    useState<boolean>(false);
zhongnanhuang authored
136
137
  const [attachmentModalVisible, setAttachmentModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
138
139
  const [uploadPayBillModalVisible, setUploadPayBillModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
140
141
  const [modifiedDiffModalVisible, setModifiedDiffModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
142
143
  const [financialReceiptsModalVisible, setFinancialReceiptsModalVisible] =
    useState(false);
zhongnanhuang authored
144
  const [financialVisible, setFinancialVisible] = useState<boolean>(false);
145
146
  const [financialEditVisible, setFinancialEditVisible] =
    useState<boolean>(false);
zhongnanhuang authored
147
148
  const [afterSalesDrawerVisible, setAfterSalesDrawerVisible] =
    useState<boolean>(false);
zhongnanhuang authored
149
150
  const [historyModalVisible, setHistoryModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
151
152
153
  const [isRePrintOrder, setIsRePrintOrder] = useState<boolean>(false);
  const [isSendProduct, setIsSendProduct] = useState<boolean>(false);
  const [isMainOrder, setIsMainOrder] = useState<boolean>(false);
zhongnanhuang authored
154
  const [importModalVisible, setImportModalVisible] = useState<boolean>(false);
155
  const [reissueVisible, setReissueVisible] = useState<boolean>(false);
zhongnanhuang authored
156
157
  const [applyForInvoicingVisible, setApplyForInvoicingVisible] =
    useState<boolean>(false);
zhongnanhuang authored
158
159
  const [procureCheckModalVisible, setProcureCheckModalVisible] =
    useState<boolean>(false);
160
161
  const [procureConvertModalVisible, setProcureConvertModalVisible] =
    useState<boolean>(false);
zhongnanhuang authored
162
163
  const [confirmReceiptVisible, setConfirmReceiptVisible] =
    useState<boolean>(false);
zhongnanhuang authored
164
165
  const [productionTimeModalVisible, setProductionTimeModalVisible] =
    useState<boolean>(false);
sanmu authored
166
  const [deliverVisible, setDeliverVisible] = useState<boolean>(false);
zhongnanhuang authored
167
168
  const [deliverInfoDrawerVisible, setDeliverInfoDrawerVisible] =
    useState<boolean>(false);
169
  const [orderOptType, setOrderOptType] = useState<string>('');
zhongnanhuang authored
170
  const [isEdit, setIsEdit] = useState<boolean>(false);
zhongnanhuang authored
171
  const [expandedRowKeys] = useState<Key[]>([]);
172
173
  const [notesType, setNotesType] = useState(1);
  const [notes, setNotes] = useState(1);
zhongnanhuang authored
174
  const [rolePath, setRolePath] = useState([]); //当前角色权限(新增跟打印按钮)
zhongnanhuang authored
175
  const userInfo = getUserInfo();
zhongnanhuang authored
176
  // const [tableHeight, setTableHeight] = useState(200);
sanmu authored
177
  const [selectedRows, setSelectedRows] = useState({});
zhongnanhuang authored
178
179
180
  const [mainOrderIdSubOrderIdRelationsMap] = useState(new Map()); //主订单id与子订单id的对照关系,用于主订单子订单的勾选校验,子订单全选中对应的主订单自动勾选上
  const [selectedMainOrderKeys, setSelectedMainOrderKeys] = useState<any[]>([]);
  const [selectedSubOrderKeys, setSelectedSubOrderKeys] = useState<any[]>([]);
zhongnanhuang authored
181
182
  const [pageSize, setPageSize] = useState(10);
  const [currentPage, setCurrentPage] = useState(1);
zhongnanhuang authored
183
  const [orderCheckType, setOrderCheckType] = useState('');
184
  const [imagesViewerOptType, setImagesViewerOptType] = useState('');
185
  const [filterCondifion, setFilterCondition] = useState(0);
zhongnanhuang authored
186
187
  const [mainOrderSelectedMap] = useState(new Map()); //选中的主订单Map key:主订单id value:主订单数据
  const [subOrderSelectedMap] = useState(new Map()); //选中的子订单Map key:主订单id value:选中的子订单数据集合
zhongnanhuang authored
188
189
190
191
  const [currentOptMainId, setCurrentMainId] = useState<any>(undefined); //当前操作对象的主订单id
  const [curretnOptSubId, setCurretnOptSubId] = useState<any>(undefined); //当前操作对象的子订单id
  const [subOrderCount, setSubOrderCount] = useState(0);
  const [sorted, setSorted] = useState(false);
zhongnanhuang authored
192
193
  const mainTableRef = useRef<ActionType>();
  const mainTableFormRef = useRef<ProFormInstance>();
zhongnanhuang authored
194
  let [searchParams, setSearchParam] = useState(Object); //表格的查询条件存储
zhongnanhuang authored
195
  const [messageApi, contextHolder] = message.useMessage();
zhongnanhuang authored
196
197
198
199
200
  const [
    shippingWarehouseChangeModalVisible,
    setShippingWarehouseChangeModalVisible,
  ] = useState(false);
  const [ids, setIds] = useState([]);
201
  const [recordOptNode, setRecordOptNode] = useState(null);
202
  const roleCode = userInfo?.roleSmallVO?.code;
zhongnanhuang authored
203
204
205
206
207
208
209
210
211
212
  const triggerRecordOptNode = async (id) => {
    const res = await postServiceOrderGetCurrentOptNode({
      query: {
        id,
      },
    });
    setRecordOptNode(res.data);
  };
zhongnanhuang authored
213
214
215
216
217
218
219
220
221
222
223
224
225
  const exportLoading = () => {
    messageApi.open({
      type: 'loading',
      content: '正在导出文件...',
      duration: 0,
    });
  };

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

  const refreshTable = () => {
226
    console.log('刷新表格');
zhongnanhuang authored
227
228
229
    mainTableRef.current?.reload();
    //刷新表格数据的时候,取消选中行
    setSelectedRows([]);
zhongnanhuang authored
230
    setSelectedSubOrderKeys([]);
zhongnanhuang authored
231
  };
232
233
234
235
236
237
238
239
  /**
   * 复制订单到剪贴板
   * @param record
   */
  function copyOrderToClipboard(record: any) {
    let text = '';
    text += record?.id;
zhongnanhuang authored
240
    text += ',' + record?.salesCode;
241
    text += ',' + record?.customerName;
zhongnanhuang authored
242
243
    text += ',' + record?.customerContactNumber;
zhongnanhuang authored
244
245
    text += ',' + record?.customerShippingAddress;
zhongnanhuang authored
246
zhongnanhuang authored
247
    if (!isSupplier()) {
zhongnanhuang authored
248
249
250
      text += ',' + record?.institutionContactName;
      text += ',' + record?.institution;
    }
251
252
253
254
255
256
    record?.subOrderInformationLists?.forEach((item) => {
      text += '\n';
      text += item?.productName;
      text += ' ' + item?.parameters;
      text += ' ' + item?.quantity;
      text += ' ' + item?.unit;
zhongnanhuang authored
257
      if (!isSupplier()) {
zhongnanhuang authored
258
259
        text += ' ¥' + item?.subOrderPayment;
      }
zhongnanhuang authored
260
      text += ' ' + item?.id;
261
262
263
264
265
266
267
268
    });
    if (copyToClipboard(text)) {
      message.info('已复制到剪贴板');
    } else {
      message.info('无法复制到剪贴板');
    }
  }
zhongnanhuang authored
269
270
271
272
273
274
275
276
277
278
279
280
  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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
  /**
   * 检查是否可以打印
   * @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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
  /**
   * 财务是否选中排序
   * @param e
   */
  function financeSorted(e: any) {
    let checked = e?.target.checked;
    setSorted(checked);
    refreshTable();
  }

  /**
   * 重置当前的操作对象
   */
  function clearOptObject() {
    setCurrentMainId(undefined);
    setCurretnOptSubId(undefined);
315
    setIsMainOrder(false);
zhongnanhuang authored
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
  }

  /**
   * 初始化当前的操作对象
   * @param subId
   * @param mainId
   */
  function createOptObject(subId: any, mainId: any) {
    setCurrentMainId(mainId);
    setCurretnOptSubId(subId);
  }

  /**
   * 检查当前操作是否异常
   */
  // function checkOptValid() {
  //   if ((currentOptMainId === undefined || currentOptMainId === null) && (curretnOptSubId === undefined || curretnOptSubId === null)) {
  //     message.error("页面错误:当前操作对象为空,请联系系统管理员");
  //     return false;
  //   }

  //   //检查数据是否存在
  //   //主订单数据
  //   if (!Array.from(mainOrderIdSubOrderIdRelationsMap.keys()).includes(currentOptMainId)) {
  //     message.error("页面错误:当前操作主订单对象为空,请联系系统管理员");
  //   }

  //   //子订单
  //   let allSubIds = [];
  //   for (const idList of mainOrderIdSubOrderIdRelationsMap.values()) {
  //     allSubIds.push(...idList);
  //   }
  //   if (!allSubIds.includes(curretnOptSubId)) {
  //     message.error("页面错误:当前操作子订单对象为空,请联系系统管理员");
  //     return false
  //   }

  //   return true;
  // }

  /**
   * 获取当前选中子订单的其中一个主订单
   */
  function getFirstMainOrder() {
    let mainId = [...subOrderSelectedMap.values()].flat()[0].mainOrderId;
    for (let item of data) {
      if (item.id === mainId) {
        return item;
      }
    }

    return null;
  }

  /**
   * 返回当前操作的主订单数据
   */
  function buildMainOrder() {
    if (currentOptMainId === undefined || currentOptMainId === null) {
      message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
      return;
    }

    let mainOrderClone = null;
    let matchedData = data.filter((item) => {
      return item.id === currentOptMainId;
    });
    if (matchedData.length > 0) {
      mainOrderClone = cloneDeep(matchedData[0]);
    }

    if (mainOrderClone === null) {
      message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员');
    }

    return mainOrderClone;
  }

  /**
   * 返回当前操作的子订单集合
   */
  function buildSubOrders() {
    if (currentOptMainId === undefined || currentOptMainId === null) {
      message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
      return;
    }

    let cloneSubOrders = [];

    //如果没有传当前操作的子订单id,说明是操作主订单
    if (curretnOptSubId === undefined || curretnOptSubId === null) {
      //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象
      let currentOptSubOrders = subOrderSelectedMap.get(currentOptMainId);
      if (
        currentOptSubOrders === null ||
        currentOptSubOrders === undefined ||
        currentOptSubOrders.length === 0
      ) {
        for (let item of data) {
          if (item.id === currentOptMainId) {
            for (let subOrder of item?.subOrderInformationLists) {
              cloneSubOrders.push(cloneDeep(subOrder));
            }
          }
        }
      } else {
        cloneSubOrders = currentOptSubOrders.map((item) => {
          return cloneDeep(item);
        });
      }
    } else {
      //操作的是子订单
      for (let item of data) {
        if (item.id === currentOptMainId) {
          for (let subOrder of item?.subOrderInformationLists) {
            if (subOrder.id === curretnOptSubId) {
              cloneSubOrders.push(cloneDeep(subOrder));
              break;
            }
          }
        }
      }
    }

    if (cloneSubOrders.length === 0) {
      message.error('页面错误:当前操作的订单数据不存在,请联系系统管理员');
      return;
    }

    return cloneSubOrders;
  }

  /**
zhongnanhuang authored
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
   * 获取当前操作申请开票的订单总金额
   */
  function getApplyInvoicingTotalPayment() {
    let subOrders = isMainOrder
      ? [...subOrderSelectedMap.values()].flat()
      : buildSubOrders();

    let totalPayment = 0;
    if (subOrders && subOrders.length > 0) {
      let mainIds = subOrders?.map((item: any) => {
        return item.mainOrderId;
      });

      let uniqueMainIds = [...new Set(mainIds)];

      let dataMap = data.reduce((map, obj: any) => {
        map.set(obj.id, obj);
        return map;
      }, new Map());

      uniqueMainIds.forEach((id: any) => {
        let o = dataMap.get(id);
        if (o) {
          totalPayment = FloatAdd(totalPayment, o.totalPayment);
        }
      });
    }
    return totalPayment;
  }

  /**
zhongnanhuang authored
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
   * 根据主订单id,将该主订单下的所有子订单取消选中
   */
  const removeSelectedSubOrderKeysByMainOrderId = (id: any) => {
    let currentMainOrderAllSubOrderIds =
      mainOrderIdSubOrderIdRelationsMap.get(id);
    if (currentMainOrderAllSubOrderIds) {
      let newSelectedSubOrderKeys = selectedSubOrderKeys.filter((item) => {
        return !currentMainOrderAllSubOrderIds.includes(item);
      });
      setSelectedSubOrderKeys(newSelectedSubOrderKeys);
    }
  };

  /**
   * 根据主订单id取消选中主订单
   * @param id
   */
  const removeSelecetMainOrderKeyByMainOrderId = (id: any) => {
    if (selectedMainOrderKeys.includes(id)) {
      let newSelectedMainOrderKeys = selectedMainOrderKeys.filter((item) => {
        return item !== id;
zhongnanhuang authored
501
      });
zhongnanhuang authored
502
503
504
505
506
507
508
509
510
511
512
      setSelectedMainOrderKeys(newSelectedMainOrderKeys);
    }
  };

  const onCheckboxChange = (record: never) => {
    let newSelectedMainOrderKeys = [];
    if (selectedMainOrderKeys.includes(record.id)) {
      newSelectedMainOrderKeys = selectedMainOrderKeys.filter(
        (key) => key !== record.id,
      );
      removeSelectedSubOrderKeysByMainOrderId(record.id);
zhongnanhuang authored
513
      setSelectedRows([]);
514
zhongnanhuang authored
515
      //删除选中主订单的信息
516
      mainOrderSelectedMap.delete(record.id);
zhongnanhuang authored
517
518
519
520
      //删除选中主订单附属子订单的信息
      subOrderSelectedMap.delete(record.id);
      //总选中按钮取消选中
      setAllMainChecked(false);
zhongnanhuang authored
521
    } else {
zhongnanhuang authored
522
      newSelectedMainOrderKeys = [...selectedMainOrderKeys, record.id];
zhongnanhuang authored
523
524
525
526
      //子订单全部自动选中
      let subIds = record.subOrderInformationLists?.map((item) => {
        return item.id;
      });
zhongnanhuang authored
527
528
529
530
531
532
533
      let newSelectedSubOrderKeys = [...selectedSubOrderKeys];
      for (let subId of subIds) {
        if (!selectedSubOrderKeys.includes(subId)) {
          newSelectedSubOrderKeys.push(subId);
        }
      }
      setSelectedSubOrderKeys(newSelectedSubOrderKeys);
534
zhongnanhuang authored
535
      setSelectedRows(record.subOrderInformationLists);
536
537
538

      //选中主订单
      mainOrderSelectedMap.set(record.id, record);
zhongnanhuang authored
539
540
541
542
543
544
545
546
547
      //选中子订单
      subOrderSelectedMap.set(record.id, record.subOrderInformationLists);

      //如果所有主订单都勾选上了,那么勾选上总选中按钮
      if (
        mainOrderSelectedMap?.size === mainOrderIdSubOrderIdRelationsMap.size
      ) {
        setAllMainChecked(true);
      }
zhongnanhuang authored
548
    }
zhongnanhuang authored
549
    setSelectedMainOrderKeys(newSelectedMainOrderKeys);
zhongnanhuang authored
550
  };
zhongnanhuang authored
551
552
553
  // const handleTableExpand = (mainOrderIds: any) => {
  //   setExpandedRowKeys(mainOrderIds);
  // };
zhongnanhuang authored
554
555
556
557
  const allMainCheckBoxChange = () => {
    let checked = !allMainChecked;
    setAllMainChecked(checked);
558
559
560
    if (checked) {
      let mainOrderIds = data?.map((item) => {
561
        mainOrderSelectedMap.set(item.id, item);
562
563
564
        return item.id;
      });
zhongnanhuang authored
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
      let subOrderIds = [];
      for (let subIdList of mainOrderIdSubOrderIdRelationsMap.values()) {
        subOrderIds.push(...subIdList);
      }

      if (data) {
        for (let item of data) {
          mainOrderSelectedMap.set(item.id, item);

          subOrderSelectedMap.set(item.id, item.subOrderInformationLists);
        }
      }

      setSelectedMainOrderKeys(mainOrderIds);
      setSelectedSubOrderKeys(subOrderIds);
580
    } else {
zhongnanhuang authored
581
582
583
584
      setSelectedMainOrderKeys([]);
      setSelectedSubOrderKeys([]);
      mainOrderSelectedMap.clear();
      subOrderSelectedMap.clear();
585
    }
zhongnanhuang authored
586
587
588

    console.log(mainOrderSelectedMap);
    console.log(subOrderSelectedMap);
589
590
  };
zhongnanhuang authored
591
592
593
594
  //表头渲染
  const OrderTableHeader = () => {
    return (
      <Flex className="w-full">
595
596
597
598
599
600
601
        <Flex className="w-[1%] ml-[7px]">
          <Checkbox
            onChange={allMainCheckBoxChange}
            checked={allMainChecked}
          ></Checkbox>
        </Flex>
        <Flex className="w-[30%] ml-[1%]">
zhongnanhuang authored
602
603
          <span className="font-medium">商品信息</span>
        </Flex>
604
        <Flex className="w-[13%]">
zhongnanhuang authored
605
606
          <span className="font-medium">交易金额</span>
        </Flex>
607
zhongnanhuang authored
608
        {!isSupplier() ? (
609
610
611
612
613
614
615
616
617
618
619
620
          <>
            <Flex className="w-[10%]">
              <span className="font-medium">支付</span>
            </Flex>
            <Flex className="w-[12%]">
              <span className="font-medium">其他</span>
            </Flex>
          </>
        ) : (
          ''
        )}
zhongnanhuang authored
621
622
623
624
625
626
        <Flex className="w-[10%]">
          <span className="font-medium">交易状态</span>
        </Flex>
        <Flex className="w-[17%]">
          <span className="font-medium">操作</span>
        </Flex>
zhongnanhuang authored
627
628
629
630
631
      </Flex>
    );
  };
  //子订单内容渲染
  const SubOderRander = ({ record, optRecord }) => {
zhongnanhuang authored
632
633
634
635
636
637
    /**
     * 获取订单状态标签
     * @param optRecord
     */
    function getOrderStatusTag(optRecord: any): import('react').ReactNode {
      const orderStatus = optRecord.orderStatus;
zhongnanhuang authored
638
639
640
641
642
643
      const paymentMethod = optRecord.paymentMethod;
      let orderStatusTagText = enumValueToLabel(
        optRecord.orderStatus,
        ORDER_STATUS_OPTIONS,
      );
644
645
646
647
648
649
650
651
652
      if (orderStatus === 'WAIT_CONFIRM_DELIVER_AFTER_INVOICE') {
        if (optRecord.afterInvoicingStatus !== 'COMPLETE_INVOICING') {
          orderStatusTagText = '待开票';
        } else {
          orderStatusTagText = '待确认发货';
        }
      }

      //如果是未审核或者领导已审核,付款状态为预付款则需要财务审核【财务待审核】,否则仓库审核【】
zhongnanhuang authored
653
654
655
656
657
658
659
660
661
662
663
664
665
      if (orderStatus === 'UNAUDITED' || orderStatus === 'LEADER_AUDITED') {
        if (paymentMethod === 'PAYMENT_IN_ADVANCE') {
          orderStatusTagText = '财务待审核';
        } else {
          orderStatusTagText = '仓库待审核';
        }
      }

      //如果是财务已审核,显示为【仓库待审核】
      if (orderStatus === 'FINANCE_PROCESS') {
        orderStatusTagText = '仓库待审核';
      }
zhongnanhuang authored
666
667
668
      if (orderStatus === 'AUDIT_FAILED') {
        return (
          <MyToolTip
669
            key="key"
zhongnanhuang authored
670
            title={optRecord.checkNotes + ' ' + optRecord.postAuditNotes}
zhongnanhuang authored
671
672
673
674
675
676
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
zhongnanhuang authored
677
                  {orderStatusTagText}
zhongnanhuang authored
678
679
680
681
682
683
684
685
686
687
688
689
690
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }

      if (
        orderStatus === 'AFTER_SALES_COMPLETION' ||
        orderStatus === 'IN_AFTER_SALES'
      ) {
        return (
zhongnanhuang authored
691
692
693
694
          <Tag
            color={TAGS_COLOR.get(optRecord.orderStatus)}
            style={{ marginRight: '4px' }}
          >
zhongnanhuang authored
695
            {orderStatusTagText}
zhongnanhuang authored
696
          </Tag>
zhongnanhuang authored
697
698
699
        );
      }
zhongnanhuang authored
700
701
702
      if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') {
        return (
          <MyToolTip
703
            key="key"
zhongnanhuang authored
704
705
706
707
708
709
710
            title={optRecord.checkNotes}
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
zhongnanhuang authored
711
                  {orderStatusTagText}
zhongnanhuang authored
712
713
714
715
716
717
718
719
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }
zhongnanhuang authored
720
      return (
721
        <Tag key="key" color={TAGS_COLOR.get(optRecord.orderStatus)}>
zhongnanhuang authored
722
723
724
725
726
727
728
729
730
731
732
733
734
          {orderStatusTagText}
        </Tag>
      );
    }

    /**
     * 获取后置审核状态标签
     * @param optRecord
     */
    function getPostAuditStatusTag(optRecord: any): import('react').ReactNode {
      return (
        <Tag key="key" color={TAGS_COLOR.get(optRecord.postAuditStatus)}>
          {enumValueToLabel(optRecord.postAuditStatus, POST_AUDIT_OPTIONS)}
zhongnanhuang authored
735
736
737
738
        </Tag>
      );
    }
739
740
    //申请开票附件处理
    const getAfterAnnexList = () => {
zhongnanhuang authored
741
      // let links = [];
742
743
      let afterAnnexList = optRecord.afterAnnexList;
      let i = 1;
zhongnanhuang authored
744
745
      let images = [];
      let otherAnnex = [];
746
747
      if (afterAnnexList?.length > 0) {
        for (let url of afterAnnexList) {
zhongnanhuang authored
748
749
750
751
752
753
          let name = getAliYunOSSFileNameFromUrl(url);
          if (isImageName(name)) {
            images.push({ name: name, url: url });
          } else {
            otherAnnex.push({ name: '附件' + i++, url: url });
          }
754
755
756
        }
      }
zhongnanhuang authored
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
      return (
        <div className="pl-1">
          <Image.PreviewGroup
            className="mr-10"
            preview={{
              onChange: (current, prev) =>
                console.log(`current index: ${current}, prev index: ${prev}`),
            }}
          >
            {images.map((item, index) => (
              <React.Fragment key={index}>
                {index > 0 ? <Divider type="vertical" /> : ''}
                <Image
                  className="max-h-[50px] max-w-[70px]"
                  src={item.url}
                  title={item.name}
                />{' '}
              </React.Fragment>
            ))}
          </Image.PreviewGroup>
          {otherAnnex.map((item, index) => {
            return (
              <Popconfirm
                title="下载或预览"
                key={index}
                onConfirm={() => {
                  window.open(
784
                    '/onlinePreview?url=' +
785
                      encodeURIComponent(Base64.encode(item.url)),
zhongnanhuang authored
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
                  );
                }}
                onCancel={() => {
                  window.open(item.url);
                }}
                okText="预览"
                cancelText="下载"
              >
                <Button className="px-1" key={index} type="link">
                  {item.name}
                </Button>
              </Popconfirm>
            );
          })}
        </div>
      );
802
803
804
805
806
807
808
809
810
811
812
813
814
    };

    //财务审核附件处理
    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
815
          >
816
817
            {invoicingCheckAnnexList.map((url, index) => (
              <React.Fragment key={index}>
818
819
                <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '}
                <Divider type="vertical" />
820
              </React.Fragment>
821
822
823
824
825
826
827
828
829
830
831
            ))}
          </Image.PreviewGroup>
        </div>
      );
    };

    return (
      <>
        <Flex className="w-full border-b-indigo-500">
          <Flex vertical className="w-[31%]" gap="small">
            {/* 商品名称 */}
zhongnanhuang authored
832
833
            <div>
              <div
834
835
836
837
838
                className="overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer"
                onClick={() => {
                  copyToClipboard(optRecord.productName);
                  message.info('商品名称复制成功:' + optRecord.productName);
                }}
zhongnanhuang authored
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
                title={optRecord.productName}
              >
                <span className="font-medium text-black ">
                  {optRecord.productName}
                </span>
              </div>
              <div className="text-xs text-[#8C8C8C]">
                <span
                  className="cursor-pointer"
                  onClick={() => {
                    copyToClipboard(optRecord.id);
                    message.info('子订单编号复制成功:' + optRecord.id);
                  }}
                >
                  {optRecord.id}
                </span>
                {(roleCode === 'salesRepresentative' ||
                  roleCode === 'salesManager') &&
857
                !optRecord.isCurrentUserOrder ? (
zhongnanhuang authored
858
859
860
861
                  <span className="text-[#f44e4e]">(非本账号订单)</span>
                ) : (
                  ''
                )}
862
863
864
865
866
867
868
869
870
871
                {optRecord.modifiedOptFlag !== null ? (
                  <span className="text-[#f44e4e] cursor-pointer">
                    {optRecord.modifiedOptFlag === 'MODIFY' ? '(修改中)' : ''}
                    {optRecord.modifiedOptFlag === 'DELETE' ? '(删除中)' : ''}
                    {optRecord.modifiedOptFlag === 'INSERT' ? '(新增中)' : ''}
                  </span>
                ) : (
                  ''
                )}
zhongnanhuang authored
872
                {optRecord.modified ? (
873
874
875
876
877
878
879
880
                  <Tooltip title="点击查看详情">
                    <span
                      className="text-[#f44e4e] cursor-pointer"
                      onClick={async () => {
                        createOptObject(optRecord.id, record.id);
                        setModifiedDiffModalVisible(true);
                      }}
                    >
881
                      (内容有变化)
882
883
                    </span>
                  </Tooltip>
zhongnanhuang authored
884
885
886
887
888
889
890
891
892
                ) : (
                  ''
                )}
                {!optRecord.logicDelete ? (
                  <span className="text-[#f44e4e]">(已作废)</span>
                ) : (
                  ''
                )}
              </div>
893
            </div>
zhongnanhuang authored
894
895
            <div
896
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer"
897
              title={optRecord.parameters}
898
899
900
901
              onClick={() => {
                copyToClipboard(optRecord.parameters);
                message.info('商品名称复制成功:' + optRecord.parameters);
              }}
902
            >
zhongnanhuang authored
903
              <span className="text-[#8C8C8C]">
904
                参数:{optRecord.parameters}
zhongnanhuang authored
905
              </span>
zhongnanhuang authored
906
            </div>
907
908
          </Flex>
          <Flex className="w-[13%]" vertical gap="small">
zhongnanhuang authored
909
            {!isSupplier() ? (
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
              <>
                <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>
              </>
            ) : (
              ''
            )}
925
926
927
928
929
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={optRecord.quantity}
            >
              <span className="text-[#8C8C8C]">数量:</span>
930
931
932
933
              <span className="text-slate-700">
                x{optRecord.quantity + ' '}
              </span>
              <span className="text-[#8C8C8C]">{optRecord.unit}</span>
934
            </div>
zhongnanhuang authored
935
zhongnanhuang authored
936
            {!isSupplier() ? (
937
938
939
940
941
              <div
                className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
                title={optRecord.subOrderPayment}
              >
                <span className="text-[#8C8C8C]">合计:</span>
942
                <span className="text-slate-700">
943
                  ¥{optRecord.subOrderPayment}
944
945
946
947
948
                </span>
              </div>
            ) : (
              ''
            )}
949
          </Flex>
950
951
          <Flex className="w-[10%]" vertical gap="small">
zhongnanhuang authored
952
            {!isSupplier() ? (
953
954
955
956
              <>
                {/* 支付方式 */}
                <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <span className="text-slate-700">
zhongnanhuang authored
957
                    {optRecord.paymentMethodText}
958
959
960
961
962
963
964
965
966
967
968
                  </span>
                </div>
                {/* 支付渠道 */}
                <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <span className="text-slate-700">
                    {enumValueToLabel(
                      optRecord.paymentChannel,
                      PAYMENT_CHANNEL_OPTIONS,
                    )}
                  </span>
                </div>
zhongnanhuang authored
969
970
971
                {/* 回款审核状态 */}
                {optRecord.paymentReceiptStatus !== null ? (
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
972
973
                    <Tag
                      className="hover:cursor-pointer"
zhongnanhuang authored
974
                      onMouseEnter={(e: any) => {
975
                        e.target.innerText = '点击查看回款凭证';
zhongnanhuang authored
976
977
                      }}
                      onMouseLeave={(e: any) => {
978
979
980
981
                        e.target.innerText = enumValueToLabel(
                          optRecord.paymentReceiptStatus,
                          PAYMENT_RECEIPTS_STATUS_OPTIONS,
                        );
zhongnanhuang authored
982
                      }}
983
984
985
                      onClick={() => {
                        createOptObject(optRecord.id, record.id);
                        setImagesViewerOptType('paymentReceipt');
zhongnanhuang authored
986
987
                        setImagesViewerModalVisible(true);
                      }}
988
989
990
991
992
993
994
                      key="key"
                      color={TAGS_COLOR.get(optRecord.paymentReceiptStatus)}
                    >
                      {enumValueToLabel(
                        optRecord.paymentReceiptStatus,
                        PAYMENT_RECEIPTS_STATUS_OPTIONS,
                      )}
zhongnanhuang authored
995
996
997
998
999
                    </Tag>
                  </div>
                ) : (
                  ''
                )}
1000
              </>
1001
1002
1003
            ) : (
              ''
            )}
1004
1005
          </Flex>
          <Flex className="w-[13%]" vertical gap="small">
zhongnanhuang authored
1006
            {!isSupplier() ? (
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
              <>
                {/* 所属部门 */}
                <div
                  className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
                  title={enumValueToLabel(
                    optRecord.productBelongBusiness,
                    PRODUCT_BELONG_DEPARTMENT_OPTIONS,
                  )}
                >
                  <span className="text-slate-700">
                    {enumValueToLabel(
                      optRecord.productBelongBusiness,
                      PRODUCT_BELONG_DEPARTMENT_OPTIONS,
                    )}
                  </span>
                </div>
zhongnanhuang authored
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
                {/* 开票类型 */}
                {optRecord.invoicingStatus !== null ? (
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                    <span className="text-slate-700">
                      {getInvoicingType(optRecord)}
                    </span>
                  </div>
                ) : (
                  ''
zhongnanhuang authored
1033
                )}
1034
1035

                {/* 开票状态 */}
1036
                {optRecord.afterInvoicingStatus !== null ? (
zhongnanhuang authored
1037
1038
1039
1040
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                    <Tooltip
                      title={
                        optRecord.invoicingUrgentCause !== null &&
1041
                        optRecord.afterInvoicingStatus ===
zhongnanhuang authored
1042
1043
1044
                          'URGENT_INVOICE_AUDITING'
                          ? optRecord.invoicingUrgentCause
                          : enumValueToLabel(
1045
1046
1047
                              optRecord.afterInvoicingStatus,
                              AFTER_INVOICING_STATUS,
                            )
zhongnanhuang authored
1048
1049
                      }
                    >
1050
1051
1052
                      <Tag
                        color={TAGS_COLOR.get(optRecord.afterInvoicingStatus)}
                      >
zhongnanhuang authored
1053
1054
1055
1056
1057
1058
1059
                        {enumValueToLabel(
                          optRecord.afterInvoicingStatus,
                          AFTER_INVOICING_STATUS,
                        )}
                      </Tag>
                    </Tooltip>
                  </div>
1060
1061
1062
                ) : (
                  ''
                )}
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077

                {/* 是否加急图标显示 */}
                {optRecord.isUrgent ? (
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                    <Tooltip
                      title={'期望开票时间:' + formatdate(optRecord.deadline)}
                    >
                      <Tag color="red">加急开票</Tag>
                    </Tooltip>
                  </div>
                ) : (
                  ''
                )}

                {(roleCode === 'warehouseKeeper' || roleCode === 'admin') &&
1078
                optRecord.shippingWarehouse !== null ? (
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
                  <div
                    className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
                    title={enumValueToLabel(
                      optRecord.shippingWarehouse,
                      SHIPPING_WAREHOUSE_OPTIONS,
                    )}
                  >
                    <span className="text-slate-700">
                      {enumValueToLabel(
                        optRecord.shippingWarehouse,
                        SHIPPING_WAREHOUSE_OPTIONS,
                      )}
                    </span>
                  </div>
                ) : (
                  ''
                )}

                {/* 生产时间 */}
                <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  {optRecord.productionStartTime !== null ||
1100
                  optRecord.productionEndTime !== null ? (
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
                    <MyToolTip
                      title={
                        formatdate(optRecord.productionStartTime) +
                        ' 至 ' +
                        formatdate(optRecord.productionEndTime)
                      }
                      content={
                        <Button type="link" size="small" style={{ padding: 0 }}>
                          生产时间
                        </Button>
                      }
                    />
                  ) : (
                    ''
zhongnanhuang authored
1115
                  )}
1116
1117
                </div>
              </>
zhongnanhuang authored
1118
1119
1120
            ) : (
              ''
            )}
1121
          </Flex>
zhongnanhuang authored
1122
1123
1124
          <Flex className="w-[10%]" vertical gap="small">
            {/* 开票状态 */}
zhongnanhuang authored
1125
            {!isSupplier() ? (
1126
1127
1128
1129
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                <Tag
                  color={
                    optRecord.invoicingTime === null ||
1130
                    optRecord.invoicingTime === undefined
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
                      ? TAGS_COLOR.get(optRecord.invoicingStatus)
                      : 'success'
                  }
                >
                  {getNeedInvoicing(optRecord)}
                </Tag>
              </div>
            ) : (
              ''
            )}
1142
1143
1144
1145
1146
            {/* 订单状态 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              {getOrderStatusTag(optRecord)}
            </div>
zhongnanhuang authored
1147
1148
1149
1150
1151
1152
1153
1154
1155
            {/* 后置审核状态 */}
            {optRecord.postAuditStatus !== null ? (
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                {getPostAuditStatusTag(optRecord)}
              </div>
            ) : (
              ''
            )}
1156
1157
            {/**采购是否已下单状态 */}
            {optRecord.procureOrderStatus !== null &&
1158
            optRecord.procureOrderStatus !== undefined ? (
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                <Tag color="success">
                  {enumValueToLabel(
                    optRecord.procureOrderStatus,
                    PROCURE_ORDER_STATUS,
                  )}
                </Tag>
              </div>
            ) : (
              ''
            )}
1171
1172
1173
            {/* 物流信息 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              {optRecord.orderStatus === 'CONFIRM_RECEIPT' ||
1174
1175
1176
              optRecord.orderStatus === 'AFTER_SALES_COMPLETION' ||
              optRecord.orderStatus === 'IN_AFTER_SALES' ||
              optRecord.orderStatus === 'SHIPPED' ? (
1177
1178
1179
1180
1181
                <MyToolTip
                  title={
                    optRecord.serialNumber === undefined
                      ? '暂无物流信息'
                      : enumValueToLabel(
1182
1183
1184
1185
1186
1187
1188
                          optRecord.logisticsMethod,
                          LOGISTICS_STATUS_OPTIONS,
                        ) +
                        '  ' +
                        optRecord.serialNumber +
                        '  ' +
                        optRecord.logisticsNotes
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
                  }
                  content={
                    <Button type="link" size="small" style={{ padding: 0 }}>
                      物流信息
                    </Button>
                  }
                />
              ) : (
                ''
              )}
1199
1200

              {/* 修改审核状态 */}
1201
              {optRecord.modifiedAuditStatus !== null &&
1202
              optRecord.modifiedAuditStatus !== 'AUDIT_FAILURE' ? (
1203
1204
                <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <Tooltip
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
                    title={recordOptNode ? recordOptNode : <Spin />}
                    onOpenChange={(open) => {
                      console.log('open:' + open);
                      console.log('id:' + optRecord.id);
                      if (open) {
                        triggerRecordOptNode(optRecord.id);
                      } else {
                        setRecordOptNode(null);
                      }
                    }}
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
                  >
                    <Tag color={TAGS_COLOR.get(optRecord.modifiedAuditStatus)}>
                      {enumValueToLabel(
                        optRecord.modifiedAuditStatus,
                        MODIFIED_AUDIT_STATUS_OPTIONS,
                      )}
                    </Tag>
                  </Tooltip>
                </div>
              ) : (
                ''
              )}
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249

              {optRecord.modifiedAuditStatus === 'AUDIT_FAILURE' ? (
                <MyToolTip
                  key="key"
                  title={optRecord.modifiedAuditNotes}
                  content={
                    <>
                      <Tag
                        color={TAGS_COLOR.get(optRecord.modifiedAuditNotes)}
                        style={{ marginRight: '4px' }}
                      >
                        {enumValueToLabel(
                          optRecord.modifiedAuditStatus,
                          MODIFIED_AUDIT_STATUS_OPTIONS,
                        )}
                      </Tag>
                      <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
                    </>
                  }
                />
              ) : (
                ''
              )}
1250
1251
1252
            </div>
          </Flex>
          <Flex className="w-[18%]" wrap="wrap" gap="small">
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
            {optRecord.subPath?.includes('postAudit') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT);
                }}
              >
                后置审核
              </Button>
            ) : (
              ''
            )}
            {/* 加急审核 */}
            {optRecord.subPath?.includes('URGENT_INVOICE_AUDITING') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  console.log('here');
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING);
                }}
              >
                加急审核
              </Button>
            ) : (
              ''
            )}
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
            {optRecord.subPath?.includes('salesConfirm') && (
              <ButtonConfirm
                className="p-0"
                title="是否确认此商城订单信息无误?确认无误之后订单将进入审核流程。"
                text="订单确认"
                onConfirm={async () => {
                  let res = await postServiceOrderSalesConfirm({
                    data: {
                      subOrderIds: [optRecord.id],
                    },
                  });

                  if (res && res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
                }}
              />
            )}
zhongnanhuang authored
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
            {optRecord.subPath?.includes('uploadPaymentReceiptBill') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setUploadPayBillModalVisible(true);
                }}
              >
                回款
              </Button>
            ) : (
              ''
            )}
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
            {optRecord.subPath?.includes('reissue') ? (
              /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'||
                optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
                  setReissueVisible(true);
                  console.log(reissueVisible);
                }}
              >
                重新开票
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('confirmReissue') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE);
                }}
              >
                重新开票审核
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1353
1354
1355
1356
1357
1358
            {optRecord.subPath?.includes('leaderAudit') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1359
1360
1361
                  console.log('here');
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.LEADER_AUDIT);
                }}
              >
                审核
              </Button>
            ) : (
              ''
            )}
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
            {optRecord.subPath?.includes('creditAudit') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.CREDIT_AUDIT);
                }}
              >
                赊账审核
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
            {optRecord.subPath?.includes('auditPaymentReceipt') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT);
                }}
              >
                回款审核
              </Button>
            ) : (
              ''
            )}
1405
1406
1407
1408
1409
1410
1411
            {optRecord.subPath?.includes('modifiedAuditRequest') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
                  setOrderCheckType(CHECK_TYPE.NODE_OPERATING_AUDIT);
                }}
              >
                节点修改审核
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('applyModify') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setOrderDrawerVisible(true);
                  setOrderOptType('order-change-normal');
1429
1430
                }}
              >
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
                申请修改
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('modifiedLeaderAuditRequest') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.MODIFY_LEADER_AUDIT);
                }}
              >
                领导修改审核
1448
1449
1450
1451
1452
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1453
1454
1455
1456
1457
1458
            {optRecord.subPath?.includes('shippingWarehouseChangeRequest') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setIds([optRecord.id]);
zhongnanhuang authored
1459
                  createOptObject(optRecord.id, record.id);
zhongnanhuang authored
1460
1461
1462
1463
1464
1465
1466
1467
1468
                  setShippingWarehouseChangeModalVisible(true);
                }}
              >
                修改仓库
              </Button>
            ) : (
              ''
            )}
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
            {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();
                  }
                }}
              />
            ) : (
              ''
            )}
1490
1491
1492
1493
1494
            {optRecord.subPath?.includes('noNeedInvoicingEdit') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1495
                  createOptObject(optRecord.id, record.id);
1496
1497
1498
1499
                  setFinancialEditVisible(true);
                  setIsMainOrder(false);
                }}
              >
1500
                编辑时间
1501
1502
1503
1504
              </Button>
            ) : (
              ''
            )}
1505
1506
1507
1508
1509
            {optRecord.subPath?.includes('sendProduct') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1510
                  createOptObject(optRecord.id, record.id);
1511
1512
                  setDeliverVisible(true);
                  setIsSendProduct(true);
zhongnanhuang authored
1513
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
                }}
              >
                仓库发货
              </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>
            ) : (
              ''
            )}
zhongnanhuang authored
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
            {optRecord.subPath?.includes('procureSend') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                }}
              >
zhongnanhuang authored
1551
                {isSupplier() ? '发货' : '采购发货'}
zhongnanhuang authored
1552
1553
1554
1555
1556
1557
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('editProductionTime') ? (
1558
1559
1560
1561
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1562
1563
                  createOptObject(optRecord.id, record.id);
                  setProductionTimeModalVisible(true);
1564
1565
                }}
              >
zhongnanhuang authored
1566
                生产时间
1567
1568
1569
1570
1571
1572
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('queryAnnex') &&
1573
            optRecord.listAnnex?.length > 0 ? (
1574
1575
1576
1577
1578
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
zhongnanhuang authored
1579
                  createOptObject(optRecord.id, record.id);
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
                  setAttachmentModalVisible(true);
                }}
              >
                附件
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('modifySendInformation') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1594
                  createOptObject(optRecord.id, record.id);
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
                  setDeliverVisible(true);
                  setIsSendProduct(false);
                }}
              >
                修改发货信息
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('printOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
zhongnanhuang authored
1610
                  createOptObject(optRecord.id, record.id);
1611
                  setOrderPrintVisible(true);
zhongnanhuang authored
1612
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
                }}
              >
                仓库打印
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('supplierPrint') ? (
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
zhongnanhuang authored
1626
                  createOptObject(optRecord.id, record.id);
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
                  setOrderPrintVisible(true);
                  setOrderCheckType(CHECK_TYPE.SUPPLIER);
                }}
              >
                供应商打印
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('procurePrint') ? (
zhongnanhuang authored
1638
              <ButtonConfirm
1639
                className="p-0"
zhongnanhuang authored
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
                title="确认打印?"
                text="采购打印"
                onConfirm={async () => {
                  let res = await postServiceOrderProcurePrint({
                    data: {
                      ids: [optRecord.id],
                    },
                  });

                  if (res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
1653
                }}
zhongnanhuang authored
1654
              />
1655
            ) : (
zhongnanhuang authored
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
              // <Button
              //   className="p-0"
              //   type="link"
              //   onClick={async () => {
              //     setOrderPrintVisible(true);
              //     setSelectedRows([optRecord]);
              //     setOrderRow(record);
              //     setOrderCheckType(CHECK_TYPE.PROCURE);
              //   }}
              // >
              //   采购打印
              // </Button>
1668
1669
1670
              ''
            )}
1671
            {optRecord.subPath?.includes('editOrder') && false ? (
1672
1673
1674
1675
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1676
                  createOptObject(optRecord.id, record.id);
1677
                  setFinancialVisible(true);
zhongnanhuang authored
1678
                  setIsEdit(true);
1679
1680
1681
1682
1683
1684
1685
                }}
              >
                编辑
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1686
1687
1688
1689
1690
1691
            {optRecord.subPath?.includes('invoicing') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1692
                  createOptObject(optRecord.id, record.id);
1693
                  setFinancialVisible(true);
zhongnanhuang authored
1694
                  setIsEdit(false);
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
                  setIsMainOrder(false);
                }}
              >
                开票
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('applyInvoicing') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setApplyForInvoicingVisible(true);
zhongnanhuang authored
1710
                  createOptObject(optRecord.id, record.id);
zhongnanhuang authored
1711
                  setIsEdit(false);
1712
                  setIsMainOrder(false);
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
                }}
              >
                申请开票
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('checkOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1726
1727
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
1728
                  setCheckVisible(true);
zhongnanhuang authored
1729
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1730
1731
1732
1733
1734
1735
1736
1737
                }}
              >
                审核
              </Button>
            ) : (
              ''
            )}
1738
1739
1740
1741
1742
            {optRecord.subPath?.includes('afterSalesCheck') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1743
                  createOptObject(optRecord.id, record.id);
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.AFTER_SALES);
                }}
              >
                售后审核
              </Button>
            ) : (
              ''
            )}
1754
1755
1756
1757
1758
            {optRecord.subPath?.includes('financeCheckOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1759
                  createOptObject(optRecord.id, record.id);
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.FINALCIAL);
                }}
              >
                财务审核
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('procureCheckOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1775
                  createOptObject(optRecord.id, record.id);
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                  setProcureCheckModalVisible(true);
                }}
              >
                采购审核
              </Button>
            ) : (
              ''
            )}
1786
1787
1788
1789
1790
            {optRecord.subPath?.includes('procureConvertProcure') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
1791
                  createOptObject(optRecord.id, record.id);
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                  setProcureConvertModalVisible(true);
                }}
              >
                转发
              </Button>
            ) : (
              ''
            )}
1802
1803
1804
1805
1806
            {optRecord.subPath?.includes('rePrintOrder') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1807
                  createOptObject(optRecord.id, record.id);
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
                  setOrderPrintVisible(true);
                  setIsRePrintOrder(true);
                }}
              >
                重新打印
              </Button>
            ) : (
              ''
            )}

            {optRecord.subPath?.includes('confirmReceipt') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1823
                  createOptObject(optRecord.id, record.id);
1824
1825
1826
1827
1828
1829
1830
1831
1832
                  setConfirmReceiptVisible(true);
                }}
              >
                确认收货
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1833
            {optRecord.subPath?.includes('applyAfterSales') ? (
1834
1835
1836
1837
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1838
                  createOptObject(optRecord.id, record.id);
1839
                  setOrderDrawerVisible(true);
zhongnanhuang authored
1840
                  setOrderOptType('after-sales');
1841
1842
1843
1844
1845
1846
                }}
              >
                申请售后
              </Button>
            ) : (
              ''
zhongnanhuang authored
1847
            )}
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
            {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;
                  }
                }}
              />
            ) : (
              ''
            )}
zhongnanhuang authored
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
            {optRecord.subPath?.includes('cancelSend') ? (
              <ButtonConfirm
                className="p-0"
                title="是否取消发货"
                text="取消发货"
                onConfirm={async () => {
                  let res = await postServiceOrderCancelSend({
                    data: { subIds: [optRecord.id] },
                  });
                  if (res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                    return true;
                  }
                }}
              />
            ) : (
              ''
            )}
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
            {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={() => {
zhongnanhuang authored
1914
                  createOptObject(optRecord.id, record.id);
1915
                  setImagesViewerOptType('shippingReceipt');
zhongnanhuang authored
1916
                  setImagesViewerModalVisible(true);
1917
1918
1919
1920
1921
1922
1923
1924
                }}
              >
                查看收货凭证
              </Button>
            ) : (
              ''
            )}
1925
1926
1927
1928
1929
1930
1931
            {optRecord.subPath?.includes('confirmDeliver') ? (
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setOrderCheckType(CHECK_TYPE.CONFIRM_DELIVER);
1932
                  setCheckVisible(true);
1933
1934
1935
1936
1937
1938
1939
1940
                }}
              >
                确认发货
              </Button>
            ) : (
              ''
            )}
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
            {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
1961
        </Flex>
1962
1963
1964
        <Flex title={optRecord.notes}>
          <div
zhongnanhuang authored
1965
            className="max-w-[1100px] overflow-hidden whitespace-normal overflow-ellipsis hover:cursor-pointer"
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
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
2051
2052
2053
2054
            onClick={() => {
              copyToClipboard(optRecord.notes);
              message.info('备注复制成功:' + optRecord.notes);
            }}
          >
            <span className="text-[#8C8C8C]">
              备注:
              {optRecord.notes === null ? '暂无备注' : optRecord.notes}
            </span>
          </div>
          {!isSupplier() && (isSales() || isWarehousekeeper() || isAdmin()) && (
            <EditTwoTone
              className="pl-1 pr-1 hover:curcor-pointer"
              onClick={() => {
                setNotesEditVisible(true);
                setSelectedRows([optRecord.id]);
                setNotes(optRecord.notes);
                setNotesType(1);
              }}
            />
          )}
        </Flex>

        {(isProcure() || isWarehousekeeper() || isSales() || isAdmin()) &&
        !isSupplier() ? (
          <div className="pt-2">
            <Flex title={optRecord.supplierName}>
              <div>
                <span className="text-[#8C8C8C]">
                  所属采购:
                  {optRecord.supplierName === null
                    ? '暂无'
                    : optRecord.supplierName}
                </span>
              </div>

              <Divider type="vertical" />

              <div className="overflow-hidden whitespace-normal overflow-ellipsis hover:cursor-pointer">
                <span className="text-[#8C8C8C]">
                  采购备注:
                  {optRecord.procureNotes === null
                    ? '暂无备注'
                    : optRecord.procureNotes}
                </span>
              </div>
              {/* 编辑备注按钮 */}
              {(isProcure() || isAdmin()) && (
                <EditTwoTone
                  className="pl-1 pr-1 hover:curcor-pointer"
                  onClick={() => {
                    setSelectedRows([optRecord.id]);
                    setNotes(optRecord.procureNotes);
                    setNotesEditVisible(true);
                    setNotesType(2);
                  }}
                />
              )}
            </Flex>

            {(isAdmin() || isProcure()) && (
              <Flex title={optRecord.supplierNotes}>
                <div className="max-w-[90%] whitespace-no-wrap overflow-hidden overflow-ellipsis">
                  <span className="text-[#8C8C8C]">
                    供应商备注:
                    {optRecord.supplierNotes === null
                      ? '暂无备注'
                      : optRecord.supplierNotes}
                  </span>
                </div>
                {/* 编辑备注按钮 */}
                <EditTwoTone
                  className="pl-1 hover:curcor-pointer"
                  onClick={() => {
                    setSelectedRows([optRecord.id]);
                    setNotes(optRecord.supplierNotes);
                    setNotesEditVisible(true);
                    setNotesType(3);
                  }}
                />
              </Flex>
            )}
          </div>
        ) : (
          ''
        )}

        {isAdmin() || isSales() || isFinance() ? (
          <Flex title={optRecord.notes} className="pt-2">
2055
2056
2057
2058
2059
2060
2061
2062
            <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
2063
                      申请开票备注:
2064
                      {optRecord.applyInvoicingNotes === undefined ||
2065
                      optRecord.applyInvoicingNotes === null
2066
2067
2068
2069
2070
2071
2072
                        ? '暂无备注'
                        : optRecord.applyInvoicingNotes}
                    </span>
                  </Tooltip>
                </div>

                {getAfterAnnexList()}
zhongnanhuang authored
2073
2074
2075
2076
2077

                <Tooltip title="编辑">
                  <EditTwoTone
                    className="pl-1 hover:curcor-pointer"
                    onClick={() => {
2078
2079
2080
2081
                      setNotesEditVisible(true);
                      setSelectedRows([optRecord.id]);
                      setNotes(optRecord.applyInvoicingNotes);
                      setNotesType(4);
zhongnanhuang authored
2082
2083
2084
                    }}
                  />
                </Tooltip>
2085
2086
2087
2088
2089
2090
2091
2092
              </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 ||
2093
                      optRecord.checkNotes === null
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
                        ? '暂无备注'
                        : optRecord.checkNotes}
                    </span>
                  </Tooltip>
                </div>

                {getInvoicingCheckAnnexList()}
              </div>
            </div>
          </Flex>
        ) : (
          ''
        )}
曾国涛 authored
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137

        {isAdmin() || isSales() || isFinance() ? (
          <Flex title={optRecord.notes} className="pt-2">
            <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.reissueNotes} placement="topLeft">
                    <span className="text-[#8C8C8C]">
                      重新开票备注:
                      {optRecord.reissueNotes === undefined ||
                      optRecord.reissueNotes === null
                        ? '暂无备注'
                        : optRecord.reissueNotes}
                    </span>
                  </Tooltip>
                </div>

                <Tooltip title="编辑">
                  <EditTwoTone
                    className="pl-1 hover:curcor-pointer"
                    onClick={() => {
                      setNotesEditVisible(true);
                      setSelectedRows([optRecord.id]);
                      setNotes(optRecord.reissueNotes);
                      setNotesType(5);
                    }}
                  />
                </Tooltip>
              </div>
              <Divider type="vertical" className="mx-5" />
            </div>
2138
2139
2140
2141
2142
          </Flex>
        ) : (
          ''
        )}
      </>
zhongnanhuang authored
2143
    );
zhongnanhuang authored
2144
  };
zhongnanhuang authored
2145
2146
2147
2148
2149
2150
  const expandedRowRender = (record) => {
    let subOrders = record.subOrderInformationLists;

    return (
      <ProTable
        id="sub-table"
zhongnanhuang authored
2151
        className="w-full "
zhongnanhuang authored
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
        showHeader={false}
        columns={[
          {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            render: (text: any, optRecord: any) => {
              return <SubOderRander record={record} optRecord={optRecord} />;
            },
          },
        ]}
        rowSelection={{
zhongnanhuang authored
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
          onSelect: (row: any) => {
            let subId = row.id;
            let mainId = row.mainOrderId;
            let newSelectedSubOrderKeys = [...selectedSubOrderKeys];
            let currentMainOrderSelectedSubOrderList =
              subOrderSelectedMap.get(mainId);
            if (!selectedSubOrderKeys.includes(subId)) {
              //选中子订单
              newSelectedSubOrderKeys.push(subId);

              //在Map中添加对应的主订单中的子订单
              if (currentMainOrderSelectedSubOrderList) {
                currentMainOrderSelectedSubOrderList.push(row);
              } else {
                currentMainOrderSelectedSubOrderList = [row];
              }

              //如果该主订单的所有子订单都选中了,那么勾选上主订单
              if (
                currentMainOrderSelectedSubOrderList?.length ===
                mainOrderIdSubOrderIdRelationsMap.get(mainId)?.length
              ) {
                selectedMainOrderKeys.push(mainId, record);
                mainOrderSelectedMap.set(mainId, record);
              }

              //如果所有主订单都勾选上了,那么勾选上总选中按钮
              if (
                mainOrderSelectedMap?.size ===
                mainOrderIdSubOrderIdRelationsMap.size
              ) {
                setAllMainChecked(true);
              }
            } else {
              //取消选中子订单
              newSelectedSubOrderKeys = newSelectedSubOrderKeys.filter(
                (item) => {
                  return item !== subId;
                },
              );

              removeSelecetMainOrderKeyByMainOrderId(mainId); //某个子订单取消勾选了,对应的主订单也要取消勾选

              //在Map中删除掉对应的主订单中的子订单
              if (currentMainOrderSelectedSubOrderList) {
                currentMainOrderSelectedSubOrderList =
                  currentMainOrderSelectedSubOrderList.filter((item) => {
                    return item.id !== subId;
                  });
              } else {
                subOrderSelectedMap.set(mainId, [row]);
              }

              mainOrderSelectedMap.delete(mainId);
              //总选中按钮取消选中
              setAllMainChecked(false);
            }

            //如果该主订单已经没有子订单选中,删除key
            if (currentMainOrderSelectedSubOrderList.length === 0) {
              subOrderSelectedMap.delete(record.id);
            } else {
              subOrderSelectedMap.set(
                record.id,
                currentMainOrderSelectedSubOrderList,
              );
            }

            setSelectedSubOrderKeys(newSelectedSubOrderKeys);
            setSelectedRows(currentMainOrderSelectedSubOrderList);

            console.log(mainOrderSelectedMap);
            console.log(subOrderSelectedMap);
zhongnanhuang authored
2237
          },
zhongnanhuang authored
2238
          selectedRowKeys: selectedSubOrderKeys,
zhongnanhuang authored
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
          // 自定义选择项参考: 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
2250
        tableAlertRender={false}
zhongnanhuang authored
2251
2252
2253
2254
      />
    );
  };
2255
  // 主订单内容渲染
sanmu authored
2256
  const MainOrderColumnRender = ({ record }: { record: OrderListItemType }) => {
sanmu authored
2257
2258
2259
    return (
      <Flex vertical={true}>
        {/* 编号、时间、销售信息 */}
zhongnanhuang authored
2260
        <Flex
zhongnanhuang authored
2261
          className="px-4 py-4 bg-white rounded-t-lg"
zhongnanhuang authored
2262
2263
2264
2265
2266
2267
          justify="space-between"
        >
          <Flex wrap="wrap" gap="middle" vertical>
            <Flex>
              <Flex>
                <Checkbox
zhongnanhuang authored
2268
                  onChange={() => onCheckboxChange(record)}
zhongnanhuang authored
2269
                  checked={selectedMainOrderKeys.includes(record.id)}
zhongnanhuang authored
2270
                >
zhongnanhuang authored
2271
2272
                  <Space split={<Divider type="vertical" />}>
                    <div>
zhongnanhuang authored
2273
                      <span className="text-[#8C8C8C]">订单号:</span>
zhongnanhuang authored
2274
                      <span className="text-slate-700">{record.id}</span>
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
                      {record.modified ? (
                        <Tooltip title="点击查看详情">
                          <span
                            className="text-[#f44e4e] cursor-pointer"
                            onClick={async () => {
                              createOptObject(null, record.id);
                              setModifiedDiffModalVisible(true);
                            }}
                          >
                            (修改过)
                          </span>
                        </Tooltip>
                      ) : (
                        ''
                      )}
zhongnanhuang authored
2290
2291
2292
                    </div>
                  </Space>
                </Checkbox>
zhongnanhuang authored
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
                <Tooltip title="点击复制订单号">
                  <CopyOutlined
                    className="hover:cursor-pointer"
                    style={{ color: '#8C8C8C' }}
                    onClick={() => {
                      copyToClipboard(record.id);
                      message.info('订单号复制成功!');
                    }}
                  />
                </Tooltip>
                <Divider type="vertical" />
                <span>{formatDateTime(record.createTime)}</span>
                <Divider type="vertical" />
zhongnanhuang authored
2306
                <Space split={<Divider type="vertical" />}>
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
                  <div
                    className="hover:cursor-pointer"
                    onClick={() => {
                      copyToClipboard(record.salesCode);
                      message.info('代表复制成功:' + record.salesCode);
                    }}
                  >
                    <span className="text-[#8C8C8C]">代表:</span>
                    <span className="text-slate-700">{record.salesCode}</span>
                  </div>
zhongnanhuang authored
2317
                  {!isSupplier() ? (
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
                    <>
                      <div
                        title={record.institution}
                        className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[150px]"
                      >
                        <span className="text-[#8C8C8C]">单位:</span>
                        <span className="text-slate-700">
                          {record.institution}
                        </span>
                      </div>
                      <span>
                        <span className="text-[#8C8C8C]">联系人:</span>
                        <span className="text-slate-700">
                          {record.institutionContactName + ' '}
                        </span>
                      </span>
                    </>
                  ) : (
                    ''
                  )}
2338
2339
2340
                  <div
                    title={record.institution}
                    className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[150px]"
2341
                  >
2342
2343
2344
2345
2346
2347
2348
2349
                    <span
                      className="hover:cursor-pointer"
                      onClick={() => {
                        copyToClipboard(record.customerName);
                        message.info('收货人复制成功:' + record.customerName);
                      }}
                    >
                      <span className="text-[#8C8C8C]">收货人:</span>
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
                      {!isSupplier() && (
                        <Tooltip className="order-tooltip" title="详情">
                          <ContainerTwoTone
                            className="px-1 hover:curcor-pointer"
                            onClick={() => {
                              createOptObject(null, record.id);
                              setDeliverInfoDrawerVisible(true);
                            }}
                          />
                        </Tooltip>
                      )}
2361
2362
2363
                      <span className="text-slate-700">
                        {record.customerName + ' '}
                      </span>
zhongnanhuang authored
2364
                    </span>
2365
2366
                  </div>
zhongnanhuang authored
2367
                  {isSupplier() ? (
2368
2369
                    <div
                      title={record.customerShippingAddress}
2370
                      className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[400px] hover:cursor-pointer"
2371
2372
2373
2374
2375
2376
                      onClick={() => {
                        copyToClipboard(record.customerShippingAddress);
                        message.info(
                          '收货地址复制成功:' + record.customerShippingAddress,
                        );
                      }}
2377
2378
2379
2380
2381
2382
2383
2384
2385
                    >
                      <span className="text-[#8C8C8C]">收货地址:</span>
                      <span className="text-slate-700">
                        {record.customerShippingAddress}
                      </span>
                    </div>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2386
                </Space>
zhongnanhuang authored
2387
              </Flex>
2388
            </Flex>
zhongnanhuang authored
2389
zhongnanhuang authored
2390
            {isSupplier() ? (
zhongnanhuang authored
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
              <Flex className="pl-6" align="center">
                <Flex
                  className="hover:cursor-pointer"
                  onClick={() => {
                    copyToClipboard(record.customerContactNumber);
                    message.info(
                      '联系电话复制成功:' + record.customerContactNumber,
                    );
                  }}
                >
                  <span className="text-[#8C8C8C]">联系电话:</span>
                  <span className="text-slate-700">
                    {record.customerContactNumber + ' '}
                  </span>
                </Flex>
              </Flex>
            ) : (
              ''
            )}
zhongnanhuang authored
2411
            <Flex className="pl-6" align="center">
2412
              {roleCode === 'finance' ? (
zhongnanhuang authored
2413
2414
2415
                <div
                  title={enumValueToLabel(
                    record.receivingCompany,
zhongnanhuang authored
2416
                    getReceivingCompanyOptions(PAYEE_OPTIONS),
zhongnanhuang authored
2417
2418
2419
                  )}
                  className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[400px]"
                >
2420
                  <span className="text-[#8C8C8C]">开票收款单位:</span>
zhongnanhuang authored
2421
2422
2423
                  <span className="text-slate-700">
                    {record.receivingCompany !== null
                      ? enumValueToLabel(
2424
2425
2426
                          record.receivingCompany,
                          getReceivingCompanyOptions(PAYEE_OPTIONS),
                        )
zhongnanhuang authored
2427
2428
2429
2430
2431
2432
2433
                      : '暂无'}
                  </span>
                </div>
              ) : (
                ''
              )}
2434
              {roleCode === 'finance' ? <Divider type="vertical" /> : ''}
zhongnanhuang authored
2435
zhongnanhuang authored
2436
              <div title={record.notes}>
2437
                <div
2438
                  className="max-w-[850px] whitespace-normal overflow-hidden overflow-ellipsis hover:cursor-pointer"
2439
2440
2441
2442
2443
                  onClick={() => {
                    copyToClipboard(record.notes);
                    message.info('备注复制成功:' + record.notes);
                  }}
                >
zhongnanhuang authored
2444
2445
                  <span className="text-[#8C8C8C]">备注:</span>
                  <span className="ml-2">
zhongnanhuang authored
2446
                    {record.notes === null ? '暂无备注' : record.notes}
zhongnanhuang authored
2447
                  </span>
zhongnanhuang authored
2448
                </div>
zhongnanhuang authored
2449
              </div>
2450
zhongnanhuang authored
2451
              {!isSupplier() ? (
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
                <Tooltip title="编辑">
                  <EditTwoTone
                    className="pl-1 hover:curcor-pointer"
                    onClick={() => {
                      setNotesEditVisible(true);
                      setSelectedRows([record.id]);
                      setNotes(record.notes);
                      setNotesType(0);
                    }}
                  />
                </Tooltip>
              ) : (
                ''
              )}
zhongnanhuang authored
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
              {record.goodsWeight !== null ? (
                <div title={record.goodsWeight + 'kg'} className="pl-3">
                  <div
                    className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer"
                    onClick={() => {
                      copyToClipboard(record.goodsWeight + 'kg');
                      message.info(
                        '包裹重量复制成功:' + record.goodsWeight + 'kg',
                      );
                    }}
                  >
                    <span className="text-[#8C8C8C]">包裹重量:</span>
                    <span className="ml-2">{record.goodsWeight + 'kg'}</span>
zhongnanhuang authored
2480
                  </div>
2481
2482
2483
2484
                </div>
              ) : (
                ''
              )}
zhongnanhuang authored
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
              {record.goodsVolume !== null ? (
                <div title={record.goodsVolume + 'm³'} className="pl-3">
                  <div
                    className="max-w-md overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer"
                    onClick={() => {
                      copyToClipboard(record.goodsVolume + 'm³');
                      message.info(
                        '包裹体积复制成功:' + record.goodsVolume + 'm³',
                      );
                    }}
                  >
                    <span className="text-[#8C8C8C]">包裹体积:</span>
                    <span className="ml-2">{record.goodsVolume + 'm³'}</span>
zhongnanhuang authored
2499
                  </div>
2500
2501
2502
2503
                </div>
              ) : (
                ''
              )}
zhongnanhuang authored
2504
2505
2506
2507
2508
            </Flex>
          </Flex>
          <Flex wrap="wrap" gap="middle" vertical>
            <Flex justify="flex-end">
              <Flex wrap="wrap" gap="middle" align="center">
zhongnanhuang authored
2509
                {!isSupplier() ? (
zhongnanhuang authored
2510
2511
2512
2513
2514
2515
2516
2517
2518
                  <div>
                    <span className="text-[#8C8C8C]">总金额:¥</span>
                    <span className="text-lg font-medium">
                      {record.totalPayment}
                    </span>
                  </div>
                ) : (
                  ''
                )}
2519
zhongnanhuang authored
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
                {rolePath?.includes('addOrder') ? (
                  <Tooltip title="复制">
                    <CopyTwoTone
                      className="hover:cursor-pointer"
                      onClick={() => {
                        createOptObject(null, record.id);
                        copyOrderToClipboard(record);
                        setOrderOptType('copy');
                        setOrderDrawerVisible(true);
                      }}
                    />
                  </Tooltip>
                ) : (
                  <Tooltip title="复制文本">
                    <CopyTwoTone
                      className="hover:cursor-pointer"
                      onClick={() => {
                        copyOrderToClipboard(record);
                      }}
                    />
                  </Tooltip>
                )}
zhongnanhuang authored
2542
                {!isSupplier() ? (
zhongnanhuang authored
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
                  <Tooltip title="历史">
                    <ClockCircleTwoTone
                      className="hover:cursor-pointer"
                      onClick={() => {
                        setHistoryModalVisible(true);
                        if (subOrderSelectedMap.get(record.id)?.length) {
                          setSelectedRows(subOrderSelectedMap.get(record.id));
                        } else {
                          setSelectedRows(record.subOrderInformationLists);
                        }
                      }}
                    />
                  </Tooltip>
zhongnanhuang authored
2556
                ) : (
2557
                  ''
zhongnanhuang authored
2558
                )}
zhongnanhuang authored
2559
2560
2561
2562
              </Flex>
            </Flex>
            <Flex justify="flex-end">
              <Space.Compact direction="vertical" align="end">
zhongnanhuang authored
2563
                <Space wrap>
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
                  {record.mainPath?.includes('postAudit') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setCurretnOptSubId(null);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT);
                      }}
                    >
                      后置审核
                    </Button>
                  ) : (
                    ''
                  )}
                  {record.mainPath?.includes('URGENT_INVOICE_AUDITING') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING);
                      }}
                    >
                      加急审核
                    </Button>
                  ) : (
                    ''
                  )}
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
                  {record.mainPath?.includes('salesConfirm') && (
                    <ButtonConfirm
                      className="p-0"
                      title="是否确认此商城订单信息无误?确认无误之后订单将进入审核流程。"
                      text="订单确认"
                      onConfirm={async () => {
                        let subIds = subOrderSelectedMap
                          .get(record.id)
                          ?.map((item) => {
                            return item.id;
                          });
                        if (subIds === null || subIds === undefined) {
                          subIds = record.subOrderInformationLists.map(
                            (item) => {
                              return item.id;
                            },
                          );
                        }
                        let res = await postServiceOrderSalesConfirm({
                          data: {
                            subOrderIds: subIds,
                          },
                        });

                        if (res && res.result === RESPONSE_CODE.SUCCESS) {
                          message.success(res.message);
                          refreshTable();
                        }
                      }}
                    />
                  )}
zhongnanhuang authored
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
                  {record.mainPath?.includes('uploadPaymentReceiptBill') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setUploadPayBillModalVisible(true);
                      }}
                    >
                      回款
                    </Button>
                  ) : (
                    ''
                  )}
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
                  {record.mainPath?.includes('modifiedAuditRequest') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.NODE_OPERATING_AUDIT);
                      }}
                    >
                      节点修改审核
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
                  {record.mainPath?.includes('auditPaymentReceipt') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT);
                      }}
                    >
                      回款审核
                    </Button>
                  ) : (
                    ''
                  )}
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
                  {record.mainPath?.includes('modifiedLeaderAuditRequest') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.MODIFY_LEADER_AUDIT);
                      }}
                    >
                      领导修改审核
                    </Button>
                  ) : (
                    ''
                  )}
2689
                  {false ? (
2690
2691
2692
2693
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2694
                        createOptObject(null, record.id);
2695
2696
2697
2698
2699
2700
2701
2702
2703
                        setFinancialReceiptsModalVisible(true);
                        setIsEdit(true);
                      }}
                    >
                      收款记录
                    </Button>
                  ) : (
                    ''
                  )}
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
                  {record.mainPath?.includes('reissue') ? (
                    /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'||
                      optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setReissueVisible(true);
                        console.log(reissueVisible);
                      }}
                    >
                      重新开票
                    </Button>
                  ) : (
                    ''
                  )}

                  {record.mainPath?.includes('confirmReissue') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setCurretnOptSubId(null);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE);
                      }}
                    >
                      重新开票审核
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803

                  {record.mainPath?.includes('procureOrder') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="是否下单?"
                      text="下单"
                      onConfirm={async () => {
                        let subIds = subOrderSelectedMap
                          .get(record.id)
                          ?.map((item) => {
                            return item.id;
                          });
                        if (subIds === null || subIds === undefined) {
                          subIds = record.subOrderInformationLists.map(
                            (item) => {
                              return item.id;
                            },
                          );
                        }
                        let res = await postServiceOrderProcureOrder({
                          data: { subIds: subIds },
                        });
                        if (res.result === RESPONSE_CODE.SUCCESS) {
                          message.success(res.message);
                          refreshTable();
                          return true;
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}

                  {record.mainPath?.includes('cancelSend') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="是否取消发货?"
                      text="取消发货"
                      onConfirm={async () => {
                        let subIds = subOrderSelectedMap
                          .get(record.id)
                          ?.map((item) => {
                            return item.id;
                          });
                        if (subIds === null || subIds === undefined) {
                          subIds = record.subOrderInformationLists.map(
                            (item) => {
                              return item.id;
                            },
                          );
                        }
                        let res = await postServiceOrderCancelSend({
                          data: { subIds: subIds },
                        });
                        if (res.result === RESPONSE_CODE.SUCCESS) {
                          message.success(res.message);
                          refreshTable();
                          return true;
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}
2804
                  {record.mainPath?.includes('applyModify') ? (
zhongnanhuang authored
2805
2806
2807
2808
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2809
                        createOptObject(null, record.id);
zhongnanhuang authored
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
                        setOrderDrawerVisible(true);
                        setOrderOptType('order-change-normal');
                      }}
                    >
                      申请修改
                    </Button>
                  ) : (
                    ''
                  )}
2820
2821
2822
2823
2824
                  {record.mainPath?.includes('leaderAudit') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2825
2826
2827
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
                            'LEADER_PROCESS'
                          ) {
                            message.error('请选择领导待审核的子订单进行审核');
                            return;
                          }
                        }
zhongnanhuang authored
2841
                        createOptObject(null, record.id);
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.LEADER_AUDIT);
                      }}
                    >
                      审核
                    </Button>
                  ) : (
                    ''
                  )}
2852
2853
2854
2855
2856
                  {record.mainPath?.includes('changeOrderAudit') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2857
2858
2859
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
                            'MODIFY_APPLY_WAIT_FOR_AUDIT'
                          ) {
                            message.error('请选择[修改待审核]的子订单进行审核');
                            return;
                          }
                        }
zhongnanhuang authored
2873
                        createOptObject(null, record.id);
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
                        setCheckVisible(true);
                        setOrderCheckType(
                          CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT,
                        );
                      }}
                    >
                      审核
                    </Button>
                  ) : (
                    ''
                  )}
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
                  {record.mainPath?.includes('creditAudit') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
                            'CREDIT_CONFIRM'
                          ) {
                            message.error('请选择[赊账待审核]的子订单进行审核');
                            return;
                          }
                        }
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.CREDIT_AUDIT);
                      }}
                    >
                      赊账审核
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
                  {record.mainPath?.includes('editProductionTime') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setProductionTimeModalVisible(true);
                      }}
                    >
                      生产时间
                    </Button>
                  ) : (
                    ''
                  )}
2933
2934
2935
2936
2937
                  {record.mainPath?.includes('procureConvertProcure') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2938
2939
2940
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }

                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            !selectedSubOrders[i].subPath.includes(
                              'procureConvertProcure',
                            )
                          ) {
                            message.error('请选择允许转发的子订单进行转发');
                            return;
                          }
                        }
2955
                        createOptObject(null, record.id);
2956
2957
2958
2959
2960
2961
2962
2963
2964
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                        setProcureConvertModalVisible(true);
                      }}
                    >
                      转发
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2965
                  {record.mainPath?.includes('sendProduct') ? (
zhongnanhuang authored
2966
2967
2968
2969
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2970
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
2971
2972
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
2973
                        createOptObject(null, record.id);
zhongnanhuang authored
2974
                        setDeliverVisible(true);
zhongnanhuang authored
2975
                        setIsSendProduct(true);
zhongnanhuang authored
2976
                        setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
zhongnanhuang authored
2977
2978
                      }}
                    >
zhongnanhuang authored
2979
                      仓库发货
zhongnanhuang authored
2980
2981
2982
2983
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2984
2985

                  {/* 供应商发货 */}
zhongnanhuang authored
2986
                  {record.mainPath?.includes('supplierSendOrder') ? (
zhongnanhuang authored
2987
2988
2989
2990
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2991
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
2992
2993
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
2994
                        createOptObject(null, record.id);
zhongnanhuang authored
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
                        setDeliverVisible(true);
                        setIsSendProduct(true);
                        setOrderCheckType(CHECK_TYPE.SUPPLIER);
                      }}
                    >
                      供应商发货
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3005
zhongnanhuang authored
3006
                  {record.mainPath?.includes('procureSend') ? (
zhongnanhuang authored
3007
3008
3009
3010
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3011
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3012
3013
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3014
                        createOptObject(null, record.id);
zhongnanhuang authored
3015
3016
3017
3018
3019
                        setDeliverVisible(true);
                        setIsSendProduct(true);
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                      }}
                    >
zhongnanhuang authored
3020
                      {isSupplier() ? '发货' : '采购发货'}
zhongnanhuang authored
3021
3022
3023
3024
3025
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3026
                  {record.mainPath?.includes('printOrder') ? (
zhongnanhuang authored
3027
3028
3029
3030
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3031
3032
3033
                        const selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3034
                        if (!selectedSubOrders?.length) {
zhongnanhuang authored
3035
3036
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3037
3038
3039
3040
3041
3042
3043

                        for (let subOrderRecord of selectedSubOrders) {
                          let subPath = subOrderRecord.subPath;
                          if (!checkePrintable(subPath)) {
                            return message.error('请选择可以打印的子订单');
                          }
                        }
zhongnanhuang authored
3044
                        createOptObject(null, record.id);
zhongnanhuang authored
3045
                        setOrderPrintVisible(true);
zhongnanhuang authored
3046
                        setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
zhongnanhuang authored
3047
3048
                      }}
                    >
zhongnanhuang authored
3049
                      仓库打印
zhongnanhuang authored
3050
3051
3052
3053
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3054
zhongnanhuang authored
3055
                  {record.mainPath?.includes('supplierPrint') ? (
zhongnanhuang authored
3056
3057
3058
3059
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3060
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3061
3062
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3063
3064

                        createOptObject(null, record.id);
zhongnanhuang authored
3065
3066
3067
3068
                        setOrderPrintVisible(true);
                        setOrderCheckType(CHECK_TYPE.SUPPLIER);
                      }}
                    >
zhongnanhuang authored
3069
                      供应商打印
zhongnanhuang authored
3070
3071
3072
3073
3074
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3075
                  {record.mainPath?.includes('rePrintOrder') ? (
zhongnanhuang authored
3076
3077
3078
3079
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3080
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3081
3082
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3083
                        createOptObject(null, record.id);
zhongnanhuang authored
3084
3085
                        setOrderPrintVisible(true);
                        setIsRePrintOrder(true);
zhongnanhuang authored
3086
3087
                      }}
                    >
zhongnanhuang authored
3088
                      重新打印
zhongnanhuang authored
3089
3090
3091
3092
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
                  {record.mainPath?.includes('confirmReceipt') ? (
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setConfirmReceiptVisible(true);
                      }}
                    >
                      确认收货
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3107
                  {record.mainPath?.includes('modifySendInformation') ? (
zhongnanhuang authored
3108
                    <Button
zhongnanhuang authored
3109
                      className="p-0"
zhongnanhuang authored
3110
3111
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3112
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3113
3114
3115
3116
                          return message.error(
                            '请选择已经发货或者已经确认收货的子订单',
                          );
                        }
zhongnanhuang authored
3117
                        for (let row of subOrderSelectedMap.get(record.id)) {
zhongnanhuang authored
3118
3119
3120
3121
3122
3123
3124
3125
3126
                          if (
                            row.orderStatus !== 'CONFIRM_RECEIPT' &&
                            row.orderStatus !== 'SHIPPED'
                          ) {
                            return message.error(
                              '请选择已经发货或者已经确认收货的子订单',
                            );
                          }
                        }
zhongnanhuang authored
3127
                        createOptObject(null, record.id);
zhongnanhuang authored
3128
3129
                        setDeliverVisible(true);
                        setIsSendProduct(false);
zhongnanhuang authored
3130
3131
                      }}
                    >
zhongnanhuang authored
3132
                      修改发货信息
zhongnanhuang authored
3133
                    </Button>
zhongnanhuang authored
3134
3135
3136
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3137
                  {record.mainPath?.includes('invoicing') ? (
zhongnanhuang authored
3138
3139
                    <Button
                      type="link"
zhongnanhuang authored
3140
                      className="p-0"
zhongnanhuang authored
3141
                      onClick={() => {
zhongnanhuang authored
3142
                        createOptObject(null, record.id);
zhongnanhuang authored
3143
                        setFinancialVisible(true);
zhongnanhuang authored
3144
                        setIsEdit(false);
zhongnanhuang authored
3145
3146
                      }}
                    >
zhongnanhuang authored
3147
                      开票
zhongnanhuang authored
3148
3149
3150
3151
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3152
3153
3154
3155
3156
3157

                  {record.mainPath?.includes('applyInvoicing') ? (
                    <Button
                      type="link"
                      className="p-0"
                      onClick={() => {
zhongnanhuang authored
3158
3159
3160
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3161
3162
3163
3164
3165
3166
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].invoicingStatus ===
3167
                              'UN_INVOICE' ||
zhongnanhuang authored
3168
                            selectedSubOrders[i].afterInvoicingStatus ===
3169
                              'APPLY_FOR_INVOICING'
zhongnanhuang authored
3170
3171
3172
3173
3174
3175
3176
                          ) {
                            message.error(
                              '请选择需要开票且未申请开票的子订单进行申请',
                            );
                            return;
                          }
                        }
zhongnanhuang authored
3177
3178

                        createOptObject(null, record.id);
zhongnanhuang authored
3179
                        setApplyForInvoicingVisible(true);
zhongnanhuang authored
3180
                        setIsEdit(false);
zhongnanhuang authored
3181
                        setIsMainOrder(false);
zhongnanhuang authored
3182
3183
3184
3185
3186
3187
3188
3189
                      }}
                    >
                      申请开票
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3190
                  {record.mainPath?.includes('updateOrder') ? (
zhongnanhuang authored
3191
3192
3193
3194
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3195
                        //勾选的子订单:如果有勾选,后面只校验有勾选的
3196
zhongnanhuang authored
3197
3198
3199
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
                        if (
                          selectedSubOrders === undefined ||
                          selectedSubOrders.length === 0
                        ) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (
                          let index = 0;
                          index < selectedSubOrders.length;
                          index++
                        ) {
                          let orderStatus =
                            selectedSubOrders[index].orderStatus;
3213
                          //仓库管理员在审核之后的任何时候都可以编辑
zhongnanhuang authored
3214
                          if (
3215
3216
                            roleCode !== 'warehouseKeeper' &&
                            roleCode !== 'admin'
zhongnanhuang authored
3217
                          ) {
3218
3219
3220
                            //是审核通过及之后的订单
                            if (
                              orderStatus !== 'UNAUDITED' &&
3221
                              orderStatus !== 'AUDIT_FAILED' &&
3222
3223
                              orderStatus !== 'LEADER_PROCESS' &&
                              orderStatus !== 'SALES_CONFIRM'
3224
3225
                            ) {
                              message.error(
3226
                                '请选择【未审核、审核失败、销售待确认】的订单进行编辑',
3227
3228
3229
3230
3231
3232
                              );
                              return;
                            }
                          } else {
                            //仓库管理员只能编辑是还未审核的订单
                            if (
3233
                              roleCode !== 'admin' &&
3234
3235
3236
3237
3238
3239
                              (orderStatus === 'UNAUDITED' ||
                                orderStatus === 'AUDIT_FAILED')
                            ) {
                              message.error('请选择已审核的订单进行编辑');
                              return;
                            }
zhongnanhuang authored
3240
3241
                          }
                        }
zhongnanhuang authored
3242
3243

                        createOptObject(null, record.id);
zhongnanhuang authored
3244
3245
                        setOrderDrawerVisible(true);
                        setOrderOptType('edit');
zhongnanhuang authored
3246
3247
                      }}
                    >
zhongnanhuang authored
3248
                      编辑
zhongnanhuang authored
3249
3250
3251
3252
                    </Button>
                  ) : (
                    ''
                  )}
3253
zhongnanhuang authored
3254
3255
                  {record?.subOrderInformationLists[0].subPath?.includes(
                    'noNeedInvoicingEdit',
3256
                  ) ? (
3257
3258
3259
3260
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3261
                        createOptObject(null, record.id);
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
                        setFinancialEditVisible(true);
                        setIsMainOrder(true);
                      }}
                    >
                      财务编辑
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3272
                  {record.mainPath?.includes('checkOrder') ? (
zhongnanhuang authored
3273
3274
3275
3276
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3277
3278
3279
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3280
3281
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
3282
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
3283
                        }
zhongnanhuang authored
3284
                        for (let i = 0; i < selectedSubOrders.length; i++) {
3285
                          let orderStatus = selectedSubOrders[i].orderStatus;
zhongnanhuang authored
3286
                          if (
3287
3288
3289
                            orderStatus !== 'UNAUDITED' &&
                            orderStatus !== 'FINANCE_PROCESS' &&
                            orderStatus !== 'LEADER_AUDITED'
zhongnanhuang authored
3290
                          ) {
3291
3292
3293
                            message.error(
                              '请选择未审核或者领导已审核的子订单进行审核',
                            );
zhongnanhuang authored
3294
3295
3296
                            return;
                          }
                        }
zhongnanhuang authored
3297
3298

                        createOptObject(null, record.id);
zhongnanhuang authored
3299
                        setCheckVisible(true);
zhongnanhuang authored
3300
                        setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
zhongnanhuang authored
3301
3302
3303
3304
3305
3306
3307
3308
                      }}
                    >
                      审核
                    </Button>
                  ) : (
                    ''
                  )}
3309
                  {record.mainPath?.includes('afterSalesCheck') ? (
3310
3311
3312
3313
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3314
3315
3316
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3317
3318
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
3319
                          selectedSubOrders = record.subOrderInformationLists;
3320
                        }
zhongnanhuang authored
3321
                        for (let i = 0; i < selectedSubOrders.length; i++) {
3322
                          if (
zhongnanhuang authored
3323
3324
                            selectedSubOrders[i].orderStatus !==
                            'IN_AFTER_SALES'
3325
3326
                          ) {
                            message.error('请选择售后中的子订单进行审核');
3327
3328
3329
                            return;
                          }
                        }
zhongnanhuang authored
3330
3331

                        createOptObject(null, record.id);
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.AFTER_SALES);
                      }}
                    >
                      售后审核
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3342
3343
3344
3345
3346
3347
                  {record.mainPath?.includes('noNeedSend') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="此订单是否无需发货?"
                      text="无需发货"
                      onConfirm={async () => {
zhongnanhuang authored
3348
3349
3350
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3351
3352
3353
3354
3355
3356
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
zhongnanhuang authored
3357
                            selectedSubOrders[i].orderStatus !== 'AUDITED' &&
zhongnanhuang authored
3358
                            selectedSubOrders[i].orderStatus !==
3359
                              'PROCURE_PROCESS' &&
zhongnanhuang authored
3360
                            selectedSubOrders[i].orderStatus !==
3361
                              'PROCURE_PROCESS_FOR_MINE' &&
zhongnanhuang authored
3362
                            selectedSubOrders[i].orderStatus !==
3363
                              'PROCURE_WAIT_SHIP' &&
zhongnanhuang authored
3364
                            selectedSubOrders[i].orderStatus !==
3365
                              'SUPPLIER_WAIT_SHIP' &&
zhongnanhuang authored
3366
                            selectedSubOrders[i].orderStatus !== 'WAIT_SHIP'
zhongnanhuang authored
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
                          ) {
                            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();
                        }
                      }}
                    />
                  ) : (
3389
3390
3391
3392
3393
3394
3395
3396
3397
                    ''
                  )}

                  {record.mainPath?.includes('saleCancelInvoicing') ? (
                    <ButtonConfirm
                      className="p-0"
                      title="确认取消申请开票?"
                      text="取消申请"
                      onConfirm={async () => {
zhongnanhuang authored
3398
3399
3400
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3401
3402
3403
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
zhongnanhuang authored
3404
3405

                        console.log(selectedSubOrders);
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
                        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
3432
3433
3434
                    ''
                  )}
zhongnanhuang authored
3435
                  {/* 财务审核:主订单暂无 */}
zhongnanhuang authored
3436
                  {record.mainPath?.includes('financeCheckOrder') ? (
zhongnanhuang authored
3437
3438
3439
3440
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3441
3442
3443
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3444
3445
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
3446
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
3447
                        }
zhongnanhuang authored
3448
                        for (let i = 0; i < selectedSubOrders.length; i++) {
zhongnanhuang authored
3449
                          if (
zhongnanhuang authored
3450
3451
                            selectedSubOrders[i].orderStatus !== 'UNAUDITED' &&
                            selectedSubOrders[i].orderStatus !==
3452
                              'FINANCE_PROCESS' &&
zhongnanhuang authored
3453
                            selectedSubOrders[i].orderStatus !==
3454
                              'LEADER_AUDITED'
zhongnanhuang authored
3455
                          ) {
zhongnanhuang authored
3456
3457
3458
                            message.error(
                              '请选择[未审核]、[财务待审核]、[领导已审核]的子订单进行审核',
                            );
zhongnanhuang authored
3459
3460
3461
                            return;
                          }
                        }
zhongnanhuang authored
3462
                        createOptObject(null, record.id);
zhongnanhuang authored
3463
                        setCheckVisible(true);
zhongnanhuang authored
3464
                        setOrderCheckType(CHECK_TYPE.FINALCIAL);
zhongnanhuang authored
3465
3466
                      }}
                    >
zhongnanhuang authored
3467
3468
3469
3470
3471
3472
3473
                      财务审核
                    </Button>
                  ) : (
                    ''
                  )}

                  {/* 采购审核 */}
zhongnanhuang authored
3474
                  {record.mainPath?.includes('procureCheckOrder') ? (
zhongnanhuang authored
3475
3476
3477
3478
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3479
3480
3481
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3482
3483
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
zhongnanhuang authored
3484
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
3485
                        }
zhongnanhuang authored
3486
                        for (let i = 0; i < selectedSubOrders.length; i++) {
zhongnanhuang authored
3487
                          if (
zhongnanhuang authored
3488
3489
                            selectedSubOrders[i].orderStatus !==
                            'PROCURE_UN_PROCESS'
zhongnanhuang authored
3490
3491
3492
3493
3494
                          ) {
                            message.error('请选择未审核的子订单进行审核');
                            return;
                          }
                        }
zhongnanhuang authored
3495
3496

                        createOptObject(null, record.id);
zhongnanhuang authored
3497
3498
3499
3500
3501
                        setProcureCheckModalVisible(true);
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                      }}
                    >
                      采购审核
zhongnanhuang authored
3502
3503
3504
3505
3506
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3507
                  {record.mainPath?.includes('applyAfterSales') ? (
zhongnanhuang authored
3508
3509
3510
3511
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3512
3513
3514
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3515
3516
3517
3518
3519
3520
3521
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
3522
                              'CONFIRM_RECEIPT' &&
zhongnanhuang authored
3523
                            selectedSubOrders[i].orderStatus !==
3524
                              'AFTER_SALES_FAILURE'
zhongnanhuang authored
3525
3526
3527
3528
3529
                          ) {
                            message.error('请选择确认收货状态的子订单进行售后');
                            return;
                          }
                        }
zhongnanhuang authored
3530
3531

                        createOptObject(null, record.id);
3532
                        setOrderDrawerVisible(true);
3533
                        setOrderOptType('after-sales');
zhongnanhuang authored
3534
3535
3536
3537
3538
3539
3540
3541
                      }}
                    >
                      申请售后
                    </Button>
                  ) : (
                    ''
                  )}
3542
                  {/* {record.mainPath?.includes('afterSalesCompletion') ? (
zhongnanhuang authored
3543
3544
3545
3546
3547
                    <ButtonConfirm
                      className="p-0"
                      title="售后是否已完成?"
                      text="完成售后"
                      onConfirm={async () => {
zhongnanhuang authored
3548
                        let selectedSubOrders = subOrderSelectedMap.get(record.id);
zhongnanhuang authored
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
                        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();
                        }
                      }}
                    />
                  ) : (
                    ''
3584
                  )} */}
zhongnanhuang authored
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
                  {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
3630
                  {record.mainPath?.includes('orderCancel') ? (
zhongnanhuang authored
3631
                    <ButtonConfirm
zhongnanhuang authored
3632
                      className="p-0"
zhongnanhuang authored
3633
3634
3635
                      title="确认作废?"
                      text="作废"
                      onConfirm={async () => {
zhongnanhuang authored
3636
3637
3638
3639
                        let body = {
                          ids: [record.id],
                          checkIsMainOrderId: true,
                        };
zhongnanhuang authored
3640
3641
3642
3643
3644
3645
3646
                        const data = await postServiceOrderOrderCancel({
                          data: body,
                        });
                        if (data.result === RESPONSE_CODE.SUCCESS) {
                          message.success(data.message);
                          refreshTable();
                        }
zhongnanhuang authored
3647
                      }}
zhongnanhuang authored
3648
                    />
zhongnanhuang authored
3649
3650
3651
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3652
zhongnanhuang authored
3653
                  {record.mainPath?.includes('procurePrint') ? (
zhongnanhuang authored
3654
                    <ButtonConfirm
zhongnanhuang authored
3655
                      className="p-0"
zhongnanhuang authored
3656
3657
3658
                      title="确认打印?"
                      text="采购打印"
                      onConfirm={async () => {
zhongnanhuang authored
3659
3660
3661
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
                        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
3689
3690
                        }
                      }}
zhongnanhuang authored
3691
                    />
zhongnanhuang authored
3692
                  ) : (
zhongnanhuang authored
3693
3694
3695
3696
                    // <Button
                    //   className="p-0"
                    //   type="link"
                    //   onClick={() => {
zhongnanhuang authored
3697
                    //     if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3698
3699
                    //       return message.error('请选择选择子订单');
                    //     }
zhongnanhuang authored
3700
                    //     setSelectedRows(subOrderSelectedMap.get(record.id));
zhongnanhuang authored
3701
3702
3703
3704
3705
3706
3707
                    //     setOrderRow(record);
                    //     setOrderPrintVisible(true);
                    //     setOrderCheckType(CHECK_TYPE.PROCURE);
                    //   }}
                    // >
                    //   采购打印
                    // </Button>
zhongnanhuang authored
3708
3709
                    ''
                  )}
zhongnanhuang authored
3710
3711
3712
3713
3714
3715
                </Space>
              </Space.Compact>
            </Flex>
          </Flex>
        </Flex>
zhongnanhuang authored
3716
        <Flex className="p-0 pb-[24px] pt-[4px] pl-[23px] pr-[5px] bg-white rounded-b-lg">
zhongnanhuang authored
3717
3718
3719
          {expandedRowRender(record)}
        </Flex>
      </Flex>
3720
3721
3722
    );
  };
zhongnanhuang authored
3723
3724
3725
  // 主订单列表
  const mainOrdersColumns: ProColumns<OrderType>[] = MAIN_ORDER_COLUMNS.map(
    (item) => {
3726
      //首能账号只能搜索订单编号
3727
3728
3729
3730
3731
3732
      let canSearchIndex = [
        'id',
        'salesCode',
        'subNotes',
        'orderStatus',
        'createTime',
3733
        'modifiedAuditStatus',
3734
      ];
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
      if (isSupplier() && !canSearchIndex.includes(item.dataIndex)) {
        item.search = false;
      }

      canSearchIndex = [
        'id',
        'salesCode',
        'customerName',
        'institution',
        'productName',
        'orderStatus',
        'createTime',
      ];

      if (isExaminer() && !canSearchIndex.includes(item.dataIndex)) {
3750
3751
        item.search = false;
      }
3752
zhongnanhuang authored
3753
3754
3755
3756
3757
3758
3759
3760
3761
      if (item.dataIndex === 'name') {
        return {
          ...item,
          title: <OrderTableHeader />,
          render: (text, record) => {
            return <MainOrderColumnRender record={record} />;
          },
        };
      }
zhongnanhuang authored
3762
3763
3764
3765

      /**
       * 采购的订单状态筛选内容
       */
3766
      if (roleCode === 'procure' && item.dataIndex === 'orderStatus') {
zhongnanhuang authored
3767
3768
3769
3770
        item.valueEnum = enumToProTableEnumValue(
          PROCURE_PRIMARY_ORDER_STATUS_OPTIONS,
        );
      }
zhongnanhuang authored
3771
3772
3773
3774
      return item;
    },
  );
3775
3776
3777
  /**
   * 采购可以筛选供应商备注
   */
3778
  if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) {
3779
3780
3781
3782
3783
3784
3785
3786
3787
    mainOrdersColumns.push({
      title: '供应商备注',
      width: 120,
      dataIndex: 'supplierNotes',
      valueType: 'text',
      hideInTable: true,
    });
  }
zhongnanhuang authored
3788
3789
3790
  /**
   * 采购可以筛选其他采购
   */
3791
  if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) {
zhongnanhuang authored
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
    mainOrdersColumns.push({
      title: '采购名称',
      width: 120,
      dataIndex: 'supplierName',
      valueType: 'select',
      request: async () => {
        const res = await postServiceOrderProvideProcurementRoles();
        let options = res.data?.map((item) => {
          return { label: item, value: item };
        });
        return options;
      },
      hideInTable: true,
    });
  }

  /**
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
   * 排除采购
   */
  if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) {
    mainOrdersColumns.push({
      title: '采购排除',
      width: 120,
      dataIndex: 'excludeProcureNames',
      fieldProps: {
        mode: 'multiple',
      },
      valueType: 'select',
      request: async () => {
        const res = await postServiceOrderProvideProcurementRoles();
        let options = res.data?.map((item) => {
          return { label: item, value: item };
        });
        return options;
      },
      hideInTable: true,
    });
  }

  /**
zhongnanhuang authored
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
   * 仓库可以筛选发货仓库
   */
  if (roleCode === 'warehouseKeeper' || roleCode === 'admin') {
    mainOrdersColumns.push({
      title: '发货仓库',
      width: 120,
      dataIndex: 'shippingWarehouse',
      valueType: 'select',
      valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS),
      hideInTable: true,
    });
  }
3845
  //判断是否是采购,是的话新增一个筛选条件
3846
  if (roleCode === 'procure' || roleCode === 'admin') {
3847
    mainOrdersColumns.push({
zhongnanhuang authored
3848
      title: isSupplier() ? '下单状态' : '采购下单状态',
3849
3850
3851
3852
3853
3854
3855
      dataIndex: 'procureOrderStatus',
      valueType: 'select',
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
    });
  }
zhongnanhuang authored
3856
3857
  function toolBarRender() {
    let toolBtns = [];
3858
3859
3860
    let radios: any[] = [];

    radios.push(<Radio value={0}>全部</Radio>);
zhongnanhuang authored
3861
3862
    if (
3863
3864
      roleCode === 'admin' ||
      roleCode === 'salesManager' ||
3865
3866
      roleCode === 'salesRepresentative'
    ) {
3867
      radios.push(<Radio value={70}>只看作废</Radio>);
3868
    }
zhongnanhuang authored
3869
zhongnanhuang authored
3870
    if (roleCode === 'warehouseKeeper') {
3871
      radios.push(<Radio value={40}>待处理</Radio>);
zhongnanhuang authored
3872
3873
    }
zhongnanhuang authored
3874
    //采购可以筛选出需要处理的订单
zhongnanhuang authored
3875
    if (roleCode === 'procure' && !isSupplier()) {
3876
3877
      radios.push(<Radio value={60}>其他采购</Radio>);
      radios.push(<Radio value={10}>待处理</Radio>);
zhongnanhuang authored
3878
3879
3880
3881
    }

    //财务可以将需要处理的订单排序到前面
    if (roleCode === 'finance') {
3882
      radios.push(<Radio value={50}>加急</Radio>);
3883
3884
      radios.push(<Radio value={40}>待处理</Radio>);
zhongnanhuang authored
3885
3886

      radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>);
zhongnanhuang authored
3887
3888
    }
3889
    if (roleCode === 'salesRepresentative' || roleCode === 'salesManager') {
3890
      radios.push(<Radio value={30}>只看我创建</Radio>);
zhongnanhuang authored
3891
3892
      radios.push(<Radio value={40}>待审核</Radio>);
3893
3894
    }
zhongnanhuang authored
3895
    if (roleCode === 'admin') {
3896
      radios.push(<Radio value={10}>待处理</Radio>);
zhongnanhuang authored
3897
      radios.push(<Checkbox onChange={financeSorted}>排序</Checkbox>);
zhongnanhuang authored
3898
3899
    }
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
    //筛选按钮配置
    let radioGroup = (
      <Radio.Group
        onChange={(e: any) => {
          setFilterCondition(e.target.value);
          refreshTable();
        }}
        defaultValue={0}
      >
        {radios}
      </Radio.Group>
    );

    toolBtns.push(radioGroup);
3915
3916
    toolBtns.push(<ImportExpressBillModal></ImportExpressBillModal>);
zhongnanhuang authored
3917
    //导出按钮配置
zhongnanhuang authored
3918
    const exportItems: MenuProps['items'] = [
zhongnanhuang authored
3919
      {
zhongnanhuang authored
3920
3921
3922
3923
3924
        label: '导出查询结果订单',
        key: '2',
        onClick: async () => {
          let body = { flag: 50, ...searchParams };
          exportLoading();
3925
3926
3927
3928
3929
3930
3931
          orderExport(
            '/api/service/order/export',
            '订单导出结果.xls',
            'POST',
            body,
            exportLoadingDestory,
          );
zhongnanhuang authored
3932
3933
3934
        },
      },
      {
zhongnanhuang authored
3935
3936
3937
        label: '导出已选中订单',
        key: '1',
        onClick: async () => {
zhongnanhuang authored
3938
          if (mainOrderSelectedMap.size === 0) {
zhongnanhuang authored
3939
3940
3941
            message.error('请选择订单');
            return;
          }
zhongnanhuang authored
3942
          let body = { flag: 30, id: Array.from(mainOrderSelectedMap.keys()) };
zhongnanhuang authored
3943
          exportLoading();
3944
3945
3946
3947
3948
3949
3950
          orderExport(
            '/api/service/order/export',
            '订单导出结果.xls',
            'POST',
            body,
            exportLoadingDestory,
          );
zhongnanhuang authored
3951
3952
3953
        },
      },
      {
zhongnanhuang authored
3954
3955
        label: '导出当天订单',
        key: '4',
zhongnanhuang authored
3956
        onClick: async () => {
zhongnanhuang authored
3957
          let body = { flag: 40, ids: [] };
zhongnanhuang authored
3958
          exportLoading();
3959
3960
3961
3962
3963
3964
3965
          orderExport(
            '/api/service/order/export',
            '订单导出结果.xls',
            'POST',
            body,
            exportLoadingDestory,
          );
zhongnanhuang authored
3966
3967
3968
3969
3970
3971
        },
      },
      {
        label: '导出所有订单',
        key: '3',
        onClick: async () => {
zhongnanhuang authored
3972
3973
          let body = { flag: 10, ids: [] };
          exportLoading();
3974
3975
3976
3977
3978
3979
3980
          orderExport(
            '/api/service/order/export',
            '订单导出结果.xls',
            'POST',
            body,
            exportLoadingDestory,
          );
zhongnanhuang authored
3981
3982
        },
      },
zhongnanhuang authored
3983
3984
    ];
zhongnanhuang authored
3985
3986
    const exportMenuProps = {
      items: exportItems,
3987
      onClick: () => {},
zhongnanhuang authored
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
    };

    //导出按钮配置
    const auditItems: MenuProps['items'] = [
      {
        label: '领导审核',
        key: '2',
        onClick: async () => {
          setIsMainOrder(true);
          setCheckVisible(true);
          setOrderCheckType(CHECK_TYPE.LEADER_AUDIT);
        },
      },
      {
        label: '后置审核',
        key: '1',
        onClick: async () => {
          setIsMainOrder(true);
          setCheckVisible(true);
          setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT);
        },
      },
      {
        label: '修改申请审核',
        key: '3',
        onClick: async () => {
          setIsMainOrder(true);
          setCheckVisible(true);
          setOrderCheckType(CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT);
        },
      },
4019
4020
4021
4022
4023
4024
4025
4026
4027
      {
        label: '加急开票审核',
        key: '4',
        onClick: async () => {
          setIsMainOrder(true);
          setCheckVisible(true);
          setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING);
        },
      },
zhongnanhuang authored
4028
4029
4030
4031
    ];

    const auditProps = {
      items: auditItems,
4032
      onClick: () => {},
zhongnanhuang authored
4033
4034
    };
zhongnanhuang authored
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
    if (rolePath?.includes('leaderMergeAudit')) {
      toolBtns.push(
        <Dropdown
          disabled={selectedSubOrderKeys.length === 0}
          menu={auditProps}
        >
          <Button>
            <Space>
              一键审核
              <DownOutlined />
            </Space>
          </Button>
        </Dropdown>,
      );
    }
4051
4052
4053
4054
4055
4056
4057
    if (rolePath?.includes('mergeAudit')) {
      toolBtns.push(
        <Button
          type="primary"
          key="out"
          onClick={() => {
            setIsMainOrder(true);
zhongnanhuang authored
4058
4059
4060
4061
4062
4063
4064
4065
            if (roleCode === 'procure') {
              setProcureCheckModalVisible(true);
            }

            if (roleCode === 'warehouseKeeper') {
              setCheckVisible(true);
              setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
            }
4066
          }}
zhongnanhuang authored
4067
          disabled={selectedSubOrderKeys?.length === 0}
4068
4069
4070
4071
4072
4073
        >
          一键审核
        </Button>,
      );
    }
zhongnanhuang authored
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
    if (rolePath?.includes('mergeProcureOrder')) {
      toolBtns.push(
        <Button
          key="mergeProcureOrder"
          type="primary"
          disabled={selectedSubOrderKeys.length === 0}
          onClick={() => {
            Modal.confirm({
              title: '一键下单',
              content: '选中的订单是否都已下单?',
              onOk: async () => {
                let res = await postServiceOrderProcureOrder({
                  data: { subIds: [...selectedSubOrderKeys.values()].flat() },
                });
                if (res.result === RESPONSE_CODE.SUCCESS) {
                  message.success(res.message);
                  refreshTable();
                  return true;
                }
              },
            });
          }}
        >
          一键下单
        </Button>,
      );
    }
4102
4103
4104
4105
4106
4107
4108
4109
    if (rolePath?.includes('mergeApplyInvoicing')) {
      toolBtns.push(
        <Button
          type="primary"
          key="out"
          onClick={() => {
            setIsEdit(false);
            setIsMainOrder(true);
zhongnanhuang authored
4110
            setApplyForInvoicingVisible(true);
4111
          }}
zhongnanhuang authored
4112
          disabled={selectedSubOrderKeys?.length === 0}
4113
        >
4114
          {roleCode === 'admin' ? '合并(销售)' : '合并开票'}
4115
4116
4117
4118
        </Button>,
      );
    }
曾国涛 authored
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
    <Button
      type="primary"
      key="out"
      onClick={() => {
        setIsEdit(false);
        setIsMainOrder(true);
        setInvoicingDrawerFormVisible(true);
      }}
      disabled={selectedSubOrderKeys?.length === 0}
    >
      申请开票
    </Button>;
4132
4133
4134
4135
4136
4137
4138
4139
    if (rolePath?.includes('mergeInvoicing')) {
      toolBtns.push(
        <Button
          type="primary"
          key="out"
          onClick={() => {
            //检查订单状态是否正确
            // 遍历Map中的键值对
zhongnanhuang authored
4140
4141
4142
4143
4144
4145
4146
4147
            let errorIds = new Set();
            [...subOrderSelectedMap.values()].flat().forEach((subOrder) => {
              if (
                subOrder.afterInvoicingStatus !== 'APPLY_FOR_INVOICING' &&
                subOrder.afterInvoicingStatus !== 'PARTIAL_INVOICING'
              ) {
                errorIds.add(subOrder.mainOrderId);
                return;
4148
4149
              }
            });
zhongnanhuang authored
4150
            if (errorIds.size > 0) {
4151
4152
              message.error(
                '订单号为:' +
4153
4154
                  [...errorIds.values()].join(',') +
                  '的订单存在不是[申请开票]或者[部分开票]状态的子订单,请检查!',
4155
4156
4157
              );
              return;
            }
zhongnanhuang authored
4158
4159
            setIsMainOrder(true);
            setFinancialVisible(true);
4160
          }}
zhongnanhuang authored
4161
          disabled={selectedSubOrderKeys?.length === 0}
4162
        >
4163
          {roleCode === 'admin' ? '合并(财务)' : '合并开票'}
4164
4165
4166
4167
        </Button>,
      );
    }
4168
    if (rolePath?.includes('addOrder')) {
zhongnanhuang authored
4169
4170
4171
4172
      toolBtns.push(
        <Button
          type="primary"
          key="out"
zhongnanhuang authored
4173
4174
          onClick={() => {
            setOrderDrawerVisible(true);
4175
            setOrderOptType('add');
zhongnanhuang authored
4176
          }}
zhongnanhuang authored
4177
4178
4179
4180
4181
        >
          新增
        </Button>,
      );
    }
4182
zhongnanhuang authored
4183
4184
4185
4186
4187
4188
4189
4190
4191
    if (rolePath?.includes('importExcel')) {
      toolBtns.push(
        <Button
          type="primary"
          key="out"
          onClick={() => {
            setImportModalVisible(true);
          }}
        >
zhongnanhuang authored
4192
          批量发货
zhongnanhuang authored
4193
4194
4195
        </Button>,
      );
    }
zhongnanhuang authored
4196
zhongnanhuang authored
4197
4198
    if (rolePath?.includes('export')) {
      toolBtns.push(
zhongnanhuang authored
4199
        <Dropdown menu={exportMenuProps}>
zhongnanhuang authored
4200
4201
4202
4203
4204
4205
4206
4207
4208
          <Button>
            <Space>
              导出
              <DownOutlined />
            </Space>
          </Button>
        </Dropdown>,
      );
    }
zhongnanhuang authored
4209
4210
4211
4212

    return toolBtns;
  }
zhongnanhuang authored
4213
4214
4215
4216
4217
4218
4219
4220
4221
  useEffect(() => {
    // 使用URLSearchParams来解析查询参数
    const params = new URLSearchParams(location.search);
    const id = params.get('id');
    if (id) {
      mainTableFormRef.current?.setFieldValue('id', id);
    }
  }, []);
calmound authored
4222
  return (
4223
    <div className="order-page-container">
4224
      <div id="resizeDiv"></div>
4225
      <ProTable
zhongnanhuang authored
4226
4227
4228
        id="main-table"
        // tableStyle={{backgroundColor:'red'}}
4229
        actionRef={mainTableRef}
zhongnanhuang authored
4230
        formRef={mainTableFormRef}
4231
4232
4233
4234
4235
        expandIconColumnIndex={-1}
        columns={mainOrdersColumns}
        rowKey="id"
        pagination={{
          showQuickJumper: true,
zhongnanhuang authored
4236
4237
4238
4239
4240
4241
4242
          pageSize: pageSize,
          current: currentPage,
          showSizeChanger: true,
          onChange: (page, size) => {
            setPageSize(size);
            setCurrentPage(page);
          },
zhongnanhuang authored
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
          showTotal: (total, range) => {
            return (
              <>
                <span>
                  {'第 ' +
                    range[0] +
                    '-' +
                    range[1] +
                    ' 条/总共 ' +
                    total +
                    ' 条主订单 '}
                </span>
                <span className="text-[#8C8C8C]">
                  {' (' + subOrderCount + ' 条子订单)'}
                </span>
              </>
            );
          },
calmound authored
4261
        }}
zhongnanhuang authored
4262
        // showHeader={false}
4263
        expandedRowKeys={expandedRowKeys}
zhongnanhuang authored
4264
        // expandable={{ expandedRowRender }}
4265
4266
        dateFormatter="string"
        options={false}
zhongnanhuang authored
4267
        headerTitle=""
4268
4269
        search={{
          labelWidth: 'auto',
zhongnanhuang authored
4270
          // onCollapse: resize,
4271
4272
4273
4274
        }}
        request={async (
          // 第一个参数 params 查询表单和 params 参数的结合
          // 第一个参数中一定会有 pageSize 和  current ,这两个参数是 antd 的规范
zhongnanhuang authored
4275
          params,
4276
          sorter,
sanmu authored
4277
4278
          filter,
        ) => {
4279
          //订单id处理
zhongnanhuang authored
4280
4281
4282
4283
4284
4285
          /**
           * 以params中的id为主,如果params没id,则取url中的id
           * 第一次进来这个页面,url带有id的话,会自动填充到查询表单中,但是第一次查询params不会带这个id进来
           */
          let orderIds = mainTableFormRef.current?.getFieldValue('id');
          params.id = params.id || orderIds;
4286
          if (params.id !== '') {
4287
            params.id = params.id?.replace(/ /g, '');
4288
            if (params.id?.indexOf(',')) {
4289
4290
4291
4292
4293
4294
              params.id = params.id.split(',');
              params.id = params.id.filter((id) => {
                return id !== '';
              });
            }
          }
zhongnanhuang authored
4295
4296
          params.condition = filterCondifion;
4297
zhongnanhuang authored
4298
4299
          //排序
          params.sorted = sorted;
zhongnanhuang authored
4300
          //是否只查看已作废
4301
          params.isDeleteQueryOrder = filterCondifion === 70;
zhongnanhuang authored
4302
          //保存这个搜索条件
zhongnanhuang authored
4303
          setSearchParam(params);
4304
          const { data } = await postServiceOrderQueryServiceOrder({
4305
            // ...params,
calmound authored
4306
4307
4308
4309
            // FIXME: remove @ts-ignore
            // @ts-ignore
            sorter,
            filter,
zhongnanhuang authored
4310
            data: { ...params },
calmound authored
4311
          });
zhongnanhuang authored
4312
zhongnanhuang authored
4313
          setRolePath(data.specialPath);
zhongnanhuang authored
4314
4315
4316
4317
4318
          setSubOrderCount(data.count);
          setAllMainChecked(false);
          setSelectedMainOrderKeys([]);
          subOrderSelectedMap.clear();
          mainOrderSelectedMap.clear();
4319
          setData(data?.data);
zhongnanhuang authored
4320
4321
4322
4323
4324
4325

          //主订单id与子订单id的对照关系保存
          mainOrderIdSubOrderIdRelationsMap.clear();
          for (let row of data?.data) {
            let mianOrderId = row.id;
            let subOrderIds = row.subOrderInformationLists?.map((item) => {
zhongnanhuang authored
4326
4327
4328
              //目前子订单存储的totalPayment不准确,这里重新处理取主订单的totalPayment
              //totalPayment在财务开票计算金额时使用到
              item.totalPayment = row.totalPayment;
zhongnanhuang authored
4329
4330
4331
4332
4333
              return item.id;
            });
            mainOrderIdSubOrderIdRelationsMap.set(mianOrderId, subOrderIds);
          }
calmound authored
4334
          return {
4335
            data: data?.data || [],
zhongnanhuang authored
4336
            total: data?.total || 0,
calmound authored
4337
4338
          };
        }}
4339
4340
4341
        toolbar={{
          multipleLine: true,
        }}
zhongnanhuang authored
4342
4343
4344
        toolBarRender={() => {
          return toolBarRender();
        }}
4345
4346
      />
sanmu authored
4347
      {orderDrawerVisible && (
sanmu authored
4348
        <OrderDrawer
zhongnanhuang authored
4349
4350
          data={orderOptType === 'add' ? {} : buildMainOrder()}
          subOrders={orderOptType === 'add' ? [] : buildSubOrders()}
zhongnanhuang authored
4351
          onClose={(isSuccess: boolean) => {
sanmu authored
4352
            setOrderDrawerVisible(false);
4353
            clearOptObject();
zhongnanhuang authored
4354
4355
4356
            if (isSuccess) {
              refreshTable();
            }
calmound authored
4357
          }}
4358
          orderOptType={orderOptType}
calmound authored
4359
        />
sanmu authored
4360
      )}
sanmu authored
4361
4362
4363

      {checkVisible && (
        <CheckModal
4364
4365
4366
4367
4368
4369
          setCheckVisible={(val: boolean) => {
            setCheckVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4370
4371
4372
4373
4374
4375
          data={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
          subOrders={
            isMainOrder
              ? [...subOrderSelectedMap.values()].flat()
              : buildSubOrders()
          }
zhongnanhuang authored
4376
          orderCheckType={orderCheckType}
zhongnanhuang authored
4377
          openOrderDrawer={(type: any, id: any) => {
zhongnanhuang authored
4378
            setCurrentMainId(id);
zhongnanhuang authored
4379
4380
4381
            setOrderOptType(type);
            setOrderDrawerVisible(true);
          }}
sanmu authored
4382
          onClose={() => {
zhongnanhuang authored
4383
            clearOptObject();
sanmu authored
4384
            setCheckVisible(false);
zhongnanhuang authored
4385
            refreshTable();
4386
4387
4388
4389
          }}
        />
      )}
zhongnanhuang authored
4390
4391
      {applyForInvoicingVisible && (
        <ApplyForInvoicingModal
4392
4393
4394
4395
4396
4397
          setCheckVisible={(val: boolean) => {
            setApplyForInvoicingVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4398
4399
4400
4401
4402
          subOrders={
            isMainOrder
              ? [...subOrderSelectedMap.values()].flat()
              : buildSubOrders()
          }
zhongnanhuang authored
4403
          totalPayment={getApplyInvoicingTotalPayment()}
4404
          isMainOrder={isMainOrder}
zhongnanhuang authored
4405
          isEdit={isEdit}
zhongnanhuang authored
4406
4407
          onClose={() => {
            setApplyForInvoicingVisible(false);
zhongnanhuang authored
4408
            setIsMainOrder(false);
zhongnanhuang authored
4409
            clearOptObject();
zhongnanhuang authored
4410
4411
4412
4413
4414
            refreshTable();
          }}
        />
      )}
4415
      {notesEditVisible && (
zhongnanhuang authored
4416
        <OrderNotesEditModal
4417
4418
4419
4420
4421
4422
          setNotesEditVisible={(val: boolean) => {
            setNotesEditVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
4423
4424
4425
          ids={selectedRows}
          notesType={notesType}
          notes={notes}
4426
4427
          onClose={() => {
            setNotesEditVisible(false);
4428
4429
4430
            setSelectedRows([]);
            setNotes(notes);
            setNotesType(1);
zhongnanhuang authored
4431
            refreshTable();
sanmu authored
4432
4433
4434
4435
4436
4437
          }}
        />
      )}

      {deliverVisible && (
        <DeliverModal
zhongnanhuang authored
4438
          data={buildSubOrders()}
zhongnanhuang authored
4439
          isSendProduct={isSendProduct}
4440
4441
4442
4443
4444
          setVisible={(val: boolean) => {
            setDeliverVisible(val);
            if (!val) {
              clearOptObject();
            }
zhongnanhuang authored
4445
          }}
zhongnanhuang authored
4446
          sendType={orderCheckType}
sanmu authored
4447
          onClose={() => {
zhongnanhuang authored
4448
            clearOptObject();
zhongnanhuang authored
4449
            setDeliverVisible(false);
zhongnanhuang authored
4450
4451
            setIsSendProduct(false);
            refreshTable();
sanmu authored
4452
4453
4454
          }}
        />
      )}
zhongnanhuang authored
4455
4456
4457

      {financialVisible && (
        <FinancialDrawer
zhongnanhuang authored
4458
          isEdit={isEdit}
zhongnanhuang authored
4459
4460
4461
4462
4463
4464
          mainOrder={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
          subOrders={
            isMainOrder
              ? [...subOrderSelectedMap.values()].flat()
              : buildSubOrders()
          }
zhongnanhuang authored
4465
          isMainOrder={isMainOrder}
zhongnanhuang authored
4466
4467
          cancel={() => {
            setFinancialVisible(false);
zhongnanhuang authored
4468
            clearOptObject();
zhongnanhuang authored
4469
            setIsMainOrder(false);
zhongnanhuang authored
4470
            setIsEdit(false);
zhongnanhuang authored
4471
          }}
zhongnanhuang authored
4472
4473
          onClose={() => {
            setFinancialVisible(false);
zhongnanhuang authored
4474
            clearOptObject();
zhongnanhuang authored
4475
            refreshTable();
zhongnanhuang authored
4476
            setIsMainOrder(false);
zhongnanhuang authored
4477
            setIsEdit(false);
zhongnanhuang authored
4478
4479
4480
4481
          }}
        />
      )}
4482
4483
      {financialEditVisible && (
        <FinancialEditDrawer
zhongnanhuang authored
4484
4485
          mainOrder={buildMainOrder()}
          subOrders={buildSubOrders()}
4486
          isMainOrder={isMainOrder}
4487
4488
          setVisible={() => {
            setFinancialEditVisible(false);
4489
            clearOptObject();
4490
4491
4492
4493
4494
          }}
          onClose={() => {
            setFinancialEditVisible(false);
            refreshTable();
            setIsMainOrder(false);
zhongnanhuang authored
4495
            clearOptObject();
4496
4497
4498
4499
          }}
        />
      )}
zhongnanhuang authored
4500
4501
      {orderPrintVisible && (
        <OrderPrintModal
zhongnanhuang authored
4502
4503
          mainOrder={buildMainOrder()}
          subOrders={buildSubOrders()}
zhongnanhuang authored
4504
          isRePrint={isRePrintOrder}
4505
4506
4507
4508
4509
          setVisible={(val: boolean) => {
            setOrderPrintVisible(val);
            if (!val) {
              clearOptObject();
            }
zhongnanhuang authored
4510
          }}
zhongnanhuang authored
4511
          printOptType={orderCheckType}
zhongnanhuang authored
4512
4513
          onClose={() => {
            setOrderPrintVisible(false);
zhongnanhuang authored
4514
            clearOptObject();
zhongnanhuang authored
4515
4516
            setIsRePrintOrder(false);
            refreshTable();
zhongnanhuang authored
4517
4518
4519
4520
4521
4522
          }}
        />
      )}

      {confirmReceiptVisible && (
        <ConfirmReceiptModal
zhongnanhuang authored
4523
          data={buildSubOrders()}
zhongnanhuang authored
4524
4525
          onClose={() => {
            setConfirmReceiptVisible(false);
zhongnanhuang authored
4526
            clearOptObject();
zhongnanhuang authored
4527
            refreshTable();
zhongnanhuang authored
4528
4529
4530
          }}
        />
      )}
zhongnanhuang authored
4531
zhongnanhuang authored
4532
4533
      {imagesViewerModalVisible && (
        <ImagesViewerModal
4534
          optType={imagesViewerOptType}
4535
          setVisible={(val: boolean) => {
zhongnanhuang authored
4536
            setImagesViewerModalVisible(val);
4537
4538
4539
4540
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4541
          onClose={() => {
zhongnanhuang authored
4542
            setImagesViewerModalVisible(false);
zhongnanhuang authored
4543
          }}
zhongnanhuang authored
4544
          orderRow={buildSubOrders()[0]}
zhongnanhuang authored
4545
4546
4547
        />
      )}
zhongnanhuang authored
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
      {importModalVisible && (
        <ImportModal
          onClose={() => {
            setImportModalVisible(false);
            refreshTable();
          }}
        />
      )}

      {attachmentModalVisible && (
        <AttachmentModal
zhongnanhuang authored
4559
          data={buildSubOrders()[0]}
zhongnanhuang authored
4560
4561
          onClose={() => {
            setAttachmentModalVisible(false);
zhongnanhuang authored
4562
            clearOptObject();
zhongnanhuang authored
4563
4564
4565
4566
          }}
        />
      )}
zhongnanhuang authored
4567
4568
4569
      {historyModalVisible && (
        <HistoryModal
          subOrders={selectedRows}
4570
          isCancelledOrder={filterCondifion === 70}
zhongnanhuang authored
4571
4572
4573
          onClose={() => {
            setHistoryModalVisible(false);
            setSelectedRows({});
4574
            clearOptObject();
zhongnanhuang authored
4575
4576
4577
4578
          }}
        />
      )}
zhongnanhuang authored
4579
4580
      {deliverInfoDrawerVisible && (
        <DeliverInfoDrawer
zhongnanhuang authored
4581
          data={buildMainOrder()}
zhongnanhuang authored
4582
4583
          onClose={() => {
            setDeliverInfoDrawerVisible(false);
zhongnanhuang authored
4584
            clearOptObject();
zhongnanhuang authored
4585
4586
4587
4588
          }}
        />
      )}
zhongnanhuang authored
4589
4590
      {deliverInfoDrawerVisible && (
        <DeliverInfoDrawer
zhongnanhuang authored
4591
          data={buildMainOrder()}
zhongnanhuang authored
4592
4593
          onClose={() => {
            setDeliverInfoDrawerVisible(false);
zhongnanhuang authored
4594
            clearOptObject();
zhongnanhuang authored
4595
4596
4597
4598
4599
4600
          }}
        />
      )}

      {procureCheckModalVisible && (
        <ProcureCheckModal
4601
4602
4603
4604
4605
4606
          setCheckVisible={(val: boolean) => {
            setProcureCheckModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
4607
          isMainOrder={isMainOrder}
zhongnanhuang authored
4608
4609
4610
4611
4612
          orders={
            isMainOrder
              ? [...subOrderSelectedMap.values()].flat()
              : buildSubOrders()
          }
zhongnanhuang authored
4613
4614
          onClose={() => {
            setProcureCheckModalVisible(false);
zhongnanhuang authored
4615
            clearOptObject();
4616
            setIsMainOrder(false);
zhongnanhuang authored
4617
4618
4619
4620
4621
            refreshTable();
          }}
        />
      )}
zhongnanhuang authored
4622
4623
      {afterSalesDrawerVisible && (
        <AfterSalesDrawer
4624
4625
4626
4627
4628
4629
          setVisible={(val: boolean) => {
            setAfterSalesDrawerVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4630
4631
          mainOrder={buildMainOrder()}
          subOrders={buildSubOrders()}
zhongnanhuang authored
4632
4633
          onClose={() => {
            setAfterSalesDrawerVisible(false);
zhongnanhuang authored
4634
            clearOptObject();
zhongnanhuang authored
4635
4636
4637
4638
4639
            refreshTable();
          }}
        />
      )}
4640
4641
      {procureConvertModalVisible && (
        <ProcureConvertModal
4642
4643
4644
4645
4646
4647
4648
          setVisible={(val: boolean) => {
            setProcureConvertModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
          subOrders={buildSubOrders()}
4649
4650
          onClose={() => {
            setProcureConvertModalVisible(false);
4651
            clearOptObject();
4652
4653
4654
4655
4656
            refreshTable();
          }}
        />
      )}
4657
4658
      {financialMergeDrawerVisible && (
        <FinancialMergeDrawer
4659
4660
4661
4662
4663
4664
          setVisible={(val: boolean) => {
            setFinancialMergeDrawerVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4665
4666
4667
4668
4669
          dataList={
            isMainOrder
              ? [...subOrderSelectedMap.values()].flat()
              : buildSubOrders()
          }
4670
4671
          onClose={() => {
            setFinancialMergeDrawerVisible(false);
zhongnanhuang authored
4672
4673
            setIsMainOrder(false);
            clearOptObject();
4674
4675
4676
4677
4678
            refreshTable();
          }}
        />
      )}
zhongnanhuang authored
4679
4680
      {financialReceiptsModalVisible && (
        <FinancialReceiptsModal
4681
4682
4683
4684
4685
4686
          setVisible={(val: boolean) => {
            setFinancialReceiptsModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
4687
          datas={selectedRows}
zhongnanhuang authored
4688
4689
4690
4691
4692
4693
4694
4695
          onClose={() => {
            setFinancialReceiptsModalVisible(false);
            setSelectedRows({});
            refreshTable();
          }}
        />
      )}
zhongnanhuang authored
4696
4697
      {shippingWarehouseChangeModalVisible && (
        <ShippingWarehouseChangeModal
4698
4699
4700
4701
4702
4703
          setVisible={(val: boolean) => {
            setShippingWarehouseChangeModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4704
          subOrderIds={ids}
zhongnanhuang authored
4705
          originShippingWarehouse={buildSubOrders()[0].shippingWarehouse}
zhongnanhuang authored
4706
4707
          onClose={() => {
            setShippingWarehouseChangeModalVisible(false);
zhongnanhuang authored
4708
            clearOptObject();
zhongnanhuang authored
4709
4710
4711
4712
4713
            setIds([]);
            refreshTable();
          }}
        />
      )}
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
      {reissueVisible && (
        <ReissueModal
          setVisible={(val: boolean) => {
            setReissueVisible(val);
            console.log(reissueVisible);
            if (!val) {
              clearOptObject();
            }
          }}
          mainOrder={buildMainOrder()}
          subOrders={buildSubOrders()}
          onClose={() => {
            setReissueVisible(false);
            clearOptObject();
            refreshTable();
          }}
        />
      )}
zhongnanhuang authored
4732
4733
      {productionTimeModalVisible && (
        <ProductionTimeModal
4734
4735
4736
4737
4738
4739
          setVisible={(val: boolean) => {
            setProductionTimeModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
          subOrders={buildSubOrders()}
          onClose={() => {
            setProductionTimeModalVisible(false);
            clearOptObject();
            refreshTable();
          }}
        />
      )}

      {modifiedDiffModalVisible && (
        <ModifiedDiffModal
4751
4752
4753
4754
4755
4756
          setVisible={(val: boolean) => {
            setModifiedDiffModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
zhongnanhuang authored
4757
          subOrders={buildSubOrders()}
4758
          mainOrder={buildMainOrder()}
zhongnanhuang authored
4759
4760
4761
4762
4763
4764
          onClose={() => {
            setModifiedDiffModalVisible(false);
            clearOptObject();
          }}
        />
      )}
zhongnanhuang authored
4765
zhongnanhuang authored
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
      {uploadPayBillModalVisible && (
        <UploadPayBillModal
          setVisible={(val: boolean) => {
            setUploadPayBillModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
          subOrders={buildSubOrders()}
          mainOrder={buildMainOrder()}
          onClose={() => {
            setUploadPayBillModalVisible(false);
            clearOptObject();
            refreshTable();
          }}
        />
      )}
曾国涛 authored
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
      {InvoicingDrawerFormVisible && (
        <InvoicingDrawerForm
          subOrders={
            isMainOrder
              ? [...subOrderSelectedMap.values()].flat()
              : buildSubOrders()
          }
          totalPayment={getApplyInvoicingTotalPayment()}
          onClose={() => {
            setApplyForInvoicingVisible(false);
            setIsMainOrder(false);
            clearOptObject();
            refreshTable();
          }}
        ></InvoicingDrawerForm>
      )}
zhongnanhuang authored
4801
      {contextHolder}
4802
      <FloatButton.BackTop visibilityHeight={0} />
4803
    </div>
calmound authored
4804
4805
4806
  );
};
sanmu authored
4807
export default OrderPage;