Blame view

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

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

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

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

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

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

  //   return true;
  // }

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

    return null;
  }

  /**
   * 返回当前操作的主订单数据
   */
  function buildMainOrder() {
boyang authored
388
    if (!currentOptMainId) {
zhongnanhuang authored
389
390
391
392
393
394
395
396
397
398
399
      message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
      return;
    }

    let mainOrderClone = null;
    let matchedData = data.filter((item) => {
      return item.id === currentOptMainId;
    });
    if (matchedData.length > 0) {
      mainOrderClone = cloneDeep(matchedData[0]);
    }
boyang authored
400
    if (!mainOrderClone) {
zhongnanhuang authored
401
402
403
404
405
406
407
408
409
      message.error('页面错误:当前操作的主订单数据不存在,请联系系统管理员');
    }
    return mainOrderClone;
  }

  /**
   * 返回当前操作的子订单集合
   */
  function buildSubOrders() {
boyang authored
410
    if (!currentOptMainId) {
zhongnanhuang authored
411
412
413
414
415
416
417
418
      message.error('页面错误:当前操作的主订单id不存在,请联系系统管理员');
      return;
    }

    let cloneSubOrders = [];

    //如果没有传当前操作的子订单id,说明是操作主订单
    if (curretnOptSubId === undefined || curretnOptSubId === null) {
boyang authored
419
      // if (!curretnOptSubId) {
zhongnanhuang authored
420
421
      //如果有选中子订单,那么取选中的子订单为操作对象,否则取当前主订单的全部子订单为操作对象
      let currentOptSubOrders = subOrderSelectedMap.get(currentOptMainId);
boyang authored
422
zhongnanhuang authored
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
      if (
        currentOptSubOrders === null ||
        currentOptSubOrders === undefined ||
        currentOptSubOrders.length === 0
      ) {
        for (let item of data) {
          if (item.id === currentOptMainId) {
            for (let subOrder of item?.subOrderInformationLists) {
              cloneSubOrders.push(cloneDeep(subOrder));
            }
          }
        }
      } else {
        cloneSubOrders = currentOptSubOrders.map((item) => {
          return cloneDeep(item);
        });
      }
    } else {
      //操作的是子订单
      for (let item of data) {
        if (item.id === currentOptMainId) {
          for (let subOrder of item?.subOrderInformationLists) {
            if (subOrder.id === curretnOptSubId) {
              cloneSubOrders.push(cloneDeep(subOrder));
              break;
            }
          }
        }
      }
    }
    if (cloneSubOrders.length === 0) {
      message.error('页面错误:当前操作的订单数据不存在,请联系系统管理员');
      return;
    }
    return cloneSubOrders;
  }

  /**
zhongnanhuang authored
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
   * 获取当前操作申请开票的订单总金额
   */
  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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
   * 根据主订单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
513
      });
zhongnanhuang authored
514
515
516
517
518
519
520
521
522
523
524
      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
525
      setSelectedRows([]);
526
zhongnanhuang authored
527
      //删除选中主订单的信息
528
      mainOrderSelectedMap.delete(record.id);
zhongnanhuang authored
529
530
531
532
      //删除选中主订单附属子订单的信息
      subOrderSelectedMap.delete(record.id);
      //总选中按钮取消选中
      setAllMainChecked(false);
