@bit-sun/business-component 1.1.6 → 1.1.7

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.
@@ -1,4 +1,4 @@
1
- export declare function commonFun(type?: string): {
1
+ export declare function commonFun(type?: string, prefixURL: any): {
2
2
  modalTableProps: {
3
3
  modalTableTitle: string;
4
4
  tableSearchForm: any[];
@@ -15,8 +15,8 @@ export declare function commonFun(type?: string): {
15
15
  requestConfig: {
16
16
  url: string;
17
17
  filter: string;
18
- otherParams: {};
19
- mappingTextField: string;
20
- mappingValueField: string;
18
+ otherParams: {
19
+ sorter: string;
20
+ };
21
21
  };
22
22
  };
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;
@@ -2485,8 +2491,22 @@ var SearchSelect = function SearchSelect(props) {
2485
2491
  setPopValue = _useState14[1];
2486
2492
 
2487
2493
  var _useDebounceFn = useDebounceFn(function () {
2494
+ // 优化搜索参数 支持传多个
2495
+ var searchParams = {};
2496
+
2497
+ if (typeof selectParamsKey === 'string') {
2498
+ searchParams = _defineProperty({}, selectParamsKey, searchValue);
2499
+ }
2500
+
2501
+ if (Array.isArray(selectParamsKey)) {
2502
+ selectParamsKey.forEach(function (i) {
2503
+ searchParams = _objectSpread2(_objectSpread2({}, searchParams), {}, _defineProperty({}, i, searchValue));
2504
+ });
2505
+ } // 防抖函数 待定
2506
+
2507
+
2488
2508
  // 防抖函数 待定
2489
- getData(_defineProperty({}, selectParamsKey, searchValue));
2509
+ getData(searchParams);
2490
2510
  }, {
2491
2511
  wait: 1000
2492
2512
  }),
@@ -2555,14 +2575,20 @@ var SearchSelect = function SearchSelect(props) {
2555
2575
  if (!requestConfig) return;
2556
2576
  var url = requestConfig.url,
2557
2577
  otherParams = requestConfig.otherParams,
2558
- isMap = requestConfig.isMap;
2578
+ isMap = requestConfig.isMap,
2579
+ fixedparameter = requestConfig.fixedparameter,
2580
+ fieldValToParam = requestConfig.fieldValToParam,
2581
+ _requestConfig$mappin = requestConfig.mappingTextField,
2582
+ mappingTextField = _requestConfig$mappin === void 0 ? 'name' : _requestConfig$mappin,
2583
+ _requestConfig$mappin2 = requestConfig.mappingValueField,
2584
+ mappingValueField = _requestConfig$mappin2 === void 0 ? 'code' : _requestConfig$mappin2;
2559
2585
  setFetching(true); // 处理dependence参数
2560
2586
 
2561
2587
  var fixedParam = {};
2562
2588
 
2563
- if (requestConfig.fixedparameter && requestConfig.fieldValToParam && ctx) {
2564
- requestConfig.fixedparameter.forEach(function (item, index) {
2565
- var fixedParamVal = ctx.form.getFieldValue(requestConfig.fieldValToParam[index]);
2589
+ if (fixedparameter && fieldValToParam && ctx) {
2590
+ fixedparameter.forEach(function (item, index) {
2591
+ var fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
2566
2592
 
2567
2593
  if (fixedParamVal) {
2568
2594
  fixedParam[item] = fixedParamVal;
@@ -2570,12 +2596,10 @@ var SearchSelect = function SearchSelect(props) {
2570
2596
  });
2571
2597
  }
2572
2598
 
2573
- var queryParams = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
2599
+ var queryParams = _objectSpread2(_objectSpread2(_objectSpread2({
2574
2600
  pageSize: pageSize,
2575
2601
  currentPage: currentPage
2576
- }, otherParams), fixedParam), params), {}, {
2577
- sorter: 'desc-createTime'
2578
- });
2602
+ }, otherParams), fixedParam), params);
2579
2603
 
2580
2604
  axios.get("".concat(url, "?").concat(stringify(queryParams))).then(function (result) {
2581
2605
  setFetching(false);
@@ -2600,13 +2624,13 @@ var SearchSelect = function SearchSelect(props) {
2600
2624
  var keys = res.list ? 'list' : 'items';
2601
2625
  source = res ? res[keys] ? res[keys].map(function (item) {
2602
2626
  return _objectSpread2(_objectSpread2({}, item), {}, {
2603
- text: requestConfig.splicing ? "".concat(item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingValueField], "-").concat(item[requestConfig.mappingTextField]) : item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingTextField],
2604
- value: item[requestConfig.mappingValueField]
2627
+ text: item[mappingTextField],
2628
+ value: item[mappingValueField]
2605
2629
  });
2606
2630
  }) : Array.isArray(res) && (res === null || res === void 0 ? void 0 : res.map(function (item) {
2607
2631
  return _objectSpread2(_objectSpread2({}, item), {}, {
2608
- text: requestConfig.splicing ? "".concat(item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingValueField], "-").concat(item[requestConfig.mappingTextField]) : item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingTextField],
2609
- value: item[requestConfig.mappingValueField]
2632
+ text: item[mappingTextField],
2633
+ value: item[mappingValueField]
2610
2634
  });
2611
2635
  })) : [];
2612
2636
  }
@@ -3160,14 +3184,15 @@ var loadSelectSource = function loadSelectSource(url, params) {
3160
3184
  });
3161
3185
  };
3162
3186
 
3163
- function commonFun(type) {
3187
+ function commonFun(type, prefixURL) {
3164
3188
  // 默认type === 'supplier' 供应商选择器
3165
3189
  var requestConfig = {
3166
- url: "/bop/api/supplier",
3167
- filter: 'qp-codeAndName-like',
3168
- otherParams: {},
3169
- mappingTextField: 'name',
3170
- mappingValueField: 'code'
3190
+ url: "".concat(prefixURL.selectPrefix, "/supplier"),
3191
+ filter: 'qp-nameAndCode-like',
3192
+ otherParams: {
3193
+ sorter: 'desc-id'
3194
+ } // 默认参数
3195
+
3171
3196
  };
3172
3197
  /*
3173
3198
  * 处理 格式化下拉框数据源
@@ -3220,23 +3245,7 @@ function commonFun(type) {
3220
3245
  return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3221
3246
  }
3222
3247
  }
3223
- } // remoteSource: {
3224
- // init: true, // 初始请求数据源
3225
- // url: '/bop/api/company',
3226
- // params: {
3227
- // pageSize: 5000,
3228
- // currentPage: 1,
3229
- // 'qp-companyType-eq': '30',
3230
- // },
3231
- // converter({ data }: any) {
3232
- // if (data?.items == undefined || data?.items?.length == 0) {
3233
- // return [];
3234
- // }
3235
- // return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
3236
- // },
3237
- // },
3238
- // initialSource: [{ text: '英伦宝贝儿童用品有限公司', value: 'A0001' }]
3239
-
3248
+ }
3240
3249
  }, {
3241
3250
  name: 'qp-accountingCode-in',
3242
3251
  type: 'select',
@@ -3255,22 +3264,7 @@ function commonFun(type) {
3255
3264
  return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3256
3265
  }
3257
3266
  }
3258
- } // remoteSource: {
3259
- // init: true, // 初始请求数据源
3260
- // url: `/bop/api/accountingSubject`,
3261
- // params: {
3262
- // pageSize: 5000,
3263
- // currentPage: 1,
3264
- // },
3265
- // converter({ data }: any ) {
3266
- // if (data?.items == undefined || data?.items?.length == 0) {
3267
- // return [];
3268
- // }
3269
- // return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
3270
- // },
3271
- // },
3272
- // initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
3273
-
3267
+ }
3274
3268
  }, {
3275
3269
  name: 'qp-companyCode-in',
3276
3270
  type: 'select',
@@ -3289,41 +3283,21 @@ function commonFun(type) {
3289
3283
  return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3290
3284
  }
3291
3285
  }
3292
- } // remoteSource: {
3293
- // init: true, // 初始请求数据源
3294
- // url: '/bop/api/company',
3295
- // params: {
3296
- // pageSize: 5000,
3297
- // currentPage: 1,
3298
- // 'qp-companyType-eq': '20',
3299
- // },
3300
- // converter: ({ data }: any) => {
3301
- // return data.items
3302
- // ? data.items.map((item: any) => {
3303
- // return {
3304
- // text: item.name,
3305
- // value: item.code,
3306
- // };
3307
- // })
3308
- // : [];
3309
- // },
3310
- // },
3311
- // initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
3312
-
3286
+ }
3313
3287
  }, {
3314
3288
  name: 'qp-sharingType-eq',
3315
3289
  type: 'select',
3316
3290
  label: '共享类型',
3317
3291
  initialSource: getDictionarySource('UC000013')
3318
3292
  }];
3319
- Promise.all([loadSelectSource('/bop/api/company', {
3293
+ Promise.all([loadSelectSource("".concat(prefixURL.formSelectFix, "/company"), {
3320
3294
  pageSize: 5000,
3321
3295
  currentPage: 1,
3322
3296
  'qp-companyType-eq': '30'
3323
- }), loadSelectSource('/bop/api/accountingSubject', {
3297
+ }), loadSelectSource("".concat(prefixURL.formSelectFix, "/accountingSubject"), {
3324
3298
  pageSize: 5000,
3325
3299
  currentPage: 1
3326
- }), loadSelectSource('/bop/api/company', {
3300
+ }), loadSelectSource("".concat(prefixURL.formSelectFix, "/company"), {
3327
3301
  pageSize: 5000,
3328
3302
  currentPage: 1,
3329
3303
  'qp-companyType-eq': '20'
@@ -3369,8 +3343,12 @@ function commonFun(type) {
3369
3343
 
3370
3344
  var BusinessSearchSelect = function BusinessSearchSelect(props) {
3371
3345
  var businessType = (props === null || props === void 0 ? void 0 : props.SelectBusinessType) || 'supplier';
3346
+ var prefixURL = (props === null || props === void 0 ? void 0 : props.prefixUrl) || {
3347
+ selectPrefix: '/bop/api',
3348
+ formSelectFix: '/bop/api'
3349
+ };
3372
3350
 
3373
- var _commonFun = commonFun(businessType),
3351
+ var _commonFun = commonFun(businessType, prefixURL),
3374
3352
  requestConfig = _commonFun.requestConfig,
3375
3353
  modalTableProps = _commonFun.modalTableProps;
3376
3354
 
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;
@@ -2496,8 +2502,22 @@ var SearchSelect = function SearchSelect(props) {
2496
2502
  setPopValue = _useState14[1];
2497
2503
 
2498
2504
  var _useDebounceFn = ahooks.useDebounceFn(function () {
2505
+ // 优化搜索参数 支持传多个
2506
+ var searchParams = {};
2507
+
2508
+ if (typeof selectParamsKey === 'string') {
2509
+ searchParams = _defineProperty({}, selectParamsKey, searchValue);
2510
+ }
2511
+
2512
+ if (Array.isArray(selectParamsKey)) {
2513
+ selectParamsKey.forEach(function (i) {
2514
+ searchParams = _objectSpread2(_objectSpread2({}, searchParams), {}, _defineProperty({}, i, searchValue));
2515
+ });
2516
+ } // 防抖函数 待定
2517
+
2518
+
2499
2519
  // 防抖函数 待定
2500
- getData(_defineProperty({}, selectParamsKey, searchValue));
2520
+ getData(searchParams);
2501
2521
  }, {
2502
2522
  wait: 1000
2503
2523
  }),
@@ -2566,14 +2586,20 @@ var SearchSelect = function SearchSelect(props) {
2566
2586
  if (!requestConfig) return;
2567
2587
  var url = requestConfig.url,
2568
2588
  otherParams = requestConfig.otherParams,
2569
- isMap = requestConfig.isMap;
2589
+ isMap = requestConfig.isMap,
2590
+ fixedparameter = requestConfig.fixedparameter,
2591
+ fieldValToParam = requestConfig.fieldValToParam,
2592
+ _requestConfig$mappin = requestConfig.mappingTextField,
2593
+ mappingTextField = _requestConfig$mappin === void 0 ? 'name' : _requestConfig$mappin,
2594
+ _requestConfig$mappin2 = requestConfig.mappingValueField,
2595
+ mappingValueField = _requestConfig$mappin2 === void 0 ? 'code' : _requestConfig$mappin2;
2570
2596
  setFetching(true); // 处理dependence参数
2571
2597
 
2572
2598
  var fixedParam = {};
2573
2599
 
2574
- if (requestConfig.fixedparameter && requestConfig.fieldValToParam && ctx) {
2575
- requestConfig.fixedparameter.forEach(function (item, index) {
2576
- var fixedParamVal = ctx.form.getFieldValue(requestConfig.fieldValToParam[index]);
2600
+ if (fixedparameter && fieldValToParam && ctx) {
2601
+ fixedparameter.forEach(function (item, index) {
2602
+ var fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
2577
2603
 
2578
2604
  if (fixedParamVal) {
2579
2605
  fixedParam[item] = fixedParamVal;
@@ -2581,12 +2607,10 @@ var SearchSelect = function SearchSelect(props) {
2581
2607
  });
2582
2608
  }
2583
2609
 
2584
- var queryParams = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
2610
+ var queryParams = _objectSpread2(_objectSpread2(_objectSpread2({
2585
2611
  pageSize: pageSize,
2586
2612
  currentPage: currentPage
2587
- }, otherParams), fixedParam), params), {}, {
2588
- sorter: 'desc-createTime'
2589
- });
2613
+ }, otherParams), fixedParam), params);
2590
2614
 
2591
2615
  axios__default['default'].get("".concat(url, "?").concat(querystring.stringify(queryParams))).then(function (result) {
2592
2616
  setFetching(false);
@@ -2611,13 +2635,13 @@ var SearchSelect = function SearchSelect(props) {
2611
2635
  var keys = res.list ? 'list' : 'items';
2612
2636
  source = res ? res[keys] ? res[keys].map(function (item) {
2613
2637
  return _objectSpread2(_objectSpread2({}, item), {}, {
2614
- text: requestConfig.splicing ? "".concat(item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingValueField], "-").concat(item[requestConfig.mappingTextField]) : item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingTextField],
2615
- value: item[requestConfig.mappingValueField]
2638
+ text: item[mappingTextField],
2639
+ value: item[mappingValueField]
2616
2640
  });
2617
2641
  }) : Array.isArray(res) && (res === null || res === void 0 ? void 0 : res.map(function (item) {
2618
2642
  return _objectSpread2(_objectSpread2({}, item), {}, {
2619
- text: requestConfig.splicing ? "".concat(item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingValueField], "-").concat(item[requestConfig.mappingTextField]) : item[requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.mappingTextField],
2620
- value: item[requestConfig.mappingValueField]
2643
+ text: item[mappingTextField],
2644
+ value: item[mappingValueField]
2621
2645
  });
2622
2646
  })) : [];
2623
2647
  }
@@ -3171,14 +3195,15 @@ var loadSelectSource = function loadSelectSource(url, params) {
3171
3195
  });
3172
3196
  };
3173
3197
 
3174
- function commonFun(type) {
3198
+ function commonFun(type, prefixURL) {
3175
3199
  // 默认type === 'supplier' 供应商选择器
3176
3200
  var requestConfig = {
3177
- url: "/bop/api/supplier",
3178
- filter: 'qp-codeAndName-like',
3179
- otherParams: {},
3180
- mappingTextField: 'name',
3181
- mappingValueField: 'code'
3201
+ url: "".concat(prefixURL.selectPrefix, "/supplier"),
3202
+ filter: 'qp-nameAndCode-like',
3203
+ otherParams: {
3204
+ sorter: 'desc-id'
3205
+ } // 默认参数
3206
+
3182
3207
  };
3183
3208
  /*
3184
3209
  * 处理 格式化下拉框数据源
@@ -3231,23 +3256,7 @@ function commonFun(type) {
3231
3256
  return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3232
3257
  }
3233
3258
  }
3234
- } // remoteSource: {
3235
- // init: true, // 初始请求数据源
3236
- // url: '/bop/api/company',
3237
- // params: {
3238
- // pageSize: 5000,
3239
- // currentPage: 1,
3240
- // 'qp-companyType-eq': '30',
3241
- // },
3242
- // converter({ data }: any) {
3243
- // if (data?.items == undefined || data?.items?.length == 0) {
3244
- // return [];
3245
- // }
3246
- // return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
3247
- // },
3248
- // },
3249
- // initialSource: [{ text: '英伦宝贝儿童用品有限公司', value: 'A0001' }]
3250
-
3259
+ }
3251
3260
  }, {
3252
3261
  name: 'qp-accountingCode-in',
3253
3262
  type: 'select',
@@ -3266,22 +3275,7 @@ function commonFun(type) {
3266
3275
  return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3267
3276
  }
3268
3277
  }
3269
- } // remoteSource: {
3270
- // init: true, // 初始请求数据源
3271
- // url: `/bop/api/accountingSubject`,
3272
- // params: {
3273
- // pageSize: 5000,
3274
- // currentPage: 1,
3275
- // },
3276
- // converter({ data }: any ) {
3277
- // if (data?.items == undefined || data?.items?.length == 0) {
3278
- // return [];
3279
- // }
3280
- // return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
3281
- // },
3282
- // },
3283
- // initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
3284
-
3278
+ }
3285
3279
  }, {
3286
3280
  name: 'qp-companyCode-in',
3287
3281
  type: 'select',
@@ -3300,41 +3294,21 @@ function commonFun(type) {
3300
3294
  return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0;
3301
3295
  }
3302
3296
  }
3303
- } // remoteSource: {
3304
- // init: true, // 初始请求数据源
3305
- // url: '/bop/api/company',
3306
- // params: {
3307
- // pageSize: 5000,
3308
- // currentPage: 1,
3309
- // 'qp-companyType-eq': '20',
3310
- // },
3311
- // converter: ({ data }: any) => {
3312
- // return data.items
3313
- // ? data.items.map((item: any) => {
3314
- // return {
3315
- // text: item.name,
3316
- // value: item.code,
3317
- // };
3318
- // })
3319
- // : [];
3320
- // },
3321
- // },
3322
- // initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
3323
-
3297
+ }
3324
3298
  }, {
3325
3299
  name: 'qp-sharingType-eq',
3326
3300
  type: 'select',
3327
3301
  label: '共享类型',
3328
3302
  initialSource: getDictionarySource('UC000013')
3329
3303
  }];
3330
- Promise.all([loadSelectSource('/bop/api/company', {
3304
+ Promise.all([loadSelectSource("".concat(prefixURL.formSelectFix, "/company"), {
3331
3305
  pageSize: 5000,
3332
3306
  currentPage: 1,
3333
3307
  'qp-companyType-eq': '30'
3334
- }), loadSelectSource('/bop/api/accountingSubject', {
3308
+ }), loadSelectSource("".concat(prefixURL.formSelectFix, "/accountingSubject"), {
3335
3309
  pageSize: 5000,
3336
3310
  currentPage: 1
3337
- }), loadSelectSource('/bop/api/company', {
3311
+ }), loadSelectSource("".concat(prefixURL.formSelectFix, "/company"), {
3338
3312
  pageSize: 5000,
3339
3313
  currentPage: 1,
3340
3314
  'qp-companyType-eq': '20'
@@ -3380,8 +3354,12 @@ function commonFun(type) {
3380
3354
 
3381
3355
  var BusinessSearchSelect = function BusinessSearchSelect(props) {
3382
3356
  var businessType = (props === null || props === void 0 ? void 0 : props.SelectBusinessType) || 'supplier';
3357
+ var prefixURL = (props === null || props === void 0 ? void 0 : props.prefixUrl) || {
3358
+ selectPrefix: '/bop/api',
3359
+ formSelectFix: '/bop/api'
3360
+ };
3383
3361
 
3384
- var _commonFun = commonFun(businessType),
3362
+ var _commonFun = commonFun(businessType, prefixURL),
3385
3363
  requestConfig = _commonFun.requestConfig,
3386
3364
  modalTableProps = _commonFun.modalTableProps;
3387
3365
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
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
+ }
@@ -5,8 +5,9 @@ import SearchSelect from '../index';
5
5
 
6
6
  const BusinessSearchSelect = (props: any) => {
7
7
  const businessType = props?.SelectBusinessType || 'supplier';
8
+ const prefixURL = props?.prefixUrl || { selectPrefix: '/bop/api', formSelectFix: '/bop/api' };
8
9
 
9
- const { requestConfig, modalTableProps } = commonFun(businessType);
10
+ const { requestConfig, modalTableProps } = commonFun(businessType, prefixURL);
10
11
 
11
12
  const currentProps = {
12
13
  requestConfig,
@@ -70,14 +70,14 @@ const loadSelectSource = (url: string, params?: any) => {
70
70
  })
71
71
  };
72
72
 
73
- export function commonFun (type?: string) {
73
+ export function commonFun (type?: string, prefixURL: any) {
74
74
  // 默认type === 'supplier' 供应商选择器
75
75
  let requestConfig = {
76
- url: `/bop/api/supplier`,
77
- filter: 'qp-codeAndName-like', // 过滤参数
78
- otherParams: {}, // 默认参数
79
- mappingTextField: 'name',
80
- mappingValueField: 'code',
76
+ url: `${prefixURL.selectPrefix}/supplier`,
77
+ filter: 'qp-nameAndCode-like', // 过滤参数
78
+ otherParams: {
79
+ sorter: 'desc-id'
80
+ }, // 默认参数
81
81
  }
82
82
 
83
83
  /*
@@ -112,24 +112,7 @@ export function commonFun (type?: string) {
112
112
  filterOption: (input: string, option: { props: { children: string } }) =>
113
113
  option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
114
114
  },
115
- },
116
- // remoteSource: {
117
- // init: true, // 初始请求数据源
118
- // url: '/bop/api/company',
119
- // params: {
120
- // pageSize: 5000,
121
- // currentPage: 1,
122
- // 'qp-companyType-eq': '30',
123
- // },
124
- // converter({ data }: any) {
125
- // if (data?.items == undefined || data?.items?.length == 0) {
126
- // return [];
127
- // }
128
- // return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
129
- // },
130
- // },
131
- // initialSource: [{ text: '英伦宝贝儿童用品有限公司', value: 'A0001' }]
132
- },
115
+ } },
133
116
  { name: 'qp-accountingCode-in', type: 'select', label: '归属核算主体', field: {
134
117
  type: 'select',
135
118
  props: {
@@ -143,23 +126,7 @@ export function commonFun (type?: string) {
143
126
  filterOption: (input: string, option: { props: { children: string } }) =>
144
127
  option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
145
128
  },
146
- },
147
- // remoteSource: {
148
- // init: true, // 初始请求数据源
149
- // url: `/bop/api/accountingSubject`,
150
- // params: {
151
- // pageSize: 5000,
152
- // currentPage: 1,
153
- // },
154
- // converter({ data }: any ) {
155
- // if (data?.items == undefined || data?.items?.length == 0) {
156
- // return [];
157
- // }
158
- // return data?.items.map((v: any) => ({ text: v.name, value: v.code }));
159
- // },
160
- // },
161
- // initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
162
- },
129
+ } },
163
130
  { name: 'qp-companyCode-in', type: 'select', label: '归属法人公司', field: {
164
131
  type: 'select',
165
132
  props: {
@@ -173,41 +140,20 @@ export function commonFun (type?: string) {
173
140
  filterOption: (input: string, option: { props: { children: string } }) =>
174
141
  option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0,
175
142
  },
176
- },
177
- // remoteSource: {
178
- // init: true, // 初始请求数据源
179
- // url: '/bop/api/company',
180
- // params: {
181
- // pageSize: 5000,
182
- // currentPage: 1,
183
- // 'qp-companyType-eq': '20',
184
- // },
185
- // converter: ({ data }: any) => {
186
- // return data.items
187
- // ? data.items.map((item: any) => {
188
- // return {
189
- // text: item.name,
190
- // value: item.code,
191
- // };
192
- // })
193
- // : [];
194
- // },
195
- // },
196
- // initialSource: [{ text: '上海哲雄母婴用品有限公司', value: 'F002' }, { text: '上海英伦宝贝儿童用品有限公司', value: 'F001' }]
197
- },
143
+ } },
198
144
  { name: 'qp-sharingType-eq', type: 'select', label: '共享类型', initialSource: getDictionarySource('UC000013') },
199
145
  ]
200
146
  Promise.all([
201
- loadSelectSource('/bop/api/company', {
147
+ loadSelectSource(`${prefixURL.formSelectFix}/company`, {
202
148
  pageSize: 5000,
203
149
  currentPage: 1,
204
150
  'qp-companyType-eq': '30',
205
151
  }),
206
- loadSelectSource('/bop/api/accountingSubject', {
152
+ loadSelectSource(`${prefixURL.formSelectFix}/accountingSubject`, {
207
153
  pageSize: 5000,
208
154
  currentPage: 1,
209
155
  }),
210
- loadSelectSource('/bop/api/company', {
156
+ loadSelectSource(`${prefixURL.formSelectFix}/company`, {
211
157
  pageSize: 5000,
212
158
  currentPage: 1,
213
159
  'qp-companyType-eq': '20',
@@ -36,6 +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
40
  selectProps, // 非必传
40
41
  onChange: (value: any) => {
41
42
  console.log(value)
@@ -28,10 +28,10 @@ export default () => {
28
28
  // labelInValue: true, // 非必填 默认为false
29
29
  requestConfig: {
30
30
  url: `http://test.i-baby.net/bop/api/supplier`,
31
- filter: 'qp-name-like', // 过滤参数
31
+ filter: 'qp-name-like', // 过滤参数 支持'qp-name-like'和['qp-name-like', 'qp-code-like']两种结构
32
32
  otherParams: {}, // 默认参数
33
- mappingTextField: 'name',
34
- mappingValueField: 'code',
33
+ // mappingTextField: 'name',
34
+ // mappingValueField: 'code',
35
35
  },
36
36
  selectProps,
37
37
  onChange: (value: any) => {
@@ -47,8 +47,18 @@ const SearchSelect = (props: any) => {
47
47
  const [popvalue, setPopValue] = useState(initVal);
48
48
  const { run } = useDebounceFn(
49
49
  () => {
50
+ // 优化搜索参数 支持传多个
51
+ let searchParams = {};
52
+ if(typeof selectParamsKey === 'string') {
53
+ searchParams = { [selectParamsKey]: searchValue }
54
+ }
55
+ if(Array.isArray(selectParamsKey)) {
56
+ selectParamsKey.forEach((i: any) => {
57
+ searchParams = { ...searchParams, [i]: searchValue }
58
+ })
59
+ }
50
60
  // 防抖函数 待定
51
- getData({ [selectParamsKey]: searchValue })
61
+ getData(searchParams)
52
62
  },
53
63
  {
54
64
  wait: 1000,
@@ -69,15 +79,15 @@ const SearchSelect = (props: any) => {
69
79
  // 获取数据源 (type: 1下拉框 2弹框 不传值默认为下拉框)
70
80
  const getData = (params={}, type=1) => {
71
81
  if (!requestConfig) return;
72
- const { url, otherParams, isMap } = requestConfig;
82
+ const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField='name', mappingValueField='code' } = requestConfig;
73
83
 
74
84
  setFetching(true)
75
85
 
76
86
  // 处理dependence参数
77
87
  const fixedParam = {};
78
- if (requestConfig.fixedparameter && requestConfig.fieldValToParam && ctx) {
79
- requestConfig.fixedparameter.forEach((item: any, index: any) => {
80
- const fixedParamVal = ctx.form.getFieldValue(requestConfig.fieldValToParam[index]);
88
+ if (fixedparameter && fieldValToParam && ctx) {
89
+ fixedparameter.forEach((item: any, index: any) => {
90
+ const fixedParamVal = ctx.form.getFieldValue(fieldValToParam[index]);
81
91
  if (fixedParamVal) {
82
92
  fixedParam[item] = fixedParamVal;
83
93
  }
@@ -90,7 +100,6 @@ const SearchSelect = (props: any) => {
90
100
  ...otherParams, // 默认参数
91
101
  ...fixedParam,
92
102
  ...params,
93
- sorter: 'desc-createTime'
94
103
  }
95
104
 
96
105
  axios
@@ -118,24 +127,16 @@ const SearchSelect = (props: any) => {
118
127
  ? res[keys].map((item: any) => {
119
128
  return {
120
129
  ...item,
121
- text: requestConfig.splicing
122
- ? `${item[requestConfig?.mappingValueField]}-${
123
- item[requestConfig.mappingTextField]
124
- }`
125
- : item[requestConfig?.mappingTextField],
126
- value: item[requestConfig.mappingValueField],
130
+ text: item[mappingTextField],
131
+ value: item[mappingValueField],
127
132
  };
128
133
  })
129
134
  : Array.isArray(res) &&
130
135
  res?.map((item: Record<string, any>) => {
131
136
  return {
132
137
  ...item,
133
- text: requestConfig.splicing
134
- ? `${item[requestConfig?.mappingValueField]}-${
135
- item[requestConfig.mappingTextField]
136
- }`
137
- : item[requestConfig?.mappingTextField],
138
- value: item[requestConfig.mappingValueField],
138
+ text: item[mappingTextField],
139
+ value: item[mappingValueField],
139
140
  };
140
141
  })
141
142
  : [];