@bit-sun/business-component 3.2.4 → 3.2.5

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.
@@ -0,0 +1 @@
1
+ export declare const coverToParallel: (treeData: any, result: any[], chilKey: string) => any[];
@@ -4,6 +4,7 @@ import './LocalstorageUtils';
4
4
  import './utils';
5
5
  import './auth';
6
6
  import './xlsxUtil';
7
+ import './TreeUtils';
7
8
  export * from './requestUtils';
8
9
  export * from './checkUtils';
9
10
  export * from './LocalstorageUtils';
@@ -14,3 +15,4 @@ export * from './TableUtils';
14
15
  export * from './businessUtils';
15
16
  export * from './utils';
16
17
  export * from './xlsxUtil';
18
+ export * from './TreeUtils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -54,7 +54,7 @@ export default class GuideWrapper extends Component {
54
54
  return (
55
55
  <div {...props} className={classNames('guide-wrapper', props?.className)}>
56
56
  {children}
57
- <div
57
+ {/* <div
58
58
  className='form-guide'
59
59
  >
60
60
  <div className='form-guide-top'>
@@ -87,7 +87,7 @@ export default class GuideWrapper extends Component {
87
87
  <div className='form-guide-bottom'>
88
88
  <img width={24} src={label_icon_bottom} />
89
89
  </div>
90
- </div>
90
+ </div> */}
91
91
  </div>
92
92
  )
93
93
  }
@@ -1477,6 +1477,23 @@ export function commonFun (type?: string, prefixUrl: any, requestConfigProp?: an
1477
1477
  needModalTable = false
1478
1478
  }
1479
1479
 
1480
+ // 新-法人公司选择器(无弹窗)
1481
+ if(type === 'platCompany') {
1482
+ requestConfig = {
1483
+ url: `${prefixUrl.selectPrefix}/platCompany`,
1484
+ filter: 'qp-name,socialCreditCode-orGroup,like', // 过滤参数
1485
+ mappingTextField: 'name',
1486
+ mappingTextShowKeyField: 'socialCreditCode',
1487
+ mappingValueField: 'socialCreditCode',
1488
+ otherParams: {
1489
+ sorter: 'desc-id'
1490
+ }, // 默认参数
1491
+ sourceName: 'platCompany',
1492
+ ...requestConfigProp,
1493
+ }
1494
+ needModalTable = false
1495
+ }
1496
+
1480
1497
  // 员工选择器
