@bit-sun/business-component 4.0.5 → 4.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bit-sun/business-component",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -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}
@@ -322,6 +322,9 @@ class RuleObjectComponent extends Component {
322
322
  handleOperatingAction,
323
323
  ruleGroupInfo,
324
324
  needShowAction = true,
325
+ extraConfig,
326
+ customTitleSubStyle,
327
+ customTitlePreStyle,
325
328
  } = this.props;
326
329
  const isRuleInstance = ruleGroupInfo?.type?.indexOf('instance') > -1; // 业务调用规则实例设计器
327
330
  const ruleGroupName = ruleGroupInfo?.ruleGroupList?.[0]?.name || '规则分组';
@@ -335,6 +338,7 @@ class RuleObjectComponent extends Component {
335
338
  background: '#fff',
336
339
  width: '160px',
337
340
  textAlign: 'center',
341
+ ...(customTitlePreStyle || {}),
338
342
  }; // height:22
339
343
  const titleSubCommon = {
340
344
  display: 'flex',
@@ -346,6 +350,7 @@ class RuleObjectComponent extends Component {
346
350
  width: '166px',
347
351
  top: '-32px', // titlePre(height + top)
348
352
  left: '200px', // titlePre(2 * left + width) 左右间距为titlePre的left: 20px
353
+ ...(customTitleSubStyle || {}),
349
354
  }; // height: 24
350
355
  const titleSubPre2 = {
351
356
  ...titlePre,
@@ -354,7 +359,7 @@ class RuleObjectComponent extends Component {
354
359
  top: '-56px', // titleSubPre(top + height)
355
360
  left: '386px', // titlePre(left + width + 20)
356
361
  }
357
- 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' } : {};
358
363
  const isRuleActionConfig =
359
364
  ruleTypeData?.length || ruleReturnConfig?.length;
360
365
  return (
@@ -383,7 +388,8 @@ class RuleObjectComponent extends Component {
383
388
  disabled,
384
389
  };
385
390
  return (
386
- <div style={ruleListBox}>
391
+ // rule-line-class方便开发自定义样式,勿删
392
+ <div className={'rule-line-class'} style={ruleListBox}>
387
393
  {!onlyOneRule && !ruleGroupInfo && (
388
394
  <div style={titlePre}>规则{classDataIndex + 1}</div>
389
395
  )}
@@ -398,7 +404,18 @@ class RuleObjectComponent extends Component {
398
404
  </div>
399
405
  {isRuleInstance && (
400
406
  <div style={titleSubPre}>
401
- <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>
402
419
  <Select
403
420
  size='small'
404
421
  disabled={canChangePriority ? !canChangePriority : disabled}
@@ -438,13 +455,57 @@ class RuleObjectComponent extends Component {
438
455
  />
439
456
  </div>
440
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
+ }
441
500
  </>
442
501
  )}
443
502
  <div
444
503
  style={{
445
504
  textAlign: 'right',
446
- marginTop: '-24px',
447
505
  display: canDelete ? 'block' : 'none',
506
+ position: 'absolute',
507
+ right: '5px',
508
+ top: '5px',
448
509
  }}
449
510
  >
450
511
  <Button
@@ -1476,7 +1537,6 @@ class RuleObjectComponent extends Component {
1476
1537
  classDataIndex
1477
1538
  ].extraInfo.response.map((i) => {
1478
1539
  if (i.code && keys.some((r) => r === i.code) && !i.enable) {
1479
- console.log('i', i);
1480
1540
  return { ...i, enable: true };
1481
1541
  }
1482
1542
  return i;
@@ -28,6 +28,9 @@ export default forwardRef((props: any, ref) => {
28
28
  baseRuleDetailList = [],
29
29
  systemVariableList = [],
30
30
  defRuleDetail = {},
31
+ customerValidator,
32
+ parseCustomParams,
33
+ saveUrl = '',
31
34
  } = props;
32
35
  const sceneId = scenceParams?.sceneId;
33
36
  const sceneName = scenceParams?.sceneName;
@@ -258,6 +261,12 @@ export default forwardRef((props: any, ref) => {
258
261
 
259
262
  const handleSave = (needCheckOnlyOne: boolean = false) => {
260
263
  const ruleResultList = handleRuleResultList(callbackData, ruleTypeData);
264
+
265
+ // 自定义规则数据保存校验
266
+ if (customerValidator && !customerValidator(ruleResultList, ruleTypeData)) {
267
+ return Promise.reject();
268
+ }
269
+
261
270
  if (needCheckOnlyOne && ruleResultList?.length === 0) {
262
271
  message.warning('请至少配置一个规则!');
263
272
  return Promise.reject();
@@ -284,6 +293,14 @@ export default forwardRef((props: any, ref) => {
284
293
 
285
294
  // setLoading(true);
286
295
 
296
+ // 退货协议特殊处理逻辑,拼接业务类型值extStrField02
297
+ let extStrField02List: any[] = [];
298
+ ruleResultList.forEach((item: any) => {
299
+ const itemList = item?.extStrField02 ? item?.extStrField02.split(',') : [];
300
+ extStrField02List = [...extStrField02List, ...itemList];
301
+ })
302
+ let extStrField02 = Array.from(new Set(extStrField02List)).join(',');
303
+
287
304
  // 兼容没有规则组的情况
288
305
  const params = ruleGroupList?.length
289
306
  ? ruleGroupList.map((groupItem: any) => ({
@@ -298,6 +315,7 @@ export default forwardRef((props: any, ref) => {
298
315
  ...(instanceName ? { name: instanceName || i?.name } : {}),
299
316
  })),
300
317
  ...(extStrField01 ? { extStrField01 } : {}),
318
+ ...(extStrField02 ? { extStrField02 } : {}),
301
319
  ruleId: groupItem.id,
302
320
  templateId: sceneId,
303
321
  }))
@@ -310,6 +328,7 @@ export default forwardRef((props: any, ref) => {
310
328
  ...(extStrField01
311
329
  ? { extStrField01: extStrField01 || i?.extStrField01 }
312
330
  : {}),
331
+ ...(extStrField02 ? { extStrField02 } : {}),
313
332
  ...(instanceName ? { name: instanceName || i?.name } : {}),
314
333
  })),
315
334
  ...(extStrField01 ? { extStrField01 } : {}),
@@ -317,14 +336,19 @@ export default forwardRef((props: any, ref) => {
317
336
  },
318
337
  ];
319
338
 
320
- const handleUrl = `/basic/ruleDetail/addAndUpdate`;
339
+ const handleUrl = saveUrl || `/basic/ruleDetail/addAndUpdate`;
321
340
  const handleMethod = 'POST';
322
341
 
342
+ let finalParams: any;
343
+ if (parseCustomParams) {
344
+ finalParams = parseCustomParams(params);
345
+ }
346
+
323
347
  return request({
324
348
  url: handleUrl,
325
349
  method: handleMethod,
326
350
  convertParams: () => {
327
- return params;
351
+ return finalParams || params;
328
352
  },
329
353
  converter: (res: any) => {
330
354
  return res;
@@ -165,6 +165,7 @@ export const handleRuleShowBack = (data: any, functionRuleList: any, ruleReturnL
165
165
  priority: item.priority,
166
166
  status: item.status,
167
167
  extStrField01: item?.extStrField01,
168
+ extStrField02: item?.extStrField02,
168
169
  name: item?.name,
169
170
  };
170
171
  if (item?.expression) {
@@ -409,6 +410,7 @@ export const handleRuleResultList = (data: any, ruleTypeData: any) => {
409
410
  priority: i.priority,
410
411
  status: i.status,
411
412
  extStrField01: i?.extStrField01,
413
+ extStrField02: i?.extStrField02,
412
414
  name: i?.name,
413
415
  };
414
416
  });
@@ -182,6 +182,9 @@ 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
+ parseCustomParams={props?.parseCustomParams}
187
+ saveUrl={props?.saveUrl}
185
188
  scenceParams={{
186
189
  sceneId: currentSceneId,
187
190
  sceneName: currentSceneName,