Blame view

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

  useEffect(() => {
曾国涛 authored
243
244
245
    // 使用URLSearchParams来解析查询参数
    const params = new URLSearchParams(location.search);
    const id = params.get('id');
曾国涛 authored
246
    const subOrderId = params.get('subOrderId');
曾国涛 authored
247
248
249
    if (id) {
      mainTableFormRef.current?.setFieldValue('id', id);
    }
曾国涛 authored
250
251
252
    if (subOrderId) {
      mainTableFormRef.current?.setFieldValue('subOrderId', subOrderId);
    }
曾国涛 authored
253
254
  }, []);
255
256
257
258
259
260
261
  /**
   * 复制订单到剪贴板
   * @param record
   */
  function copyOrderToClipboard(record: any) {
    let text = '';
    text += record?.id;
262
    text += ',' + record?.salesCode;
263
    text += ',' + record?.customerName;
zhongnanhuang authored
264
265
    text += ',' + record?.customerContactNumber;
zhongnanhuang authored
266
267
    text += ',' + record?.customerShippingAddress;
zhongnanhuang authored
268
zhongnanhuang authored
269
    if (!isSupplier()) {
zhongnanhuang authored
270
271
272
      text += ',' + record?.institutionContactName;
      text += ',' + record?.institution;
    }
273
274
275
276
277
278
    record?.subOrderInformationLists?.forEach((item) => {
      text += '\n';
      text += item?.productName;
      text += ' ' + item?.parameters;
      text += ' ' + item?.quantity;
      text += ' ' + item?.unit;
zhongnanhuang authored
279
      if (!isSupplier()) {
zhongnanhuang authored
280
281
        text += ' ¥' + item?.subOrderPayment;
      }
zhongnanhuang authored
282
      text += ' ' + item?.id;
283
284
285
286
287
288
289
290
    });
    if (copyToClipboard(text)) {
      message.info('已复制到剪贴板');
    } else {
      message.info('无法复制到剪贴板');
    }
  }
zhongnanhuang authored
291
292
293
294
295
296
297
298
299
300
301
302
  const MyToolTip = ({ title, content }) => {
    return (
      <Tooltip
        color="#FFFFFF"
        placement="bottom"
        title={<div className="px-5 py-4 text-black">{title}</div>}
      >
        {content}
      </Tooltip>
    );
  };
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  /**
   * 检查是否可以打印
   * @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
321
322
323
324
325
326
  /**
   * 重置当前的操作对象
   */
  function clearOptObject() {
    setCurrentMainId(undefined);
    setCurretnOptSubId(undefined);
327
    setIsMainOrder(false);
zhongnanhuang authored
328
329
330
331
332
333
334
335
  }

  /**
   * 初始化当前的操作对象
   * @param subId
   * @param mainId
   */
  function createOptObject(subId: any, mainId: any) {
柏杨 authored
336
    console.log(currentOptMainId, '5656createOptObject1', curretnOptSubId);
zhongnanhuang authored
337
338
    setCurrentMainId(mainId);
    setCurretnOptSubId(subId);
柏杨 authored
339
    console.log(currentOptMainId, '5656createOptObject2', curretnOptSubId);
zhongnanhuang authored
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
  }

  /**
   * 检查当前操作是否异常
   */
  // 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() {
柏杨 authored
388
389
390
391
392
393
    console.log(
      currentOptMainId,
      '5656buildMainOrder currentOptMainId/curretnOptSubId',
      curretnOptSubId,
    );
    if (!currentOptMainId) {
zhongnanhuang authored
394
395
396
397
398
399
400
401
      message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
      return;
    }

    let mainOrderClone = null;
    let matchedData = data.filter((item) => {
      return item.id === currentOptMainId;
    });
柏杨 authored
402
    console.log(data, '5656buildMainOrder2 data/matchedData', matchedData);
zhongnanhuang authored
403
404
405
    if (matchedData.length > 0) {
      mainOrderClone = cloneDeep(matchedData[0]);
    }
柏杨 authored
406
407
    console.log(mainOrderClone, '5656buildMainOrder mainOrderClone');
    if (!mainOrderClone) {
zhongnanhuang authored
408
409
410
411
412
413
414
415
416
      message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员');
    }
    return mainOrderClone;
  }

  /**
   * 返回当前操作的子订单集合
   */
  function buildSubOrders() {
柏杨 authored
417
418
419
420
421
422
    console.log(
      curretnOptSubId,
      '5656buildSubOrders currentOptMainId/currentOptMainId',
      currentOptMainId,
    );
    if (!currentOptMainId) {
zhongnanhuang authored
423
424
425
426
427
428
429
430
      message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
      return;
    }

    let cloneSubOrders = [];

    //如果没有传当前操作的子订单id,说明是操作主订单
    if (curretnOptSubId === undefined || curretnOptSubId === null) {
柏杨 authored
431
      // if (!curretnOptSubId) {
zhongnanhuang authored
432
433
      //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象
      let currentOptSubOrders = subOrderSelectedMap.get(currentOptMainId);
柏杨 authored
434
435
436
437
438
      console.log(
        subOrderSelectedMap,
        '5656buildSubOrders subOrderSelectedMap/currentOptSubOrders',
        currentOptSubOrders,
      );
zhongnanhuang authored
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
      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 {
      //操作的是子订单
柏杨 authored
458
459
460
461
462
      console.log(
        subOrderSelectedMap,
        '5656buildSubOrders2 subOrderSelectedMap/data',
        data,
      );
zhongnanhuang authored
463
464
465
466
467
468
469
470
471
472
473
      for (let item of data) {
        if (item.id === currentOptMainId) {
          for (let subOrder of item?.subOrderInformationLists) {
            if (subOrder.id === curretnOptSubId) {
              cloneSubOrders.push(cloneDeep(subOrder));
              break;
            }
          }
        }
      }
    }
柏杨 authored
474
475
476
477
478
    console.log(
      cloneSubOrders,
      '5656cloneSubOrders/length',
      cloneSubOrders.length,
    );
zhongnanhuang authored
479
480
481
482
483
484
485
486
    if (cloneSubOrders.length === 0) {
      message.error('页面错误:当前操作的订单数据不存在,请联系系统管理员');
      return;
    }
    return cloneSubOrders;
  }

  /**
zhongnanhuang authored
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
   * 获取当前操作申请开票的订单总金额
   */
  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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
   * 根据主订单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
539
      });
zhongnanhuang authored
540
541
542
543
544
545
546
547
548
549
550
      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
551
      setSelectedRows([]);
552
zhongnanhuang authored
553
      //删除选中主订单的信息
554
      mainOrderSelectedMap.delete(record.id);
zhongnanhuang authored
555
556
557
558
      //删除选中主订单附属子订单的信息
      subOrderSelectedMap.delete(record.id);
      //总选中按钮取消选中
      setAllMainChecked(false);
zhongnanhuang authored
559
    } else {
zhongnanhuang authored
560
      newSelectedMainOrderKeys = [...selectedMainOrderKeys, record.id];
zhongnanhuang authored
561
562
563
564
      //子订单全部自动选中
      let subIds = record.subOrderInformationLists?.map((item) => {
        return item.id;
      });
zhongnanhuang authored
565
566
567
568
569
570
571
      let newSelectedSubOrderKeys = [...selectedSubOrderKeys];
      for (let subId of subIds) {
        if (!selectedSubOrderKeys.includes(subId)) {
          newSelectedSubOrderKeys.push(subId);
        }
      }
      setSelectedSubOrderKeys(newSelectedSubOrderKeys);
572
zhongnanhuang authored
573
      setSelectedRows(record.subOrderInformationLists);
574
575
576

      //选中主订单
      mainOrderSelectedMap.set(record.id, record);
zhongnanhuang authored
577
578
      //选中子订单
      subOrderSelectedMap.set(record.id, record.subOrderInformationLists);
579
      setSubOrderSelectedMap(new Map(subOrderSelectedMap));
zhongnanhuang authored
580
581
582
583
584
585
586

      //如果所有主订单都勾选上了,那么勾选上总选中按钮
      if (
        mainOrderSelectedMap?.size === mainOrderIdSubOrderIdRelationsMap.size
      ) {
        setAllMainChecked(true);
      }
zhongnanhuang authored
587
    }
zhongnanhuang authored
588
    setSelectedMainOrderKeys(newSelectedMainOrderKeys);
zhongnanhuang authored
589
  };
zhongnanhuang authored
590
591
592
  // const handleTableExpand = (mainOrderIds: any) => {
  //   setExpandedRowKeys(mainOrderIds);
  // };
zhongnanhuang authored
593
594
595
596
  const allMainCheckBoxChange = () => {
    let checked = !allMainChecked;
    setAllMainChecked(checked);
597
598
599
    if (checked) {
      let mainOrderIds = data?.map((item) => {
600
        mainOrderSelectedMap.set(item.id, item);
601
602
603
        return item.id;
      });
zhongnanhuang authored
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
      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);
619
    } else {
zhongnanhuang authored
620
621
622
623
      setSelectedMainOrderKeys([]);
      setSelectedSubOrderKeys([]);
      mainOrderSelectedMap.clear();
      subOrderSelectedMap.clear();
624
625
626
    }
  };
zhongnanhuang authored
627
628
629
630
  //表头渲染
  const OrderTableHeader = () => {
    return (
      <Flex className="w-full">
631
632
633
634
635
636
637
        <Flex className="w-[1%] ml-[7px]">
          <Checkbox
            onChange={allMainCheckBoxChange}
            checked={allMainChecked}
          ></Checkbox>
        </Flex>
        <Flex className="w-[30%] ml-[1%]">
zhongnanhuang authored
638
639
          <span className="font-medium">商品信息</span>
        </Flex>
640
        <Flex className="w-[13%]">
zhongnanhuang authored
641
642
          <span className="font-medium">交易金额</span>
        </Flex>
643
zhongnanhuang authored
644
        {!isSupplier() ? (
645
646
647
648
649
650
651
652
653
654
655
656
          <>
            <Flex className="w-[10%]">
              <span className="font-medium">支付</span>
            </Flex>
            <Flex className="w-[12%]">
              <span className="font-medium">其他</span>
            </Flex>
          </>
        ) : (
          ''
        )}
zhongnanhuang authored
657
658
659
660
661
662
        <Flex className="w-[10%]">
          <span className="font-medium">交易状态</span>
        </Flex>
        <Flex className="w-[17%]">
          <span className="font-medium">操作</span>
        </Flex>
zhongnanhuang authored
663
664
665
666
667
      </Flex>
    );
  };
  //子订单内容渲染
  const SubOderRander = ({ record, optRecord }) => {
zhongnanhuang authored
668
669
670
671
672
    /**
     * 获取订单状态标签
     * @param optRecord
     */
    function getOrderStatusTag(optRecord: any): import('react').ReactNode {
673
674
      console.log(optRecord);
zhongnanhuang authored
675
      const orderStatus = optRecord.orderStatus;
zhongnanhuang authored
676
677
678
679
680
681
      const paymentMethod = optRecord.paymentMethod;
      let orderStatusTagText = enumValueToLabel(
        optRecord.orderStatus,
        ORDER_STATUS_OPTIONS,
      );
682
683
684
685
686
687
688
689
690
      if (orderStatus === 'WAIT_CONFIRM_DELIVER_AFTER_INVOICE') {
        if (optRecord.afterInvoicingStatus !== 'COMPLETE_INVOICING') {
          orderStatusTagText = '待开票';
        } else {
          orderStatusTagText = '待确认发货';
        }
      }

      //如果是未审核或者领导已审核,付款状态为预付款则需要财务审核【财务待审核】,否则仓库审核【】
zhongnanhuang authored
691
692
693
694
695
696
697
698
699
700
701
702
703
      if (orderStatus === 'UNAUDITED' || orderStatus === 'LEADER_AUDITED') {
        if (paymentMethod === 'PAYMENT_IN_ADVANCE') {
          orderStatusTagText = '财务待审核';
        } else {
          orderStatusTagText = '仓库待审核';
        }
      }

      //如果是财务已审核,显示为【仓库待审核】
      if (orderStatus === 'FINANCE_PROCESS') {
        orderStatusTagText = '仓库待审核';
      }
zhongnanhuang authored
704
705
706
      if (orderStatus === 'AUDIT_FAILED') {
        return (
          <MyToolTip
707
            key="key"
zhongnanhuang authored
708
            title={optRecord.checkNotes + ' ' + optRecord.postAuditNotes}
zhongnanhuang authored
709
710
711
712
713
714
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
zhongnanhuang authored
715
                  {orderStatusTagText}
zhongnanhuang authored
716
717
718
719
720
721
722
723
724
725
726
727
728
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }

      if (
        orderStatus === 'AFTER_SALES_COMPLETION' ||
        orderStatus === 'IN_AFTER_SALES'
      ) {
        return (
729
730
731
732
          <Tag
            color={TAGS_COLOR.get(optRecord.orderStatus)}
            style={{ marginRight: '4px' }}
          >
zhongnanhuang authored
733
            {orderStatusTagText}
734
          </Tag>
zhongnanhuang authored
735
736
737
        );
      }
738
739
740
      if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') {
        return (
          <MyToolTip
741
            key="key"
742
743
744
745
746
747
748
            title={optRecord.checkNotes}
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
zhongnanhuang authored
749
                  {orderStatusTagText}
750
751
752
753
754
755
756
757
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }
zhongnanhuang authored
758
      return (
759
        <Tag key="key" color={TAGS_COLOR.get(optRecord.orderStatus)}>
zhongnanhuang authored
760
761
762
763
764
765
766
767
768
769
770
771
772
          {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
773
774
775
776
        </Tag>
      );
    }
777
778
    //申请开票附件处理
    const getAfterAnnexList = () => {
zhongnanhuang authored
779
      // let links = [];
780
781
      let afterAnnexList = optRecord.afterAnnexList;
      let i = 1;
zhongnanhuang authored
782
783
      let images = [];
      let otherAnnex = [];
784
785
      if (afterAnnexList?.length > 0) {
        for (let url of afterAnnexList) {
zhongnanhuang authored
786
787
788
789
790
791
          let name = getAliYunOSSFileNameFromUrl(url);
          if (isImageName(name)) {
            images.push({ name: name, url: url });
          } else {
            otherAnnex.push({ name: '附件' + i++, url: url });
          }
792
793
794
        }
      }
zhongnanhuang authored
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
      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(
822
                    '/previewApi/onlinePreview?url=' +
柏杨 authored
823
                      encodeURIComponent(Base64.encode(item.url)),
zhongnanhuang authored
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
                  );
                }}
                onCancel={() => {
                  window.open(item.url);
                }}
                okText="预览"
                cancelText="下载"
              >
                <Button className="px-1" key={index} type="link">
                  {item.name}
                </Button>
              </Popconfirm>
            );
          })}
        </div>
      );
840
841
842
843
844
845
846
847
848
849
850
851
852
    };

    //财务审核附件处理
    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
853
          >