1481
1498
  if(type === 'employee') {
1482
1499
  requestConfig = {
@@ -76,7 +76,7 @@ const loadSelectSource = (url: string, params?: any) => {
76
76
  const handleDefaultPrefixUrl = (type: string) => {
77
77
  let result;
78
78
  switch (type){
79
- case 'supplier2': case 'customer2': case 'shopFile2':
79
+ case 'supplier2': case 'customer2': case 'shopFile2': case 'platCompany':
80
80
  result = '/channel-manage';
81
81
  break;
82
82
  case 'skuCommodity': case 'skuPropertyValue': case 'spuCommodity': case 'skcCommodity': case 'brand':
@@ -374,7 +374,14 @@ const AddSelect = (props: any) => {
374
374
  }
375
375
  }
376
376
 
377
- return item
377
+ return {
378
+ ...item,
379
+ ...(item?.render?{
380
+ render: (text, record, index) => {
381
+ return item?.render(text, record, index, popvalue,editRecord)
382
+ }
383
+ }:{})
384
+ }
378
385
  }), {
379
386
  title: '操作',
380
387
  width: 50,
@@ -44,6 +44,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
44
44
  extralHeaders = {},// 额外请求头参数
45
45
  specialBracket = false,// 是否使用特殊括弧显示选项 【value】text
46
46
  noNeedSplit = false,// label显示不需要任何特殊化
47
+ method = 'get'
47
48
  } = requestConfig || {};
48
49
  const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || ctx?.name || 'supplierCode')
49
50
 
@@ -288,13 +289,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
288
289
  if (isNil(queryParams[selectParamsKey])) {
289
290
  queryParams[selectParamsKey] = searchValue;
290
291
  }
291
- request
292
- .get(
293
- `${url}?${stringify(queryParams)}`,
294
- {
295
- headers: { ...extralHeaders }
296
- })
297
- .then((result: any) => {
292
+
293
+ let getRequest
294
+ const methodName = method?.toLocaleLowerCase();
295
+ if(['post','patch','put'].includes(methodName)) {
296
+ getRequest = request[methodName](`${url}`,{ ...queryParams })
297
+ } else {
298
+ getRequest = request.get( `${url}?${stringify(queryParams)}`,{headers: { ...extralHeaders }})
299
+ }
300
+ if (!getRequest) return;
301
+
302
+ getRequest.then((result: any) => {
298
303
  setFetching(false)
299
304
  result = result.data;
300
305
  if (judgeIsRequestError(result)) {
@@ -1,7 +1,7 @@
1
1
  // @ts-nocheck
2
2
  import { BsCascader } from '@/components/Functional/BsAntdSula';
3
3
  import { BusinessSearchSelect, BusinessTreeSearchSelect } from '@/index';
4
- import { getDictionarySource, uuid } from '../../../utils/utils';
4
+ import { getDictionarySource, judgeIsEmpty, uuid } from '../../../utils/utils';
5
5
  import { useRequest } from 'ahooks';
6
6
  import { Input, InputNumber, DatePicker, Switch, Select } from 'antd';
7
7
  import React, { useEffect, useState } from 'react'
@@ -81,8 +81,10 @@ export default function RenderCompItem(props:any){
81
81
  (ites?.valueType === 23 || ites?.valueType === 22) && (
82
82
  <InputNumber
83
83
  disabled={disabled}
84
- max={Number.MAX_SAFE_INTEGER}
85
- min={ites?.valueType === 23 ? 0 : Number.MIN_SAFE_INTEGER}
84
+ // max={Number.MAX_SAFE_INTEGER}
85
+ max={judgeIsEmpty(ites?.maxValue) ? Number.MAX_SAFE_INTEGER : ites.maxValue}
86
+ // min={ites?.valueType === 23 ? 0 : Number.MIN_SAFE_INTEGER}
87
+ min={judgeIsEmpty(ites?.minValue) ? (ites?.valueType === 23 ? 0 : Number.MIN_SAFE_INTEGER) : ites.minValue}
86
88
  precision={ites?.valueType === 23 ? 0 : 2}
87
89
  defaultValue={ites.defaultValue}
88
90
  style={style2}
@@ -34,6 +34,7 @@ import {
34
34
  isObj,
35
35
  } from './util';
36
36
  import { getDictionarySource, uuid } from '../../../utils/utils';
37
+ import { coverToParallel } from '../../../utils/TreeUtils';
37
38
  import {
38
39
  BusinessSearchSelect,
39
40
  BusinessTreeSearchSelect,
@@ -321,6 +322,9 @@ class RuleObjectComponent extends Component {
321
322
  handleOperatingAction,
322
323
  ruleGroupInfo,
323
324
  needShowAction = true,
325
+ extraConfig,
326
+ customTitleSubStyle,
327
+ customTitlePreStyle,
324
328
  } = this.props;
325
329
  const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1; // 业务调用规则实例设计器
326
330
  const ruleGroupName = ruleGroupInfo?.ruleGroupList?.[0]?.name || '规则分组';
@@ -334,6 +338,7 @@ class RuleObjectComponent extends Component {
334
338
  background: '#fff',
335
339
  width: '160px',
336
340
  textAlign: 'center',
341
+ ...(customTitlePreStyle || {}),
337
342
  }; // height:22
338
343
  const titleSubCommon = {
339
344
  display: 'flex',
@@ -345,6 +350,7 @@ class RuleObjectComponent extends Component {
345
350
  width: '166px',
346
351
  top: '-32px', // titlePre(height + top)
347
352
  left: '200px', // titlePre(2 * left + width) 左右间距为titlePre的left: 20px
353
+ ...(customTitleSubStyle || {}),
348
354
  }; // height: 24
349
355
  const titleSubPre2 = {
350
356
  ...titlePre,
@@ -353,7 +359,7 @@ class RuleObjectComponent extends Component {
353
359
  top: '-56px', // titleSubPre(top + height)
354
360
  left: '386px', // titlePre(left + width + 20)
355
361
  }
356
- const ruleListBox = (!onlyOneRule || ruleGroupInfo) ? { border: '1px dashed #d9d9d9', marginBottom: 10, overflowX: 'clip' } : {};
362
+ const ruleListBox = (!onlyOneRule || ruleGroupInfo) ? { border: '1px dashed #d9d9d9', marginBottom: 10, overflowX: 'clip', position: 'relative' } : {};
357
363
  const isRuleActionConfig =
358
364
  ruleTypeData?.length || ruleReturnConfig?.length;
359
365
  return (
@@ -382,7 +388,8 @@ class RuleObjectComponent extends Component {
382
388
  disabled,
383
389
  };
384
390
  return (
385
- <div style={ruleListBox}>
391
+ // rule-line-class方便开发自定义样式,勿删
392
+ <div className={'rule-line-class'} style={ruleListBox}>
386
393
  {!onlyOneRule && !ruleGroupInfo && (
387
394
  <div style={titlePre}>规则{classDataIndex + 1}</div>
388
395
  )}
@@ -397,7 +404,18 @@ class RuleObjectComponent extends Component {
397
404
  </div>
398
405
  {isRuleInstance && (
399
406
  <div style={titleSubPre}>
400
- <span style={{ marginRight: 10, display: 'block' }}>优先级</span>
407
+ <span
408
+ style={{
409
+ marginRight: 10,
410
+ display: 'block',
411
+ width: '100px',
412
+ textAlign: 'right',
413
+ overflow: 'hidden',
414
+ textOverflow:'ellipsis',
415
+ whiteSpace: 'nowrap'
416
+ }}>
417
+ 优先级
418
+ </span>
401
419
  <Select
402
420
  size='small'
403
421
  disabled={canChangePriority ? !canChangePriority : disabled}
@@ -437,13 +455,57 @@ class RuleObjectComponent extends Component {
437
455
  />
438
456
  </div>
439
457
  )}
458
+ {/* 规则组额外extStrField */}
459
+ {
460
+ extraConfig && extraConfig.map((extraItem, index) => (
461
+ <div style={titleSubPre}>
462
+ <span
463
+ style={{
464
+ marginRight: 10,
465
+ display: 'block',
466
+ width: '100px',
467
+ textAlign: 'right',
468
+ overflow: 'hidden',
469
+ textOverflow:'ellipsis',
470
+ whiteSpace: 'nowrap'
471
+ }}
472
+ >
473
+ {extraItem?.label}
474
+ </span>
475
+ <Select
476
+ size='small'
477
+ style={{ width: 100 }}
478
+ mode={extraItem?.mode || null}
479
+ disabled={disabled}
480
+ value={ extraItem?.mode === 'multiple' ? (item[extraItem?.code] ? item[extraItem?.code].split(',') : []) : item[extraItem?.code] }
481
+ onChange={(v) => {
482
+ item[extraItem?.code] = Array.isArray(v) ? v.join(',') : v;
483
+ this.setState(
484
+ {
485
+ ruleClassData,
486
+ },
487
+ () => {
488
+ callBack(ruleClassData);
489
+ },
490
+ );
491
+ }}
492
+ >
493
+ {extraItem?.optionList?.map((s,sindex) => (
494
+ <Option value={s?.value}>{s?.text}</Option>
495
+ ))}
496
+ </Select>
497
+ </div>
498
+ ))
499
+ }
440
500
  </>
441
501
  )}
442
502
  <div
443
503
  style={{
444
504
  textAlign: 'right',
445
- marginTop: '-24px',
446
505
  display: canDelete ? 'block' : 'none',
506
+ position: 'absolute',
507
+ right: '5px',
508
+ top: '5px',
447
509
  }}
448
510
  >
449
511
  <Button
@@ -613,18 +675,6 @@ class RuleObjectComponent extends Component {
613
675
  );
614
676
  };
615
677
 
616
- // 树结构 转化成 平行树 (递归函数)
617
- coverToParallel = (treeData, result) => {
618
- treeData.forEach((el) => {
619
- result.push(el);
620
- if (el.children && el.children.length > 0) {
621
- // 子级递归
622
- this.coverToParallel(el.children, result);
623
- }
624
- });
625
- return result;
626
- };
627
-
628
678
  renderRuleItem = (
629
679
  itemDetail,
630
680
  parentDetail,
@@ -687,7 +737,7 @@ class RuleObjectComponent extends Component {
687
737
  queryIdentifyType = 'dynamicDictCodeIdentify';
688
738
  }
689
739
 
690
- const parallelTreeData = this.coverToParallel(ruleTreeData, []) || [];
740
+ const parallelTreeData = coverToParallel(ruleTreeData, []) || [];
691
741
  const currentTreeItem =
692
742
  itemDetail?.elementId &&
693
743
  parallelTreeData.find((i) => (i?.key?.indexOf('.') > -1 ? i.id : i.key) === itemDetail?.elementId);
@@ -1487,7 +1537,6 @@ class RuleObjectComponent extends Component {
1487
1537
  classDataIndex
1488
1538
  ].extraInfo.response.map((i) => {
1489
1539
  if (i.code && keys.some((r) => r === i.code) && !i.enable) {
1490
- console.log('i', i);
1491
1540
  return { ...i, enable: true };
1492
1541
  }
1493
1542
  return i;
@@ -28,6 +28,8 @@ export default forwardRef((props: any, ref) => {
28
28
  baseRuleDetailList = [],
29
29
  systemVariableList = [],
30
30
  defRuleDetail = {},
31
+ customerValidator,
32
+ saveUrl = '',
31
33
  } = props;
32
34
  const sceneId = scenceParams?.sceneId;
33
35
  const sceneName = scenceParams?.sceneName;
@@ -258,6 +260,12 @@ export default forwardRef((props: any, ref) => {
258
260
 
259
261
  const handleSave = (needCheckOnlyOne: boolean = false) => {
260
262
  const ruleResultList = handleRuleResultList(callbackData, ruleTypeData);
263
+
264
+ // 自定义规则数据保存校验
265
+ if (customerValidator && !customerValidator(ruleResultList, ruleTypeData)) {
266
+ return Promise.reject();
267
+ }
268
+
261
269
  if (needCheckOnlyOne && ruleResultList?.length === 0) {
262
270
  message.warning('请至少配置一个规则!');
263
271
  return Promise.reject();
@@ -265,7 +273,9 @@ export default forwardRef((props: any, ref) => {
265
273
  const actionRequiredCheckObject = handleRuleRequireCheck(
266
274
  ruleResultList,
267
275
  ruleTypeData,
268
- ruleReturnConfig
276
+ ruleReturnConfig,
277
+ type == 'instance',
278
+ regularDataList
269
279
  );
270
280
  if (actionRequiredCheckObject?.checkResult) {
271
281
  const modal = Modal.warning({
@@ -277,11 +287,19 @@ export default forwardRef((props: any, ref) => {
277
287
  setTimeout(() => {
278
288
  modal.destroy();
279
289
  }, 10000);
280
- return;
290
+ return Promise.reject();
281
291
  }
282
292
 
283
293
  // setLoading(true);
284
294
 
295
+ // 退货协议特殊处理逻辑,拼接业务类型值extStrField02
296
+ let extStrField02List: any[] = [];
297
+ ruleResultList.forEach((item: any) => {
298
+ const itemList = item?.extStrField02 ? item?.extStrField02.split(',') : [];
299
+ extStrField02List = [...extStrField02List, ...itemList];
300
+ })
301
+ let extStrField02 = Array.from(new Set(extStrField02List)).join(',');
302
+
285
303
  // 兼容没有规则组的情况
286
304
  const params = ruleGroupList?.length
287
305
  ? ruleGroupList.map((groupItem: any) => ({
@@ -296,6 +314,7 @@ export default forwardRef((props: any, ref) => {
296
314
  ...(instanceName ? { name: instanceName || i?.name } : {}),
297
315
  })),
298
316
  ...(extStrField01 ? { extStrField01 } : {}),
317
+ ...(extStrField02 ? { extStrField02 } : {}),
299
318
  ruleId: groupItem.id,
300
319
  templateId: sceneId,
301
320
  }))
@@ -308,6 +327,7 @@ export default forwardRef((props: any, ref) => {
308
327
  ...(extStrField01
309
328
  ? { extStrField01: extStrField01 || i?.extStrField01 }
310
329
  : {}),
330
+ ...(extStrField02 ? { extStrField02 } : {}),
311
331
  ...(instanceName ? { name: instanceName || i?.name } : {}),
312
332
  })),
313
333
  ...(extStrField01 ? { extStrField01 } : {}),
@@ -315,7 +335,7 @@ export default forwardRef((props: any, ref) => {
315
335
  },
316
336
  ];
317
337
 
318
- const handleUrl = `/basic/ruleDetail/addAndUpdate`;
338
+ const handleUrl = saveUrl || `/basic/ruleDetail/addAndUpdate`;
319
339
  const handleMethod = 'POST';
320
340
 
321
341
  return request({
@@ -48,6 +48,7 @@
48
48
  // }
49
49
  // ]
50
50
  // }
51
+ import { coverToParallel } from '@/utils/TreeUtils';
51
52
  export const formatOperationList = (data: any) => {
52
53
  let result = data||[];
53
54
  result = result.concat([{
@@ -164,6 +165,7 @@ export const handleRuleShowBack = (data: any, functionRuleList: any, ruleReturnL
164
165
  priority: item.priority,
165
166
  status: item.status,
166
167
  extStrField01: item?.extStrField01,
168
+ extStrField02: item?.extStrField02,
167
169
  name: item?.name,
168
170
  };
169
171
  if (item?.expression) {
@@ -194,12 +196,39 @@ const isNoEmpty = (data: any) =>
194
196
  !(data == null || data == undefined || String(data).trim() == '');
195
197
 
196
198
  // 校验必填数据
197
- export const handleRuleRequireCheck = (saveData: any, ruleActionData: any, ruleReturnConfig: any) => {
199
+ export const handleRuleRequireCheck = (saveData: any, ruleActionData: any, ruleReturnConfig: any, isInstance?: boolean, regularDataList?: any) => {
198
200
  let checkResult = false; // 默认通过校验
199
- let checkInfo: any = []; // 没有选必填执行动作(暂不考虑);执行动作下的对象未选
201
+ const checkInfo: any = []; // 没有选必填执行动作(暂不考虑);执行动作下的对象未选
202
+
203
+ // 处理对象-设置了必填-规则实例保存时数据必填校验
204
+ if (isInstance && regularDataList?.length && saveData?.length) {
205
+ const list = coverToParallel(regularDataList,[],'propertyList'); // 平铺对象树
206
+ const requiredList = list.filter((c: any) => c.required == 1)||[]; // 获取对象属性为true的集合
207
+ requiredList?.length &&
208
+ saveData.forEach((s: any, index: number) => {
209
+ const coverExpressionTree = s?.expression?.subExpression?.length ? coverToParallel(s?.expression?.subExpression,[],'subExpression') : (s?.expression && [s?.expression]);
210
+ coverExpressionTree?.length &&
211
+ coverExpressionTree?.forEach?.((e: any) => {
212
+ if (requiredList.some((r: any) => r.id === e.elementId)) {
213
+ const isComplete = !!e?.params?.length && isNoEmpty(e?.params?.[0]);
214
+ if (!isComplete) {
215
+ checkResult = true;
216
+ // 如果 e.elementName 不存在于 checkInfo 中,则添加
217
+ if (Array.isArray(checkInfo) && e && typeof e.elementName === 'string') {
218
+ const checkText = `规则${index + 1}: 存在对象【${e.elementName}】信息填写不完整`
219
+ const checkInfoSet = new Set(checkInfo);
220
+ if (!checkInfoSet.has(checkText)) {
221
+ checkInfo.push(checkText);
222
+ }
223
+ }
224
+ }
225
+ }
226
+ });
227
+ });
228
+ }
200
229
 
201
230
  // 校验返回值必填数据(兼容新/老数据: 配置对象为新数据/旧数据、规则返回值配置为老/新数据。组合一共是四种情况)
202
- if((ruleReturnConfig?.required || (Array.isArray(ruleReturnConfig) && ruleReturnConfig?.length)) && saveData.length) {
231
+ if ((ruleReturnConfig?.required || (Array.isArray(ruleReturnConfig) && ruleReturnConfig?.length)) && saveData.length) {
203
232
  const checkKey = 'code'
204
233
 
205
234
  saveData.forEach((s: any, index: number) => {
@@ -381,6 +410,7 @@ export const handleRuleResultList = (data: any, ruleTypeData: any) => {
381
410
  priority: i.priority,
382
411
  status: i.status,
383
412
  extStrField01: i?.extStrField01,
413
+ extStrField02: i?.extStrField02,
384
414
  name: i?.name,
385
415
  };
386
416
  });
@@ -182,6 +182,8 @@ export default forwardRef((props: any, ref) => {
182
182
  <Card bordered={false} bodyStyle={{ paddingTop: 0 }}>
183
183
  <BaseRule
184
184
  ref={baseRuleRef}
185
+ customerValidator={props?.customerValidator}
186
+ saveUrl={props?.saveUrl}
185
187
  scenceParams={{
186
188
  sceneId: currentSceneId,
187
189
  sceneName: currentSceneName,
package/src/index.ts CHANGED
@@ -34,6 +34,7 @@ export { default as MoreTreeTable } from './components/Business/moreTreeTable';;
34
34
  export { default as JsonQueryTable } from './components/Business/JsonQueryTable';
35
35
  export { default as TableColumnSetting} from './plugin/TableColumnSetting';
36
36
  export { default as AuthButton } from './components/Functional/AuthButton';
37
+ export { default as CustomSelector } from './components/Solution/RuleComponent/CustomPlugin/CustomSelector';
37
38
 
38
39
  export { default as EllipsisTooltip} from './components/Functional/EllipsisTooltip';
39
40
  export * from './components/Functional/BsAntdSula/index';
@@ -0,0 +1,12 @@
1
+ // 获取树平行结构
2
+ export const coverToParallel = (treeData: any, result: any[],chilKey: string) =>{
3
+ let childrenKey = chilKey || 'children';
4
+ treeData.forEach((el: any)=>{
5
+ result.push(el);
6
+ if(el?.[childrenKey] && el?.[childrenKey]?.length>0) {
7
+ // 子级递归
8
+ coverToParallel(el?.[childrenKey],result,chilKey)
9
+ }
10
+ });
11
+ return result
12
+ };
@@ -4,6 +4,7 @@ import './LocalstorageUtils';
4
4
  import './utils';
5
5
  import './auth'
6
6
  import './xlsxUtil';
7
+ import './TreeUtils';
7
8
 
8
9
  // 导出所有工具函数
9
10
  export * from './requestUtils';
@@ -16,4 +17,5 @@ export * from './TableUtils';
16
17
  export * from './businessUtils';
17
18
  export * from './utils';
18
19
  export * from './xlsxUtil';
20
+ export * from './TreeUtils';
19
21