zhongnanhuang authored
533
    } else {
zhongnanhuang authored
534
      newSelectedMainOrderKeys = [...selectedMainOrderKeys, record.id];
zhongnanhuang authored
535
536
537
538
      //子订单全部自动选中
      let subIds = record.subOrderInformationLists?.map((item) => {
        return item.id;
      });
zhongnanhuang authored
539
540
541
542
543
544
545
      let newSelectedSubOrderKeys = [...selectedSubOrderKeys];
      for (let subId of subIds) {
        if (!selectedSubOrderKeys.includes(subId)) {
          newSelectedSubOrderKeys.push(subId);
        }
      }
      setSelectedSubOrderKeys(newSelectedSubOrderKeys);
546
zhongnanhuang authored
547
      setSelectedRows(record.subOrderInformationLists);
548
549
550

      //选中主订单
      mainOrderSelectedMap.set(record.id, record);
zhongnanhuang authored
551
552
      //选中子订单
      subOrderSelectedMap.set(record.id, record.subOrderInformationLists);
553
      setSubOrderSelectedMap(new Map(subOrderSelectedMap));
zhongnanhuang authored
554
555
556
557
558
559
560

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

      //如果是未审核或者领导已审核,付款状态为预付款则需要财务审核【财务待审核】,否则仓库审核【】
zhongnanhuang authored
665
666
667
668
669
670
671
672
673
674
675
676
677
      if (orderStatus === 'UNAUDITED' || orderStatus === 'LEADER_AUDITED') {
        if (paymentMethod === 'PAYMENT_IN_ADVANCE') {
          orderStatusTagText = '财务待审核';
        } else {
          orderStatusTagText = '仓库待审核';
        }
      }

      //如果是财务已审核,显示为【仓库待审核】
      if (orderStatus === 'FINANCE_PROCESS') {
        orderStatusTagText = '仓库待审核';
      }
zhongnanhuang authored
678
679
680
      if (orderStatus === 'AUDIT_FAILED') {
        return (
          <MyToolTip
681
            key="key"
zhongnanhuang authored
682
            title={optRecord.checkNotes + ' ' + optRecord.postAuditNotes}
zhongnanhuang authored
683
684
685
686
687
688
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
zhongnanhuang authored
689
                  {orderStatusTagText}
zhongnanhuang authored
690
691
692
693
694
695
696
697
698
699
700
701
702
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }

      if (
        orderStatus === 'AFTER_SALES_COMPLETION' ||
        orderStatus === 'IN_AFTER_SALES'
      ) {
        return (
zhongnanhuang authored
703
704
705
706
          <Tag
            color={TAGS_COLOR.get(optRecord.orderStatus)}
            style={{ marginRight: '4px' }}
          >
zhongnanhuang authored
707
            {orderStatusTagText}
zhongnanhuang authored
708
          </Tag>
zhongnanhuang authored
709
710
711
        );
      }
zhongnanhuang authored
712
713
714
      if (orderStatus === 'PROCURE_CONVERT_WAREHOUSE_KEEPER') {
        return (
          <MyToolTip
715
            key="key"
zhongnanhuang authored
716
717
718
719
720
721
722
            title={optRecord.checkNotes}
            content={
              <>
                <Tag
                  color={TAGS_COLOR.get(optRecord.orderStatus)}
                  style={{ marginRight: '4px' }}
                >
zhongnanhuang authored
723
                  {orderStatusTagText}
zhongnanhuang authored
724
725
726
727
728
729
730
731
                </Tag>
                <QuestionCircleOutlined style={{ color: '#C1C1C1' }} />
              </>
            }
          />
        );
      }
zhongnanhuang authored
732
      return (
733
        <Tag key="key" color={TAGS_COLOR.get(optRecord.orderStatus)}>
zhongnanhuang authored
734
735
736
737
738
739
740
741
742
743
744
745
746
          {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
747
748
749
750
        </Tag>
      );
    }
751
752
    //申请开票附件处理
    const getAfterAnnexList = () => {
zhongnanhuang authored
753
      // let links = [];
754
755
      let afterAnnexList = optRecord.afterAnnexList;
      let i = 1;
zhongnanhuang authored
756
757
      let images = [];
      let otherAnnex = [];
758
759
      if (afterAnnexList?.length > 0) {
        for (let url of afterAnnexList) {
zhongnanhuang authored
760
761
762
763
764
765
          let name = getAliYunOSSFileNameFromUrl(url);
          if (isImageName(name)) {
            images.push({ name: name, url: url });
          } else {
            otherAnnex.push({ name: '附件' + i++, url: url });
          }
766
767
768
        }
      }
zhongnanhuang authored
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
      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(
796
                    '/previewApi/onlinePreview?url=' +
797
                      encodeURIComponent(Base64.encode(item.url)),
zhongnanhuang authored
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
                  );
                }}
                onCancel={() => {
                  window.open(item.url);
                }}
                okText="预览"
                cancelText="下载"
              >
                <Button className="px-1" key={index} type="link">
                  {item.name}
                </Button>
              </Popconfirm>
            );
          })}
        </div>
      );
814
815
816
817
818
819
820
821
822
823
824
825
826
    };

    //财务审核附件处理
    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
827
          >
828
829
            {invoicingCheckAnnexList.map((url, index) => (
              <React.Fragment key={index}>
830
831
                <Image className="max-h-[50px] max-w-[70px]" src={url} />{' '}
                <Divider type="vertical" />
832
              </React.Fragment>
833
834
835
836
837
838
839
840
841
842
843
            ))}
          </Image.PreviewGroup>
        </div>
      );
    };

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

                {/* 开票状态 */}