854
855
            {invoicingCheckAnnexList.map((url, index) => (
              <React.Fragment key={index}>
856
857
                <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '}
                <Divider type="vertical" />
858
              </React.Fragment>
859
860
861
862
863
864
865
866
867
868
869
            ))}
          </Image.PreviewGroup>
        </div>
      );
    };

    return (
      <>
        <Flex className="w-full border-b-indigo-500">
          <Flex vertical className="w-[31%]" gap="small">
            {/* 商品名称 */}
zhongnanhuang authored
870
871
            <div>
              <div
872
873
874
875
876
                className="overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer"
                onClick={() => {
                  copyToClipboard(optRecord.productName);
                  message.info('商品名称复制成功:' + optRecord.productName);
                }}
zhongnanhuang authored
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
                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') &&
柏杨 authored
895
                !optRecord.isCurrentUserOrder ? (
zhongnanhuang authored
896
897
898
899
                  <span className="text-[#f44e4e]">(非本账号订单)</span>
                ) : (
                  ''
                )}
900
901
902
903
904
905
906
907
908
909
                {optRecord.modifiedOptFlag !== null ? (
                  <span className="text-[#f44e4e] cursor-pointer">
                    {optRecord.modifiedOptFlag === 'MODIFY' ? '(修改中)' : ''}
                    {optRecord.modifiedOptFlag === 'DELETE' ? '(删除中)' : ''}
                    {optRecord.modifiedOptFlag === 'INSERT' ? '(新增中)' : ''}
                  </span>
                ) : (
                  ''
                )}
zhongnanhuang authored
910
                {optRecord.modified ? (
911
912
913
914
915
916
917
918
                  <Tooltip title="点击查看详情">
                    <span
                      className="text-[#f44e4e] cursor-pointer"
                      onClick={async () => {
                        createOptObject(optRecord.id, record.id);
                        setModifiedDiffModalVisible(true);
                      }}
                    >
919
                      (内容有变化)
920
921
                    </span>
                  </Tooltip>
zhongnanhuang authored
922
923
924
925
926
927
928
929
930
                ) : (
                  ''
                )}
                {!optRecord.logicDelete ? (
                  <span className="text-[#f44e4e]">(已作废)</span>
                ) : (
                  ''
                )}
              </div>
931
            </div>
zhongnanhuang authored
932
933
            <div
934
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis hover:cursor-pointer"
935
              title={optRecord.parameters}
936
937
938
939
              onClick={() => {
                copyToClipboard(optRecord.parameters);
                message.info('商品名称复制成功:' + optRecord.parameters);
              }}
940
            >
zhongnanhuang authored
941
              <span className="text-[#8C8C8C]">
942
                参数:{optRecord.parameters}
zhongnanhuang authored
943
              </span>
zhongnanhuang authored
944
            </div>
945
946
          </Flex>
          <Flex className="w-[13%]" vertical gap="small">
zhongnanhuang authored
947
            {!isSupplier() ? (
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
              <>
                <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>
              </>
            ) : (
              ''
            )}
963
964
965
966
967
            <div
              className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
              title={optRecord.quantity}
            >
              <span className="text-[#8C8C8C]">数量:</span>
968
969
970
971
              <span className="text-slate-700">
                x{optRecord.quantity + ' '}
              </span>
              <span className="text-[#8C8C8C]">{optRecord.unit}</span>
972
            </div>
zhongnanhuang authored
973
zhongnanhuang authored
974
            {!isSupplier() ? (
975
976
977
978
979
              <div
                className="overflow-hidden whitespace-no-wrap overflow-ellipsis"
                title={optRecord.subOrderPayment}
              >
                <span className="text-[#8C8C8C]">合计:</span>
980
                <span className="text-slate-700">
981
                  ¥{optRecord.subOrderPayment}
982
983
984
985
986
                </span>
              </div>
            ) : (
              ''
            )}
987
          </Flex>
988
989
          <Flex className="w-[10%]" vertical gap="small">
zhongnanhuang authored
990
            {!isSupplier() ? (
991
992
993
994
              <>
                {/* 支付方式 */}
                <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <span className="text-slate-700">
zhongnanhuang authored
995
                    {optRecord.paymentMethodText}
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
                  </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
1007
1008
1009
                {/* 回款审核状态 */}
                {optRecord.paymentReceiptStatus !== null ? (
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
1010
1011
                    <Tag
                      className="hover:cursor-pointer"
zhongnanhuang authored
1012
                      onMouseEnter={(e: any) => {
1013
                        e.target.innerText = '点击查看回款凭证';
zhongnanhuang authored
1014
1015
                      }}
                      onMouseLeave={(e: any) => {
1016
1017
1018
1019
                        e.target.innerText = enumValueToLabel(
                          optRecord.paymentReceiptStatus,
                          PAYMENT_RECEIPTS_STATUS_OPTIONS,
                        );
zhongnanhuang authored
1020
                      }}
1021
1022
1023
                      onClick={() => {
                        createOptObject(optRecord.id, record.id);
                        setImagesViewerOptType('paymentReceipt');
zhongnanhuang authored
1024
1025
                        setImagesViewerModalVisible(true);
                      }}
1026
1027
1028
1029
1030
1031
1032
                      key="key"
                      color={TAGS_COLOR.get(optRecord.paymentReceiptStatus)}
                    >
                      {enumValueToLabel(
                        optRecord.paymentReceiptStatus,
                        PAYMENT_RECEIPTS_STATUS_OPTIONS,
                      )}
zhongnanhuang authored
1033
1034
1035
1036
1037
                    </Tag>
                  </div>
                ) : (
                  ''
                )}
1038
              </>
1039
1040
1041
            ) : (
              ''
            )}
1042
1043
          </Flex>
          <Flex className="w-[13%]" vertical gap="small">
zhongnanhuang authored
1044
            {!isSupplier() ? (
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
              <>
                {/* 所属部门 */}
                <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
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
                {/* 开票类型 */}
                {optRecord.invoicingStatus !== null ? (
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                    <span className="text-slate-700">
                      {getInvoicingType(optRecord)}
                    </span>
                  </div>
                ) : (
                  ''
zhongnanhuang authored
1071
                )}
1072
1073

                {/* 开票状态 */}
1074
                {optRecord.afterInvoicingStatus !== null ? (
zhongnanhuang authored
1075
1076
1077
1078
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                    <Tooltip
                      title={
                        optRecord.invoicingUrgentCause !== null &&
柏杨 authored
1079
                        optRecord.afterInvoicingStatus ===
zhongnanhuang authored
1080
1081
1082
                          'URGENT_INVOICE_AUDITING'
                          ? optRecord.invoicingUrgentCause
                          : enumValueToLabel(
柏杨 authored
1083
1084
1085
                              optRecord.afterInvoicingStatus,
                              AFTER_INVOICING_STATUS,
                            )
zhongnanhuang authored
1086
1087
                      }
                    >
1088
1089
1090
                      <Tag
                        color={TAGS_COLOR.get(optRecord.afterInvoicingStatus)}
                      >
zhongnanhuang authored
1091
1092
1093
1094
1095
1096
1097
                        {enumValueToLabel(
                          optRecord.afterInvoicingStatus,
                          AFTER_INVOICING_STATUS,
                        )}
                      </Tag>
                    </Tooltip>
                  </div>
1098
1099
1100
                ) : (
                  ''
                )}
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115

                {/* 是否加急图标显示 */}
                {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') &&
柏杨 authored
1116
                optRecord.shippingWarehouse !== null ? (
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
                  <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 ||
柏杨 authored
1138
                  optRecord.productionEndTime !== null ? (
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
                    <MyToolTip
                      title={
                        formatdate(optRecord.productionStartTime) +
                        ' 至 ' +
                        formatdate(optRecord.productionEndTime)
                      }
                      content={
                        <Button type="link" size="small" style={{ padding: 0 }}>
                          生产时间
                        </Button>
                      }
                    />
                  ) : (
                    ''
zhongnanhuang authored
1153
                  )}
1154
1155
                </div>
              </>
zhongnanhuang authored
1156
1157
1158
            ) : (
              ''
            )}
1159
          </Flex>
zhongnanhuang authored
1160
1161
1162
          <Flex className="w-[10%]" vertical gap="small">
            {/* 开票状态 */}
zhongnanhuang authored
1163
            {!isSupplier() ? (
1164
1165
1166
1167
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                <Tag
                  color={
                    optRecord.invoicingTime === null ||
柏杨 authored
1168
                    optRecord.invoicingTime === undefined
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
                      ? TAGS_COLOR.get(optRecord.invoicingStatus)
                      : 'success'
                  }
                >
                  {getNeedInvoicing(optRecord)}
                </Tag>
              </div>
            ) : (
              ''
            )}
1180
1181
1182
1183
1184
            {/* 订单状态 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              {getOrderStatusTag(optRecord)}
            </div>
zhongnanhuang authored
1185
1186
1187
1188
1189
1190
1191
1192
1193
            {/* 后置审核状态 */}
            {optRecord.postAuditStatus !== null ? (
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                {getPostAuditStatusTag(optRecord)}
              </div>
            ) : (
              ''
            )}
1194
1195
            {/**采购是否已下单状态 */}
            {optRecord.procureOrderStatus !== null &&
柏杨 authored
1196
            optRecord.procureOrderStatus !== undefined ? (
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
              <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                <Tag color="success">
                  {enumValueToLabel(
                    optRecord.procureOrderStatus,
                    PROCURE_ORDER_STATUS,
                  )}
                </Tag>
              </div>
            ) : (
              ''
            )}
1209
1210
1211
            {/* 物流信息 */}
            <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
              {optRecord.orderStatus === 'CONFIRM_RECEIPT' ||
柏杨 authored
1212
1213
1214
              optRecord.orderStatus === 'AFTER_SALES_COMPLETION' ||
              optRecord.orderStatus === 'IN_AFTER_SALES' ||
              optRecord.orderStatus === 'SHIPPED' ? (
1215
1216
1217
1218
1219
                <MyToolTip
                  title={
                    optRecord.serialNumber === undefined
                      ? '暂无物流信息'
                      : enumValueToLabel(
柏杨 authored
1220
1221
1222
1223
1224
1225
1226
                          optRecord.logisticsMethod,
                          LOGISTICS_STATUS_OPTIONS,
                        ) +
                        '  ' +
                        optRecord.serialNumber +
                        '  ' +
                        optRecord.logisticsNotes
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
                  }
                  content={
                    <Button type="link" size="small" style={{ padding: 0 }}>
                      物流信息
                    </Button>
                  }
                />
              ) : (
                ''
              )}
1237
1238

              {/* 修改审核状态 */}
1239
              {optRecord.modifiedAuditStatus !== null &&
柏杨 authored
1240
              optRecord.modifiedAuditStatus !== 'AUDIT_FAILURE' ? (
1241
1242
                <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <Tooltip
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
                    title={recordOptNode ? recordOptNode : <Spin />}
                    onOpenChange={(open) => {
                      console.log('open:' + open);
                      console.log('id:' + optRecord.id);
                      if (open) {
                        triggerRecordOptNode(optRecord.id);
                      } else {
                        setRecordOptNode(null);
                      }
                    }}
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
                  >
                    <Tag color={TAGS_COLOR.get(optRecord.modifiedAuditStatus)}>
                      {enumValueToLabel(
                        optRecord.modifiedAuditStatus,
                        MODIFIED_AUDIT_STATUS_OPTIONS,
                      )}
                    </Tag>
                  </Tooltip>
                </div>
              ) : (
                ''
              )}
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287

              {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' }} />
                    </>
                  }
                />
              ) : (
                ''
              )}
1288
1289
1290
            </div>
          </Flex>
          <Flex className="w-[18%]" wrap="wrap" gap="small">
1291
            {optRecord.paths?.includes('postAudit') ? (
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT);
                }}
              >
                后置审核
              </Button>
            ) : (
              ''
            )}
            {/* 加急审核 */}
1307
            {optRecord.paths?.includes('URGENT_INVOICE_AUDITING') ? (
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  console.log('here');
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING);
                }}
              >
1319
                加急审核(新)
1320
1321
1322
1323
              </Button>
            ) : (
              ''
            )}
1324
            {optRecord.paths?.includes('URGENT_INVOICE_AUDITING_old') ? (
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  console.log('here');
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD);
                }}
              >
                加急审核(旧)
              </Button>
            ) : (
              ''
            )}
1341
            {optRecord.paths?.includes('salesConfirm') && (
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
              <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();
                  }
                }}
              />
            )}
1360
            {optRecord.paths?.includes('uploadPaymentReceiptBill') ? (
zhongnanhuang authored
1361
1362
1363
1364
              <Button
                className="p-0"
                type="link"
                onClick={() => {
柏杨 authored
1365
1366
1367
1368
1369
                  console.log(
                    optRecord.id,
                    '5656optRecord.id, record.id',
                    record.id,
                  );
zhongnanhuang authored
1370
1371
1372
1373
1374
1375
1376
1377
1378
                  createOptObject(optRecord.id, record.id);
                  setUploadPayBillModalVisible(true);
                }}
              >
                回款
              </Button>
            ) : (
              ''
            )}
1379
            {optRecord.paths?.includes('reissue_old') ? (
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
              /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'||
                  optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
                  setReissueVisibleOld(true);
                }}
              >
                重新开票(旧)
              </Button>
            ) : (
              ''
            )}
1395
            {optRecord.paths?.includes('reissue') ? (
1396
1397
1398
1399
1400
1401
1402
              /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'||
                optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
1403
                  setCurretnOptSubId(optRecord.id);
1404
1405
1406
                  setReissueVisible(true);
                }}
              >
1407
                重新开票(新)
1408
1409
1410
1411
1412
              </Button>
            ) : (
              ''
            )}
1413
            {optRecord.paths?.includes('confirmReissue_old') ? (
1414
1415
1416
1417
1418
1419
1420
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
1421
1422
1423
1424
1425
1426
1427
1428
                  setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE_OLD);
                }}
              >
                重新开票审核(旧)
              </Button>
            ) : (
              ''
            )}
1429
            {optRecord.paths?.includes('confirmReissue') ? (
1430
1431
1432
1433
1434
1435
1436
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
1437
1438
1439
                  setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE);
                }}
              >
1440
                重新开票审核(新)
1441
1442
1443
1444
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1445
1446
            {optRecord.paths?.includes('leaderAudit') ? (
1447
1448
1449
1450
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1451
1452
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.LEADER_AUDIT);
                }}
              >
                审核
              </Button>
            ) : (
              ''
            )}
1463
            {optRecord.paths?.includes('creditAudit') ? (
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.CREDIT_AUDIT);
                }}
              >
                赊账审核
              </Button>
            ) : (
              ''
            )}
1480
            {optRecord.paths?.includes('auditPaymentReceipt') ? (
zhongnanhuang authored
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT);
                }}
              >
                回款审核
              </Button>
            ) : (
              ''
            )}
1496
            {optRecord.paths?.includes('modifiedAuditRequest') ? (
1497
1498
1499
1500
1501
1502
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
1503
1504
1505
1506
1507
1508
1509
1510
1511
                  setOrderCheckType(CHECK_TYPE.NODE_OPERATING_AUDIT);
                }}
              >
                节点修改审核
              </Button>
            ) : (
              ''
            )}
1512
            {optRecord.paths?.includes('applyModify') ? (
1513
1514
1515
1516
1517
1518
1519
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setOrderDrawerVisible(true);
                  setOrderOptType('order-change-normal');
1520
1521
                }}
              >
1522
1523
1524
1525
1526
1527
                申请修改
              </Button>
            ) : (
              ''
            )}
1528
            {optRecord.paths?.includes('modifiedLeaderAuditRequest') ? (
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.MODIFY_LEADER_AUDIT);
                }}
              >
                领导修改审核
1539
1540
1541
1542
1543
              </Button>
            ) : (
              ''
            )}
