@bit-sun/business-component 1.1.25 → 1.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ import { getDictionarySource, getDictionaryTextByValue, loadSelectSource } from
6
6
  const hasDictSharingType = getDictionarySource('UC000013')?.length;
7
7
  const sharingTypeDataList = hasDictSharingType && getDictionarySource('UC000013') || sharingType
8
8
 
9
- export function commonFun (type?: string, prefixUrl: any) {
9
+ export function commonFun (type?: string, prefixUrl: any, requestConfigProp?: any, modalTableBusProps?:any) {
10
10
  // 默认type === 'supplier' 供应商选择器
11
11
  let requestConfig = {
12
12
  url: `${prefixUrl.selectPrefix}/supplier`,
@@ -14,6 +14,7 @@ export function commonFun (type?: string, prefixUrl: any) {
14
14
  otherParams: {
15
15
  sorter: 'desc-id'
16
16
  }, // 默认参数
17
+ ...requestConfigProp
17
18
  }
18
19
 
19
20
  /*
@@ -155,7 +156,8 @@ export function commonFun (type?: string, prefixUrl: any) {
155
156
  dataIndex: 'sharingType',
156
157
  render: (text: number) => hasDictSharingType ? getDictionaryTextByValue('UC000013', text) : sharingType.find((i: any) => i.value === text)?.text
157
158
  },
158
- ]
159
+ ],
160
+ ...modalTableBusProps,
159
161
  }
160
162
  let needModalTable = true;
161
163
 
@@ -171,6 +173,7 @@ export function commonFun (type?: string, prefixUrl: any) {
171
173
  sorter: 'desc-id'
172
174
  }, // 默认参数
173
175
  sourceName: 'skuCode',
176
+ ...requestConfigProp,
174
177
  }
175
178
  tableSearchForm = [
176
179
  { name: 'qp-name-like', label: 'SKU名称' },
@@ -279,7 +282,8 @@ export function commonFun (type?: string, prefixUrl: any) {
279
282
  title: '条形码',
280
283
  dataIndex: 'barCode',
281
284
  },
282
- ]
285
+ ],
286
+ ...modalTableBusProps
283
287
  }
284
288
  }
285
289
 
@@ -296,6 +300,7 @@ export function commonFun (type?: string, prefixUrl: any) {
296
300
  sorter: 'desc-id'
297
301
  }, // 默认参数
298
302
  sourceName: 'warehouseIds',
303
+ ...requestConfigProp,
299
304
  }
300
305
  tableSearchForm = [
301
306
  { name: 'qp-physicalWarehouseName-like', label: '物理仓名称' },
@@ -346,7 +351,8 @@ export function commonFun (type?: string, prefixUrl: any) {
346
351
  title: '所属公司',
347
352
  dataIndex: 'companyName',
348
353
  },
349
- ]
354
+ ],
355
+ ...modalTableBusProps
350
356
  }
351
357
  }
352
358
  if(type === 'realWarehouse') {
@@ -361,6 +367,7 @@ export function commonFun (type?: string, prefixUrl: any) {
361
367
  sorter: 'desc-id'
362
368
  }, // 默认参数
363
369
  sourceName: 'warehouseIds',
370
+ ...requestConfigProp,
364
371
  }
365
372
  tableSearchForm = [
366
373
  { name: 'qp-realWarehouseName-like', label: '逻辑仓名称' },
@@ -384,7 +391,8 @@ export function commonFun (type?: string, prefixUrl: any) {
384
391
  dataIndex: 'realWarehouseType',
385
392
  render: (text: number) => getDictionaryTextByValue('SC00004', text),
386
393
  },
387
- ]
394
+ ],
395
+ ...modalTableBusProps,
388
396
  }
389
397
  }
390
398
 
@@ -401,6 +409,7 @@ export function commonFun (type?: string, prefixUrl: any) {
401
409
  sorter: 'desc-id'
402
410
  }, // 默认参数
403
411
  sourceName: 'warehouseIds',
412
+ ...requestConfigProp,
404
413
  }
405
414
  needModalTable = false
406
415
  }
@@ -416,6 +425,7 @@ export function commonFun (type?: string, prefixUrl: any) {
416
425
  sorter: 'desc-id'
417
426
  }, // 默认参数
418
427
  sourceName: 'warehouseIds',
428
+ ...requestConfigProp,
419
429
  }
420
430
  needModalTable = false
421
431
  }
@@ -431,6 +441,7 @@ export function commonFun (type?: string, prefixUrl: any) {
431
441
  sorter: 'desc-id'
432
442
  }, // 默认参数
433
443
  sourceName: 'customCode',
444
+ ...requestConfigProp,
434
445
  }
435
446
  tableSearchForm = [
436
447
  { name: 'qp-name-like', label: '客户名称' },
@@ -528,7 +539,8 @@ export function commonFun (type?: string, prefixUrl: any) {
528
539
  dataIndex: 'sharingType',
529
540
  render: (text: number) => hasDictSharingType ? getDictionaryTextByValue('UC000013', text) : sharingType.find((i: any) => i.value === text)?.text,
530
541
  },
531
- ]
542
+ ],
543
+ ...modalTableBusProps
532
544
  }
533
545
  }
534
546
 
@@ -543,6 +555,7 @@ export function commonFun (type?: string, prefixUrl: any) {
543
555
  sorter: 'desc-id'
544
556
  }, // 默认参数
545
557
  sourceName: 'code',
558
+ ...requestConfigProp,
546
559
  }
547
560
  tableSearchForm = [
548
561
  { name: 'qp-name-like', label: '店铺名称' },
@@ -664,7 +677,8 @@ export function commonFun (type?: string, prefixUrl: any) {
664
677
  title: '归属核算主体',
665
678
  dataIndex: 'accountingName',
666
679
  },
667
- ]
680
+ ],
681
+ ...modalTableBusProps
668
682
  }
669
683
  }
670
684
 
@@ -680,6 +694,7 @@ export function commonFun (type?: string, prefixUrl: any) {
680
694
  sorter: 'desc-id'
681
695
  }, // 默认参数
682
696
  sourceName: 'accountingSubjectCode',
697
+ ...requestConfigProp,
683
698
  }
684
699
  needModalTable = false
685
700
  }
@@ -695,6 +710,7 @@ export function commonFun (type?: string, prefixUrl: any) {
695
710
  sorter: 'desc-id'
696
711
  }, // 默认参数
697
712
  sourceName: 'inventoryOrgCode',
713
+ ...requestConfigProp,
698
714
  }
699
715
  needModalTable = false
700
716
  }
@@ -710,6 +726,7 @@ export function commonFun (type?: string, prefixUrl: any) {
710
726
  sorter: 'desc-id'
711
727
  }, // 默认参数
712
728
  sourceName: 'corporationCompany',
729
+ ...requestConfigProp,
713
730
  }
714
731
  needModalTable = false
715
732
  }
@@ -718,7 +735,7 @@ export function commonFun (type?: string, prefixUrl: any) {
718
735
  if(type === 'employee') {
719
736
  requestConfig = {
720
737
  url: `${prefixUrl.selectPrefix}/employee/v2`,
721
- filter: 'qp-name,employeeNumber-orGroup,like', // 过滤参数
738
+ filter: 'qp-employeeNumber,name-orGroup,like', // 过滤参数
722
739
  mappingTextField: 'name',
723
740
  mappingTextShowKeyField: 'employeeNumber',
724
741
  mappingValueField: 'employeeNumber',
@@ -727,6 +744,7 @@ export function commonFun (type?: string, prefixUrl: any) {
727
744
  sorter: 'desc-id'
728
745
  }, // 默认参数
729
746
  sourceName: 'employeeNumber',
747
+ ...requestConfigProp,
730
748
  }
731
749
  tableSearchForm = [
732
750
  { name: 'qp-name-like', label: '员工名称' },
@@ -781,7 +799,8 @@ export function commonFun (type?: string, prefixUrl: any) {
781
799
  title: '手机号',
782
800
  dataIndex: 'officeTelephone',
783
801
  },
784
- ]
802
+ ],
803
+ ...modalTableBusProps
785
804
  }
786
805
  }
787
806
 
@@ -797,6 +816,7 @@ export function commonFun (type?: string, prefixUrl: any) {
797
816
  sorter: 'desc-id'
798
817
  }, // 默认参数
799
818
  sourceName: 'deliveryModeCode',
819
+ ...requestConfigProp
800
820
  }
801
821
  tableSearchForm = [
802
822
  { name: 'qp-name-like', label: '配送方式名称' },
@@ -880,7 +900,8 @@ export function commonFun (type?: string, prefixUrl: any) {
880
900
  dataIndex: 'remark',
881
901
  title: '备注',
882
902
  },
883
- ]
903
+ ],
904
+ ...modalTableBusProps
884
905
  }
885
906
  }
886
907
 
@@ -177,14 +177,11 @@ export default () => {
177
177
  setValue(value)
178
178
  },
179
179
  // requestConfig: {
180
- // url: `/bop/api/physicalWarehouse`,
181
- // filter: 'qp-physicalWarehouseName,physicalWarehouseCode-orGroup,like',
182
- // mappingTextField: 'physicalWarehouseName',
183
180
  // mappingValueField: 'physicalWarehouseCode',
184
- // otherParams: {
185
- // sorter: 'desc-id'
186
- // }, // 默认参数
187
- // sourceName: 'warehouseIds',
181
+ // sourceName: 'physicalWarehouseCode',
182
+ // },
183
+ // modalTableProps: {
184
+ // modalTableTitle: '选择物理仓-更改title测试',
188
185
  // },
189
186
  prefixUrl: { selectPrefix: '/bop/api', formSelectFix: '/bop/api' },
190
187
  selectProps,
@@ -1,26 +1,43 @@
1
- import React from 'react';
1
+ /*
2
+ * @Description:
3
+ * @Author: rodchen
4
+ * @Date: 2022-05-07 15:17:28
5
+ * @LastEditTime: 2022-05-08 21:01:21
6
+ * @LastEditors: rodchen
7
+ */
8
+ import React, { useMemo } from 'react';
2
9
  import { commonFun } from './BusinessUtils';
3
10
  import SearchSelect from '@/components/Functional/SearchSelect';
4
11
 
12
+ const MemoSearchSelect = React.memo(SearchSelect)
5
13
 
6
14
  const BusinessSearchSelect = (props: any) => {
7
15
  const businessType = props?.selectBusinessType || 'supplier';
8
16
  const prefixUrl = props?.prefixUrl || { selectPrefix: '/bop/api', formSelectFix: '/bop/api' };
9
17
 
10
- const { requestConfig, modalTableProps, needModalTable } = commonFun(businessType, prefixUrl);
11
-
12
- const currentProps = {
13
- requestConfig,
14
- ...props,
15
- needModalTable,
16
- modalTableProps
17
- }
18
+ const { requestConfig, modalTableProps, needModalTable } = commonFun(businessType, prefixUrl,props?.requestConfig || {}, props?.modalTableProps || {});
19
+ const currentProps = useMemo(() => {
20
+ return {
21
+ ...props,
22
+ requestConfig,
23
+ needModalTable,
24
+ modalTableProps
25
+ }
26
+ }, [props?.value])
18
27
 
19
28
  return (
20
29
  <div>
21
- <SearchSelect {...currentProps} />
30
+ <MemoSearchSelect {...currentProps} />
22
31
  </div>
23
32
  );
24
33
  };
25
34
 
26
- export default BusinessSearchSelect;
35
+ export default React.memo(BusinessSearchSelect, (props, nextProps) => {
36
+ if(props && props.labelInValue && props.value && JSON.stringify(props.value) !== JSON.stringify(nextProps.value)) {
37
+ return false
38
+ }
39
+ if(props && props.value !== nextProps.value) {
40
+ return false
41
+ }
42
+ return true
43
+ });
@@ -12,7 +12,7 @@ const { Option } = Select;
12
12
 
13
13
  const SearchSelect = (props: any) => {
14
14
  const {
15
- value,
15
+ value, // 必传
16
16
  onChange,
17
17
  selectProps={},
18
18
  modalTableProps={},
@@ -21,6 +21,7 @@ const SearchSelect = (props: any) => {
21
21
  ctx,
22
22
  sourceName,
23
23
  needModalTable=true,
24
+ getPopupContainer=undefined
24
25
  } = props;
25
26
  const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField='name', mappingTextShowKeyField,mappingValueField='code' } = requestConfig || {};
26
27
  const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
@@ -300,14 +301,18 @@ const SearchSelect = (props: any) => {
300
301
  }
301
302
  };
302
303
 
303
- const handleOk = () => {
304
- if(popvalue?.length) {
305
- formaData(popvalue);
304
+ const handleSelectOver = (selectedValue: any) => {
305
+ if(selectedValue?.length) {
306
+ formaData(selectedValue);
306
307
  // 解决选择最后1页的sku,返回后,不显示名称问题
307
- const source = _.uniqBy(items.concat(popvalue), 'value')
308
+ const source = _.uniqBy(items.concat(selectedValue), 'value')
308
309
  ctx?.form?.setFieldSource(resultSourceKey, source)
309
310
  setItems(source)
310
311
  }
312
+ }
313
+
314
+ const handleOk = () => {
315
+ handleSelectOver(popvalue)
311
316
  handleCancel();
312
317
  };
313
318
 
@@ -431,6 +436,8 @@ const SearchSelect = (props: any) => {
431
436
  // 处理单选
432
437
  filterRows = selectRows;
433
438
  sksResult = selectRows.map((i) => i.value)
439
+ // 单选直接选中 不需要确定
440
+ handleSelectOver(filterRows)
434
441
  }
435
442
 
436
443
  setSelectedRowKeys(sksResult)
@@ -499,77 +506,74 @@ const SearchSelect = (props: any) => {
499
506
  }
500
507
  }
501
508
 
502
- const TooltipContent = () => {
503
- if(selectMode && value && value?.length){
504
- const listSelected = JSON.parse(JSON.stringify(items)).filter((i: any) => value.find(item => item === i.value)) || []
505
- const onClose = (e: any,item: any) => {
506
- e.preventDefault();
507
- const newValue = JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
508
- onChange(newValue);
509
- }
510
- return listSelected?.length && listSelected.map((i: any) => (
509
+ const maxTagPlaceholder = (selectedValues) => {
510
+ const onClose = (e: any,item: any) => {
511
+ e.preventDefault();
512
+ const newValue = labelInValue ? JSON.parse(JSON.stringify(value)).filter((i: any) => i.value !== item.value): JSON.parse(JSON.stringify(value)).filter((i: any) => i !== item.value)
513
+ onChange(newValue);
514
+ }
515
+ return (
516
+ <Tooltip title={selectedValues.map((i: any) => (
511
517
  <Tag
512
518
  closable={true}
513
519
  onClose={(e) => onClose(e,i)}
514
520
  style={{ marginRight: 3, background: '#f5f5f5', height: '24px', border: '1px solid #f0f0f0' }}
515
521
  >
516
- {i.text}
522
+ {i.label}
517
523
  </Tag>
518
- )) || ''
519
- } else {
520
- setTooltipVisible(false)
521
- }
522
- return ''
524
+ ))}>
525
+ {`+ ${selectedValues?.length}`}
526
+ </Tooltip>
527
+ )
523
528
  }
524
529
 
525
530
  return (
526
531
  <div className={'search_select'}>
527
532
  <div className="search_select_show" id={`search_select_div_${uniqueValue}`}>
528
- <Tooltip title={TooltipContent} visible={tooltipVisible} trigger={'hover'} onVisibleChange={visible => { if(selectMode && value && value?.length) { setTooltipVisible(visible)} }}>
529
- <Select
530
- virtual
531
- labelInValue={labelInValue}
532
- value={value}
533
- onChange={onChange}
534
- dropdownRender={menu => (
535
- <>
536
- <Input
537
- value={searchValue}
538
- style={{ width: '98%', marginLeft: '1%' }}
539
- placeholder="请输入"
540
- onChange={e=> onSearchChange(e)}
541
- onBlur={onSearchBlur}
542
- onKeyDown={(e) => {
543
- // 阻止多选的冒泡
544
- e.stopPropagation()
545
- }}
546
- />
547
- <Divider style={{ margin: '8px 0' }} />
548
- {menu}
549
- </>
550
- )}
551
- notFoundContent={
552
- fetching ? <Spin size="small" /> :
553
- <div style={{ textAlign: 'center'}}>
554
- <div style={{ marginBottom: 16 }}>
555
- <CopyOutlined style={{ fontSize: '50px' }} />
556
- </div>
557
- <div>无匹配结果,请更换其他内容再试</div>
533
+ <Select
534
+ virtual
535
+ labelInValue={labelInValue}
536
+ value={value}
537
+ onChange={onChange}
538
+ dropdownRender={menu => (
539
+ <>
540
+ <Input
541
+ value={searchValue}
542
+ style={{ width: '98%', marginLeft: '1%' }}
543
+ placeholder="请输入"
544
+ onChange={e=> onSearchChange(e)}
545
+ onBlur={onSearchBlur}
546
+ onKeyDown={(e) => {
547
+ // 阻止多选的冒泡
548
+ e.stopPropagation()
549
+ }}
550
+ />
551
+ <Divider style={{ margin: '8px 0' }} />
552
+ {menu}
553
+ </>
554
+ )}
555
+ notFoundContent={
556
+ fetching ? <Spin size="small" /> :
557
+ <div style={{ textAlign: 'center'}}>
558
+ <div style={{ marginBottom: 16 }}>
559
+ <CopyOutlined style={{ fontSize: '50px' }} />
558
560
  </div>
559
- }
560
- onPopupScroll={SelectScroll}
561
- style={{ width: needModalTable?'calc(100% - 30px)':'calc(100%)' }}
562
- placeholder="请选择"
563
- {...currentSelectProps}
564
- getPopupContainer={() => document.getElementById(`search_select_div_${uniqueValue}`)}
565
- >
566
- {items.map(item => (
567
- <Option key={item.value} label={item.text}>
568
- {LightHeightOption({ text: `${item.textShowKey} ${item.text}`, filterTxt: searchValue })}
569
- </Option>
570
- ))}
571
- </Select>
572
- </Tooltip>
561
+ <div>无匹配结果,请更换其他内容再试</div>
562
+ </div>
563
+ }
564
+ onPopupScroll={SelectScroll}
565
+ style={{ width: needModalTable?'calc(100% - 30px)':'calc(100%)' }}
566
+ placeholder="请选择"
567
+ maxTagPlaceholder={maxTagPlaceholder}
568
+ {...currentSelectProps}
569
+ getPopupContainer={() => (getPopupContainer && getPopupContainer()) || document.getElementById(`search_select_div_${uniqueValue}`)}
570
+ >
571
+ {items.map(item => (
572
+ <Option key={item.value} label={item.text}>
573
+ {LightHeightOption({ text: `${item.textShowKey} ${item.text}`, filterTxt: searchValue })}
574
+ </Option>
575
+ ))}
576
+ </Select>
573
577
  {needModalTable && (
574
578
  <Button style={{width: '30px', padding: '2px', height: 'auto'}} onClick={showModal} type="primary">
575
579
  <SearchOutlined />
@@ -583,7 +587,7 @@ const SearchSelect = (props: any) => {
583
587
  visible={isModalVisible}
584
588
  onOk={handleOk}
585
589
  onCancel={handleCancel}
586
- footer={[
590
+ footer={selectMode?[
587
591
  <Button key="back" onClick={handleCancel}>
588
592
  取消
589
593
  </Button>,
@@ -595,7 +599,7 @@ const SearchSelect = (props: any) => {
595
599
  >
596
600
  确定
597
601
  </Button>,
598
- ]}
602
+ ]:null}
599
603
  >
600
604
  <div className={'search_select_wrapper'}>
601
605
  <div className={'search_select_wrapper_click_flag'} onClick={() => setCaretLeftFlag(!caretLeftFlag)}>