1048
                {optRecord.afterInvoicingStatus !== null ? (
zhongnanhuang authored
1049
1050
1051
1052
                  <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                    <Tooltip
                      title={
                        optRecord.invoicingUrgentCause !== null &&
1053
                        optRecord.afterInvoicingStatus ===
zhongnanhuang authored
1054
1055
1056
                          'URGENT_INVOICE_AUDITING'
                          ? optRecord.invoicingUrgentCause
                          : enumValueToLabel(
1057
1058
1059
                              optRecord.afterInvoicingStatus,
                              AFTER_INVOICING_STATUS,
                            )
zhongnanhuang authored
1060
1061
                      }
                    >
1062
1063
1064
                      <Tag
                        color={TAGS_COLOR.get(optRecord.afterInvoicingStatus)}
                      >
zhongnanhuang authored
1065
1066
1067
1068
1069
1070
1071
                        {enumValueToLabel(
                          optRecord.afterInvoicingStatus,
                          AFTER_INVOICING_STATUS,
                        )}
                      </Tag>
                    </Tooltip>
                  </div>
1072
1073
1074
                ) : (
                  ''
                )}
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089

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

              {/* 修改审核状态 */}
1213
              {optRecord.modifiedAuditStatus !== null &&
1214
              optRecord.modifiedAuditStatus !== 'AUDIT_FAILURE' ? (
1215
1216
                <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis">
                  <Tooltip
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
                    title={recordOptNode ? recordOptNode : <Spin />}
                    onOpenChange={(open) => {
                      console.log('open:' + open);
                      console.log('id:' + optRecord.id);
                      if (open) {
                        triggerRecordOptNode(optRecord.id);
                      } else {
                        setRecordOptNode(null);
                      }
                    }}
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
                  >
                    <Tag color={TAGS_COLOR.get(optRecord.modifiedAuditStatus)}>
                      {enumValueToLabel(
                        optRecord.modifiedAuditStatus,
                        MODIFIED_AUDIT_STATUS_OPTIONS,
                      )}
                    </Tag>
                  </Tooltip>
                </div>
              ) : (
                ''
              )}
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261

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

                  if (res && res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
                }}
              />
            ) : (
              ''
1549
            )}
1550
            {optRecord.paths?.includes('saleCancelInvoicing') ? (
曾国涛 authored
1551
1552
1553
              <ButtonConfirm
                className="p-0"
                title="确认取消申请开票?"
1554
                text="取消申请(新)"
曾国涛 authored
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
                onConfirm={async () => {
                  let res = await postServiceInvoiceCancelApply({
                    data: {
                      subOrderIds: [optRecord.id],
                    },
                  });

                  if (res && res.result === RESPONSE_CODE.SUCCESS) {
                    message.success(res.message);
                    refreshTable();
                  }
                }}
              />
            ) : (
              ''
1570
            )}
1571
            {optRecord.paths?.includes('noNeedInvoicingEdit') ? (
1572
1573
1574
1575
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1576
                  createOptObject(optRecord.id, record.id);
1577
1578
1579
1580
                  setFinancialEditVisible(true);
                  setIsMainOrder(false);
                }}
              >
1581
                编辑时间
1582
1583
1584
1585
              </Button>
            ) : (
              ''
            )}
1586
            {optRecord.paths?.includes('sendProduct') ? (
1587
1588
1589
1590
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1591
                  createOptObject(optRecord.id, record.id);
1592
1593
                  setDeliverVisible(true);
                  setIsSendProduct(true);
zhongnanhuang authored
1594
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1595
1596
1597
1598
1599
1600
1601
1602
                }}
              >
                仓库发货
              </Button>
            ) : (
              ''
            )}
1603
            {optRecord.paths?.includes('supplierSendOrder') ? (
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
                  setSelectedRows([cloneDeep(optRecord)]); //克隆一份数据,避免后续修改污染
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.SUPPLIER);
                }}
              >
                供应商发货
              </Button>
            ) : (
              ''
            )}
1621
            {optRecord.paths?.includes('procureSend') ? (
zhongnanhuang authored
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  createOptObject(optRecord.id, record.id);
                  setDeliverVisible(true);
                  setIsSendProduct(true);
                  setOrderCheckType(CHECK_TYPE.PROCURE);
                }}
              >
zhongnanhuang authored
1632
                {isSupplier() ? '发货' : '采购发货'}
zhongnanhuang authored
1633
1634
1635
1636
1637
              </Button>
            ) : (
              ''
            )}
1638
            {optRecord.paths?.includes('editProductionTime') ? (
1639
1640
1641
1642
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1643
1644
                  createOptObject(optRecord.id, record.id);
                  setProductionTimeModalVisible(true);
1645
1646
                }}
              >
zhongnanhuang authored
1647
                生产时间
1648
1649
1650
1651
1652
              </Button>
            ) : (
              ''
            )}