1544
            {optRecord.paths?.includes('shippingWarehouseChangeRequest') ? (
zhongnanhuang authored
1545
1546
1547
1548
1549
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setIds([optRecord.id]);
zhongnanhuang authored
1550
                  createOptObject(optRecord.id, record.id);
zhongnanhuang authored
1551
1552
1553
1554
1555
1556
1557
1558
1559
                  setShippingWarehouseChangeModalVisible(true);
                }}
              >
                修改仓库
              </Button>
            ) : (
              ''
            )}
1560
            {optRecord.paths?.includes('saleCancelInvoicing_old') ? (
1561
1562
1563
              <ButtonConfirm
                className="p-0"
                title="确认取消申请开票?"
1564
                text="取消申请(旧)"
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
                onConfirm={async () => {
                  let res = await postServiceOrderSaleCancelInvoicing({
                    data: {
                      subOrderIds: [optRecord.id],
                    },
                  });

                  if (res && res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
                }}
              />
            ) : (
              ''
1580
            )}
1581
            {optRecord.paths?.includes('saleCancelInvoicing') ? (
曾国涛 authored
1582
1583
1584
              <ButtonConfirm
                className="p-0"
                title="确认取消申请开票?"
1585
                text="取消申请(新)"
曾国涛 authored
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
                onConfirm={async () => {
                  let res = await postServiceInvoiceCancelApply({
                    data: {
                      subOrderIds: [optRecord.id],
                    },
                  });

                  if (res && res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
                }}
              />
            ) : (
              ''
1601
            )}
1602
            {optRecord.paths?.includes('noNeedInvoicingEdit') ? (
1603
1604
1605
1606
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1607
                  createOptObject(optRecord.id, record.id);
1608
1609
1610
1611
                  setFinancialEditVisible(true);
                  setIsMainOrder(false);
                }}
              >
1612
                编辑时间
1613
1614
1615
1616
              </Button>
            ) : (
              ''
            )}
1617
            {optRecord.paths?.includes('sendProduct') ? (
1618
1619
1620
1621
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1622
                  createOptObject(optRecord.id, record.id);
1623
1624
                  setDeliverVisible(true);
                  setIsSendProduct(true);
zhongnanhuang authored
1625
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1626
1627
1628
1629
1630
1631
1632
1633
                }}
              >
                仓库发货
              </Button>
            ) : (
              ''
            )}
1634
            {optRecord.paths?.includes('supplierSendOrder') ? (
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
                  setSelectedRows([cloneDeep(optRecord)]); //克隆一份数据,避免后续修改污染
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.SUPPLIER);
                }}
              >
                供应商发货
              </Button>
            ) : (
              ''
            )}
1652
            {optRecord.paths?.includes('procureSend') ? (
zhongnanhuang authored
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                }}
              >
zhongnanhuang authored
1663
                {isSupplier() ? '发货' : '采购发货'}
zhongnanhuang authored
1664
1665
1666
1667
1668
              </Button>
            ) : (
              ''
            )}
1669
            {optRecord.paths?.includes('editProductionTime') ? (
1670
1671
1672
1673
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1674
1675
                  createOptObject(optRecord.id, record.id);
                  setProductionTimeModalVisible(true);
1676
1677
                }}
              >
zhongnanhuang authored
1678
                生产时间
1679
1680
1681
1682
1683
              </Button>
            ) : (
              ''
            )}
1684
            {optRecord.paths?.includes('queryAnnex') &&
柏杨 authored
1685
            optRecord.listAnnex?.length > 0 ? (
1686
1687
1688
1689
1690
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
zhongnanhuang authored
1691
                  createOptObject(optRecord.id, record.id);
1692
1693
1694
1695
1696
1697
1698
1699
1700
                  setAttachmentModalVisible(true);
                }}
              >
                附件
              </Button>
            ) : (
              ''
            )}
1701
            {optRecord.paths?.includes('modifySendInformation') ? (
1702
1703
1704
1705
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1706
                  createOptObject(optRecord.id, record.id);
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
                  setDeliverVisible(true);
                  setIsSendProduct(false);
                }}
              >
                修改发货信息
              </Button>
            ) : (
              ''
            )}
1717
            {optRecord.paths?.includes('printOrder') ? (
1718
1719
1720
1721
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
zhongnanhuang authored
1722
                  createOptObject(optRecord.id, record.id);
1723
                  setOrderPrintVisible(true);
zhongnanhuang authored
1724
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1725
1726
1727
1728
1729
1730
1731
1732
                }}
              >
                仓库打印
              </Button>
            ) : (
              ''
            )}
1733
            {optRecord.paths?.includes('supplierPrint') ? (
1734
1735
1736
1737
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
zhongnanhuang authored
1738
                  createOptObject(optRecord.id, record.id);
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
                  setOrderPrintVisible(true);
                  setOrderCheckType(CHECK_TYPE.SUPPLIER);
                }}
              >
                供应商打印
              </Button>
            ) : (
              ''
            )}
1749
            {optRecord.paths?.includes('procurePrint') ? (
zhongnanhuang authored
1750
              <ButtonConfirm
1751
                className="p-0"
zhongnanhuang authored
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
                title="确认打印?"
                text="采购打印"
                onConfirm={async () => {
                  let res = await postServiceOrderProcurePrint({
                    data: {
                      ids: [optRecord.id],
                    },
                  });

                  if (res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
1765
                }}
zhongnanhuang authored
1766
              />
1767
            ) : (
zhongnanhuang authored
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
              // <Button
              //   className="p-0"
              //   type="link"
              //   onClick={async () => {
              //     setOrderPrintVisible(true);
              //     setSelectedRows([optRecord]);
              //     setOrderRow(record);
              //     setOrderCheckType(CHECK_TYPE.PROCURE);
              //   }}
              // >
              //   采购打印
              // </Button>
1780
1781
1782
              ''
            )}
1783
            {optRecord.paths?.includes('editOrder') && false ? (
1784
1785
1786
1787
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1788
                  createOptObject(optRecord.id, record.id);
1789
                  setFinancialVisible(true);
zhongnanhuang authored
1790
                  setIsEdit(true);
1791
1792
1793
1794
1795
1796
1797
                }}
              >
                编辑
              </Button>
            ) : (
              ''
            )}
zhongnanhuang authored
1798
1799
            {optRecord.paths?.includes('invoicing') ? (
1800
1801
1802
1803
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1804
                  createOptObject(optRecord.id, record.id);
1805
                  setFinancialVisible(true);
zhongnanhuang authored
1806
                  setIsEdit(false);
1807
1808
1809
1810
1811
1812
1813
1814
1815
                  setIsMainOrder(false);
                }}
              >
                开票
              </Button>
            ) : (
              ''
            )}
1816
            {optRecord.paths?.includes('applyInvoicing') ? (
曾国涛 authored
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setInvoicingDrawerFormVisible(true);
                  createOptObject(optRecord.id, record.id);
                  setIsEdit(false);
                  setIsMainOrder(false);
                }}
              >
1827
                申请开票(新)
曾国涛 authored
1828
1829
1830
              </Button>
            ) : (
              ''
1831
1832
            )}
1833
            {optRecord.paths?.includes('applyInvoicing_old') ? (
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  setApplyForInvoicingVisible(true);
                  createOptObject(optRecord.id, record.id);
                  setIsEdit(false);
                  setIsMainOrder(false);
                }}
              >
                申请开票(旧)
              </Button>
            ) : (
              ''
            )}
1850
            {optRecord.paths?.includes('checkOrder') ? (
1851
1852
1853
1854
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1855
1856
                  setCurrentMainId(record.id);
                  setCurretnOptSubId(optRecord.id);
1857
                  setCheckVisible(true);
zhongnanhuang authored
1858
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1859
1860
1861
1862
1863
1864
1865
1866
                }}
              >
                审核
              </Button>
            ) : (
              ''
            )}
1867
            {optRecord.paths?.includes('afterSalesCheck') ? (
1868
1869
1870
1871
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1872
                  createOptObject(optRecord.id, record.id);
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.AFTER_SALES);
                }}
              >
                售后审核
              </Button>
            ) : (
              ''
            )}
1883
            {optRecord.paths?.includes('financeCheckOrder') ? (
1884
1885
1886
1887
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1888
                  createOptObject(optRecord.id, record.id);
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
                  setCheckVisible(true);
                  setOrderCheckType(CHECK_TYPE.FINALCIAL);
                }}
              >
                财务审核
              </Button>
            ) : (
              ''
            )}
1899
            {optRecord.paths?.includes('procureCheckOrder') ? (
1900
1901
1902
1903
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1904
                  createOptObject(optRecord.id, record.id);
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                  setProcureCheckModalVisible(true);
                }}
              >
                采购审核
              </Button>
            ) : (
              ''
            )}
1915
            {optRecord.paths?.includes('procureConvertProcure') ? (
1916
1917
1918
1919
              <Button
                className="p-0"
                type="link"
                onClick={() => {
1920
                  createOptObject(optRecord.id, record.id);
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                  setProcureConvertModalVisible(true);
                }}
              >
                转发
              </Button>
            ) : (
              ''
            )}
1931
            {optRecord.paths?.includes('rePrintOrder') ? (
1932
1933
1934
1935
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1936
                  createOptObject(optRecord.id, record.id);
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
                  setOrderPrintVisible(true);
                  setIsRePrintOrder(true);
                }}
              >
                重新打印
              </Button>
            ) : (
              ''
            )}
1947
            {optRecord.paths?.includes('confirmReceipt') ? (
1948
1949
1950
1951
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1952
                  createOptObject(optRecord.id, record.id);
1953
1954
1955
1956
1957
1958
1959
1960
1961
                  setConfirmReceiptVisible(true);
                }}
              >
                确认收货
              </Button>
            ) : (
              ''
            )}
1962
            {optRecord.paths?.includes('applyAfterSales') ? (
1963
1964
1965
1966
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1967
                  createOptObject(optRecord.id, record.id);
1968
                  setOrderDrawerVisible(true);
zhongnanhuang authored
1969
                  setOrderOptType('after_sales');
1970
1971
1972
1973
1974
1975
                }}
              >
                申请售后
              </Button>
            ) : (
              ''
zhongnanhuang authored
1976
            )}
1977
1978
            {optRecord.paths?.includes('procureOrder') ? (
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
              <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;
                  }
                }}
              />
            ) : (
              ''
            )}
1998
            {optRecord.paths?.includes('cancelSend') ? (
zhongnanhuang authored
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
              <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;
                  }
                }}
              />
            ) : (
              ''
            )}
2018
            {optRecord.paths?.includes('noNeedSend') ? (
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
              <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;
                  }
                }}
              />
            ) : (
              ''
            )}
2038
            {optRecord.paths?.includes('viewImages') ? (
2039
2040
2041
2042
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
2043
                  createOptObject(optRecord.id, record.id);
2044
                  setImagesViewerOptType('shippingReceipt');
zhongnanhuang authored
2045
                  setImagesViewerModalVisible(true);
2046
2047
2048
2049
2050
2051
2052
2053
                }}
              >
                查看收货凭证
              </Button>
            ) : (
              ''
            )}
2054
            {optRecord.paths?.includes('confirmDeliver') ? (
2055
2056
2057
2058
2059
2060
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setOrderCheckType(CHECK_TYPE.CONFIRM_DELIVER);
2061
                  setCheckVisible(true);
2062
2063
2064
2065
2066
2067
2068
2069
                }}
              >
                确认发货
              </Button>
            ) : (
              ''
            )}
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
            {optRecord.paths?.includes('confirmInvoice') ? (
              <ButtonConfirm
                className="p-0"
                title="已和客户确认发票??"
                text="确认发票"
                onConfirm={async () => {
                  const data = await postServiceOrderConfirmInvoice({
                    data: [optRecord.id],
                  });
                  if (data.result === RESPONSE_CODE.SUCCESS) {
                    message.success(data.message);
                    refreshTable();
                  }
                }}
              />
            ) : (
              ''
            )}
2089
            {optRecord.paths?.includes('orderCancel') ? (
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
              <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
2109
        </Flex>
2110
2111
2112
        <Flex title={optRecord.notes}>
          <div
zhongnanhuang authored
2113
            className="max-w-[1100px] overflow-hidden whitespace-normal overflow-ellipsis hover:cursor-pointer"
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
            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()) &&
柏杨 authored
2138
        !isSupplier() ? (
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
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
          <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">
2203
2204
2205
2206
2207
2208
2209
2210
            <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
2211
                      申请开票备注:
2212
                      {optRecord.applyInvoicingNotes === undefined ||
柏杨 authored
2213
                      optRecord.applyInvoicingNotes === null
2214
2215
2216
2217
2218
2219
2220
                        ? '暂无备注'
                        : optRecord.applyInvoicingNotes}
                    </span>
                  </Tooltip>
                </div>

                {getAfterAnnexList()}
zhongnanhuang authored
2221
2222
2223
2224
2225

                <Tooltip title="编辑">
                  <EditTwoTone
                    className="pl-1 hover:curcor-pointer"
                    onClick={() => {
2226
2227
2228
2229
                      setNotesEditVisible(true);
                      setSelectedRows([optRecord.id]);
                      setNotes(optRecord.applyInvoicingNotes);
                      setNotesType(4);
zhongnanhuang authored
2230
2231
2232
                    }}
                  />
                </Tooltip>
2233
2234
2235
2236
2237
2238
2239
2240
              </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 ||
柏杨 authored
2241
                      optRecord.checkNotes === null
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
                        ? '暂无备注'
                        : optRecord.checkNotes}
                    </span>
                  </Tooltip>
                </div>

                {getInvoicingCheckAnnexList()}
              </div>
            </div>
          </Flex>
        ) : (
          ''
        )}
曾国涛 authored
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264

        {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 ||
柏杨 authored
2265
                      optRecord.reissueNotes === null
曾国涛 authored
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
                        ? '暂无备注'
                        : 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>
2286
2287
2288
2289
2290
          </Flex>
        ) : (
          ''
        )}
      </>
zhongnanhuang authored
2291
    );
zhongnanhuang authored
2292
  };
