@bit-sun/business-component 1.1.13 → 1.1.16

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.
package/dist/index.esm.js CHANGED
@@ -1265,6 +1265,14 @@ function injectCSS(css) {
1265
1265
  return styleNode;
1266
1266
  }
1267
1267
  var containerCache = new Map();
1268
+
1269
+ function findExistNode(key) {
1270
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1271
+ var container = getContainer(option);
1272
+ return Array.from(containerCache.get(container).children).find(function (node) {
1273
+ return node.tagName === 'STYLE' && node[MARK_KEY] === key;
1274
+ });
1275
+ }
1268
1276
  function updateCSS(css, key) {
1269
1277
  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1270
1278
  var container = getContainer(option); // Get real parent
@@ -1276,9 +1284,7 @@ function updateCSS(css, key) {
1276
1284
  parentNode.removeChild(placeholderStyle);
1277
1285
  }
1278
1286
 
1279
- var existNode = Array.from(containerCache.get(container).children).find(function (node) {
1280
- return node.tagName === 'STYLE' && node[MARK_KEY] === key;
1281
- });
1287
+ var existNode = findExistNode(key, option);
1282
1288
 
1283
1289
  if (existNode) {
1284
1290
  var _option$csp3, _option$csp4;
@@ -2442,6 +2448,7 @@ var SearchSelect = function SearchSelect(props) {
2442
2448
  fieldValToParam = _ref.fieldValToParam,
2443
2449
  _ref$mappingTextField = _ref.mappingTextField,
2444
2450
  mappingTextField = _ref$mappingTextField === void 0 ? 'name' : _ref$mappingTextField,
2451
+ mappingTextShowKeyField = _ref.mappingTextShowKeyField,
2445
2452
  _ref$mappingValueFiel = _ref.mappingValueField,
2446
2453
  mappingValueField = _ref$mappingValueFiel === void 0 ? 'code' : _ref$mappingValueFiel,
2447
2454
  _ref$sourceName = _ref.sourceName,
@@ -2502,12 +2509,12 @@ var SearchSelect = function SearchSelect(props) {
2502
2509
  popvalue = _useState14[0],
2503
2510
  setPopValue = _useState14[1];
2504
2511
 
2505
- var _useDebounceFn = useDebounceFn(function () {
2512
+ var _useDebounceFn = useDebounceFn(function (v) {
2506
2513
  // 优化搜索参数 支持传多个
2507
2514
  var searchParams = {};
2508
2515
 
2509
2516
  if (typeof selectParamsKey === 'string') {
2510
- searchParams = _defineProperty({}, selectParamsKey, searchValue);
2517
+ searchParams = _defineProperty({}, selectParamsKey, v ? initVal : searchValue);
2511
2518
  }
2512
2519
 
2513
2520
  if (Array.isArray(selectParamsKey)) {
@@ -2628,11 +2635,13 @@ var SearchSelect = function SearchSelect(props) {
2628
2635
  source = res ? res[keys] ? res[keys].map(function (item) {
2629
2636
  return _objectSpread2(_objectSpread2({}, item), {}, {
2630
2637
  text: item[mappingTextField],
2638
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
2631
2639
  value: item[mappingValueField]
2632
2640
  });
2633
2641
  }) : Array.isArray(res) && (res === null || res === void 0 ? void 0 : res.map(function (item) {
2634
2642
  return _objectSpread2(_objectSpread2({}, item), {}, {
2635
2643
  text: item[mappingTextField],
2644
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
2636
2645
  value: item[mappingValueField]
2637
2646
  });
2638
2647
  })) : [];
@@ -2643,7 +2652,6 @@ var SearchSelect = function SearchSelect(props) {
2643
2652
  if (type === 1) {
2644
2653
  var _ctx$form;
2645
2654
 
2646
- console.log(sourceName, 'sourceName');
2647
2655
  ctx === null || ctx === void 0 ? void 0 : (_ctx$form = ctx.form) === null || _ctx$form === void 0 ? void 0 : _ctx$form.setFieldSource(sourceName, source);
2648
2656
  setItems(source);
2649
2657
  setItemsTotal(Number(res === null || res === void 0 ? void 0 : res.total));
@@ -2679,7 +2687,7 @@ var SearchSelect = function SearchSelect(props) {
2679
2687
  };
2680
2688
 
2681
2689
  useEffect(function () {
2682
- getData();
2690
+ run('init');
2683
2691
  }, []);
2684
2692
  useEffect(function () {
2685
2693
  if (value) {
@@ -2742,7 +2750,14 @@ var SearchSelect = function SearchSelect(props) {
2742
2750
 
2743
2751
  var handleOk = function handleOk() {
2744
2752
  if (popvalue === null || popvalue === void 0 ? void 0 : popvalue.length) {
2745
- formaData(popvalue);
2753
+ var _ctx$form2;
2754
+
2755
+ formaData(popvalue); // 解决选择最后1页的sku,返回后,不显示名称问题
2756
+
2757
+ var source = _.uniqBy(items.concat(popvalue), 'value');
2758
+
2759
+ ctx === null || ctx === void 0 ? void 0 : (_ctx$form2 = ctx.form) === null || _ctx$form2 === void 0 ? void 0 : _ctx$form2.setFieldSource(sourceName, source);
2760
+ setItems(source);
2746
2761
  }
2747
2762
 
2748
2763
  setIsModalVisible(false);
@@ -3041,7 +3056,7 @@ var SearchSelect = function SearchSelect(props) {
3041
3056
  key: item.value,
3042
3057
  label: item.text
3043
3058
  }, LightHeightOption({
3044
- text: "".concat(item.value, " ").concat(item.text),
3059
+ text: "".concat(item.textShowKey, " ").concat(item.text),
3045
3060
  filterTxt: searchValue
3046
3061
  }));
3047
3062
  })), /*#__PURE__*/React.createElement(Button, {
@@ -3521,7 +3536,144 @@ function commonFun(type, prefixUrl) {
3521
3536
  };
3522
3537
  } // 仓库选择器
3523
3538
 
3524
- console.log(requestConfig, 'requestConfig');
3539
+
3540
+ if (type === 'physicalWarehouse') {
3541
+ requestConfig = {
3542
+ url: "".concat(prefixUrl.selectPrefix, "/physicalWarehouse"),
3543
+ filter: 'qp-nameAndCode-like',
3544
+ mappingTextField: 'physicalWarehouseName',
3545
+ mappingTextShowKeyField: 'physicalWarehouseCode',
3546
+ mappingValueField: 'id',
3547
+ otherParams: {
3548
+ sorter: 'desc-id'
3549
+ },
3550
+ sourceName: 'warehouseIds'
3551
+ };
3552
+ tableSearchForm = [{
3553
+ name: 'qp-physicalWarehouseName-like',
3554
+ label: '物理仓名称'
3555
+ }, {
3556
+ name: 'qp-physicalWarehouseCode-like',
3557
+ label: '物理仓编码'
3558
+ }, {
3559
+ name: 'qp-physicalWarehouseType-eq',
3560
+ type: 'select',
3561
+ label: '物理仓类型',
3562
+ initialSource: getDictionarySource('SC00002')
3563
+ }, {
3564
+ name: 'qp-companyCode-eq',
3565
+ type: 'select',
3566
+ label: '所属公司',
3567
+ field: {
3568
+ type: 'select',
3569
+ props: {
3570
+ mode: 'multiple',
3571
+ notFoundContent: '暂无数据',
3572
+ allowClear: true,
3573
+ showSearch: true,
3574
+ showArrow: true,
3575
+ maxTagCount: 1,
3576
+ optionFilterProp: 'children',
3577
+ filterOption: function filterOption(input, option) {
3578
+ return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3579
+ }
3580
+ }
3581
+ }
3582
+ }, {
3583
+ name: 'qp-isEnable-eq',
3584
+ type: 'select',
3585
+ label: '物理仓状态',
3586
+ initialSource: getDictionarySource('SC00001')
3587
+ }];
3588
+ Promise.all([loadSelectSource("".concat(prefixUrl.formSelectFix, "/company"), {
3589
+ pageSize: 5000,
3590
+ currentPage: 1,
3591
+ 'qp-companyType-eq': 20
3592
+ })]).then(function (x) {
3593
+ formatSource(x, 0, 3, tableSearchForm);
3594
+ });
3595
+ modalTableProps = {
3596
+ modalTableTitle: '选择物理仓',
3597
+ tableSearchForm: tableSearchForm,
3598
+ tableColumns: [{
3599
+ title: '物理仓编码',
3600
+ dataIndex: 'physicalWarehouseCode'
3601
+ }, {
3602
+ title: '物理仓名称',
3603
+ dataIndex: 'physicalWarehouseName'
3604
+ }, {
3605
+ title: '物理仓类型',
3606
+ dataIndex: 'physicalWarehouseType',
3607
+ render: function render(text) {
3608
+ return getDictionaryTextByValue('SC00002', text);
3609
+ }
3610
+ }, {
3611
+ title: '物理仓状态',
3612
+ dataIndex: 'isEnable',
3613
+ render: function render(text) {
3614
+ return getDictionaryTextByValue('SC00001', text);
3615
+ }
3616
+ }, {
3617
+ title: '所属公司',
3618
+ dataIndex: 'companyName'
3619
+ }]
3620
+ };
3621
+ }
3622
+
3623
+ if (type === 'realWarehouse') {
3624
+ requestConfig = {
3625
+ url: "".concat(prefixUrl.selectPrefix, "/realWarehouse"),
3626
+ filter: 'qp-nameAndCode-like',
3627
+ mappingTextField: 'realWarehouseName',
3628
+ mappingTextShowKeyField: 'realWarehouseCode',
3629
+ mappingValueField: 'id',
3630
+ otherParams: {
3631
+ sorter: 'desc-id'
3632
+ },
3633
+ sourceName: 'warehouseIds'
3634
+ };
3635
+ tableSearchForm = [{
3636
+ name: 'qp-realWarehouseName-like',
3637
+ label: '逻辑仓名称'
3638
+ }, {
3639
+ name: 'qp-realWarehouseCode-like',
3640
+ label: '逻辑仓编码'
3641
+ }, {
3642
+ name: 'qp-realWarehouseType-eq',
3643
+ type: 'select',
3644
+ label: '逻辑仓类型',
3645
+ initialSource: getDictionarySource('SC00004')
3646
+ }, {
3647
+ name: 'qp-isEnable-eq',
3648
+ type: 'select',
3649
+ label: '逻辑仓状态',
3650
+ initialSource: getDictionarySource('SC00001')
3651
+ }];
3652
+ modalTableProps = {
3653
+ modalTableTitle: '选择逻辑仓',
3654
+ tableSearchForm: tableSearchForm,
3655
+ tableColumns: [{
3656
+ title: '逻辑仓编码',
3657
+ dataIndex: 'realWarehouseCode'
3658
+ }, {
3659
+ title: '逻辑仓名称',
3660
+ dataIndex: 'realWarehouseName'
3661
+ }, {
3662
+ title: '逻辑仓类型',
3663
+ dataIndex: 'realWarehouseType',
3664
+ render: function render(text) {
3665
+ return getDictionaryTextByValue('SC00004', text);
3666
+ }
3667
+ }, {
3668
+ title: '逻辑仓状态',
3669
+ dataIndex: 'isEnable',
3670
+ render: function render(text) {
3671
+ return getDictionaryTextByValue('SC00001', text);
3672
+ }
3673
+ }]
3674
+ };
3675
+ }
3676
+
3525
3677
  return {
3526
3678
  modalTableProps: modalTableProps,
3527
3679
  requestConfig: requestConfig
package/dist/index.js CHANGED
@@ -1276,6 +1276,14 @@ function injectCSS(css) {
1276
1276
  return styleNode;
1277
1277
  }
1278
1278
  var containerCache = new Map();
1279
+
1280
+ function findExistNode(key) {
1281
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1282
+ var container = getContainer(option);
1283
+ return Array.from(containerCache.get(container).children).find(function (node) {
1284
+ return node.tagName === 'STYLE' && node[MARK_KEY] === key;
1285
+ });
1286
+ }
1279
1287
  function updateCSS(css, key) {
1280
1288
  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1281
1289
  var container = getContainer(option); // Get real parent
@@ -1287,9 +1295,7 @@ function updateCSS(css, key) {
1287
1295
  parentNode.removeChild(placeholderStyle);
1288
1296
  }
1289
1297
 
1290
- var existNode = Array.from(containerCache.get(container).children).find(function (node) {
1291
- return node.tagName === 'STYLE' && node[MARK_KEY] === key;
1292
- });
1298
+ var existNode = findExistNode(key, option);
1293
1299
 
1294
1300
  if (existNode) {
1295
1301
  var _option$csp3, _option$csp4;
@@ -2453,6 +2459,7 @@ var SearchSelect = function SearchSelect(props) {
2453
2459
  fieldValToParam = _ref.fieldValToParam,
2454
2460
  _ref$mappingTextField = _ref.mappingTextField,
2455
2461
  mappingTextField = _ref$mappingTextField === void 0 ? 'name' : _ref$mappingTextField,
2462
+ mappingTextShowKeyField = _ref.mappingTextShowKeyField,
2456
2463
  _ref$mappingValueFiel = _ref.mappingValueField,
2457
2464
  mappingValueField = _ref$mappingValueFiel === void 0 ? 'code' : _ref$mappingValueFiel,
2458
2465
  _ref$sourceName = _ref.sourceName,
@@ -2513,12 +2520,12 @@ var SearchSelect = function SearchSelect(props) {
2513
2520
  popvalue = _useState14[0],
2514
2521
  setPopValue = _useState14[1];
2515
2522
 
2516
- var _useDebounceFn = ahooks.useDebounceFn(function () {
2523
+ var _useDebounceFn = ahooks.useDebounceFn(function (v) {
2517
2524
  // 优化搜索参数 支持传多个
2518
2525
  var searchParams = {};
2519
2526
 
2520
2527
  if (typeof selectParamsKey === 'string') {
2521
- searchParams = _defineProperty({}, selectParamsKey, searchValue);
2528
+ searchParams = _defineProperty({}, selectParamsKey, v ? initVal : searchValue);
2522
2529
  }
2523
2530
 
2524
2531
  if (Array.isArray(selectParamsKey)) {
@@ -2639,11 +2646,13 @@ var SearchSelect = function SearchSelect(props) {
2639
2646
  source = res ? res[keys] ? res[keys].map(function (item) {
2640
2647
  return _objectSpread2(_objectSpread2({}, item), {}, {
2641
2648
  text: item[mappingTextField],
2649
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
2642
2650
  value: item[mappingValueField]
2643
2651
  });
2644
2652
  }) : Array.isArray(res) && (res === null || res === void 0 ? void 0 : res.map(function (item) {
2645
2653
  return _objectSpread2(_objectSpread2({}, item), {}, {
2646
2654
  text: item[mappingTextField],
2655
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
2647
2656
  value: item[mappingValueField]
2648
2657
  });
2649
2658
  })) : [];
@@ -2654,7 +2663,6 @@ var SearchSelect = function SearchSelect(props) {
2654
2663
  if (type === 1) {
2655
2664
  var _ctx$form;
2656
2665
 
2657
- console.log(sourceName, 'sourceName');
2658
2666
  ctx === null || ctx === void 0 ? void 0 : (_ctx$form = ctx.form) === null || _ctx$form === void 0 ? void 0 : _ctx$form.setFieldSource(sourceName, source);
2659
2667
  setItems(source);
2660
2668
  setItemsTotal(Number(res === null || res === void 0 ? void 0 : res.total));
@@ -2690,7 +2698,7 @@ var SearchSelect = function SearchSelect(props) {
2690
2698
  };
2691
2699
 
2692
2700
  React.useEffect(function () {
2693
- getData();
2701
+ run('init');
2694
2702
  }, []);
2695
2703
  React.useEffect(function () {
2696
2704
  if (value) {
@@ -2753,7 +2761,14 @@ var SearchSelect = function SearchSelect(props) {
2753
2761
 
2754
2762
  var handleOk = function handleOk() {
2755
2763
  if (popvalue === null || popvalue === void 0 ? void 0 : popvalue.length) {
2756
- formaData(popvalue);
2764
+ var _ctx$form2;
2765
+
2766
+ formaData(popvalue); // 解决选择最后1页的sku,返回后,不显示名称问题
2767
+
2768
+ var source = ___default['default'].uniqBy(items.concat(popvalue), 'value');
2769
+
2770
+ ctx === null || ctx === void 0 ? void 0 : (_ctx$form2 = ctx.form) === null || _ctx$form2 === void 0 ? void 0 : _ctx$form2.setFieldSource(sourceName, source);
2771
+ setItems(source);
2757
2772
  }
2758
2773
 
2759
2774
  setIsModalVisible(false);
@@ -3052,7 +3067,7 @@ var SearchSelect = function SearchSelect(props) {
3052
3067
  key: item.value,
3053
3068
  label: item.text
3054
3069
  }, LightHeightOption({
3055
- text: "".concat(item.value, " ").concat(item.text),
3070
+ text: "".concat(item.textShowKey, " ").concat(item.text),
3056
3071
  filterTxt: searchValue
3057
3072
  }));
3058
3073
  })), /*#__PURE__*/React__default['default'].createElement(antd.Button, {
@@ -3532,7 +3547,144 @@ function commonFun(type, prefixUrl) {
3532
3547
  };
3533
3548
  } // 仓库选择器
3534
3549
 
3535
- console.log(requestConfig, 'requestConfig');
3550
+
3551
+ if (type === 'physicalWarehouse') {
3552
+ requestConfig = {
3553
+ url: "".concat(prefixUrl.selectPrefix, "/physicalWarehouse"),
3554
+ filter: 'qp-nameAndCode-like',
3555
+ mappingTextField: 'physicalWarehouseName',
3556
+ mappingTextShowKeyField: 'physicalWarehouseCode',
3557
+ mappingValueField: 'id',
3558
+ otherParams: {
3559
+ sorter: 'desc-id'
3560
+ },
3561
+ sourceName: 'warehouseIds'
3562
+ };
3563
+ tableSearchForm = [{
3564
+ name: 'qp-physicalWarehouseName-like',
3565
+ label: '物理仓名称'
3566
+ }, {
3567
+ name: 'qp-physicalWarehouseCode-like',
3568
+ label: '物理仓编码'
3569
+ }, {
3570
+ name: 'qp-physicalWarehouseType-eq',
3571
+ type: 'select',
3572
+ label: '物理仓类型',
3573
+ initialSource: getDictionarySource('SC00002')
3574
+ }, {
3575
+ name: 'qp-companyCode-eq',
3576
+ type: 'select',
3577
+ label: '所属公司',
3578
+ field: {
3579
+ type: 'select',
3580
+ props: {
3581
+ mode: 'multiple',
3582
+ notFoundContent: '暂无数据',
3583
+ allowClear: true,
3584
+ showSearch: true,
3585
+ showArrow: true,
3586
+ maxTagCount: 1,
3587
+ optionFilterProp: 'children',
3588
+ filterOption: function filterOption(input, option) {
3589
+ return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3590
+ }
3591
+ }
3592
+ }
3593
+ }, {
3594
+ name: 'qp-isEnable-eq',
3595
+ type: 'select',
3596
+ label: '物理仓状态',
3597
+ initialSource: getDictionarySource('SC00001')
3598
+ }];
3599
+ Promise.all([loadSelectSource("".concat(prefixUrl.formSelectFix, "/company"), {
3600
+ pageSize: 5000,
3601
+ currentPage: 1,
3602
+ 'qp-companyType-eq': 20
3603
+ })]).then(function (x) {
3604
+ formatSource(x, 0, 3, tableSearchForm);
3605
+ });
3606
+ modalTableProps = {
3607
+ modalTableTitle: '选择物理仓',
3608
+ tableSearchForm: tableSearchForm,
3609
+ tableColumns: [{
3610
+ title: '物理仓编码',
3611
+ dataIndex: 'physicalWarehouseCode'
3612
+ }, {
3613
+ title: '物理仓名称',
3614
+ dataIndex: 'physicalWarehouseName'
3615
+ }, {
3616
+ title: '物理仓类型',
3617
+ dataIndex: 'physicalWarehouseType',
3618
+ render: function render(text) {
3619
+ return getDictionaryTextByValue('SC00002', text);
3620
+ }
3621
+ }, {
3622
+ title: '物理仓状态',
3623
+ dataIndex: 'isEnable',
3624
+ render: function render(text) {
3625
+ return getDictionaryTextByValue('SC00001', text);
3626
+ }
3627
+ }, {
3628
+ title: '所属公司',
3629
+ dataIndex: 'companyName'
3630
+ }]
3631
+ };
3632
+ }
3633
+
3634
+ if (type === 'realWarehouse') {
3635
+ requestConfig = {
3636
+ url: "".concat(prefixUrl.selectPrefix, "/realWarehouse"),
3637
+ filter: 'qp-nameAndCode-like',
3638
+ mappingTextField: 'realWarehouseName',
3639
+ mappingTextShowKeyField: 'realWarehouseCode',
3640
+ mappingValueField: 'id',
3641
+ otherParams: {
3642
+ sorter: 'desc-id'
3643
+ },
3644
+ sourceName: 'warehouseIds'
3645
+ };
3646
+ tableSearchForm = [{
3647
+ name: 'qp-realWarehouseName-like',
3648
+ label: '逻辑仓名称'
3649
+ }, {
3650
+ name: 'qp-realWarehouseCode-like',
3651
+ label: '逻辑仓编码'
3652
+ }, {
3653
+ name: 'qp-realWarehouseType-eq',
3654
+ type: 'select',
3655
+ label: '逻辑仓类型',
3656
+ initialSource: getDictionarySource('SC00004')
3657
+ }, {
3658
+ name: 'qp-isEnable-eq',
3659
+ type: 'select',
3660
+ label: '逻辑仓状态',
3661
+ initialSource: getDictionarySource('SC00001')
3662
+ }];
3663
+ modalTableProps = {
3664
+ modalTableTitle: '选择逻辑仓',
3665
+ tableSearchForm: tableSearchForm,
3666
+ tableColumns: [{
3667
+ title: '逻辑仓编码',
3668
+ dataIndex: 'realWarehouseCode'
3669
+ }, {
3670
+ title: '逻辑仓名称',
3671
+ dataIndex: 'realWarehouseName'
3672
+ }, {
3673
+ title: '逻辑仓类型',
3674
+ dataIndex: 'realWarehouseType',
3675
+ render: function render(text) {
3676
+ return getDictionaryTextByValue('SC00004', text);
3677
+ }
3678
+ }, {
3679
+ title: '逻辑仓状态',
3680
+ dataIndex: 'isEnable',
3681
+ render: function render(text) {
3682
+ return getDictionaryTextByValue('SC00001', text);
3683
+ }
3684
+ }]
3685
+ };
3686
+ }
3687
+
3536
3688
  return {
3537
3689
  modalTableProps: modalTableProps,
3538
3690
  requestConfig: requestConfig
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "1.1.13",
3
+ "version": "1.1.16",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -47,4 +47,4 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  }
50
- }
50
+ }
@@ -346,10 +346,119 @@ export function commonFun (type?: string, prefixUrl: any) {
346
346
  }
347
347
 
348
348
  // 仓库选择器
349
- if(type === 'warehouse') {
350
-
349
+ if(type === 'physicalWarehouse') {
350
+ requestConfig = {
351
+ url: `${prefixUrl.selectPrefix}/physicalWarehouse`,
352
+ filter: 'qp-nameAndCode-like', // 过滤参数
353
+ mappingTextField: 'physicalWarehouseName',
354
+ mappingTextShowKeyField: 'physicalWarehouseCode',
355
+ mappingValueField: 'id',
356
+ otherParams: {
357
+ sorter: 'desc-id'
358
+ }, // 默认参数
359
+ sourceName: 'warehouseIds',
360
+ }
361
+ tableSearchForm = [
362
+ { name: 'qp-physicalWarehouseName-like', label: '物理仓名称' },
363
+ { name: 'qp-physicalWarehouseCode-like', label: '物理仓编码' },
364
+ { name: 'qp-physicalWarehouseType-eq', type: 'select', label: '物理仓类型', initialSource: getDictionarySource('SC00002') },
365
+ { name: 'qp-companyCode-eq', type: 'select', label: '所属公司', field: {
366
+ type: 'select',
367
+ props: {
368
+ mode: 'multiple',
369
+ notFoundContent: '暂无数据',
370
+ allowClear: true,
371
+ showSearch: true,
372
+ showArrow: true,
373
+ maxTagCount: 1,
374
+ optionFilterProp: 'children',
375
+ filterOption: (input: string, option: { props: { children: string } }) =>
376
+ option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
377
+ },
378
+ } },
379
+ { name: 'qp-isEnable-eq', type: 'select', label: '物理仓状态', initialSource: getDictionarySource('SC00001') },
380
+ ]
381
+ Promise.all([
382
+ loadSelectSource(`${prefixUrl.formSelectFix}/company`, {
383
+ pageSize: 5000,
384
+ currentPage: 1,
385
+ 'qp-companyType-eq': 20,
386
+ }),
387
+ ]).then((x: any)=>{
388
+ formatSource(x,0, 3, tableSearchForm);
389
+ })
390
+ modalTableProps = {
391
+ modalTableTitle: '选择物理仓',
392
+ tableSearchForm,
393
+ tableColumns: [
394
+ {
395
+ title: '物理仓编码',
396
+ dataIndex: 'physicalWarehouseCode',
397
+ },
398
+ {
399
+ title: '物理仓名称',
400
+ dataIndex: 'physicalWarehouseName',
401
+ },
402
+ {
403
+ title: '物理仓类型',
404
+ dataIndex: 'physicalWarehouseType',
405
+ render: (text: number) => getDictionaryTextByValue('SC00002', text),
406
+ },
407
+ {
408
+ title: '物理仓状态',
409
+ dataIndex: 'isEnable',
410
+ render: (text: number) => getDictionaryTextByValue('SC00001', text),
411
+ },
412
+ {
413
+ title: '所属公司',
414
+ dataIndex: 'companyName',
415
+ },
416
+ ]
417
+ }
418
+ }
419
+ if(type === 'realWarehouse') {
420
+ requestConfig = {
421
+ url: `${prefixUrl.selectPrefix}/realWarehouse`,
422
+ filter: 'qp-nameAndCode-like', // 过滤参数
423
+ mappingTextField: 'realWarehouseName',
424
+ mappingTextShowKeyField: 'realWarehouseCode',
425
+ mappingValueField: 'id',
426
+ otherParams: {
427
+ sorter: 'desc-id'
428
+ }, // 默认参数
429
+ sourceName: 'warehouseIds',
430
+ }
431
+ tableSearchForm = [
432
+ { name: 'qp-realWarehouseName-like', label: '逻辑仓名称' },
433
+ { name: 'qp-realWarehouseCode-like', label: '逻辑仓编码' },
434
+ { name: 'qp-realWarehouseType-eq', type: 'select', label: '逻辑仓类型', initialSource: getDictionarySource('SC00004') },
435
+ { name: 'qp-isEnable-eq', type: 'select', label: '逻辑仓状态', initialSource: getDictionarySource('SC00001') },
436
+ ]
437
+ modalTableProps = {
438
+ modalTableTitle: '选择逻辑仓',
439
+ tableSearchForm,
440
+ tableColumns: [
441
+ {
442
+ title: '逻辑仓编码',
443
+ dataIndex: 'realWarehouseCode',
444
+ },
445
+ {
446
+ title: '逻辑仓名称',
447
+ dataIndex: 'realWarehouseName',
448
+ },
449
+ {
450
+ title: '逻辑仓类型',
451
+ dataIndex: 'realWarehouseType',
452
+ render: (text: number) => getDictionaryTextByValue('SC00004', text),
453
+ },
454
+ {
455
+ title: '逻辑仓状态',
456
+ dataIndex: 'isEnable',
457
+ render: (text: number) => getDictionaryTextByValue('SC00001', text),
458
+ },
459
+ ]
460
+ }
351
461
  }
352
462
 
353
- console.log(requestConfig, 'requestConfig')
354
463
  return { modalTableProps, requestConfig };
355
464
  }
@@ -36,7 +36,7 @@ export default () => {
36
36
  // mappingTextField: 'name',
37
37
  // mappingValueField: 'code',
38
38
  // }, // 非必传,业务字段已根据业务默认默认
39
- // prefixUrl: { selectPrefix: '/bop/api', formSelectFix: '/bop/api' }, // 非必传,下拉框和tableForm下拉框接口前缀,默认为bop的接口
39
+ prefixUrl: { selectPrefix: 'http://test.i-baby.net/bop/api', formSelectFix: 'http://test.i-baby.net/bop/api' }, // 非必传,下拉框和tableForm下拉框接口前缀,默认为bop的接口
40
40
  selectProps, // 非必传
41
41
  onChange: (value: any) => {
42
42
  console.log(value)
@@ -73,15 +73,16 @@ export default () => {
73
73
  console.log(value)
74
74
  setValue(value)
75
75
  },
76
- requestConfig: {
77
- url: `/bop/api/sku`,
78
- filter: 'qp-nameAndCode-like',
79
- mappingValueField: 'skuCode',
80
- otherParams: {
81
- sorter: 'desc-id'
82
- }, // 默认参数
83
- sourceName: 'skuCode',
84
- },
76
+ // requestConfig: {
77
+ // url: `http://test.i-baby.net/bop/api/sku`,
78
+ // filter: 'qp-nameAndCode-like',
79
+ // mappingValueField: 'skuCode',
80
+ // otherParams: {
81
+ // sorter: 'desc-id'
82
+ // }, // 默认参数
83
+ // sourceName: 'skuCode',
84
+ // },
85
+ prefixUrl: { selectPrefix: 'http://test.i-baby.net/bop/api', formSelectFix: 'http://test.i-baby.net/bop/api' },
85
86
  selectProps,
86
87
  selectBusinessType: 'skuCommodity',
87
88
  };
@@ -93,4 +94,88 @@ export default () => {
93
94
  );
94
95
  };
95
96
  ```
97
+
98
+ 仓库选择器(物理仓) Select-Warehouse-001:
99
+
100
+ ```tsx
101
+ import React, { useState } from 'react';
102
+ import {BusinessSearchSelect} from '../../../index.ts';
103
+
104
+ export default () => {
105
+ const selectProps = {
106
+ mode: 'multiple',
107
+ maxTagCount: 1,
108
+ // disabled: true
109
+ }
110
+ const [value, setValue] = useState(selectProps?.mode ? [] : null);
111
+ const props = {
112
+ value,
113
+ onChange: (value: any) => {
114
+ console.log(value)
115
+ setValue(value)
116
+ },
117
+ // requestConfig: {
118
+ // url: `http://test.i-baby.net/bop/api/physicalWarehouse`,
119
+ // filter: 'qp-nameAndCode-like',
120
+ // mappingTextField: 'physicalWarehouseName',
121
+ // mappingValueField: 'physicalWarehouseCode',
122
+ // otherParams: {
123
+ // sorter: 'desc-id'
124
+ // }, // 默认参数
125
+ // sourceName: 'warehouseIds',
126
+ // },
127
+ prefixUrl: { selectPrefix: 'http://test.i-baby.net/bop/api', formSelectFix: 'http://test.i-baby.net/bop/api' },
128
+ selectProps,
129
+ selectBusinessType: 'physicalWarehouse',
130
+ };
131
+
132
+ return (
133
+ <div>
134
+ <BusinessSearchSelect {...props} />
135
+ </div>
136
+ );
137
+ };
138
+ ```
139
+
140
+ 仓库选择器(逻辑仓) Select-Warehouse-002:
141
+
142
+ ```tsx
143
+ import React, { useState } from 'react';
144
+ import {BusinessSearchSelect} from '../../../index.ts';
145
+
146
+ export default () => {
147
+ const selectProps = {
148
+ mode: 'multiple',
149
+ maxTagCount: 1,
150
+ // disabled: true
151
+ }
152
+ const [value, setValue] = useState(selectProps?.mode ? [] : null);
153
+ const props = {
154
+ value,
155
+ onChange: (value: any) => {
156
+ console.log(value)
157
+ setValue(value)
158
+ },
159
+ // requestConfig: {
160
+ // url: `http://test.i-baby.net/bop/api/realWarehouse`,
161
+ // filter: 'qp-nameAndCode-like',
162
+ // mappingTextField: 'realWarehouseName',
163
+ // mappingValueField: 'realWarehouseCode',
164
+ // otherParams: {
165
+ // sorter: 'desc-id'
166
+ // }, // 默认参数
167
+ // sourceName: 'warehouseIds',
168
+ // },
169
+ prefixUrl: { selectPrefix: 'http://test.i-baby.net/bop/api', formSelectFix: 'http://test.i-baby.net/bop/api' },
170
+ selectProps,
171
+ selectBusinessType: 'realWarehouse',
172
+ };
173
+
174
+ return (
175
+ <div>
176
+ <BusinessSearchSelect {...props} />
177
+ </div>
178
+ );
179
+ };
180
+ ```
96
181
  More skills for writing demo: https://d.umijs.org/guide/demo-principle
@@ -20,7 +20,7 @@ const SearchSelect = (props: any) => {
20
20
  requestConfig,
21
21
  ctx,
22
22
  } = props;
23
- const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField='name', mappingValueField='code', sourceName='supplierCode' } = requestConfig || {};
23
+ const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField='name', mappingTextShowKeyField,mappingValueField='code', sourceName='supplierCode' } = requestConfig || {};
24
24
 
25
25
  const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
26
26
  const initVal = value || (selectMode ? [] : null);
@@ -47,11 +47,11 @@ const SearchSelect = (props: any) => {
47
47
  const [isModalVisible, setIsModalVisible] = useState(false);
48
48
  const [popvalue, setPopValue] = useState(initVal);
49
49
  const { run } = useDebounceFn(
50
- () => {
50
+ (v?: any) => {
51
51
  // 优化搜索参数 支持传多个
52
52
  let searchParams = {};
53
53
  if(typeof selectParamsKey === 'string') {
54
- searchParams = { [selectParamsKey]: searchValue }
54
+ searchParams = { [selectParamsKey]: v ? initVal : searchValue }
55
55
  }
56
56
  if(Array.isArray(selectParamsKey)) {
57
57
  selectParamsKey.forEach((i: any) => {
@@ -76,6 +76,7 @@ const SearchSelect = (props: any) => {
76
76
  const [filterRows, setFilterRows] = useState([]); // 存放拼接后的一维数组的变量
77
77
  const [checkedAll, setCheckedAll] = useState(false)
78
78
  const [indeterminate, setIndeterminate] = useState(false)
79
+ const [tableFormParams, setTableFormParams] = useState({});
79
80
 
80
81
  // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
81
82
  const getData = (params={}, type=1) => {
@@ -128,6 +129,7 @@ const SearchSelect = (props: any) => {
128
129
  return {
129
130
  ...item,
130
131
  text: item[mappingTextField],
132
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
131
133
  value: item[mappingValueField],
132
134
  };
133
135
  })
@@ -136,6 +138,7 @@ const SearchSelect = (props: any) => {
136
138
  return {
137
139
  ...item,
138
140
  text: item[mappingTextField],
141
+ textShowKey: item[mappingTextShowKeyField || mappingValueField],
139
142
  value: item[mappingValueField],
140
143
  };
141
144
  })
@@ -143,7 +146,6 @@ const SearchSelect = (props: any) => {
143
146
  }
144
147
  source = Array.isArray(source) ? source : []
145
148
  if(type === 1) {
146
- console.log(sourceName, 'sourceName')
147
149
  ctx?.form?.setFieldSource(sourceName, source)
148
150
  setItems(source)
149
151
  setItemsTotal(Number(res?.total))
@@ -171,7 +173,7 @@ const SearchSelect = (props: any) => {
171
173
  }
172
174
 
173
175
  useEffect(() => {
174
- getData()
176
+ run('init')
175
177
  }, [])
176
178
 
177
179
  useEffect(() => {
@@ -203,8 +205,12 @@ const SearchSelect = (props: any) => {
203
205
  const handleOk = () => {
204
206
  if(popvalue?.length) {
205
207
  formaData(popvalue);
208
+ // 解决选择最后1页的sku,返回后,不显示名称问题
209
+ const source = _.uniqBy(items.concat(popvalue), 'value')
210
+ ctx?.form?.setFieldSource(sourceName, source)
211
+ setItems(source)
206
212
  }
207
- setIsModalVisible(false);
213
+ handleCancel();
208
214
  };
209
215
 
210
216
  const formaData = (value) => {
@@ -218,6 +224,8 @@ const SearchSelect = (props: any) => {
218
224
  };
219
225
 
220
226
  const handleCancel = () => {
227
+ form.resetFields();
228
+ setTableFormParams({});
221
229
  setIsModalVisible(false);
222
230
  };
223
231
 
@@ -233,17 +241,18 @@ const SearchSelect = (props: any) => {
233
241
 
234
242
  const onSearchTable = () => {
235
243
  const params = form.getFieldsValue();
244
+ setTableFormParams(params);
236
245
  getData({ ...params, pageSize: tableInitPageSize }, 2)
237
246
  }
238
247
 
239
248
  const onResetTable = () => {
240
249
  form.resetFields();
250
+ setTableFormParams({});
241
251
  handleTableChange({ pageSize: tableInitPageSize, currentPage: 1 })
242
252
  }
243
253
 
244
254
  const handleTableChange = (pagination) => {
245
- const params = form.getFieldsValue();
246
- getData({ ...params, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
255
+ getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
247
256
  }
248
257
 
249
258
  const onChangeCheckAll = (e) => {
@@ -430,7 +439,7 @@ const SearchSelect = (props: any) => {
430
439
  >
431
440
  {items.map(item => (
432
441
  <Option key={item.value} label={item.text}>
433
- {LightHeightOption({ text: `${item.value} ${item.text}`, filterTxt: searchValue })}
442
+ {LightHeightOption({ text: `${item.textShowKey} ${item.text}`, filterTxt: searchValue })}
434
443
  </Option>
435
444
  ))}
436
445
  </Select>