1653
            {optRecord.paths?.includes('queryAnnex') &&
1654
            optRecord.listAnnex?.length > 0 ? (
1655
1656
1657
1658
1659
              <Button
                className="p-0"
                type="link"
                onClick={() => {
                  optRecord.mainOrderId = record.id;
zhongnanhuang authored
1660
                  createOptObject(optRecord.id, record.id);
1661
1662
1663
1664
1665
1666
1667
1668
1669
                  setAttachmentModalVisible(true);
                }}
              >
                附件
              </Button>
            ) : (
              ''
            )}
1670
            {optRecord.paths?.includes('modifySendInformation') ? (
1671
1672
1673
1674
              <Button
                className="p-0"
                type="link"
                onClick={() => {
zhongnanhuang authored
1675
                  createOptObject(optRecord.id, record.id);
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
                  setDeliverVisible(true);
                  setIsSendProduct(false);
                }}
              >
                修改发货信息
              </Button>
            ) : (
              ''
            )}
1686
            {optRecord.paths?.includes('printOrder') ? (
1687
1688
1689
1690
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
zhongnanhuang authored
1691
                  createOptObject(optRecord.id, record.id);
1692
                  setOrderPrintVisible(true);
zhongnanhuang authored
1693
                  setOrderCheckType(CHECK_TYPE.WEARHOUSE_KEEPER);
1694
1695
1696
1697
1698
1699
1700
1701
                }}
              >
                仓库打印
              </Button>
            ) : (
              ''
            )}
1702
            {optRecord.paths?.includes('supplierPrint') ? (
1703
1704
1705
1706
              <Button
                className="p-0"
                type="link"
                onClick={async () => {
zhongnanhuang authored
1707
                  createOptObject(optRecord.id, record.id);
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
                  setOrderPrintVisible(true);
                  setOrderCheckType(CHECK_TYPE.SUPPLIER);
                }}
              >
                供应商打印
              </Button>
            ) : (
              ''
            )}
1718
            {optRecord.paths?.includes('procurePrint') ? (
zhongnanhuang authored
1719
              <ButtonConfirm
1720
                className="p-0"
zhongnanhuang authored
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
                title="确认打印?"
                text="采购打印"
                onConfirm={async () => {
                  let res = await postServiceOrderProcurePrint({
                    data: {
                      ids: [optRecord.id],
                    },
                  });

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

                {getAfterAnnexList()}
zhongnanhuang authored
2204
2205
2206
2207
2208

                <Tooltip title="编辑">
                  <EditTwoTone
                    className="pl-1 hover:curcor-pointer"
                    onClick={() => {
2209
2210
2211
2212
                      setNotesEditVisible(true);
                      setSelectedRows([optRecord.id]);
                      setNotes(optRecord.applyInvoicingNotes);
                      setNotesType(4);
zhongnanhuang authored
2213
2214
2215
                    }}
                  />
                </Tooltip>
2216
2217
2218
2219
2220
2221
2222
2223
              </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 ||
2224
                      optRecord.checkNotes === null
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
                        ? '暂无备注'
                        : optRecord.checkNotes}
                    </span>
                  </Tooltip>
                </div>

                {getInvoicingCheckAnnexList()}
              </div>
            </div>
          </Flex>
        ) : (
          ''
        )}
曾国涛 authored
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247

        {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 ||
2248
                      optRecord.reissueNotes === null
曾国涛 authored
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
                        ? '暂无备注'
                        : 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>
2269
2270
2271
2272
          </Flex>
        ) : (
          ''
        )}
boyang authored
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
        {isAdmin() || isSales() ? (
          <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.feedbackRegistrationContent}
                    placement="topLeft"
                  >
                    <span className="text-[#8C8C8C] mr-3">
                      产品回访登记:
                      {optRecord.feedbackRegistrationContent === undefined ||
2285
                      optRecord.feedbackRegistrationContent === null
boyang authored
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
                        ? '暂无'
                        : optRecord.feedbackRegistrationContent}
                    </span>
                  </Tooltip>
                </div>
              </div>
            </div>
          </Flex>
        ) : (
          ''
        )}
2297
      </>
zhongnanhuang authored
2298
    );
zhongnanhuang authored
2299
  };