zhongnanhuang authored
2293
2294
2295
2296
2297
2298
  const expandedRowRender = (record) => {
    let subOrders = record.subOrderInformationLists;

    return (
      <ProTable
        id="sub-table"
zhongnanhuang authored
2299
        className="w-full "
zhongnanhuang authored
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
        showHeader={false}
        columns={[
          {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            render: (text: any, optRecord: any) => {
              return <SubOderRander record={record} optRecord={optRecord} />;
            },
          },
        ]}
        rowSelection={{
zhongnanhuang authored
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
          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
2371
            if (currentMainOrderSelectedSubOrderList?.length === 0) {
zhongnanhuang authored
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
              subOrderSelectedMap.delete(record.id);
            } else {
              subOrderSelectedMap.set(
                record.id,
                currentMainOrderSelectedSubOrderList,
              );
            }

            setSelectedSubOrderKeys(newSelectedSubOrderKeys);
            setSelectedRows(currentMainOrderSelectedSubOrderList);
zhongnanhuang authored
2382
          },
zhongnanhuang authored
2383
          selectedRowKeys: selectedSubOrderKeys,
zhongnanhuang authored
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
          // 自定义选择项参考: 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
2395
        tableAlertRender={false}
zhongnanhuang authored
2396
2397
2398
2399
      />
    );
  };
2400
  // 主订单内容渲染
sanmu authored
2401
  const MainOrderColumnRender = ({ record }: { record: OrderListItemType }) => {
sanmu authored
2402
2403
2404
    return (
      <Flex vertical={true}>
        {/* 编号、时间、销售信息 */}
zhongnanhuang authored
2405
        <Flex
zhongnanhuang authored
2406
          className="px-4 py-4 bg-white rounded-t-lg"
zhongnanhuang authored
2407
2408
2409
2410
2411
2412
          justify="space-between"
        >
          <Flex wrap="wrap" gap="middle" vertical>
            <Flex>
              <Flex>
                <Checkbox
zhongnanhuang authored
2413
                  onChange={() => onCheckboxChange(record)}
zhongnanhuang authored
2414
                  checked={selectedMainOrderKeys.includes(record.id)}
zhongnanhuang authored
2415
                >
zhongnanhuang authored
2416
2417
                  <Space split={<Divider type="vertical" />}>
                    <div>
zhongnanhuang authored
2418
                      <span className="text-[#8C8C8C]">订单号:</span>
zhongnanhuang authored
2419
                      <span className="text-slate-700">{record.id}</span>
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
                      {record.modified ? (
                        <Tooltip title="点击查看详情">
                          <span
                            className="text-[#f44e4e] cursor-pointer"
                            onClick={async () => {
                              createOptObject(null, record.id);
                              setModifiedDiffModalVisible(true);
                            }}
                          >
                            (修改过)
                          </span>
                        </Tooltip>
                      ) : (
                        ''
                      )}
zhongnanhuang authored
2435
2436
2437
                    </div>
                  </Space>
                </Checkbox>
zhongnanhuang authored
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
                <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
2451
                <Space split={<Divider type="vertical" />}>
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
                  <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
2462
                  {!isSupplier() ? (
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
                    <>
                      <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>
                    </>
                  ) : (
                    ''
                  )}
2483
2484
2485
                  <div
                    title={record.institution}
                    className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[150px]"
2486
                  >
2487
2488
2489
2490
2491
2492
2493
2494
                    <span
                      className="hover:cursor-pointer"
                      onClick={() => {
                        copyToClipboard(record.customerName);
                        message.info('收货人复制成功:' + record.customerName);
                      }}
                    >
                      <span className="text-[#8C8C8C]">收货人:</span>
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
                      {!isSupplier() && (
                        <Tooltip className="order-tooltip" title="详情">
                          <ContainerTwoTone
                            className="px-1 hover:curcor-pointer"
                            onClick={() => {
                              createOptObject(null, record.id);
                              setDeliverInfoDrawerVisible(true);
                            }}
                          />
                        </Tooltip>
                      )}
2506
2507
2508
                      <span className="text-slate-700">
                        {record.customerName + ' '}
                      </span>
zhongnanhuang authored
2509
                    </span>
2510
2511
                  </div>
zhongnanhuang authored
2512
                  {isSupplier() ? (
2513
2514
                    <div
                      title={record.customerShippingAddress}
2515
                      className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[400px] hover:cursor-pointer"
2516
2517
2518
2519
2520
2521
                      onClick={() => {
                        copyToClipboard(record.customerShippingAddress);
                        message.info(
                          '收货地址复制成功:' + record.customerShippingAddress,
                        );
                      }}
2522
2523
2524
2525
2526
2527
2528
2529
2530
                    >
                      <span className="text-[#8C8C8C]">收货地址:</span>
                      <span className="text-slate-700">
                        {record.customerShippingAddress}
                      </span>
                    </div>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2531
                </Space>
zhongnanhuang authored
2532
              </Flex>
2533
            </Flex>
zhongnanhuang authored
2534
zhongnanhuang authored
2535
            {isSupplier() ? (
zhongnanhuang authored
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
              <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
2556
            <Flex className="pl-6" align="center">
2557
              {roleCode === 'finance' ? (
zhongnanhuang authored
2558
2559
2560
                <div
                  title={enumValueToLabel(
                    record.receivingCompany,
zhongnanhuang authored
2561
                    getReceivingCompanyOptions(PAYEE_OPTIONS),
zhongnanhuang authored
2562
2563
2564
                  )}
                  className="whitespace-no-wrap overflow-hidden overflow-ellipsis max-w-[400px]"
                >
2565
                  <span className="text-[#8C8C8C]">开票收款单位:</span>
zhongnanhuang authored
2566
2567
2568
                  <span className="text-slate-700">
                    {record.receivingCompany !== null
                      ? enumValueToLabel(
柏杨 authored
2569
2570
2571
                          record.receivingCompany,
                          getReceivingCompanyOptions(PAYEE_OPTIONS),
                        )
zhongnanhuang authored
2572
2573
2574
2575
2576
2577
2578
                      : '暂无'}
                  </span>
                </div>
              ) : (
                ''
              )}
2579
              {roleCode === 'finance' ? <Divider type="vertical" /> : ''}
zhongnanhuang authored
2580
zhongnanhuang authored
2581
              <div title={record.notes}>
2582
                <div
2583
                  className="max-w-[850px] whitespace-normal overflow-hidden overflow-ellipsis hover:cursor-pointer"
2584
2585
2586
2587
2588
                  onClick={() => {
                    copyToClipboard(record.notes);
                    message.info('备注复制成功:' + record.notes);
                  }}
                >
zhongnanhuang authored
2589
2590
                  <span className="text-[#8C8C8C]">备注:</span>
                  <span className="ml-2">
zhongnanhuang authored
2591
                    {record.notes === null ? '暂无备注' : record.notes}
zhongnanhuang authored
2592
                  </span>
zhongnanhuang authored
2593
                </div>
zhongnanhuang authored
2594
              </div>
2595
zhongnanhuang authored
2596
              {!isSupplier() ? (
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
                <Tooltip title="编辑">
                  <EditTwoTone
                    className="pl-1 hover:curcor-pointer"
                    onClick={() => {
                      setNotesEditVisible(true);
                      setSelectedRows([record.id]);
                      setNotes(record.notes);
                      setNotesType(0);
                    }}
                  />
                </Tooltip>
              ) : (
                ''
              )}
zhongnanhuang authored
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
              {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
2625
                  </div>
2626
2627
2628
2629
                </div>
              ) : (
                ''
              )}
zhongnanhuang authored
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
              {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
2644
                  </div>
2645
2646
2647
2648
                </div>
              ) : (
                ''
              )}
zhongnanhuang authored
2649
2650
2651
2652
2653
            </Flex>
          </Flex>
          <Flex wrap="wrap" gap="middle" vertical>
            <Flex justify="flex-end">
              <Flex wrap="wrap" gap="middle" align="center">
zhongnanhuang authored
2654
                {!isSupplier() ? (
zhongnanhuang authored
2655
2656
2657
2658
2659
2660
2661
2662
2663
                  <div>
                    <span className="text-[#8C8C8C]">总金额:¥</span>
                    <span className="text-lg font-medium">
                      {record.totalPayment}
                    </span>
                  </div>
                ) : (
                  ''
                )}
2664
zhongnanhuang authored
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
                {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
2687
                {!isSupplier() ? (
zhongnanhuang authored
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
                  <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
2701
                ) : (
2702
                  ''
zhongnanhuang authored
2703
                )}
zhongnanhuang authored
2704
2705
2706
2707
              </Flex>
            </Flex>
            <Flex justify="flex-end">
              <Space.Compact direction="vertical" align="end">
zhongnanhuang authored
2708
                <Space wrap>
2709
                  {record.paths?.includes('postAudit') ? (
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setCurretnOptSubId(null);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.WAITING_FOR_POST_AUDIT);
                      }}
                    >
                      后置审核
                    </Button>
                  ) : (
                    ''
                  )}
2725
                  {record.paths?.includes('URGENT_INVOICE_AUDITING') ? (
2726
2727
2728
2729
2730
2731
2732
2733
2734
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.URGENT_INVOICE_AUDITING);
                      }}
                    >
2735
                      加急审核(新)
2736
2737
2738
2739
                    </Button>
                  ) : (
                    ''
                  )}
2740
                  {record.paths?.includes('URGENT_INVOICE_AUDITING_old') ? (
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(
                          CHECK_TYPE.URGENT_INVOICE_AUDITING_OLD,
                        );
                      }}
                    >
                      加急审核(旧)
                    </Button>
                  ) : (
                    ''
                  )}
2757
                  {record.paths?.includes('salesConfirm') && (
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
                    <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();
                        }
                      }}
                    />
                  )}
2788
                  {record.paths?.includes('uploadPaymentReceiptBill') ? (
zhongnanhuang authored
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setUploadPayBillModalVisible(true);
                      }}
                    >
                      回款
                    </Button>
                  ) : (
                    ''
                  )}
2803
                  {record.paths?.includes('modifiedAuditRequest') ? (
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.NODE_OPERATING_AUDIT);
                      }}
                    >
                      节点修改审核
                    </Button>
                  ) : (
                    ''
                  )}
2819
                  {record.paths?.includes('auditPaymentReceipt') ? (
zhongnanhuang authored
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.PAYMENT_RECEIPTS_AUDIT);
                      }}
                    >
                      回款审核
                    </Button>
                  ) : (
                    ''
                  )}
2835
                  {record.paths?.includes('modifiedLeaderAuditRequest') ? (
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.MODIFY_LEADER_AUDIT);
                      }}
                    >
                      领导修改审核
                    </Button>
                  ) : (
                    ''
                  )}
2851
                  {false ? (
2852
2853
2854
2855
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
2856
                        createOptObject(null, record.id);
2857
2858
2859
2860
2861
2862
2863
2864
2865
                        setFinancialReceiptsModalVisible(true);
                        setIsEdit(true);
                      }}
                    >
                      收款记录
                    </Button>
                  ) : (
                    ''
                  )}
2866
2867
                  {record.paths?.includes('reissue_old') ? (
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
                    /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'||
                        optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setReissueVisibleOld(true);
                        console.log(reissueVisible);
                      }}
                    >
                      重新开票(旧)
                    </Button>
                  ) : (
                    ''
                  )}
2885
                  {record.paths?.includes('confirmReissue_old') ? (
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setCurretnOptSubId(null);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE_OLD);
                      }}
                    >
                      重新开票审核(旧)
                    </Button>
                  ) : (
                    ''
                  )}
2902
                  {record.paths?.includes('reissue') ? (
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
                    /*optRecord.afterInvoicingStatus==='PARTIAL_INVOICING'||
                      optRecord.afterInvoicingStatus==='COMPLETE_INVOICING'*/
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setReissueVisible(true);
                      }}
                    >
2913
                      重新开票(新)
2914
2915
2916
2917
2918
                    </Button>
                  ) : (
                    ''
                  )}
2919
                  {record.paths?.includes('confirmReissue') ? (
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        setCurrentMainId(record.id);
                        setCurretnOptSubId(null);
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.CONFIRM_REISSUE);
                      }}
                    >
2930
                      重新开票审核(新)
2931
2932
2933
2934
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
2935
2936
                  {record.paths?.includes('procureOrder') ? (
zhongnanhuang authored
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
                    <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;
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}
2968
                  {record.paths?.includes('cancelSend') ? (
zhongnanhuang authored
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
                    <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;
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}
3000
                  {record.paths?.includes('applyModify') ? (
zhongnanhuang authored
3001
3002
3003
3004
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3005
                        createOptObject(null, record.id);
zhongnanhuang authored
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
                        setOrderDrawerVisible(true);
                        setOrderOptType('order-change-normal');
                      }}
                    >
                      申请修改
                    </Button>
                  ) : (
                    ''
                  )}
3016
                  {record.paths?.includes('leaderAudit') ? (
3017
3018
3019
3020
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3021
3022
3023
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
                        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
3037
                        createOptObject(null, record.id);
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.LEADER_AUDIT);
                      }}
                    >
                      审核
                    </Button>
                  ) : (
                    ''
                  )}
3048
                  {record.paths?.includes('changeOrderAudit') ? (
3049
3050
3051
3052
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3053
3054
3055
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
                        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
3069
                        createOptObject(null, record.id);
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
                        setCheckVisible(true);
                        setOrderCheckType(
                          CHECK_TYPE.MODIFY_APPLY_WAIT_FOR_AUDIT,
                        );
                      }}
                    >
                      审核
                    </Button>
                  ) : (
                    ''
                  )}
3082
                  {record.paths?.includes('creditAudit') ? (
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
                    <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>
                  ) : (
                    ''
                  )}
3114
                  {record.paths?.includes('editProductionTime') ? (
zhongnanhuang authored
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setProductionTimeModalVisible(true);
                      }}
                    >
                      生产时间
                    </Button>
                  ) : (
                    ''
                  )}
3129
                  {record.paths?.includes('procureConvertProcure') ? (
3130
3131
3132
3133
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3134
3135
3136
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3137
3138
3139
3140
3141
3142
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }

                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
3143
                            !selectedSubOrders[i].paths.includes(
3144
3145
3146
3147
3148
3149
3150
                              'procureConvertProcure',
                            )
                          ) {
                            message.error('请选择允许转发的子订单进行转发');
                            return;
                          }
                        }
3151
                        createOptObject(null, record.id);
3152
3153
3154
3155
3156
3157
3158
3159
3160
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                        setProcureConvertModalVisible(true);
                      }}
                    >
                      转发
                    </Button>
                  ) : (
                    ''
                  )}
3161
                  {record.paths?.includes('sendProduct') ? (
zhongnanhuang authored
3162
3163
3164
3165
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3166
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3167
3168
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3169
                        createOptObject(null, record.id);
zhongnanhuang authored
3170
                        setDeliverVisible(true);
zhongnanhuang authored
3171
                        setIsSendProduct(true);
zhongnanhuang authored
3172
                        setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
zhongnanhuang authored
3173
3174
                      }}
                    >
zhongnanhuang authored
3175
                      仓库发货
zhongnanhuang authored
3176
3177
3178
3179
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3180
3181

                  {/* 供应商发货 */}
3182
                  {record.paths?.includes('supplierSendOrder') ? (
zhongnanhuang authored
3183
3184
3185
3186
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3187
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3188
3189
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3190
                        createOptObject(null, record.id);
zhongnanhuang authored
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
                        setDeliverVisible(true);
                        setIsSendProduct(true);
                        setOrderCheckType(CHECK_TYPE.SUPPLIER);
                      }}
                    >
                      供应商发货
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3201
3202
                  {record.paths?.includes('procureSend') ? (
zhongnanhuang authored
3203
3204
3205
3206
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3207
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3208
3209
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3210
                        createOptObject(null, record.id);
zhongnanhuang authored
3211
3212
3213
3214
3215
                        setDeliverVisible(true);
                        setIsSendProduct(true);
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                      }}
                    >
zhongnanhuang authored
3216
                      {isSupplier() ? '发货' : '采购发货'}
zhongnanhuang authored
3217
3218
3219
3220
3221
                    </Button>
                  ) : (
                    ''
                  )}
3222
                  {record.paths?.includes('printOrder') ? (
zhongnanhuang authored
3223
3224
3225
3226
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3227
3228
3229
                        const selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3230
                        if (!selectedSubOrders?.length) {
zhongnanhuang authored
3231
3232
                          return message.error('请选择选择子订单');
                        }
3233
3234

                        for (let subOrderRecord of selectedSubOrders) {
3235
3236
                          let paths = subOrderRecord.paths;
                          if (!checkePrintable(paths)) {
3237
3238
3239
                            return message.error('请选择可以打印的子订单');
                          }
                        }
zhongnanhuang authored
3240
                        createOptObject(null, record.id);
zhongnanhuang authored
3241
                        setOrderPrintVisible(true);
zhongnanhuang authored
3242
                        setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
zhongnanhuang authored
3243
3244
                      }}
                    >
