Blame view

src/pages/Order/components/OrderDrawer.tsx 25.2 KB
zhongnanhuang authored
1
import { RESPONSE_CODE } from '@/constants/enum';
2
3
import {
  postServiceOrderAddOrder,
zhongnanhuang authored
4
  postServiceOrderQueryCustomerNameInformation,
5
  postServiceOrderQueryProductInformation,
zhongnanhuang authored
6
  postServiceOrderUpdateOrder,
7
} from '@/services';
zhongnanhuang authored
8
9
10
11
12
import {
  enumToSelect,
  getAliYunOSSFileNameFromUrl,
  getUserInfo,
} from '@/utils';
sanmu authored
13
14
15
16
import {
  DrawerForm,
  FormListActionType,
  ProCard,
17
  ProFormDateTimePicker,
18
  ProFormDigit,
sanmu authored
19
  ProFormList,
20
  ProFormSelect,
sanmu authored
21
  ProFormText,
22
  ProFormTextArea,
zhongnanhuang authored
23
  ProFormUploadDragger,
sanmu authored
24
} from '@ant-design/pro-components';
zhongnanhuang authored
25
import { Button, Form, message } from 'antd';
zhongnanhuang authored
26
import { cloneDeep } from 'lodash';
zhongnanhuang authored
27
import { useEffect, useRef, useState } from 'react';
28
29
import {
  INVOCING_STATUS_OPTIONS,
zhongnanhuang authored
30
  INVOCING_STATUS_OPTIONS_OLD,
31
32
33
  PAYMENT_CHANNEL_OPTIONS,
  PAYMENT_METHOD_OPTIONS,
  PRODUCT_BELONG_DEPARTMENT_OPTIONS,
zhongnanhuang authored
34
  SALES_CODE_OPTIONS,
35
} from '../constant';
sanmu authored
36
37
export default ({ onClose, data, subOrders, orderOptType }) => {
zhongnanhuang authored
38
  const [invoicingStatus, setInvoicingStatus] = useState('');
zhongnanhuang authored
39
  let originSubOrders = cloneDeep(subOrders);
40
41
42
43
44
45
46
  /**
   * 获取当前的操作类型boolean值
   * @param type 操作类型,如果与当前匹配返回true
   */
  function optType(type: string) {
    return orderOptType === type;
  }
zhongnanhuang authored
47
zhongnanhuang authored
48
49
50
51
52
53
54
55
56
57
58
  /**
   *
   * @returns 获取开票选项
   */
  function getInvoicingSelect() {
    if (optType('edit') || optType('copy')) {
      return enumToSelect(INVOCING_STATUS_OPTIONS_OLD);
    }
    return enumToSelect(INVOCING_STATUS_OPTIONS);
  }
zhongnanhuang authored
59
  const fileList: any = [];
60
61
62
63
64
65
66

  useEffect(() => {
    // 在组件挂载或数据变化时,更新组件状态
    if (data) {
      setInvoicingStatus(data.invoicingStatus);
    }
  }, [data]);
zhongnanhuang authored
67
  // let mainInfoDisbled = optType('edit');
68
  if (optType('edit') || optType('copy')) {
69
70
71
72
    //订单修改和新增的子订单列表命名是list
    data.list = data.subOrderInformationLists;
    //主订单事业部默认显示子订单第一条的事业部
    data.productBelongBusiness = data.list[0].productBelongBusiness;
zhongnanhuang authored
73
74
75
    data.paymentMethod = data.list[0].paymentMethod;
    data.paymentChannel = data.list[0].paymentChannel;
    data.invoicingStatus = data.list[0].invoicingStatus;
zhongnanhuang authored
76
77
78
79
80
81
82
83
84
85
86
87
88
89

    data.list = data.list?.map((item) => {
      item.filePaths = item.listAnnex?.map((path) => {
        let i = 0;
        return {
          uid: i++,
          name: getAliYunOSSFileNameFromUrl(path),
          status: 'uploaded',
          url: path,
          response: { data: [path] },
        };
      });
      return item;
    });
zhongnanhuang authored
90
  }
zhongnanhuang authored
91
zhongnanhuang authored
92
93
94
95
96
  //复制的时候,如果是不需要开票,要把开票信息清空
  if (optType('copy') && data.invoicingStatus === 'UN_INVOICE') {
    data.invoiceIdentificationNumber = undefined;
  }
97
98
99
  if (subOrders !== undefined && subOrders.length > 0) {
    data.list = subOrders;
  }
zhongnanhuang authored
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  const [form] = Form.useForm<{
    salesCode: '';
    customerName: '';
    customerContactNumber: '';
    institution: '';
    institutionContactName: '';
    customerShippingAddress: '';
    totalPayment: '';
    paymentChannel: '';
    paymentMethod: '';
    productBelongBusiness: '';
    invoicingStatus: '';
    invoiceIdentificationNumber: '';
    invoicingTime: '';
    bank: '';
    bankAccountNumber: '';
116
    deleteSubOrderLists: [];
zhongnanhuang authored
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
    notes: '';
    list: [
      {
        productCode: '';
        productName: '';
        quantity: '';
        productPrice: '';
        parameters: '';
        subOrderPayment: '';
        unit: '';
        serialNumber: '';
        notes: '';
      },
    ];
  }>();
132
133
134
135
136
  const actionRef = useRef<
    FormListActionType<{
      name: string;
    }>
  >();
sanmu authored
137
138
139
140
141

  useEffect(() => {
    form.setFieldsValue({ ...data });
  }, [data]);
zhongnanhuang authored
142
143
144
145
146
147
148
149
  /**
   *
   * @param option 商品名称所对应的商品数据
   * @param currentRowData list中当前行的数据
   */
  function autoFillProductInfo(option: any, currentRowData: any) {
    let copyList = form.getFieldValue('list');
    let currentData = copyList[currentRowData.field.key];
150
151
152
    currentData.productCode = option?.productCode;
    currentData.parameters = option?.specifications;
    currentData.unit = option?.unit;
zhongnanhuang authored
153
    form.setFieldValue('list', copyList);
154
  }
zhongnanhuang authored
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

  /**
   * 选择收货人后自动填充信息
   * @param option 收货人信息
   */
  function autoFillCustomerInfo(option: any) {
    form.setFieldValue('institution', option.institution);
    form.setFieldValue('institutionContactName', option.institutionContactName);
    form.setFieldValue(
      'customerShippingAddress',
      option.customerShippingAddress,
    );
    form.setFieldValue('customerContactNumber', option.customerContactNumber);
    form.setFieldValue('customerName', option.customerName);
  }

  /**
   * 计算子订单金额
   * @param listMeta 当前商品信息
   */
  function computeSubOrderPayment(listMeta: any) {
    let quantity = listMeta?.record?.quantity;
    let productPrice = listMeta?.record?.productPrice;
    quantity = quantity === '' || quantity === undefined ? 0 : quantity;
    productPrice =
      productPrice === '' || productPrice === undefined ? 0 : productPrice;

    listMeta.subOrderPayment = quantity * productPrice;
    let list = form.getFieldValue('list');
    list[listMeta?.index].subOrderPayment = quantity * productPrice;
    form.setFieldValue('list', list);
  }

  /**
   * 计算支付总额
   */
  function computeTotalPayment() {
    let list = form.getFieldValue('list');
    let totalPayment = 0;
    list?.forEach((subOrder: any) => {
      let subOrderPayment = subOrder?.subOrderPayment;
      if (subOrderPayment === '' || subOrderPayment === undefined) {
        totalPayment += 0;
      } else {
        totalPayment += subOrderPayment;
      }
    });
    form.setFieldValue('totalPayment', totalPayment);
  }
sanmu authored
205
206
  return (
    <DrawerForm<{
207
      deleteSubOrderLists: any;
sanmu authored
208
209
210
211
      name: string;
      company: string;
    }>
      open
212
      width="35%"
213
      title={optType('add') || optType('copy') ? '新建订单' : '修改订单'}
zhongnanhuang authored
214
      initialValues={() => {
215
216
        //编辑和复制回显数据
        if (optType('edit') || optType('copy')) {
zhongnanhuang authored
217
218
          return data;
        }
zhongnanhuang authored
219
        return {};
220
      }}
sanmu authored
221
222
223
224
225
226
227
228
229
230
231
232
233
      resize={{
        onResize() {
          console.log('resize!');
        },
        maxWidth: window.innerWidth * 0.8,
        minWidth: 400,
      }}
      // layout="horizontal"
      // labelCol={{ span: 8 }}
      form={form}
      autoFocusFirstInput
      drawerProps={{
        destroyOnClose: true,
zhongnanhuang authored
234
        maskClosable: false,
sanmu authored
235
236
237
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
238
        let res = {};
zhongnanhuang authored
239
240
241
242
243
244
245
246
247
248
249
250
        //附件处理
        let list = values.list;
        // console.log(list);
        list = list.map((item) => {
          item.filePaths = item.filePaths?.map((file) => {
            console.log(file);
            return { url: file.response.data[0] };
          });
          return item;
        });

        values.list = list;
251
        if (optType('add') || optType('copy')) {
252
          res = await postServiceOrderAddOrder({ data: values });
zhongnanhuang authored
253
        } else {
254
          //计算已删除的子订单id
zhongnanhuang authored
255
          const originIds = originSubOrders.map((item) => {
256
257
258
259
260
            return item.id;
          });
          const curIds = form.getFieldValue('list')?.map((item) => {
            return item.id;
          });
261
          let diff = originIds.filter((item) => !curIds.includes(item));
262
263
          values.deleteSubOrderLists = diff;
          res = await postServiceOrderUpdateOrder({ data: values });
zhongnanhuang authored
264
265
        }
266
267
        if (res.result === RESPONSE_CODE.SUCCESS) {
          message.success(res.message);
zhongnanhuang authored
268
          // 不返回不会关闭弹框
zhongnanhuang authored
269
          onClose(true);
zhongnanhuang authored
270
          return true;
zhongnanhuang authored
271
        }
sanmu authored
272
273
      }}
      onOpenChange={(val) => {
sanmu authored
274
        return !val && onClose();
sanmu authored
275
276
277
278
      }}
    >
      <h2>订单基本信息</h2>
      <ProFormText
zhongnanhuang authored
279
        key="id"
zhongnanhuang authored
280
281
282
283
284
285
286
        name="id"
        width="lg"
        disabled
        label="id"
        placeholder="id"
        hidden
      />
zhongnanhuang authored
287
      <ProFormSelect
288
        name="salesCode"
zhongnanhuang authored
289
        key="salesCode"
290
        width="lg"
zhongnanhuang authored
291
        showSearch
292
293
        label="销售代表"
        placeholder="请输入销售代表"
zhongnanhuang authored
294
295
        options={SALES_CODE_OPTIONS}
        rules={[{ required: true, message: '销售代表必填' }]}
zhongnanhuang authored
296
        // disabled={mainInfoDisbled}
297
      />
zhongnanhuang authored
298
      <ProFormSelect
zhongnanhuang authored
299
        key="customerName"
300
        label="收货人"
zhongnanhuang authored
301
302
303
304
        width="lg"
        showSearch
        name="customerName"
        // options={options}
305
        placeholder="请输入收货人"
306
        rules={[{ required: true, message: '收货人必填' }]}
zhongnanhuang authored
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
        onChange={(_, option) => {
          autoFillCustomerInfo(option);
        }}
        fieldProps={{
          optionItemRender(item) {
            if (item.type === 'add') {
              return (
                <div title={item.customerName + '(新增商品信息)'}>
                  <span style={{ color: '#333333' }}>{item.customerName}</span>
                  {' | '}
                  <span style={{ color: 'orange' }}>自定义</span>
                </div>
              );
            }
            return (
              <div
                title={
                  item.customerName +
                  ' | ' +
                  item.customerContactNumber +
                  ' | ' +
                  (item.customerShippingAddress === undefined
                    ? '无地址'
                    : item.customerShippingAddress) +
                  ' | ' +
                  item.institutionContactName +
                  ' | ' +
                  item.institution
                }
              >
                <span style={{ color: '#333333' }}>{item.customerName}</span>
                {' | '}
                <span style={{ color: '#339999' }}>
                  {item.customerContactNumber === undefined
                    ? '无电话号码'
                    : item.customerContactNumber}
                </span>
                {' | '}
                <span style={{ color: '#666666' }}>
                  {item.customerShippingAddress === undefined
                    ? '无地址'
                    : item.customerShippingAddress}
                </span>
                {' | '}
                <span style={{ color: '#666666' }}>
                  {item.institutionContactName === undefined
                    ? '无单位联系人'
                    : item.institutionContactName}
                </span>
                {' | '}
                <span style={{ color: '#666666' }}>
                  {item.institution === undefined ? '无单位' : item.institution}
                </span>
              </div>
            );
          },
        }}
        request={async (value, { params }) => {
          const keywords = value.keyWords;
          const { data } = await postServiceOrderQueryCustomerNameInformation({
            data: { customerName: keywords },
            params: params,
          });
          let options = data.map((c: any) => {
            return {
              ...c,
              label: c.customerName,
              value: c.id,
              key: c.id,
            };
          });

          //第一个商品默认为要新增的商品
          if (keywords.trim() !== '') {
            options.unshift({
              customerName: keywords,
              type: 'add',
              label: keywords,
              value: 3.1415926,
              key: keywords,
            });
          }
          return options;
        }}
391
392
393
      />
      <ProFormText
        width="lg"
zhongnanhuang authored
394
        key="customerContactNumber"
395
        name="customerContactNumber"
396
397
        label="联系方式"
        placeholder="请输入联系方式"
398
        rules={[{ required: true, message: '联系方式必填' }]}
zhongnanhuang authored
399
        // disabled={mainInfoDisbled}
400
401
402
      />
      <ProFormText
        width="lg"
zhongnanhuang authored
403
        key="institution"
404
405
406
        name="institution"
        label="单位"
        placeholder="请输入单位"
407
        rules={[{ required: true, message: '单位必填' }]}
zhongnanhuang authored
408
        // disabled={mainInfoDisbled}
sanmu authored
409
      />
410
411
      <ProFormText
        width="lg"
zhongnanhuang authored
412
        key="institutionContactName"
413
414
415
        name="institutionContactName"
        label="单位联系人"
        placeholder="请输入单位联系人"
416
        rules={[{ required: true, message: '单位联系人必填' }]}
zhongnanhuang authored
417
        // disabled={mainInfoDisbled}
418
      />
419
420
      <ProFormTextArea
        width="lg"
zhongnanhuang authored
421
        key="customerShippingAddress"
422
423
424
        name="customerShippingAddress"
        label="收货地址"
        placeholder="请输入收货地址"
425
        rules={[{ required: true, message: '收货地址必填' }]}
zhongnanhuang authored
426
        // disabled={mainInfoDisbled}
427
      />
zhongnanhuang authored
428
429
430
431
      <div id="total-payment">
        <ProFormDigit
          name="totalPayment"
          width="lg"
zhongnanhuang authored
432
          key="totalPayment"
zhongnanhuang authored
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
          label="支付总额(¥)"
          rules={[{ required: true, message: '支付总额必填' }]}
          tooltip="点击计算,合计所有子订单金额"
          fieldProps={{
            addonAfter: (
              <Button
                className="rounded-l-none"
                type="primary"
                onClick={computeTotalPayment}
              >
                计算
              </Button>
            ),
          }}
          // disabled={mainInfoDisbled}
        />
      </div>
451
452
453
454
      <ProFormSelect
        placeholder="请输入支付渠道"
        name="paymentChannel"
        width="lg"
zhongnanhuang authored
455
        key="paymentChannel"
456
457
        label="支付渠道"
        options={enumToSelect(PAYMENT_CHANNEL_OPTIONS)}
458
        rules={[{ required: true, message: '支付渠道必填' }]}
zhongnanhuang authored
459
        // disabled={mainInfoDisbled}
460
461
462
463
464
      />
      <ProFormSelect
        placeholder="请输入支付方式"
        name="paymentMethod"
        width="lg"
zhongnanhuang authored
465
        key="paymentMethod"
466
467
        label="支付方式"
        options={enumToSelect(PAYMENT_METHOD_OPTIONS)}
468
        rules={[{ required: true, message: '支付方式必填' }]}
zhongnanhuang authored
469
        // disabled={mainInfoDisbled}
470
471
      />
      <ProFormSelect
zhongnanhuang authored
472
        placeholder="选择是否需要开票"
473
474
        name="invoicingStatus"
        width="lg"
zhongnanhuang authored
475
        key="invoicingStatus"
zhongnanhuang authored
476
        label="是否需要开票"
zhongnanhuang authored
477
        options={getInvoicingSelect()}
zhongnanhuang authored
478
        // disabled={mainInfoDisbled}
zhongnanhuang authored
479
480
        onChange={(_, option) => {
          setInvoicingStatus(option.value);
zhongnanhuang authored
481
482
483
484
485
          if (option.value === 'UN_INVOICE') {
            form.setFieldValue('invoiceIdentificationNumber', undefined);
            form.setFieldValue('bank', undefined);
            form.setFieldValue('bankAccountNumber', undefined);
          }
zhongnanhuang authored
486
        }}
487
        rules={[{ required: true, message: '是否需要开票必填' }]}
488
      />
zhongnanhuang authored
489
490
491
492
      <ProFormText
        width="lg"
        name="invoiceIdentificationNumber"
        label="开票信息"
zhongnanhuang authored
493
        key="invoiceIdentificationNumber"
zhongnanhuang authored
494
        // disabled={mainInfoDisbled}
zhongnanhuang authored
495
        hidden={invoicingStatus === 'UN_INVOICE'}
zhongnanhuang authored
496
497
498
        placeholder="请输入开票信息"
        rules={[
          {
zhongnanhuang authored
499
            required: invoicingStatus === 'UN_INVOICE' ? false : true,
zhongnanhuang authored
500
501
502
503
            message: '开票信息必填',
          },
        ]}
      />
504
zhongnanhuang authored
505
      {getUserInfo().roleSmallVO?.code === 'admin' ? (
zhongnanhuang authored
506
507
        <ProFormDateTimePicker
          width="lg"
zhongnanhuang authored
508
          key="invoicingTime"
zhongnanhuang authored
509
          name="invoicingTime"
zhongnanhuang authored
510
          // disabled={mainInfoDisbled}
zhongnanhuang authored
511
          hidden={invoicingStatus === 'UN_INVOICE'}
zhongnanhuang authored
512
513
514
515
516
517
          label="开票时间"
          placeholder="请输入开票时间"
        />
      ) : (
        ''
      )}
518
519
520
      <ProFormText
        width="lg"
        name="bank"
zhongnanhuang authored
521
        key="bank"
522
        label="开户银行"
zhongnanhuang authored
523
        // disabled={mainInfoDisbled}
zhongnanhuang authored
524
        hidden={invoicingStatus === 'UN_INVOICE'}
525
526
527
528
        placeholder="请输入开户银行"
      />
      <ProFormText
        width="lg"
zhongnanhuang authored
529
        key="bankAccountNumber"
530
        name="bankAccountNumber"
zhongnanhuang authored
531
        hidden={invoicingStatus === 'UN_INVOICE'}
532
        label="银行账号"
zhongnanhuang authored
533
        // disabled={mainInfoDisbled}
534
535
536
537
538
539
        placeholder="请输入银行账号"
      />
      <ProFormText
        width="lg"
        name="notes"
        label="备注"
zhongnanhuang authored
540
        key="notes"
zhongnanhuang authored
541
        // disabled={mainInfoDisbled}
542
        placeholder="请输入备注"
zhongnanhuang authored
543
544
545
546
547
548
        rules={[
          {
            max: 120, // 最大长度为120个字符
            message: '备注不能超过120个字符',
          },
        ]}
549
550
551
552
      />

      <h2>商品信息</h2>
      <ProFormList
553
        creatorButtonProps={{ disabled: false }}
554
        name="list"
555
        label=""
zhongnanhuang authored
556
        copyIconProps={false} //复制按钮不显示
sanmu authored
557
558
559
560
561
562
563
564
565
566
        initialValue={[
          {
            productCode: '',
            productName: '',
            quantity: '',
            productPrice: '',
            parameters: '',
            subOrderPayment: '',
          },
        ]}
567
568
569
570
        actionGuard={{
          beforeRemoveRow: async (index) => {
            return new Promise((resolve) => {
              if (index === 0) {
zhongnanhuang authored
571
                message.error('第一行数据不能删除');
572
573
574
                resolve(false);
                return;
              }
zhongnanhuang authored
575
              resolve(true);
576
577
578
            });
          },
        }}
zhongnanhuang authored
579
        itemRender={(doms, listMeta) => {
zhongnanhuang authored
580
581
582
583
584
585
586
587
588
589
590
591
592
593
          if (optType('edit')) {
            let i = 0;
            let defaultFileList = listMeta.record?.listAnnex?.map((annex) => {
              return {
                uid: i++,
                name: annex,
                status: 'uploaded',
                url: annex,
                response: { data: [annex] },
              };
            });
            fileList[listMeta.index] = defaultFileList;
          }
          let itemFileList = fileList[listMeta.index];
sanmu authored
594
          return (
595
596
            <ProCard
              bordered
zhongnanhuang authored
597
              extra={doms.action}
zhongnanhuang authored
598
              title={'商品' + (listMeta.index + 1)}
599
600
601
602
              style={{
                marginBlockEnd: 8,
              }}
            >
zhongnanhuang authored
603
604
              {[
                <ProFormSelect
605
                  key="key"
zhongnanhuang authored
606
607
608
609
                  label="商品名称"
                  width="lg"
                  showSearch
                  name="productName"
zhongnanhuang authored
610
                  // options={options}
zhongnanhuang authored
611
                  placeholder="请搜索商品"
612
                  rules={[{ required: true, message: '商品名称必填' }]}
zhongnanhuang authored
613
614
615
                  onChange={(_, option) => {
                    autoFillProductInfo(option, listMeta);
                  }}
zhongnanhuang authored
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
                  fieldProps={{
                    optionItemRender(item) {
                      if (item.type === 'add') {
                        return (
                          <div title={item.productName + '(新增商品信息)'}>
                            <span style={{ color: '#333333' }}>
                              {item.productName}
                            </span>
                            {' | '}
                            <span style={{ color: 'orange' }}>新增商品</span>
                          </div>
                        );
                      }
                      return (
                        <div
                          title={
                            item.label +
                            ' | ' +
                            (item.specifications === undefined
                              ? '无参数'
                              : item.specifications) +
                            ' | ' +
                            item.unit
                          }
                        >
                          <span style={{ color: '#333333' }}>{item.label}</span>
                          {' | '}
                          <span style={{ color: '#339999' }}>
                            {item.specifications === undefined
                              ? '无参数'
                              : item.specifications}
                          </span>
                          {' | '}
                          <span style={{ color: '#666666' }}>
                            {item.unit === undefined ? '无单位' : item.unit}
                          </span>
                        </div>
                      );
                    },
                  }}
                  request={async (value, { params }) => {
                    const keywords = value.keyWords;
zhongnanhuang authored
658
659
                    const { data } =
                      await postServiceOrderQueryProductInformation({
zhongnanhuang authored
660
661
                        data: { productName: keywords },
                        params: params,
zhongnanhuang authored
662
                      });
zhongnanhuang authored
663
                    let options = data.map((p: any) => {
664
665
666
                      return {
                        ...p,
                        label: p.productName,
zhongnanhuang authored
667
                        value: p.id + '|' + p.productName,
668
669
                        key: p.id,
                      };
zhongnanhuang authored
670
                    });
zhongnanhuang authored
671
672
673
674
675
676
677

                    //第一个商品默认为要新增的商品
                    if (keywords.trim() !== '') {
                      options.unshift({
                        productName: keywords,
                        type: 'add',
                        label: keywords,
zhongnanhuang authored
678
679
                        value: 13 + '|' + keywords,
                        key: keywords,
zhongnanhuang authored
680
681
682
                      });
                    }
                    return options;
zhongnanhuang authored
683
684
                  }}
                />,
zhongnanhuang authored
685
                <ProFormText
zhongnanhuang authored
686
                  key={'productCode' + listMeta.index}
zhongnanhuang authored
687
688
689
690
691
692
693
694
695
696
697
698
699
700
                  width="lg"
                  name="productCode"
                  disabled
                  label={
                    <>
                      <span>商品编码</span>
                      <span className="text-gray-400 text-xs pl-2">
                        新增商品时,商品编码由系统自动生成
                      </span>
                    </>
                  }
                  placeholder="未输入商品名称"
                />,
                <ProFormText
zhongnanhuang authored
701
                  key={'parameters' + listMeta.index}
zhongnanhuang authored
702
703
704
705
706
707
708
                  width="lg"
                  name="parameters"
                  label="商品参数"
                  placeholder="请输入商品参数"
                  rules={[{ required: true, message: '商品参数必填' }]}
                />,
                <ProFormDigit
zhongnanhuang authored
709
                  key={'quantity' + listMeta.index}
zhongnanhuang authored
710
711
712
713
714
715
716
717
718
719
720
721
722
                  width="lg"
                  name="quantity"
                  label="商品数量"
                  fieldProps={{
                    onChange: (value) => {
                      listMeta.record.quantity = value;
                      computeSubOrderPayment(listMeta);
                    },
                  }}
                  placeholder="请输入商品数量"
                  rules={[{ required: true, message: '商品数量必填' }]}
                />,
                <ProFormDigit
zhongnanhuang authored
723
                  key={'productPrice' + listMeta.index}
zhongnanhuang authored
724
725
726
727
728
729
730
731
732
733
734
735
736
                  width="lg"
                  name="productPrice"
                  label="商品单价"
                  fieldProps={{
                    onChange: (value) => {
                      listMeta.record.productPrice = value;
                      computeSubOrderPayment(listMeta);
                    },
                  }}
                  placeholder="请输入商品单价"
                  rules={[{ required: true, message: '商品单价必填' }]}
                />,
                <ProFormText
zhongnanhuang authored
737
                  key={'unit' + listMeta.index}
zhongnanhuang authored
738
739
740
741
742
743
744
745
746
                  width="lg"
                  name="unit"
                  label="商品单位"
                  placeholder="请输入商品单位"
                  rules={[{ required: true, message: '商品单位必填' }]}
                />,

                <ProFormDigit
                  width="lg"
zhongnanhuang authored
747
                  key={'subOrderPayment' + listMeta.index}
zhongnanhuang authored
748
749
750
751
752
753
754
                  name="subOrderPayment"
                  label="子订单金额"
                  placeholder="请输入子订单金额"
                  tooltip="商品数量和单价变化后会自动计算子订单金额"
                  rules={[{ required: true, message: '子订单金额必填' }]}
                />,
                <ProFormSelect
zhongnanhuang authored
755
                  key={'productBelongBusiness' + listMeta.index}
zhongnanhuang authored
756
757
758
759
760
761
762
763
764
765
                  placeholder="请输入所属事业部"
                  name="productBelongBusiness"
                  width="lg"
                  label="所属事业部"
                  options={enumToSelect(PRODUCT_BELONG_DEPARTMENT_OPTIONS)}
                  initialValue={'EXPERIMENTAL_CONSUMABLES'}
                  rules={[{ required: true, message: '所属事业部必填' }]}
                  // disabled={mainInfoDisbled}
                />,
                <ProFormText
zhongnanhuang authored
766
                  key={'notes' + listMeta.index}
zhongnanhuang authored
767
768
769
770
                  width="lg"
                  name="notes"
                  label="备注"
                  placeholder="请输入备注"
zhongnanhuang authored
771
772
773
774
775
776
                  rules={[
                    {
                      max: 120, // 最大长度为120个字符
                      message: '备注不能超过120个字符',
                    },
                  ]}
zhongnanhuang authored
777
                />,
zhongnanhuang authored
778
779
                <>
                  <ProFormUploadDragger
zhongnanhuang authored
780
                    key={'filePaths' + listMeta.index}
zhongnanhuang authored
781
782
783
784
785
786
787
788
789
                    label="附件"
                    name="filePaths"
                    action="/api/service/order/fileProcess"
                    fieldProps={{
                      headers: { Authorization: localStorage.getItem('token') },
                      itemFileList,
                    }}
                  />
                </>,
zhongnanhuang authored
790
              ]}
791
            </ProCard>
sanmu authored
792
793
          );
        }}
794
        actionRef={actionRef}
zhongnanhuang authored
795
      ></ProFormList>
sanmu authored
796
797
798
    </DrawerForm>
  );
};