zhongnanhuang authored
2300
2301
2302
2303
2304
2305
  const expandedRowRender = (record) => {
    let subOrders = record.subOrderInformationLists;

    return (
      <ProTable
        id="sub-table"
zhongnanhuang authored
2306
        className="w-full "
zhongnanhuang authored
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
        showHeader={false}
        columns={[
          {
            title: 'ID',
            dataIndex: 'id',
            key: 'id',
            render: (text: any, optRecord: any) => {
              return <SubOderRander record={record} optRecord={optRecord} />;
            },
          },
        ]}
        rowSelection={{
zhongnanhuang authored
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
2371
2372
2373
2374
2375
2376
2377
          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
2378
            if (currentMainOrderSelectedSubOrderList?.length === 0) {
zhongnanhuang authored
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
              subOrderSelectedMap.delete(record.id);
            } else {
              subOrderSelectedMap.set(
                record.id,
                currentMainOrderSelectedSubOrderList,
              );
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

      if (isExaminer() && !canSearchIndex.includes(item.dataIndex)) {
4013
4014
        item.search = false;
      }
4015
zhongnanhuang authored
4016
4017
4018
4019
4020
4021
4022
4023
4024
      if (item.dataIndex === 'name') {
        return {
          ...item,
          title: <OrderTableHeader />,
          render: (text, record) => {
            return <MainOrderColumnRender record={record} />;
          },
        };
      }
zhongnanhuang authored
4025
4026
4027
4028

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

  /**
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
   * 排除采购
   */
  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
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
   * 仓库可以筛选发货仓库
   */
  if (roleCode === 'warehouseKeeper' || roleCode === 'admin') {
    mainOrdersColumns.push({
      title: '发货仓库',
      width: 120,
      dataIndex: 'shippingWarehouse',
      valueType: 'select',
      valueEnum: enumToProTableEnumValue(SHIPPING_WAREHOUSE_OPTIONS),
      hideInTable: true,
    });
  }
4108
  //判断是否是采购,是的话新增一个筛选条件
4109
  if (roleCode === 'procure' || roleCode === 'admin') {
4110
    mainOrdersColumns.push({
zhongnanhuang authored
4111
      title: isSupplier() ? '下单状态' : '采购下单状态',
4112
4113
4114
4115
4116
4117
4118
      dataIndex: 'procureOrderStatus',
      valueType: 'select',
      hideInTable: true,
      valueEnum: enumToProTableEnumValue(PROCURE_ORDER_STATUS),
    });
  }
boyang authored
4119
4120
4121
  //选择天数1
  const options1 = [
    {
boyang authored
4122
4123
      label: '超过7天',
      value: 7,
boyang authored
4124
    },
4125
    {
boyang authored
4126
4127
      label: '超过10天',
      value: 10,
4128
    },
boyang authored
4129
4130
4131
  ];
  const options2 = [
    {
boyang authored
4132
4133
      label: '超过20天',
      value: 20,
boyang authored
4134
4135
    },
    {
boyang authored
4136
4137
      label: '超过45天',
      value: 45,
4138
4139
4140
4141
4142
4143
4144
4145
    },
  ];
  const options3 = [
    {
      label: '超过5天',
      value: 5,
    },
    {
boyang authored
4146
4147
      label: '超过15天',
      value: 15,
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
    },
  ];
  const options4 = [
    {
      label: '超过30天',
      value: 30,
    },
    {
      label: '超过75天',
      value: 75,
    },
    {
      label: '超过90天',
      value: 90,
    },
    {
      label: '超过120天',
      value: 120,
boyang authored
4166
4167
    },
  ];
4168
4169
4170
4171
  //选择天数
  const [calDate, setCalDate] = useState<string | null>(null);
  const [value1, setValue1] = useState(0);
  const radioOnChange1 = ({ target: { value } }) => {
4172
4173
4174
    const currentDate = new Date();
    // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天
    const newDate = new Date(currentDate);
4175
    newDate.setDate(currentDate.getDate() - value);
4176
    const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss');
4177
4178
    setCalDate(formattedDate);
    setValue1(value);
boyang authored
4179
  };
boyang authored
4180
4181
4182
4183
4184
4185
4186
4187
  function setOriginTime(value) {
    const currentDate = new Date();
    // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天
    const newDate = new Date(currentDate);
    newDate.setDate(currentDate.getDate() - value);
    const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss');
    return formattedDate;
  }
4188
4189
  const [invoiceWarningNum, setInvoiceWarningNum] = useState(0);
  const [invoiceRefundWarningNum, setInvoiceRefundWarningNum] = useState(0);
4190
4191
  const [waitConfirmPayment, setWaitConfirmPayment] = useState(0);
  const [waitFeedback, setWaitFeedback] = useState(0);
boyang authored
4192
  const [staticSalesCode, setStaticSalesCode] = useState(userInfo.username);
boyang authored
4193
  const [salesCodePermission, setSalesCodePermission] = useState(false);
boyang authored
4194
4195
4196
  //修改预警数请求salesCode
  const changeSalesCode = () => {
    if (salesCodeSelect === undefined) {
boyang authored
4197
      setStaticSalesCode(userInfo.username);
boyang authored
4198
4199
4200
4201
    } else {
      setStaticSalesCode(salesCodeSelect);
    }
  };
boyang authored
4202
4203
4204
4205
4206
4207
4208
4209
4210
  //选择栏权限
  const permission = () => {
    const { roles } = userInfo;
    const boolean =
      roles?.includes('SALES_MANAGER') || roles?.includes('ADMIN');
    if (boolean) {
      setSalesCodePermission(true);
    }
  };
4211
  async function getInvoiceWarningNum() {
boyang authored
4212
4213
4214
4215
    changeSalesCode();
    const res = await postServiceOrderWarningOrderStatistics({
      data: {
        salesCode: staticSalesCode,
boyang authored
4216
4217
4218
4219
        waitConfirmReiceptStatusDateTimeLe: setOriginTime(options1[0].value),
        waitFeedbackStatusDateTimeLe: setOriginTime(options2[0].value),
        waitConfirmInvoiceStatusDateTimeLe: setOriginTime(options3[0].value),
        waitConfirmPaymentStatusDateTimeLe: setOriginTime(options4[0].value),
boyang authored
4220
4221
      },
    });
4222
4223
    setInvoiceWarningNum(res.data.waitConfirmInvoice);
    setInvoiceRefundWarningNum(res.data.waitConfirmReceipt);
4224
4225
    setWaitConfirmPayment(res.data.waitConfirmPayment);
    setWaitFeedback(res.data.waitFeedback);
4226
4227
4228
4229
  }
  useEffect(() => {
    //预警订单数
    getInvoiceWarningNum();
boyang authored
4230
    permission();
boyang authored
4231
  }, [salesCodeSelect]);
4232
4233
4234
  //biaojiup
  // 监听 calDate 变化,触发请求
  useEffect(() => {
4235
    mainTableRef.current?.reload();
4236
  }, [calDate]);
boyang authored
4237
  useEffect(() => {
4238
4239
4240
4241
4242
4243
4244
    if (
      activeTabKey === 1 ||
      activeTabKey === 2 ||
      activeTabKey === 3 ||
      activeTabKey === 4
    ) {
      setValue1(0); // 清空 value1
boyang authored
4245
    }
4246
    mainTableRef.current?.reload(); // **修改位置:在选择第二个标签时请求request2**
boyang authored
4247
  }, [activeTabKey]);
4248
  // 修改位置:监听 value1 的变化
boyang authored
4249
4250
4251
4252
4253
4254
4255
4256
  // useEffect(() => {
  //   // if (value1 === 0) {
  //   //   // 这里执行你希望在 value1 为 0 时的逻辑
  //   //   mainTableRef.current?.reload(); // 重新请求数据
  //   // }

  // }, [value1]); // 添加了 value1 作为依赖
4257
  useEffect(() => {
boyang authored
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
    // 根据 activeTabKey 设置 value1 为当前选项组的第一个 value
    let options;
    switch (activeTabKey) {
      case 1:
        options = options1;
        break;
      case 2:
        options = options2;
        break;
      case 3:
        options = options3;
        break;
      case 4:
        options = options4;
        break;
      default:
        options = []; // 如果没有匹配的选项组,默认为空
4275
    }
boyang authored
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285

    const firstOptionValue = options[0]?.value || 0; // 获取第一个值
    setValue1(firstOptionValue);
    const currentDate = new Date();
    // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天
    const newDate = new Date(currentDate);
    newDate.setDate(currentDate.getDate() - firstOptionValue);
    const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss');
    setCalDate(formattedDate);
  }, [activeTabKey]);
4286
4287
4288
  //biaojidown2
  //取消单选,将时间设为null
  const handleSetNull = () => {
4289
    setCalDate(null); // 这应该会触发 useEffect
4290
  };
4291
4292
4293
  const selectSalesCode = (value) => {
    setSalesCodeSelect(value); // 这应该会触发 useEffect
  };
4294
4295
4296
4297
4298
4299
  const warningOptions = [
    {
      value: 1,
      label: (
        <span>
          确认收货预警
boyang authored
4300
          <Badge count={invoiceRefundWarningNum} style={{ marginLeft: 8 }} />
4301
4302
4303
        </span>
      ),
    },
boyang authored
4304
    {
4305
      value: 2,
boyang authored
4306
4307
      label: (
        <span>
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
          回访登记预警
          <Badge count={waitFeedback} style={{ marginLeft: 8 }} />
        </span>
      ),
    },
    {
      value: 3,
      label: (
        <span>
          确认发票预警
boyang authored
4318
4319
4320
          <Badge count={invoiceWarningNum} style={{ marginLeft: 8 }} />
        </span>
      ),
4321
4322
4323
4324
4325
4326
    },
    {
      value: 4,
      label: (
        <span>
          订单回款预警
boyang authored
4327
          <Badge count={waitConfirmPayment} style={{ marginLeft: 8 }} />
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
        </span>
      ),
    },
  ];

  return (
    <div className="order-page-container">
      <div id="resizeDiv"></div>
      <div key={'activeTabKey'}>
        <Radio.Group
          options={warningOptions}
          onChange={(e) => {
            setActiveTabKey(e.target.value);
            mainTableRef.current?.reload(); // 重新请求数据
          }}
          value={activeTabKey}
          optionType="button"
        />
      </div>
      <div style={{ height: '25px' }}></div>
4348
4349
4350
4351
4352
4353
4354
      <div
        style={{
          display: 'flex',
          justifyContent: 'space-between',
          alignItems: 'center',
          width: '100%',
        }}
4355
      >
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
        {/* 左边的 Radio.Group */}
        <span style={{ flex: '1' }}>
          {' '}
          {/* 修改:设置 flex 属性 */}
          <Radio.Group value={value1} onChange={radioOnChange1}>
            {(activeTabKey === 1
              ? options1
              : activeTabKey === 2
                ? options2
                : activeTabKey === 3
                  ? options3
                  : options4
            ).map((option) => (
              <Radio
                key={option.value}
                value={option.value}
                onClick={(e) => {
                  radioOnChange1(
                    e as unknown as React.ChangeEvent<HTMLInputElement>,
                  );
                  handleSetNull();
                }}
              >
                {option.label}
              </Radio>
            ))}
          </Radio.Group>
        </span>

        {/* 右边的 ProFormSelect */}
        <span style={{ width: '300px', marginLeft: 'auto', marginTop: '30px' }}>
          {' '}
          {/* 修改:设置 width 和 marginLeft */}
boyang authored
4389
4390
4391
4392
4393
4394
4395
          {salesCodePermission && (
            <ProFormSelect
              name="salesCode"
              key="salesCode"
              width="200px"
              actionRef={mainTableRef}
              formRef={mainTableFormRef}
boyang authored
4396
              initialValue={userInfo.username}
boyang authored
4397
4398
4399
4400
4401
4402
              showSearch
              label="销售代表"
              placeholder="请输入销售代表"
              options={salesCodeOptions}
              onChange={(_, option) => {
                if (option === undefined) {
boyang authored
4403
                  selectSalesCode(userInfo.username);
boyang authored
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
                }
                // if (option.value !== undefined) {
                //   selectSalesCode(option.value);
                // }
                if (option && option.value !== undefined) {
                  selectSalesCode(option.value);
                }
                mainTableRef.current?.reload();
              }}
              request={async () => {
                let options = await getSalesCodeOptions();
                setSalesCodeOptions(options);
                return options;
              }}
            />
          )}
4420
4421
4422
4423
        </span>
      </div>

      <div style={{ height: '15px' }}></div>
4424
4425
4426
      <ProTable
        id="main-table"
        // tableStyle={{backgroundColor:'red'}}
boyang authored
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
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
        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}
        request={async (
          // 第一个参数 params 查询表单和 params 参数的结合
          // 第一个参数中一定会有 pageSize 和  current ,这两个参数是 antd 的规范
          params,
          sorter,
          filter,
        ) => {
          //订单id处理
          /**
           * 以params中的id为主,如果params没id,则取url中的id
           * 第一次进来这个页面,url带有id的话,会自动填充到查询表单中,但是第一次查询params不会带这个id进来
           */
          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) => {
                return id !== '';
              });
            }
          }
boyang authored
4494
          params.salesCode = userInfo.username;
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
          params.condition = filterCondifion;
          //排序
          params.sorted = sorted;
          //是否只查看已作废
          params.isDeleteQueryOrder = filterCondifion === 70;
          let finalParams = {
            ...params,
          };
          if (value1 === 0) {
            // const currentDate = new Date();
            // const newDate = new Date(currentDate);
            // newDate.setDate(currentDate.getDate() - 0);
            handleSetNull();
          }
          if (activeTabKey === 1) {
            // // 第一段代码
            // if (calDate === 'null') {
            //   params.applyTimeLe = null;
            // } else {
            //   params.applyTimeLe = calDate;
            // }
            // params.applyTimeIsNotNull = true; // 要求申请时间非空
            params.orderStatus = 'SHIPPED'; // 发票确认预警
            params.isDeleteQueryOrder = false; // 强制查询非作废订单
boyang authored
4519
            params.salesCode = userInfo.username;
boyang authored
4520
            params.warningStatus = 'waitConfirmReicept';
boyang authored
4521
            if (salesCodeSelect !== undefined && salesCodeSelect !== null) {
4522
4523
              params.salesCode = salesCodeSelect;
            }
4524
4525
4526
            // params.paymentMethod = 'UNPAID';
            finalParams = {
              ...params,
boyang authored
4527
              statusDatetimeLe: calDate,
4528
4529
4530
4531
4532
4533
4534
4535
4536
            };
          } else if (activeTabKey === 2) {
            // // 第一段代码
            // if (calDate === 'null') {
            //   params.applyTimeLe = null;
            // } else {
            //   params.applyTimeLe = calDate;
            // }
            // params.applyTimeIsNotNull = true; // 要求申请时间非空
boyang authored
4537
4538
            params.salesCode = userInfo.username;
            if (salesCodeSelect !== undefined && salesCodeSelect !== null) {
4539
4540
              params.salesCode = salesCodeSelect;
            }
4541
4542
4543
4544
4545
            params.warningStatus = 'waitFeedbackWarning'; // 发票确认预警
            params.isDeleteQueryOrder = false; // 强制查询非作废订单
            // params.paymentMethod = 'UNPAID';
            finalParams = {
              ...params,
boyang authored
4546
              confirmReceiptDatetimeLe: calDate,
4547
4548
4549
4550
4551
4552
4553
4554
            };
          } else if (activeTabKey === 3) {
            // 第一段代码
            // if (calDate === 'null') {
            //   params.applyTimeLe = null;
            // } else {
            //   params.applyTimeLe = calDate;
            // }
boyang authored
4555
            // params.applyTimeIsNotNull = true; // 要求申请时间非空
boyang authored
4556
4557
            params.salesCode = userInfo.username;
            if (salesCodeSelect !== undefined && salesCodeSelect !== null) {
4558
4559
              params.salesCode = salesCodeSelect;
            }
4560
4561
            params.warningStatus = 'invoiceConfirmWarning'; // 发票确认预警
            params.isDeleteQueryOrder = false; // 强制查询非作废订单
boyang authored
4562
            // params.paymentMethod = 'UNPAID';
4563
4564
            finalParams = {
              ...params,
boyang authored
4565
              invoicingEndTime: calDate,
4566
4567
4568
            };
          } else if (activeTabKey === 4) {
            params.warningStatus = 'paymentReceiptStatusWarning'; // 用于回款预警
boyang authored
4569
4570
            params.salesCode = userInfo.username;
            if (salesCodeSelect !== undefined && salesCodeSelect !== null) {
4571
4572
              params.salesCode = salesCodeSelect;
            }
4573
4574
4575
4576
            params.isDeleteQueryOrder = false; // 强制查询非作废订单
            params.paymentNotReceipt = true; // 在回款预警中标记未支付订单
            finalParams = {
              ...params,
boyang authored
4577
              applyTimeLe: calDate,
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
            };
          }
          //保存这个搜索条件
          setSearchParam(params);
          const { data } = await postServiceOrderQueryServiceOrder({
            // ...params,
            // FIXME: remove @ts-ignore
            // @ts-ignore
            sorter,
            filter,
            data: finalParams,
          });

          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);
boyang authored
4610
          }
boyang authored
4611
4612
          // 请求完成后触发 getInvoiceWarningNum
          getInvoiceWarningNum();
4613
4614
4615
4616
4617
4618
4619
          return {
            data: data?.data || [],
            total: data?.total || 0,
          };
        }}
        toolbar={{
          multipleLine: true,
boyang authored
4620
        }}
4621
4622
4623
        // toolBarRender={() => {
        //   return toolBarRender();
        // }}
boyang authored
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
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
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
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123

      {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();
          }}
        />
      )}
      {feedbackRegistrationModalVisible && (
        <FeedbackRegistrationModal
          setVisible={(val: boolean) => {
            setFeedbackRegistrationModalVisible(val);
            if (!val) {
              clearOptObject();
            }
          }}
          subOrders={buildSubOrders()}
          mainOrder={buildMainOrder()}
          onClose={() => {
            setFeedbackRegistrationModalVisible(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} />
5124
    </div>
calmound authored
5125
5126
5127
  );
};
sanmu authored
5128
export default OrderPage;