zhongnanhuang authored
3245
                      仓库打印
zhongnanhuang authored
3246
3247
3248
3249
                    </Button>
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3250
3251
                  {record.paths?.includes('supplierPrint') ? (
zhongnanhuang authored
3252
3253
3254
3255
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3256
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3257
3258
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3259
3260

                        createOptObject(null, record.id);
zhongnanhuang authored
3261
3262
3263
3264
                        setOrderPrintVisible(true);
                        setOrderCheckType(CHECK_TYPE.SUPPLIER);
                      }}
                    >
zhongnanhuang authored
3265
                      供应商打印
zhongnanhuang authored
3266
3267
3268
3269
3270
                    </Button>
                  ) : (
                    ''
                  )}
3271
                  {record.paths?.includes('rePrintOrder') ? (
zhongnanhuang authored
3272
3273
3274
3275
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3276
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3277
3278
                          return message.error('请选择选择子订单');
                        }
zhongnanhuang authored
3279
                        createOptObject(null, record.id);
zhongnanhuang authored
3280
3281
                        setOrderPrintVisible(true);
                        setIsRePrintOrder(true);
zhongnanhuang authored
3282
3283
                      }}
                    >
zhongnanhuang authored
3284
                      重新打印
zhongnanhuang authored
3285
3286
3287
3288
                    </Button>
                  ) : (
                    ''
                  )}
3289
                  {record.paths?.includes('confirmReceipt') ? (
zhongnanhuang authored
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
                        createOptObject(null, record.id);
                        setConfirmReceiptVisible(true);
                      }}
                    >
                      确认收货
                    </Button>
                  ) : (
                    ''
                  )}
3303
                  {record.paths?.includes('modifySendInformation') ? (
zhongnanhuang authored
3304
                    <Button
zhongnanhuang authored
3305
                      className="p-0"
zhongnanhuang authored
3306
3307
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3308
                        if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3309
3310
3311
3312
                          return message.error(
                            '请选择已经发货或者已经确认收货的子订单',
                          );
                        }
zhongnanhuang authored
3313
                        for (let row of subOrderSelectedMap.get(record.id)) {
zhongnanhuang authored
3314
3315
3316
3317
3318
3319
3320
3321
3322
                          if (
                            row.orderStatus !== 'CONFIRM_RECEIPT' &&
                            row.orderStatus !== 'SHIPPED'
                          ) {
                            return message.error(
                              '请选择已经发货或者已经确认收货的子订单',
                            );
                          }
                        }
zhongnanhuang authored
3323
                        createOptObject(null, record.id);
zhongnanhuang authored
3324
3325
                        setDeliverVisible(true);
                        setIsSendProduct(false);
zhongnanhuang authored
3326
3327
                      }}
                    >
zhongnanhuang authored
3328
                      修改发货信息
zhongnanhuang authored
3329
                    </Button>
zhongnanhuang authored
3330
3331
3332
                  ) : (
                    ''
                  )}
3333
                  {record.paths?.includes('invoicing') ? (
zhongnanhuang authored
3334
3335
                    <Button
                      type="link"
zhongnanhuang authored
3336
                      className="p-0"
zhongnanhuang authored
3337
                      onClick={() => {
zhongnanhuang authored
3338
                        createOptObject(null, record.id);
zhongnanhuang authored
3339
                        setFinancialVisible(true);
zhongnanhuang authored
3340
                        setIsEdit(false);
zhongnanhuang authored
3341
3342
                      }}
                    >
zhongnanhuang authored
3343
                      开票
zhongnanhuang authored
3344
3345
3346
3347
                    </Button>
                  ) : (
                    ''
                  )}
3348
3349
                  {record.paths?.includes('applyInvoicing_old') ? (
3350
3351
3352
3353
                    <Button
                      type="link"
                      className="p-0"
                      onClick={() => {
zhongnanhuang authored
3354
3355
3356
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3357
3358
3359
3360
3361
3362
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].invoicingStatus ===
柏杨 authored
3363
                              'UN_INVOICE' ||
3364
                            selectedSubOrders[i].afterInvoicingStatus ===
柏杨 authored
3365
                              'APPLY_FOR_INVOICING'
3366
3367
3368
3369
3370
3371
3372
                          ) {
                            message.error(
                              '请选择需要开票且未申请开票的子订单进行申请',
                            );
                            return;
                          }
                        }
zhongnanhuang authored
3373
3374

                        createOptObject(null, record.id);
3375
                        setApplyForInvoicingVisible(true);
zhongnanhuang authored
3376
                        setIsEdit(false);
zhongnanhuang authored
3377
                        setIsMainOrder(false);
3378
3379
                      }}
                    >
3380
                      申请开票(旧)
3381
3382
3383
                    </Button>
                  ) : (
                    ''
3384
                  )}
3385
3386
                  {record.paths?.includes('applyInvoicing') ? (
曾国涛 authored
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
                    <Button
                      type="link"
                      className="p-0"
                      onClick={() => {
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].invoicingStatus ===
柏杨 authored
3400
                              'UN_INVOICE' ||
曾国涛 authored
3401
                            selectedSubOrders[i].afterInvoicingStatus ===
柏杨 authored
3402
                              'APPLY_FOR_INVOICING'
曾国涛 authored
3403
3404
3405
                          ) {
                            message.error(
                              '请选择需要开票且未申请开票的子订单进行申请',
曾国涛 authored
3406
                            );
曾国涛 authored
3407
3408
3409
                            return;
                          }
                        }
曾国涛 authored
3410
曾国涛 authored
3411
3412
3413
3414
3415
3416
                        createOptObject(null, record.id);
                        setInvoicingDrawerFormVisible(true);
                        setIsEdit(false);
                        setIsMainOrder(false);
                      }}
                    >
3417
                      申请开票(新)
曾国涛 authored
3418
                    </Button>
曾国涛 authored
3419
                  ) : (
曾国涛 authored
3420
                    ''
3421
3422
                  )}
3423
3424
                  {record.paths?.includes('confirmInvoice') ? (
                    <ButtonConfirm
柏杨 authored
3425
                      className="p-0"
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
                      title="已和客户确认发票?"
                      text="确认发票"
                      onConfirm={async () => {
                        const data = await postServiceOrderConfirmInvoice({
                          data: [
                            ...record.subOrderInformationLists.map(
                              (subOrder) => subOrder.id,
                            ),
                          ],
                        });
                        if (data.result === RESPONSE_CODE.SUCCESS) {
                          message.success(data.message);
                          refreshTable();
                        }
柏杨 authored
3440
                      }}
3441
                    />
柏杨 authored
3442
3443
3444
3445
                  ) : (
                    ''
                  )}
3446
                  {record.paths?.includes('updateOrder') ? (
zhongnanhuang authored
3447
3448
3449
3450
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3451
                        //勾选的子订单:如果有勾选,后面只校验有勾选的
3452
zhongnanhuang authored
3453
3454
3455
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
                        if (
                          selectedSubOrders === undefined ||
                          selectedSubOrders.length === 0
                        ) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        for (
                          let index = 0;
                          index < selectedSubOrders.length;
                          index++
                        ) {
                          let orderStatus =
                            selectedSubOrders[index].orderStatus;
3469
                          //仓库管理员在审核之后的任何时候都可以编辑
zhongnanhuang authored
3470
                          if (
3471
3472
                            roleCode !== 'warehouseKeeper' &&
                            roleCode !== 'admin'
zhongnanhuang authored
3473
                          ) {
3474
3475
3476
                            //是审核通过及之后的订单
                            if (
                              orderStatus !== 'UNAUDITED' &&
3477
                              orderStatus !== 'AUDIT_FAILED' &&
3478
                              orderStatus !== 'LEADER_PROCESS' &&
zhongnanhuang authored
3479
3480
                              orderStatus !== 'SALES_CONFIRM' &&
                              orderStatus !== 'CREDIT_CONFIRM'
3481
3482
                            ) {
                              message.error(
zhongnanhuang authored
3483
                                '请选择【未审核、审核失败、销售待确认、赊账待审核】的订单进行编辑',
3484
3485
3486
3487
3488
3489
                              );
                              return;
                            }
                          } else {
                            //仓库管理员只能编辑是还未审核的订单
                            if (
3490
                              roleCode !== 'admin' &&
3491
3492
3493
3494
3495
3496
                              (orderStatus === 'UNAUDITED' ||
                                orderStatus === 'AUDIT_FAILED')
                            ) {
                              message.error('请选择已审核的订单进行编辑');
                              return;
                            }
zhongnanhuang authored
3497
3498
                          }
                        }
zhongnanhuang authored
3499
3500

                        createOptObject(null, record.id);
zhongnanhuang authored
3501
3502
                        setOrderDrawerVisible(true);
                        setOrderOptType('edit');
zhongnanhuang authored
3503
3504
                      }}
                    >
zhongnanhuang authored
3505
                      编辑
zhongnanhuang authored
3506
3507
3508
3509
                    </Button>
                  ) : (
                    ''
                  )}
3510
3511
                  {record?.subOrderInformationLists[0].paths?.includes(
zhongnanhuang authored
3512
                    'noNeedInvoicingEdit',
3513
                  ) ? (
3514
3515
3516
3517
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3518
                        createOptObject(null, record.id);
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
                        setFinancialEditVisible(true);
                        setIsMainOrder(true);
                      }}
                    >
                      财务编辑
                    </Button>
                  ) : (
                    ''
                  )}
3529
                  {record.paths?.includes('checkOrder') ? (
zhongnanhuang authored
3530
3531
3532
3533
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3534
3535
3536
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3537
3538
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
3539
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
3540
                        }
3541
                        for (let i = 0; i < selectedSubOrders.length; i++) {
3542
                          let orderStatus = selectedSubOrders[i].orderStatus;
zhongnanhuang authored
3543
                          if (
3544
3545
3546
                            orderStatus !== 'UNAUDITED' &&
                            orderStatus !== 'FINANCE_PROCESS' &&
                            orderStatus !== 'LEADER_AUDITED'
zhongnanhuang authored
3547
                          ) {
3548
3549
3550
                            message.error(
                              '请选择未审核或者领导已审核的子订单进行审核',
                            );
zhongnanhuang authored
3551
3552
3553
                            return;
                          }
                        }
zhongnanhuang authored
3554
3555

                        createOptObject(null, record.id);
zhongnanhuang authored
3556
                        setCheckVisible(true);
zhongnanhuang authored
3557
                        setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
zhongnanhuang authored
3558
3559
3560
3561
3562
3563
3564
3565
                      }}
                    >
                      审核
                    </Button>
                  ) : (
                    ''
                  )}
3566
                  {record.paths?.includes('afterSalesCheck') ? (
3567
3568
3569
3570
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3571
3572
3573
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3574
3575
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
3576
                          selectedSubOrders = record.subOrderInformationLists;
3577
                        }
3578
                        for (let i = 0; i < selectedSubOrders.length; i++) {
3579
                          if (
3580
3581
                            selectedSubOrders[i].orderStatus !==
                            'IN_AFTER_SALES'
3582
3583
                          ) {
                            message.error('请选择售后中的子订单进行审核');
3584
3585
3586
                            return;
                          }
                        }
zhongnanhuang authored
3587
3588

                        createOptObject(null, record.id);
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
                        setCheckVisible(true);
                        setOrderCheckType(CHECK_TYPE.AFTER_SALES);
                      }}
                    >
                      售后审核
                    </Button>
                  ) : (
                    ''
                  )}
3599
                  {record.paths?.includes('noNeedSend') ? (
zhongnanhuang authored
3600
3601
3602
3603
3604
                    <ButtonConfirm
                      className="p-0"
                      title="此订单是否无需发货?"
                      text="无需发货"
                      onConfirm={async () => {
zhongnanhuang authored
3605
3606
3607
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3608
3609
3610
3611
3612
3613
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
zhongnanhuang authored
3614
                            selectedSubOrders[i].orderStatus !== 'AUDITED' &&
zhongnanhuang authored
3615
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3616
                              'PROCURE_PROCESS' &&
zhongnanhuang authored
3617
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3618
                              'PROCURE_PROCESS_FOR_MINE' &&
zhongnanhuang authored
3619
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3620
                              'PROCURE_WAIT_SHIP' &&
zhongnanhuang authored
3621
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3622
                              'SUPPLIER_WAIT_SHIP' &&
zhongnanhuang authored
3623
                            selectedSubOrders[i].orderStatus !== 'WAIT_SHIP'
zhongnanhuang authored
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
                          ) {
                            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();
                        }
                      }}
                    />
                  ) : (
3646
3647
3648
                    ''
                  )}
3649
                  {record.paths?.includes('saleCancelInvoicing_old') ? (
3650
3651
3652
                    <ButtonConfirm
                      className="p-0"
                      title="确认取消申请开票?"
3653
                      text="取消申请(旧)"
3654
                      onConfirm={async () => {
zhongnanhuang authored
3655
3656
3657
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
3658
3659
3660
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
zhongnanhuang authored
3661
3662
                        console.log(selectedSubOrders);
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
                        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
3689
3690
                    ''
                  )}
zhongnanhuang authored
3691
                  {/* 财务审核:主订单暂无 */}
3692
                  {record.paths?.includes('financeCheckOrder') ? (
zhongnanhuang authored
3693
3694
3695
3696
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3697
3698
3699
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3700
3701
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
3702
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
3703
                        }
3704
                        for (let i = 0; i < selectedSubOrders.length; i++) {
zhongnanhuang authored
3705
                          if (
3706
3707
                            selectedSubOrders[i].orderStatus !== 'UNAUDITED' &&
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3708
                              'FINANCE_PROCESS' &&
zhongnanhuang authored
3709
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3710
                              'LEADER_AUDITED'
zhongnanhuang authored
3711
                          ) {
zhongnanhuang authored
3712
3713
3714
                            message.error(
                              '请选择[未审核]、[财务待审核]、[领导已审核]的子订单进行审核',
                            );
zhongnanhuang authored
3715
3716
3717
                            return;
                          }
                        }
zhongnanhuang authored
3718
                        createOptObject(null, record.id);
zhongnanhuang authored
3719
                        setCheckVisible(true);
zhongnanhuang authored
3720
                        setOrderCheckType(CHECK_TYPE.FINALCIAL);
zhongnanhuang authored
3721
3722
                      }}
                    >
zhongnanhuang authored
3723
3724
3725
3726
3727
3728
3729
                      财务审核
                    </Button>
                  ) : (
                    ''
                  )}

                  {/* 采购审核 */}
3730
                  {record.paths?.includes('procureCheckOrder') ? (
zhongnanhuang authored
3731
3732
3733
3734
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3735
3736
3737
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3738
3739
                        setSelectedRows(selectedSubOrders);
                        if (selectedSubOrders === undefined) {
3740
                          selectedSubOrders = record.subOrderInformationLists;
zhongnanhuang authored
3741
                        }
3742
                        for (let i = 0; i < selectedSubOrders.length; i++) {
zhongnanhuang authored
3743
                          if (
3744
3745
                            selectedSubOrders[i].orderStatus !==
                            'PROCURE_UN_PROCESS'
zhongnanhuang authored
3746
3747
3748
3749
3750
                          ) {
                            message.error('请选择未审核的子订单进行审核');
                            return;
                          }
                        }
zhongnanhuang authored
3751
3752

                        createOptObject(null, record.id);
zhongnanhuang authored
3753
3754
3755
3756
3757
                        setProcureCheckModalVisible(true);
                        setOrderCheckType(CHECK_TYPE.PROCURE);
                      }}
                    >
                      采购审核
zhongnanhuang authored
3758
3759
3760
3761
3762
                    </Button>
                  ) : (
                    ''
                  )}
3763
                  {record.paths?.includes('applyAfterSales') ? (
zhongnanhuang authored
3764
3765
3766
3767
                    <Button
                      className="p-0"
                      type="link"
                      onClick={() => {
zhongnanhuang authored
3768
3769
3770
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3771
3772
3773
3774
3775
3776
3777
                        if (selectedSubOrders === undefined) {
                          selectedSubOrders = record.subOrderInformationLists;
                        }
                        setSelectedRows(selectedSubOrders);
                        for (let i = 0; i < selectedSubOrders.length; i++) {
                          if (
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3778
                              'CONFIRM_RECEIPT' &&
zhongnanhuang authored
3779
                            selectedSubOrders[i].orderStatus !==
柏杨 authored
3780
                              'AFTER_SALES_FAILURE'
zhongnanhuang authored
3781
3782
3783
3784
3785
                          ) {
                            message.error('请选择确认收货状态的子订单进行售后');
                            return;
                          }
                        }
zhongnanhuang authored
3786
3787

                        createOptObject(null, record.id);
3788
                        setOrderDrawerVisible(true);
3789
                        setOrderOptType('after-sales');
zhongnanhuang authored
3790
3791
3792
3793
3794
3795
3796
3797
                      }}
                    >
                      申请售后
                    </Button>
                  ) : (
                    ''
                  )}
3798
                  {/* {record.paths?.includes('afterSalesCompletion') ? (
zhongnanhuang authored
3799
3800
3801
3802
3803
                    <ButtonConfirm
                      className="p-0"
                      title="售后是否已完成?"
                      text="完成售后"
                      onConfirm={async () => {
zhongnanhuang authored
3804
                        let selectedSubOrders = subOrderSelectedMap.get(record.id);
zhongnanhuang authored
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
                        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();
                        }
                      }}
                    />
                  ) : (
                    ''
3840
                  )} */}
zhongnanhuang authored
3841
3842
                  {record.paths?.includes('salOrderSave') ? (
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
                    <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();
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}
3864
                  {record.paths?.includes('salBillOutbound') ? (
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
                    <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();
                        }
                      }}
                    />
                  ) : (
                    ''
                  )}
3886
                  {record.paths?.includes('orderCancel') ? (
zhongnanhuang authored
3887
                    <ButtonConfirm
zhongnanhuang authored
3888
                      className="p-0"
zhongnanhuang authored
3889
3890
3891
                      title="确认作废?"
                      text="作废"
                      onConfirm={async () => {
zhongnanhuang authored
3892
3893
3894
3895
                        let body = {
                          ids: [record.id],
                          checkIsMainOrderId: true,
                        };
zhongnanhuang authored
3896
3897
3898
3899
3900
3901
3902
                        const data = await postServiceOrderOrderCancel({
                          data: body,
                        });
                        if (data.result === RESPONSE_CODE.SUCCESS) {
                          message.success(data.message);
                          refreshTable();
                        }
zhongnanhuang authored
3903
                      }}
zhongnanhuang authored
3904
                    />
zhongnanhuang authored
3905
3906
3907
                  ) : (
                    ''
                  )}
zhongnanhuang authored
3908
3909
                  {record.paths?.includes('procurePrint') ? (
zhongnanhuang authored
3910
                    <ButtonConfirm
zhongnanhuang authored
3911
                      className="p-0"
zhongnanhuang authored
3912
3913
3914
                      title="确认打印?"
                      text="采购打印"
                      onConfirm={async () => {
zhongnanhuang authored
3915
3916
3917
                        let selectedSubOrders = subOrderSelectedMap.get(
                          record.id,
                        );
zhongnanhuang authored
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
                        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
3945
3946
                        }
                      }}
zhongnanhuang authored
3947
                    />
zhongnanhuang authored
3948
                  ) : (
zhongnanhuang authored
3949
3950
3951
3952
                    // <Button
                    //   className="p-0"
                    //   type="link"
                    //   onClick={() => {
zhongnanhuang authored
3953
                    //     if (!subOrderSelectedMap.get(record.id)?.length) {
zhongnanhuang authored
3954
3955
                    //       return message.error('请选择选择子订单');
                    //     }
zhongnanhuang authored
3956
                    //     setSelectedRows(subOrderSelectedMap.get(record.id));
zhongnanhuang authored
3957
3958
3959
3960
3961
3962
3963
                    //     setOrderRow(record);
                    //     setOrderPrintVisible(true);
                    //     setOrderCheckType(CHECK_TYPE.PROCURE);
                    //   }}
                    // >
                    //   采购打印
                    // </Button>
zhongnanhuang authored
3964
3965
                    ''
                  )}
zhongnanhuang authored
3966
3967
3968
3969
3970
3971
                </Space>
              </Space.Compact>
            </Flex>
          </Flex>
        </Flex>
zhongnanhuang authored
3972
        <Flex className="p-0 pb-[24px] pt-[4px] pl-[23px] pr-[5px] bg-white rounded-b-lg">
zhongnanhuang authored
3973
3974
3975
          {expandedRowRender(record)}
        </Flex>
      </Flex>
3976
3977
3978
    );
  };
zhongnanhuang authored
3979
3980
3981
  // 主订单列表
  const mainOrdersColumns: ProColumns<OrderType>[] = MAIN_ORDER_COLUMNS.map(
    (item) => {
3982
      //首能账号只能搜索订单编号
3983
3984
3985
3986
3987
3988
      let canSearchIndex = [
        'id',
        'salesCode',
        'subNotes',
        'orderStatus',
        'createTime',
3989
        'modifiedAuditStatus',
3990
      ];
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
      if (isSupplier() && !canSearchIndex.includes(item.dataIndex)) {
        item.search = false;
      }

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

      if (isExaminer() && !canSearchIndex.includes(item.dataIndex)) {
4006
4007
        item.search = false;
      }
4008
zhongnanhuang authored
4009
4010
4011
4012
4013
4014
4015
4016
4017
      if (item.dataIndex === 'name') {
        return {
          ...item,
          title: <OrderTableHeader />,
          render: (text, record) => {
            return <MainOrderColumnRender record={record} />;
          },
        };
      }
zhongnanhuang authored
4018
4019
4020
4021

      /**
       * 采购的订单状态筛选内容
       */
4022
      if (roleCode === 'procure' && item.dataIndex === 'orderStatus') {
zhongnanhuang authored
4023
4024
4025
4026
        item.valueEnum = enumToProTableEnumValue(
          PROCURE_PRIMARY_ORDER_STATUS_OPTIONS,
        );
      }
zhongnanhuang authored
4027
4028
4029
4030
      return item;
    },
  );
4031
4032
4033
  /**
   * 采购可以筛选供应商备注
   */
4034
  if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) {
4035
4036
4037
4038
4039
4040
4041
4042
4043
    mainOrdersColumns.push({
      title: '供应商备注',
      width: 120,
      dataIndex: 'supplierNotes',
      valueType: 'text',
      hideInTable: true,
    });
  }
zhongnanhuang authored
4044
4045
4046
  /**
   * 采购可以筛选其他采购
   */
4047
  if ((roleCode === 'procure' || roleCode === 'admin') && !isSupplier()) {
zhongnanhuang authored
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
    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,
    });
  }

  /**
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
   * 排除采购
   */
  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
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
   * 仓库可以筛选发货仓库
   */
  if (roleCode === 'warehouseKeeper' || roleCode === 'admin') {
    mainOrdersColumns.push({
      title: '发货仓库',
      width: 120,
      dataIndex: 'shippingWarehouse',
      valueType: 'select',
      valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS),
      hideInTable: true,
    });
  }
4101
  //判断是否是采购,是的话新增一个筛选条件
4102
  if (roleCode === 'procure' || roleCode === 'admin') {
4103
    mainOrdersColumns.push({
zhongnanhuang authored
4104
      title: isSupplier() ? '下单状态' : '采购下单状态',
4105
4106
4107
4108
4109
4110
4111
      dataIndex: 'procureOrderStatus',
      valueType: 'select',
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
    });
  }
柏杨 authored
4112
4113
4114
  //选择天数1
  const options1 = [
    {
柏杨 authored
4115
4116
      label: '超过5天',
      value: 5,
柏杨 authored
4117
4118
    },
    {
柏杨 authored
4119
4120
      label: '超过15天',
      value: 15,
柏杨 authored
4121
4122
    },
  ];
4123
4124
4125
  //选择天数
  const [calDate, setCalDate] = useState<string | null>(null);
  const [calDate2, setCalDate2] = useState<string | null>(null);
柏杨 authored
4126
4127
  const [value1, setValue1] = useState();
  const radioOnChange1 = ({ target: { value } }) => {
4128
4129
4130
    const currentDate = new Date();
    // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天
    const newDate = new Date(currentDate);
柏杨 authored
4131
    newDate.setDate(currentDate.getDate() - value);
4132
4133
    const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss');
    setCalDate(formattedDate);
柏杨 authored
4134
4135
4136
4137
4138
4139
    setValue1(value);
  };
  //选择天数2
  const options2 = [
    {
      label: '超过15天',
4140
      value: 15,
柏杨 authored
4141
4142
4143
    },
    {
      label: '超过25天',
4144
      value: 25,
柏杨 authored
4145
4146
4147
4148
    },
  ];
  const [value2, setValue2] = useState();
  const radioOnChange2 = ({ target: { value } }) => {
4149
4150
4151
4152
    const currentDate = new Date();

    // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天
    const newDate = new Date(currentDate);
柏杨 authored
4153
    newDate.setDate(currentDate.getDate() - value);
4154
4155
    const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss');
    setCalDate2(formattedDate);
柏杨 authored
4156
4157
    setValue2(value);
  };
4158
  const confirmInvoice = async () => {
柏杨 authored
4159
    let flat = [...subOrderSelectedMap.values()].flat().map((item) => item.id);
4160
    const data = await postServiceOrderConfirmInvoice({
柏杨 authored
4161
      data: flat,
4162
4163
4164
4165
4166
    });
    if (data.result === RESPONSE_CODE.SUCCESS) {
      message.success(data.message);
      refreshTable();
    }
柏杨 authored
4167
  };
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
  const [invoiceWarningNum, setInvoiceWarningNum] = useState(0);
  const [invoiceRefundWarningNum, setInvoiceRefundWarningNum] = useState(0);
  async function getInvoiceWarningNum() {
    const res = await postServiceOrderWarningOrderStatistics();
    setInvoiceWarningNum(res.data.waitConfirmInvoice);
    setInvoiceRefundWarningNum(res.data.waitConfirmReceipt);
  }
  useEffect(() => {
    //预警订单数
    getInvoiceWarningNum();
  }, []);
  //biaojiup
  // 监听 calDate 变化,触发请求
  useEffect(() => {
    if (calDate) {
      mainTableRef.current?.reload();
    }
  }, [calDate]);
柏杨 authored
4187
  const request = async (params: any, sorter: any, filter: any) => {
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
    let orderIds = mainTableFormRef.current?.getFieldValue('id');
    let subOrderId = mainTableFormRef.current?.getFieldValue('subOrderId');
    params.id = params.id || orderIds;
    params.subOrderId = params.subOrderId || subOrderId;
    if (params.id !== '') {
      params.id = params.id?.replace(/ /g, '');
      if (params.id?.indexOf(',')) {
        params.id = params.id.split(',');
        params.id = params.id.filter((id) => id !== '');
      }
    }
    params.salesCode = userInfo.username;
    params.condition = filterCondifion;
4201
    params.paymentMethod = 'UNPAID';
4202
4203
4204
    params.sorted = sorted;
    // params.isDeleteQueryOrder = filterCondifion === 70;
    params.isDeleteQueryOrder = false;
柏杨 authored
4205
    params.invoiceConfirmStatusNe = 'CONFIRMED';
柏杨 authored
4206
    params.invoicingStatusNe = 'UN_INVOICE';
4207
    if (calDate === 'null') {
柏杨 authored
4208
      params.applyTimeLe = null;
4209
    } else {
柏杨 authored
4210
      params.applyTimeLe = calDate;
4211
    }
柏杨 authored
4212
    params.applyTimeIsNotNull = true;
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
    setSearchParam(params);

    const res = await postServiceOrderQueryServiceOrder({
      sorter,
      filter,
      data: { ...params, statusDatetimeGe: calDate },
    });

    const data = res.data;
    setRolePath(data.specialPath);
    setSubOrderCount(data.count);
    setAllMainChecked(false);
    setSelectedMainOrderKeys([]);
    subOrderSelectedMap.clear();
    mainOrderSelectedMap.clear();
    setData(data?.data);

    mainOrderIdSubOrderIdRelationsMap.clear();
    for (let row of data?.data) {
      let mianOrderId = row.id;
      let subOrderIds = row.subOrderInformationLists?.map((item) => {
        item.totalPayment = row.totalPayment;
        return item.id;
      });
      mainOrderIdSubOrderIdRelationsMap.set(mianOrderId, subOrderIds);
    }

    return {
      data: data?.data || [],
      total: data?.total || 0,
    };
  };
  //biaojidown

  //biaojiup2
  // 监听 calDate 变化,触发请求
  useEffect(() => {
    if (calDate2) {
4251
4252
      // mainTableRef.current?.reload();
      mainTableSecondRef.current?.reload();
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
    }
  }, [calDate2]);

  const request2 = async (
    // 第一个参数 params 查询表单和 params 参数的结合
    // 第一个参数中一定会有 pageSize 和  current ,这两个参数是 antd 的规范
    params,
    sorter,
    filter,
  ) => {
柏杨 authored
4263
    params.invoiceConfirmStatus = 'CONFIRMED';
4264
    params.paymentMethod = 'UNPAID';
柏杨 authored
4265
    params.salesCode = userInfo.username;
4266
    if (calDate2 === 'null') {
柏杨 authored
4267
      params.invoiceConfirmStatusDatetimeLe = null;
4268
    } else {
柏杨 authored
4269
      params.invoiceConfirmStatusDatetimeLe = calDate2;
4270
4271
4272
4273
4274
4275
    }
    //订单id处理
    /**
     * 以params中的id为主,如果params没id,则取url中的id
     * 第一次进来这个页面,url带有id的话,会自动填充到查询表单中,但是第一次查询params不会带这个id进来
     */
4276
4277
4278
    let orderIds = mainTableSecondFormRef.current?.getFieldValue('id');
    let subOrderId =
      mainTableSecondFormRef.current?.getFieldValue('subOrderId');
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
    params.id = params.id || orderIds;
    params.subOrderId = params.subOrderId || subOrderId;
    if (params.id !== '') {
      params.id = params.id?.replace(/ /g, '');
      if (params.id?.indexOf(',')) {
        params.id = params.id.split(',');
        params.id = params.id.filter((id) => {
          return id !== '';
        });
      }
    }

    params.condition = filterCondifion;

    //排序
    params.sorted = sorted;
    //是否只查看已作废
    params.isDeleteQueryOrder = filterCondifion === 70;
柏杨 authored
4297
    params.paymentNotReceipt = true;
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
    //保存这个搜索条件
    setSearchParam(params);

    //订单标记2
    const { data } = await postServiceOrderQueryServiceOrder({
      // ...params,
      // FIXME: remove @ts-ignore
      // @ts-ignore
      sorter,
      filter,
      data: { ...params },
    });

    setRolePath(data.specialPath);
    setSubOrderCount(data.count);
    setAllMainChecked(false);
    setSelectedMainOrderKeys([]);
    subOrderSelectedMap.clear();
    mainOrderSelectedMap.clear();
    setData(data?.data);

    //主订单id与子订单id的对照关系保存
    mainOrderIdSubOrderIdRelationsMap.clear();
    for (let row of data?.data) {
      let mianOrderId = row.id;
      let subOrderIds = row.subOrderInformationLists?.map((item) => {
        //目前子订单存储的totalPayment不准确,这里重新处理取主订单的totalPayment
        //totalPayment在财务开票计算金额时使用到
        item.totalPayment = row.totalPayment;
        return item.id;
      });
      mainOrderIdSubOrderIdRelationsMap.set(mianOrderId, subOrderIds);
    }

    return {
      data: data?.data || [],
      total: data?.total || 0,
    };
柏杨 authored
4336
  };
4337
4338
4339
4340
4341
4342
4343
4344
  //biaojidown2
  //取消单选,将时间设为null
  const handleSetNull = () => {
    setCalDate('null'); // 这应该会触发 useEffect
  };
  const handleSetNull2 = () => {
    setCalDate2('null'); // 这应该会触发 useEffect
  };
柏杨 authored
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
  const tabsItems = [
    {
      key: 1,
      label: (
        <span>
          发票确认预警
          <Badge count={invoiceWarningNum} style={{ marginLeft: 8 }} />
        </span>
      ),
      children: (
        <div>
          <div style={{ position: 'relative' }}>
4357
4358
4359
4360
            {/* <Radio.Group options={options1} onChange={radioOnChange1} value={value1} /> */}
            <Radio.Group
              value={value1}
              onChange={radioOnChange1}
柏杨 authored
4361
              // 通过 onClick 处理单独 Radio 的点击事件
4362
            >
柏杨 authored
4363
              {options1.map((option) => (
4364
4365
4366
4367
                <Radio
                  key={option.value}
                  value={option.value}
                  onClick={(e) => {
柏杨 authored
4368
4369
4370
                    radioOnChange1(
                      e as unknown as React.ChangeEvent<HTMLInputElement>,
                    );
4371
                    handleSetNull();
柏杨 authored
4372
                  }}
4373
4374
4375
4376
4377
                >
                  {option.label}
                </Radio>
              ))}
            </Radio.Group>
柏杨 authored
4378
            <Button
柏杨 authored
4379
              size="large"
柏杨 authored
4380
4381
4382
4383
              type="primary"
              onClick={confirmInvoice}
              style={{ position: 'absolute', right: '20px' }}
            >
4384
              确认发票
柏杨 authored
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
            </Button>
          </div>
          <div style={{ height: '25px' }}></div>
          <ProTable
            id="main-table"
            // tableStyle={{backgroundColor:'red'}}

            actionRef={mainTableRef}
            formRef={mainTableFormRef}
            expandIconColumnIndex={-1}
            columns={mainOrdersColumns}
            rowKey="id"
            pagination={{
              showQuickJumper: true,
              pageSize: pageSize,
              current: currentPage,
              showSizeChanger: true,
              onChange: (page, size) => {
                setPageSize(size);
                setCurrentPage(page);
              },
              showTotal: (total, range) => {
                return (
                  <>
                    <span>
                      {'第 ' +
                        range[0] +
                        '-' +
                        range[1] +
                        ' 条/总共 ' +
                        total +
                        ' 条主订单 '}
                    </span>
                    <span className="text-[#8C8C8C]">
                      {' (' + subOrderCount + ' 条子订单)'}
                    </span>
                  </>
                );
              },
            }}
            // showHeader={false}
            expandedRowKeys={expandedRowKeys}
            // expandable={{ expandedRowRender }}
            dateFormatter="string"
            options={false}
            headerTitle=""
            search={false}
            // labelWidth: 'auto',
            // onCollapse: resize,
4434
            request={request}
柏杨 authored
4435
4436
4437
            toolbar={{
              multipleLine: true,
            }}
柏杨 authored
4438
4439
4440
            // toolBarRender={() => {
            //   return toolBarRender();
            // }}
柏杨 authored
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
          />

          {orderDrawerVisible && (
            <OrderDrawer
              data={orderOptType === 'add' ? {} : buildMainOrder()}
              subOrders={orderOptType === 'add' ? [] : buildSubOrders()}
              onClose={(isSuccess: boolean) => {
                setOrderDrawerVisible(false);
                clearOptObject();
                if (isSuccess) {
                  refreshTable();
                }
              }}
              orderOptType={orderOptType}
            />
          )}

          {checkVisible && (
            <CheckModal
              setCheckVisible={(val: boolean) => {
                setCheckVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              data={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              orderCheckType={orderCheckType}
              openOrderDrawer={(type: any, id: any) => {
                setCurrentMainId(id);
                setOrderOptType(type);
                setOrderDrawerVisible(true);
              }}
              onClose={() => {
                clearOptObject();
                setCheckVisible(false);
                refreshTable();
              }}
            />
          )}

          {applyForInvoicingVisible && (
            <ApplyForInvoicingModal
              setCheckVisible={(val: boolean) => {
                setApplyForInvoicingVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              totalPayment={getApplyInvoicingTotalPayment()}
              isMainOrder={isMainOrder}
              isEdit={isEdit}
              onClose={() => {
                setApplyForInvoicingVisible(false);
                setIsMainOrder(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}

          {notesEditVisible && (
            <OrderNotesEditModal
              setNotesEditVisible={(val: boolean) => {
                setNotesEditVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              ids={selectedRows}
              notesType={notesType}
              notes={notes}
              onClose={() => {
                setNotesEditVisible(false);
                setSelectedRows([]);
                setNotes(notes);
                setNotesType(1);
                refreshTable();
              }}
            />
          )}

          {deliverVisible && (
            <DeliverModal
              data={buildSubOrders()}
              isSendProduct={isSendProduct}
              setVisible={(val: boolean) => {
                setDeliverVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              sendType={orderCheckType}
              onClose={() => {
                clearOptObject();
                setDeliverVisible(false);
                setIsSendProduct(false);
                refreshTable();
              }}
            />
          )}

          {financialVisible && (
            <FinancialDrawer
              isEdit={isEdit}
              mainOrder={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              isMainOrder={isMainOrder}
              cancel={() => {
                setFinancialVisible(false);
                clearOptObject();
                setIsMainOrder(false);
                setIsEdit(false);
              }}
              onClose={() => {
                setFinancialVisible(false);
                clearOptObject();
                refreshTable();
                setIsMainOrder(false);
                setIsEdit(false);
              }}
            />
          )}

          {financialEditVisible && (
            <FinancialEditDrawer
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              isMainOrder={isMainOrder}
              setVisible={() => {
                setFinancialEditVisible(false);
                clearOptObject();
              }}
              onClose={() => {
                setFinancialEditVisible(false);
                refreshTable();
                setIsMainOrder(false);
                clearOptObject();
              }}
            />
          )}

          {orderPrintVisible && (
            <OrderPrintModal
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              isRePrint={isRePrintOrder}
              setVisible={(val: boolean) => {
                setOrderPrintVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              printOptType={orderCheckType}
              onClose={() => {
                setOrderPrintVisible(false);
                clearOptObject();
                setIsRePrintOrder(false);
                refreshTable();
              }}
            />
          )}

          {confirmReceiptVisible && (
            <ConfirmReceiptModal
              data={buildSubOrders()}
              onClose={() => {
                setConfirmReceiptVisible(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}

          {imagesViewerModalVisible && (
            <ImagesViewerModal
              optType={imagesViewerOptType}
              setVisible={(val: boolean) => {
                setImagesViewerModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              onClose={() => {
                setImagesViewerModalVisible(false);
              }}
              orderRow={buildSubOrders()[0]}
            />
          )}

          {importModalVisible && (
            <ImportModal
              onClose={() => {
                setImportModalVisible(false);
                refreshTable();
              }}
            />
          )}

          {attachmentModalVisible && (
            <AttachmentModal
              data={buildSubOrders()[0]}
              onClose={() => {
                setAttachmentModalVisible(false);
                clearOptObject();
              }}
            />
          )}

          {historyModalVisible && (
            <HistoryModal
              subOrders={selectedRows}
              isCancelledOrder={filterCondifion === 70}
              onClose={() => {
                setHistoryModalVisible(false);
                setSelectedRows({});
                clearOptObject();
              }}
            />
          )}

          {deliverInfoDrawerVisible && (
            <DeliverInfoDrawer
              data={buildMainOrder()}
              onClose={() => {
                setDeliverInfoDrawerVisible(false);
                clearOptObject();
              }}
            />
          )}

          {deliverInfoDrawerVisible && (
            <DeliverInfoDrawer
              data={buildMainOrder()}
              onClose={() => {
                setDeliverInfoDrawerVisible(false);
                clearOptObject();
              }}
            />
          )}

          {procureCheckModalVisible && (
            <ProcureCheckModal
              setCheckVisible={(val: boolean) => {
                setProcureCheckModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              isMainOrder={isMainOrder}
              orders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              onClose={() => {
                setProcureCheckModalVisible(false);
                clearOptObject();
                setIsMainOrder(false);
                refreshTable();
              }}
            />
          )}

          {afterSalesDrawerVisible && (
            <AfterSalesDrawer
              setVisible={(val: boolean) => {
                setAfterSalesDrawerVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              onClose={() => {
                setAfterSalesDrawerVisible(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}

          {procureConvertModalVisible && (
            <ProcureConvertModal
              setVisible={(val: boolean) => {
                setProcureConvertModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              subOrders={buildSubOrders()}
              onClose={() => {
                setProcureConvertModalVisible(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}

          {financialMergeDrawerVisible && (
            <FinancialMergeDrawer
              setVisible={(val: boolean) => {
                setFinancialMergeDrawerVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              dataList={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              onClose={() => {
                setFinancialMergeDrawerVisible(false);
                setIsMainOrder(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}

          {financialReceiptsModalVisible && (
            <FinancialReceiptsModal
              setVisible={(val: boolean) => {
                setFinancialReceiptsModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              datas={selectedRows}
              onClose={() => {
                setFinancialReceiptsModalVisible(false);
                setSelectedRows({});
                refreshTable();
              }}
            />
          )}

          {shippingWarehouseChangeModalVisible && (
            <ShippingWarehouseChangeModal
              setVisible={(val: boolean) => {
                setShippingWarehouseChangeModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              subOrderIds={ids}
              originShippingWarehouse={buildSubOrders()[0].shippingWarehouse}
              onClose={() => {
                setShippingWarehouseChangeModalVisible(false);
                clearOptObject();
                setIds([]);
                refreshTable();
              }}
            />
          )}
          {reissueVisible && (
            <ReissueModal
              setVisible={(val: boolean) => {
                setReissueVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              onClose={() => {
                setReissueVisible(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}
          {reissueVisibleOld && (
            <ReissueModal_old
              setVisible={(val: boolean) => {
                setReissueVisibleOld(val);
                console.log(reissueVisible);
                if (!val) {
                  clearOptObject();
                }
              }}
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              onClose={() => {
                setReissueVisibleOld(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}
          {productionTimeModalVisible && (
            <ProductionTimeModal
              setVisible={(val: boolean) => {
                setProductionTimeModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              subOrders={buildSubOrders()}
              onClose={() => {
                setProductionTimeModalVisible(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}

          {modifiedDiffModalVisible && (
            <ModifiedDiffModal
              setVisible={(val: boolean) => {
                setModifiedDiffModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              subOrders={buildSubOrders()}
              mainOrder={buildMainOrder()}
              onClose={() => {
                setModifiedDiffModalVisible(false);
                clearOptObject();
              }}
            />
          )}

          {uploadPayBillModalVisible && (
            <UploadPayBillModal
              setVisible={(val: boolean) => {
                setUploadPayBillModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              subOrders={buildSubOrders()}
              mainOrder={buildMainOrder()}
              onClose={() => {
                setUploadPayBillModalVisible(false);
                clearOptObject();
                refreshTable();
              }}
            />
          )}
          {invoicingDrawerFormVisible && (
            <InvoicingDrawerForm
              dataList={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              setVisible={(val: boolean) => {
                setInvoicingDrawerFormVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              mainOrder={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
              onClose={() => {
                setInvoicingDrawerFormVisible(false);
                setIsMainOrder(true);
                clearOptObject();
                refreshTable();
              }}
            />
          )}
          {contextHolder}
          <FloatButton.BackTop visibilityHeight={0} />
        </div>
柏杨 authored
4924
      ),
柏杨 authored
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
    },
    {
      key: 2,
      label: (
        <span>
          订单回款预警
          <Badge count={invoiceRefundWarningNum} style={{ marginLeft: 8 }} />
        </span>
      ),
      children: (
        <div>
4936
4937
4938
4939
          {/* <Radio.Group options={options2} onChange={radioOnChange2} value={value2} /> */}
          <Radio.Group
            value={value2}
            onChange={radioOnChange2}
柏杨 authored
4940
            // 通过 onClick 处理单独 Radio 的点击事件
4941
          >
柏杨 authored
4942
            {options2.map((option) => (
4943
4944
4945
4946
              <Radio
                key={option.value}
                value={option.value}
                onClick={(e) => {
柏杨 authored
4947
4948
4949
                  radioOnChange2(
                    e as unknown as React.ChangeEvent<HTMLInputElement>,
                  );
4950
                  handleSetNull2();
柏杨 authored
4951
                }}
4952
4953
4954
4955
4956
              >
                {option.label}
              </Radio>
            ))}
          </Radio.Group>
柏杨 authored
4957
4958
4959
4960
4961
          <div style={{ height: '25px' }}></div>
          <ProTable
            id="main-table"
            // tableStyle={{backgroundColor:'red'}}
4962
4963
            actionRef={mainTableSecondRef}
            formRef={mainTableSecondFormRef}
柏杨 authored
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
            expandIconColumnIndex={-1}
            columns={mainOrdersColumns}
            rowKey="id"
            pagination={{
              showQuickJumper: true,
              pageSize: pageSize,
              current: currentPage,
              showSizeChanger: true,
              onChange: (page, size) => {
                setPageSize(size);
                setCurrentPage(page);
              },
              showTotal: (total, range) => {
                return (
                  <>
                    <span>
                      {'第 ' +
                        range[0] +
                        '-' +
                        range[1] +
                        ' 条/总共 ' +
                        total +
                        ' 条主订单 '}
                    </span>
                    <span className="text-[#8C8C8C]">
                      {' (' + subOrderCount + ' 条子订单)'}
                    </span>
                  </>
                );
              },
            }}
            // showHeader={false}
            expandedRowKeys={expandedRowKeys}
            // expandable={{ expandedRowRender }}
            dateFormatter="string"
            options={false}
            headerTitle=""
            search={false}
            // labelWidth: 'auto',
            // onCollapse: resize,
5004
            request={request2}
柏杨 authored
5005
5006
5007
            toolbar={{
              multipleLine: true,
            }}
柏杨 authored
5008
5009
5010
            // toolBarRender={() => {
            //   return toolBarRender();
            // }}
柏杨 authored
5011
          />
zhongnanhuang authored
5012
柏杨 authored
5013
5014
5015
5016
5017
5018
5019
5020
          {orderDrawerVisible && (
            <OrderDrawer
              data={orderOptType === 'add' ? {} : buildMainOrder()}
              subOrders={orderOptType === 'add' ? [] : buildSubOrders()}
              onClose={(isSuccess: boolean) => {
                setOrderDrawerVisible(false);
                clearOptObject();
                if (isSuccess) {
5021
                  refreshTable2();
柏杨 authored
5022
5023
5024
5025
5026
                }
              }}
              orderOptType={orderOptType}
            />
          )}
5027
柏杨 authored
5028
5029
5030
5031
5032
          {checkVisible && (
            <CheckModal
              setCheckVisible={(val: boolean) => {
                setCheckVisible(val);
                if (!val) {
柏杨 authored
5033
5034
                  clearOptObject();
                }
柏杨 authored
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
              }}
              data={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              orderCheckType={orderCheckType}
              openOrderDrawer={(type: any, id: any) => {
                setCurrentMainId(id);
                setOrderOptType(type);
                setOrderDrawerVisible(true);
              }}
              onClose={() => {
                clearOptObject();
                setCheckVisible(false);
5051
                refreshTable2();
柏杨 authored
5052
5053
5054
              }}
            />
          )}
柏杨 authored
5055
柏杨 authored
5056
5057
5058
5059
5060
          {applyForInvoicingVisible && (
            <ApplyForInvoicingModal
              setCheckVisible={(val: boolean) => {
                setApplyForInvoicingVisible(val);
                if (!val) {
柏杨 authored
5061
5062
                  clearOptObject();
                }
柏杨 authored
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
              }}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              totalPayment={getApplyInvoicingTotalPayment()}
              isMainOrder={isMainOrder}
              isEdit={isEdit}
              onClose={() => {
                setApplyForInvoicingVisible(false);
                setIsMainOrder(false);
                clearOptObject();
5076
                refreshTable2();
柏杨 authored
5077
5078
5079
              }}
            />
          )}
柏杨 authored
5080
柏杨 authored
5081
5082
5083
5084
5085
          {notesEditVisible && (
            <OrderNotesEditModal
              setNotesEditVisible={(val: boolean) => {
                setNotesEditVisible(val);
                if (!val) {
柏杨 authored
5086
                  clearOptObject();
柏杨 authored
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
                }
              }}
              ids={selectedRows}
              notesType={notesType}
              notes={notes}
              onClose={() => {
                setNotesEditVisible(false);
                setSelectedRows([]);
                setNotes(notes);
                setNotesType(1);
5097
                refreshTable2();
柏杨 authored
5098
5099
5100
              }}
            />
          )}
柏杨 authored
5101
柏杨 authored
5102
5103
5104
5105
5106
5107
5108
          {deliverVisible && (
            <DeliverModal
              data={buildSubOrders()}
              isSendProduct={isSendProduct}
              setVisible={(val: boolean) => {
                setDeliverVisible(val);
                if (!val) {
柏杨 authored
5109
                  clearOptObject();
柏杨 authored
5110
5111
5112
5113
5114
5115
5116
                }
              }}
              sendType={orderCheckType}
              onClose={() => {
                clearOptObject();
                setDeliverVisible(false);
                setIsSendProduct(false);
5117
                refreshTable2();
柏杨 authored
5118
5119
5120
              }}
            />
          )}
柏杨 authored
5121
柏杨 authored
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
          {financialVisible && (
            <FinancialDrawer
              isEdit={isEdit}
              mainOrder={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              isMainOrder={isMainOrder}
              cancel={() => {
                setFinancialVisible(false);
                clearOptObject();
                setIsMainOrder(false);
                setIsEdit(false);
              }}
              onClose={() => {
                setFinancialVisible(false);
                clearOptObject();
5141
                refreshTable2();
柏杨 authored
5142
5143
5144
5145
5146
                setIsMainOrder(false);
                setIsEdit(false);
              }}
            />
          )}
柏杨 authored
5147
柏杨 authored
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
          {financialEditVisible && (
            <FinancialEditDrawer
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              isMainOrder={isMainOrder}
              setVisible={() => {
                setFinancialEditVisible(false);
                clearOptObject();
              }}
              onClose={() => {
                setFinancialEditVisible(false);
5159
                refreshTable2();
柏杨 authored
5160
5161
5162
5163
5164
                setIsMainOrder(false);
                clearOptObject();
              }}
            />
          )}
柏杨 authored
5165
柏杨 authored
5166
5167
5168
5169
5170
5171
5172
5173
          {orderPrintVisible && (
            <OrderPrintModal
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              isRePrint={isRePrintOrder}
              setVisible={(val: boolean) => {
                setOrderPrintVisible(val);
                if (!val) {
柏杨 authored
5174
                  clearOptObject();
柏杨 authored
5175
5176
5177
5178
5179
5180
5181
                }
              }}
              printOptType={orderCheckType}
              onClose={() => {
                setOrderPrintVisible(false);
                clearOptObject();
                setIsRePrintOrder(false);
5182
                refreshTable2();
柏杨 authored
5183
5184
5185
              }}
            />
          )}
柏杨 authored
5186
柏杨 authored
5187
5188
5189
5190
5191
5192
          {confirmReceiptVisible && (
            <ConfirmReceiptModal
              data={buildSubOrders()}
              onClose={() => {
                setConfirmReceiptVisible(false);
                clearOptObject();
5193
                refreshTable2();
柏杨 authored
5194
5195
5196
              }}
            />
          )}
柏杨 authored
5197
柏杨 authored
5198
5199
5200
5201
5202
5203
          {imagesViewerModalVisible && (
            <ImagesViewerModal
              optType={imagesViewerOptType}
              setVisible={(val: boolean) => {
                setImagesViewerModalVisible(val);
                if (!val) {
柏杨 authored
5204
                  clearOptObject();
柏杨 authored
5205
5206
5207
5208
5209
5210
5211
5212
                }
              }}
              onClose={() => {
                setImagesViewerModalVisible(false);
              }}
              orderRow={buildSubOrders()[0]}
            />
          )}
柏杨 authored
5213
柏杨 authored
5214
5215
5216
5217
          {importModalVisible && (
            <ImportModal
              onClose={() => {
                setImportModalVisible(false);
5218
                refreshTable2();
柏杨 authored
5219
5220
5221
              }}
            />
          )}
柏杨 authored
5222
柏杨 authored
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
          {attachmentModalVisible && (
            <AttachmentModal
              data={buildSubOrders()[0]}
              onClose={() => {
                setAttachmentModalVisible(false);
                clearOptObject();
              }}
            />
          )}

          {historyModalVisible && (
            <HistoryModal
              subOrders={selectedRows}
              isCancelledOrder={filterCondifion === 70}
              onClose={() => {
                setHistoryModalVisible(false);
                setSelectedRows({});
                clearOptObject();
              }}
            />
          )}

          {deliverInfoDrawerVisible && (
            <DeliverInfoDrawer
              data={buildMainOrder()}
              onClose={() => {
                setDeliverInfoDrawerVisible(false);
                clearOptObject();
              }}
            />
          )}

          {deliverInfoDrawerVisible && (
            <DeliverInfoDrawer
              data={buildMainOrder()}
              onClose={() => {
                setDeliverInfoDrawerVisible(false);
                clearOptObject();
              }}
            />
          )}

          {procureCheckModalVisible && (
            <ProcureCheckModal
              setCheckVisible={(val: boolean) => {
                setProcureCheckModalVisible(val);
                if (!val) {
                  clearOptObject();
柏杨 authored
5271
                }
柏杨 authored
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
              }}
              isMainOrder={isMainOrder}
              orders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              onClose={() => {
                setProcureCheckModalVisible(false);
                clearOptObject();
                setIsMainOrder(false);
5283
                refreshTable2();
柏杨 authored
5284
5285
5286
5287
5288
5289
5290
5291
5292
              }}
            />
          )}

          {afterSalesDrawerVisible && (
            <AfterSalesDrawer
              setVisible={(val: boolean) => {
                setAfterSalesDrawerVisible(val);
                if (!val) {
柏杨 authored
5293
                  clearOptObject();
柏杨 authored
5294
5295
5296
5297
5298
5299
5300
                }
              }}
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              onClose={() => {
                setAfterSalesDrawerVisible(false);
                clearOptObject();
5301
                refreshTable2();
柏杨 authored
5302
5303
5304
              }}
            />
          )}
柏杨 authored
5305
柏杨 authored
5306
5307
5308
5309
5310
          {procureConvertModalVisible && (
            <ProcureConvertModal
              setVisible={(val: boolean) => {
                setProcureConvertModalVisible(val);
                if (!val) {
柏杨 authored
5311
                  clearOptObject();
柏杨 authored
5312
5313
5314
5315
5316
5317
                }
              }}
              subOrders={buildSubOrders()}
              onClose={() => {
                setProcureConvertModalVisible(false);
                clearOptObject();
5318
                refreshTable2();
柏杨 authored
5319
5320
5321
              }}
            />
          )}
柏杨 authored
5322
柏杨 authored
5323
5324
5325
5326
5327
          {financialMergeDrawerVisible && (
            <FinancialMergeDrawer
              setVisible={(val: boolean) => {
                setFinancialMergeDrawerVisible(val);
                if (!val) {
柏杨 authored
5328
5329
                  clearOptObject();
                }
柏杨 authored
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
              }}
              dataList={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              onClose={() => {
                setFinancialMergeDrawerVisible(false);
                setIsMainOrder(false);
                clearOptObject();
5340
                refreshTable2();
柏杨 authored
5341
5342
5343
              }}
            />
          )}
柏杨 authored
5344
柏杨 authored
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
          {financialReceiptsModalVisible && (
            <FinancialReceiptsModal
              setVisible={(val: boolean) => {
                setFinancialReceiptsModalVisible(val);
                if (!val) {
                  clearOptObject();
                }
              }}
              datas={selectedRows}
              onClose={() => {
                setFinancialReceiptsModalVisible(false);
                setSelectedRows({});
5357
                refreshTable2();
柏杨 authored
5358
5359
5360
              }}
            />
          )}
柏杨 authored
5361
柏杨 authored
5362
5363
5364
5365
5366
          {shippingWarehouseChangeModalVisible && (
            <ShippingWarehouseChangeModal
              setVisible={(val: boolean) => {
                setShippingWarehouseChangeModalVisible(val);
                if (!val) {
柏杨 authored
5367
5368
                  clearOptObject();
                }
柏杨 authored
5369
5370
5371
5372
5373
5374
5375
              }}
              subOrderIds={ids}
              originShippingWarehouse={buildSubOrders()[0].shippingWarehouse}
              onClose={() => {
                setShippingWarehouseChangeModalVisible(false);
                clearOptObject();
                setIds([]);
5376
                refreshTable2();
柏杨 authored
5377
5378
5379
5380
5381
5382
5383
5384
              }}
            />
          )}
          {reissueVisible && (
            <ReissueModal
              setVisible={(val: boolean) => {
                setReissueVisible(val);
                if (!val) {
柏杨 authored
5385
                  clearOptObject();
柏杨 authored
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
                }
              }}
              subOrders={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              onClose={() => {
                setReissueVisible(false);
                clearOptObject();
5396
                refreshTable2();
柏杨 authored
5397
5398
5399
5400
5401
5402
5403
5404
5405
              }}
            />
          )}
          {reissueVisibleOld && (
            <ReissueModal_old
              setVisible={(val: boolean) => {
                setReissueVisibleOld(val);
                console.log(reissueVisible);
                if (!val) {
柏杨 authored
5406
                  clearOptObject();
柏杨 authored
5407
5408
5409
5410
5411
5412
5413
                }
              }}
              mainOrder={buildMainOrder()}
              subOrders={buildSubOrders()}
              onClose={() => {
                setReissueVisibleOld(false);
                clearOptObject();
5414
                refreshTable2();
柏杨 authored
5415
5416
5417
5418
5419
5420
5421
5422
              }}
            />
          )}
          {productionTimeModalVisible && (
            <ProductionTimeModal
              setVisible={(val: boolean) => {
                setProductionTimeModalVisible(val);
                if (!val) {
柏杨 authored
5423
                  clearOptObject();
柏杨 authored
5424
5425
5426
5427
5428
5429
                }
              }}
              subOrders={buildSubOrders()}
              onClose={() => {
                setProductionTimeModalVisible(false);
                clearOptObject();
5430
                refreshTable2();
柏杨 authored
5431
5432
5433
              }}
            />
          )}
柏杨 authored
5434
柏杨 authored
5435
5436
5437
5438
5439
          {modifiedDiffModalVisible && (
            <ModifiedDiffModal
              setVisible={(val: boolean) => {
                setModifiedDiffModalVisible(val);
                if (!val) {
柏杨 authored
5440
                  clearOptObject();
柏杨 authored
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
                }
              }}
              subOrders={buildSubOrders()}
              mainOrder={buildMainOrder()}
              onClose={() => {
                setModifiedDiffModalVisible(false);
                clearOptObject();
              }}
            />
          )}
柏杨 authored
5451
柏杨 authored
5452
5453
5454
5455
5456
          {uploadPayBillModalVisible && (
            <UploadPayBillModal
              setVisible={(val: boolean) => {
                setUploadPayBillModalVisible(val);
                if (!val) {
柏杨 authored
5457
5458
                  clearOptObject();
                }
柏杨 authored
5459
5460
5461
5462
5463
5464
              }}
              subOrders={buildSubOrders()}
              mainOrder={buildMainOrder()}
              onClose={() => {
                setUploadPayBillModalVisible(false);
                clearOptObject();
5465
                refreshTable2();
柏杨 authored
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
              }}
            />
          )}
          {invoicingDrawerFormVisible && (
            <InvoicingDrawerForm
              dataList={
                isMainOrder
                  ? [...subOrderSelectedMap.values()].flat()
                  : buildSubOrders()
              }
              setVisible={(val: boolean) => {
                setInvoicingDrawerFormVisible(val);
                if (!val) {
柏杨 authored
5479
                  clearOptObject();
柏杨 authored
5480
5481
5482
5483
5484
5485
5486
                }
              }}
              mainOrder={isMainOrder ? getFirstMainOrder() : buildMainOrder()}
              onClose={() => {
                setInvoicingDrawerFormVisible(false);
                setIsMainOrder(true);
                clearOptObject();
5487
                refreshTable2();
柏杨 authored
5488
5489
5490
              }}
            />
          )}
柏杨 authored
5491
5492
          {contextHolder}
          <FloatButton.BackTop visibilityHeight={0} />
柏杨 authored
5493
5494
5495
5496
        </div>
      ),
    },
  ];
柏杨 authored
5497
柏杨 authored
5498
5499
5500
  return (
    <div className="order-page-container">
      <div id="resizeDiv"></div>
柏杨 authored
5501
      <Tabs defaultActiveKey="1" items={tabsItems} onChange={() => {}} />
5502
    </div>
calmound authored
5503
5504
5505
  );
};
sanmu authored
5506
export default OrderPage;