@bit-sun/business-component 2.3.10 → 2.3.11-alpha.2
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/components/Business/SearchSelect/common.d.ts +9 -1
- package/dist/index.esm.js +425 -290
- package/dist/index.js +424 -289
- package/dist/utils/LocalstorageUtils.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Business/AddSelectBusiness/index.md +1 -0
- package/src/components/Business/AddSelectBusiness/index.tsx +50 -16
- package/src/components/Business/BsLayouts/index.tsx +0 -51
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +1 -1
- package/src/components/Business/BsSulaQueryTable/index.tsx +5 -2
- package/src/components/Business/BsSulaQueryTable/utils.tsx +31 -29
- package/src/components/Business/SearchSelect/BusinessUtils.ts +37 -7
- package/src/components/Business/SearchSelect/common.ts +23 -1
- package/src/components/Business/SearchSelect/index.md +12 -2
- package/src/components/Business/SearchSelect/index.tsx +5 -2
- package/src/components/Business/TreeSearchSelect/index.md +2 -0
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +1 -1
- package/src/components/Business/columnSettingTable/utils.tsx +30 -28
- package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +1 -0
- package/src/components/Functional/AddSelect/index.tsx +6 -3
- package/src/components/Functional/SearchSelect/index.tsx +78 -57
- package/src/components/Functional/TreeSearchSelect/index.tsx +42 -6
- package/src/components/Solution/RuleComponent/index.js +10 -6
- package/src/utils/LocalstorageUtils.ts +5 -0
|
@@ -13,33 +13,35 @@ import {
|
|
|
13
13
|
//设置queryTable默认列宽
|
|
14
14
|
export const getItemDefaultWidth = (item: any) => {
|
|
15
15
|
let defaultWidth = 200;
|
|
16
|
-
let lowerCaseKey = (item.key || item.dataIndex)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
16
|
+
let lowerCaseKey = (item.key || item.dataIndex)?.toLowerCase();
|
|
17
|
+
if (lowerCaseKey) {
|
|
18
|
+
switch (true) {
|
|
19
|
+
case item?.title === '操作' || lowerCaseKey === 'operate':
|
|
20
|
+
defaultWidth = 60;
|
|
21
|
+
break;
|
|
22
|
+
case lowerCaseKey.indexOf('number') > -1:
|
|
23
|
+
case lowerCaseKey.indexOf('quantity') > -1:
|
|
24
|
+
case lowerCaseKey.indexOf('amount') > -1:
|
|
25
|
+
defaultWidth = 90;
|
|
26
|
+
break;
|
|
27
|
+
case (lowerCaseKey.indexOf('no') > -1):
|
|
28
|
+
defaultWidth = 200;
|
|
29
|
+
break;
|
|
30
|
+
case lowerCaseKey.indexOf('code') > -1:
|
|
31
|
+
defaultWidth = 170;
|
|
32
|
+
break;
|
|
33
|
+
case lowerCaseKey.indexOf('time') > -1:
|
|
34
|
+
defaultWidth = 130;
|
|
35
|
+
break;
|
|
36
|
+
case lowerCaseKey.indexOf('status') > -1:
|
|
37
|
+
defaultWidth = 100;
|
|
38
|
+
break;
|
|
39
|
+
case lowerCaseKey.indexOf('user') > -1:
|
|
40
|
+
defaultWidth = 130;
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
43
45
|
}
|
|
44
46
|
return defaultWidth;
|
|
45
47
|
};
|
|
@@ -66,4 +68,4 @@ export const handleTextOverflow = (
|
|
|
66
68
|
</span>
|
|
67
69
|
</Tooltip>
|
|
68
70
|
);
|
|
69
|
-
};
|
|
71
|
+
};
|
|
@@ -127,7 +127,8 @@ const AddSelect = (props: any) => {
|
|
|
127
127
|
beforeShowModal,
|
|
128
128
|
tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
|
|
129
129
|
businessType = 'sku',
|
|
130
|
-
isAllowRepeatedSelect = false
|
|
130
|
+
isAllowRepeatedSelect = false,
|
|
131
|
+
noUseItemEancode = true
|
|
131
132
|
} = props;
|
|
132
133
|
const { url, otherParams, isMap, fixedparameter, fieldValToParam, mappingTextField = 'name', mappingTextShowKeyField, mappingValueField = 'code', mappingTextShowTextField } = requestConfig || {};
|
|
133
134
|
const resultSourceKey = sourceName || requestConfig?.sourceName || 'supplierCode'
|
|
@@ -677,8 +678,10 @@ const AddSelect = (props: any) => {
|
|
|
677
678
|
currentPage: 1,
|
|
678
679
|
}),
|
|
679
680
|
]).then((x: any)=>{
|
|
680
|
-
|
|
681
|
-
|
|
681
|
+
const searchPosition1 = noUseItemEancode ? 3 : 2;
|
|
682
|
+
const searchPosition2 = noUseItemEancode ? 4 : 3;
|
|
683
|
+
formatSource(x,0, searchPosition1, tableSearchForm,['id','name'])
|
|
684
|
+
formatTreeDataSource(x,1, searchPosition2, tableSearchForm)
|
|
682
685
|
})
|
|
683
686
|
}
|
|
684
687
|
if(businessType == 'skc') {
|
|
@@ -25,6 +25,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
25
25
|
needModalTable = true,
|
|
26
26
|
getPopupContainer = undefined,
|
|
27
27
|
fieldComponent,
|
|
28
|
+
selectBusinessType,
|
|
28
29
|
} = props;
|
|
29
30
|
const {
|
|
30
31
|
url,
|
|
@@ -39,6 +40,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
39
40
|
mappingTextShowTextField,
|
|
40
41
|
init = true,// 是否初始请求
|
|
41
42
|
extralHeaders = {},// 额外请求头参数
|
|
43
|
+
specialBracket = false,// 是否使用特殊括弧显示选项 【value】text
|
|
42
44
|
} = requestConfig || {};
|
|
43
45
|
const resultSourceKey = handleSourceName(sourceName || requestConfig?.sourceName || 'supplierCode')
|
|
44
46
|
|
|
@@ -100,7 +102,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
100
102
|
const [tableData, setTableData] = useState([]);
|
|
101
103
|
const [tablePagination, setTablePagination] = useState(tableInitPagination)
|
|
102
104
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
103
|
-
const [
|
|
105
|
+
const [selectedRows, setSelectedRows] = useState([]);
|
|
104
106
|
const [checkedAll, setCheckedAll] = useState(false)
|
|
105
107
|
const [indeterminate, setIndeterminate] = useState(false)
|
|
106
108
|
const [tableFormParams, setTableFormParams] = useState({});
|
|
@@ -136,7 +138,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
136
138
|
}))
|
|
137
139
|
|
|
138
140
|
// 获取数据源 (type: 1下拉框 2/3弹框 不传值默认为下拉框)
|
|
139
|
-
const getData = (params = {}, type = 1) => {
|
|
141
|
+
const getData = (params = {}, type = 1,callback?: any) => {
|
|
140
142
|
if (!requestConfig) return;
|
|
141
143
|
|
|
142
144
|
setFetching(true)
|
|
@@ -311,7 +313,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
311
313
|
}
|
|
312
314
|
return {
|
|
313
315
|
...item,
|
|
314
|
-
text:
|
|
316
|
+
text: specialBracket
|
|
317
|
+
? `【${item[mappingValueField]}】${item[mappingTextField]}`
|
|
318
|
+
: item[mappingTextField],
|
|
315
319
|
textShowText,
|
|
316
320
|
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
317
321
|
value: item[mappingValueField],
|
|
@@ -332,7 +336,9 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
332
336
|
}
|
|
333
337
|
return {
|
|
334
338
|
...item,
|
|
335
|
-
text:
|
|
339
|
+
text: specialBracket
|
|
340
|
+
? `【${item[mappingValueField]}】${item[mappingTextField]}`
|
|
341
|
+
: item[mappingTextField],
|
|
336
342
|
textShowText,
|
|
337
343
|
textShowKey: item[mappingTextShowKeyField || mappingValueField],
|
|
338
344
|
value: item[mappingValueField],
|
|
@@ -341,13 +347,17 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
341
347
|
: [];
|
|
342
348
|
}
|
|
343
349
|
source = Array.isArray(source) ? source : []
|
|
344
|
-
if
|
|
345
|
-
|
|
346
|
-
setItems(source)
|
|
347
|
-
setItemsTotal(Number(res?.total || res?.totalCount || source.length))
|
|
350
|
+
if(callback) {
|
|
351
|
+
callback(source)
|
|
348
352
|
} else {
|
|
349
|
-
|
|
350
|
-
|
|
353
|
+
if (type === 1) {
|
|
354
|
+
ctx?.form?.setFieldSource(resultSourceKey, source)
|
|
355
|
+
setItems(source)
|
|
356
|
+
setItemsTotal(Number(res?.total || res?.totalCount || source.length))
|
|
357
|
+
} else {
|
|
358
|
+
setTableData(source)
|
|
359
|
+
setTablePagination({ ...tablePagination, total: Number(res?.total || res?.totalCount || source.length), pageSize: Number(res?.size || res?.pageSize || (params?.pageSize || pageSize)), current: Number(res?.page || res?.currentPage || (params?.currentPage || currentPage)) })
|
|
360
|
+
}
|
|
351
361
|
}
|
|
352
362
|
})
|
|
353
363
|
.catch((err) => { setFetching(false) });
|
|
@@ -394,6 +404,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
394
404
|
makeUniqueValue();
|
|
395
405
|
}, [resultSourceKey])
|
|
396
406
|
|
|
407
|
+
useEffect(() => {
|
|
408
|
+
if (init) {
|
|
409
|
+
setItems([]);
|
|
410
|
+
setItemsTotal(0);
|
|
411
|
+
run('init')
|
|
412
|
+
}
|
|
413
|
+
},[selectBusinessType])
|
|
414
|
+
|
|
397
415
|
const showModal = () => {
|
|
398
416
|
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 3)
|
|
399
417
|
setIsModalVisible(true);
|
|
@@ -401,15 +419,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
401
419
|
if (value) {
|
|
402
420
|
if (selectMode) {
|
|
403
421
|
setSelectedRowKeys(labelInValue ? value.map(i => i.key) : value)
|
|
422
|
+
setSelectedRows(labelInValue ? value.map(i => ({ [mappingValueField]: i.key, value: i.key, text: i.label })) : value.map(i => ({ [mappingValueField]: i, value: i })))
|
|
404
423
|
setPopValue(labelInValue ? value.map(i => ({ value: i.key, text: i.label })) : value.map(i => ({ value: i })));
|
|
405
424
|
setIndeterminate(!!value.length && value.length < itemsTotal);
|
|
406
425
|
setCheckedAll(itemsTotal && value.length === itemsTotal);
|
|
407
|
-
// 需清空数据
|
|
408
|
-
if (!value.length) {
|
|
409
|
-
setDoubleArr([])
|
|
410
|
-
}
|
|
411
426
|
} else {
|
|
412
427
|
setSelectedRowKeys(labelInValue ? [value.key] : [value])
|
|
428
|
+
setSelectedRows(labelInValue ? [{ [mappingValueField]: value.key, value: value.key, text: value.label }] : [{ [mappingValueField]: value, value: value }])
|
|
413
429
|
setPopValue(labelInValue ? [{ value: value.key, text: value.label }] : [{ value: value }]);
|
|
414
430
|
}
|
|
415
431
|
}
|
|
@@ -449,7 +465,7 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
449
465
|
setTableData([]);
|
|
450
466
|
setTablePagination(tableInitPagination);
|
|
451
467
|
setSelectedRowKeys([]);
|
|
452
|
-
|
|
468
|
+
setSelectedRows([]);
|
|
453
469
|
setCheckedAll(false);
|
|
454
470
|
setIndeterminate(false);
|
|
455
471
|
};
|
|
@@ -510,25 +526,32 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
510
526
|
getData({ ...tableFormParams, pageSize: pagination.pageSize, currentPage: pagination.current }, 2)
|
|
511
527
|
}
|
|
512
528
|
|
|
529
|
+
const onCheckAllData = (pSize) => {
|
|
530
|
+
getData({ ...tableFormParams, pageSize: pSize, currentPage: 1 }, 2,(source) => {
|
|
531
|
+
const currentItemsData = JSON.parse(JSON.stringify(source))
|
|
532
|
+
setSelectedRowKeys(currentItemsData.map(i => i.value))
|
|
533
|
+
setPopValue(currentItemsData);
|
|
534
|
+
setSelectedRows(currentItemsData)
|
|
535
|
+
})
|
|
536
|
+
}
|
|
513
537
|
const onChangeCheckAll = (e) => {
|
|
514
538
|
if (e.target.checked) {
|
|
515
539
|
// 如果下拉框有所有数据就处理选中所有【items.length === itemsTotal】(最多可选100条)
|
|
516
540
|
// 如果超过100条 就默认查出所有数据
|
|
517
|
-
const currentItemsData = JSON.parse(JSON.stringify(items))
|
|
518
|
-
const totalPage = Math.ceil(itemsTotal / tablePagination?.pageSize)
|
|
519
|
-
for (let i = 0; i <= totalPage - 1; i++) {
|
|
520
|
-
doubleArr[i] = currentItemsData.slice(tablePagination?.pageSize * i, tablePagination?.pageSize * (i + 1))
|
|
521
|
-
}
|
|
522
|
-
setDoubleArr(doubleArr)
|
|
523
|
-
setSelectedRowKeys(currentItemsData.map(i => i.value))
|
|
524
|
-
setPopValue(currentItemsData);
|
|
525
541
|
if (items.length < itemsTotal) {
|
|
526
|
-
|
|
542
|
+
const totalPage = Math.ceil(itemsTotal / tablePagination?.pageSize);
|
|
543
|
+
const allPageSize = totalPage * tablePagination?.pageSize;
|
|
544
|
+
onCheckAllData(allPageSize)
|
|
545
|
+
} else {
|
|
546
|
+
const currentItemsData = JSON.parse(JSON.stringify(items))
|
|
547
|
+
setSelectedRowKeys(currentItemsData.map(i => i.value))
|
|
548
|
+
setPopValue(currentItemsData);
|
|
549
|
+
setSelectedRows(currentItemsData)
|
|
527
550
|
}
|
|
528
551
|
} else {
|
|
529
552
|
setSelectedRowKeys([])
|
|
530
553
|
setPopValue([]);
|
|
531
|
-
|
|
554
|
+
setSelectedRows([])
|
|
532
555
|
}
|
|
533
556
|
setIndeterminate(false);
|
|
534
557
|
setCheckedAll(e.target.checked);
|
|
@@ -538,13 +561,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
538
561
|
const {
|
|
539
562
|
filterTxt, text,
|
|
540
563
|
} = props
|
|
541
|
-
const heightLightTxt = (
|
|
564
|
+
const heightLightTxt = (text, heightTxt) => {
|
|
542
565
|
if (heightTxt === '') {
|
|
543
|
-
return
|
|
566
|
+
return text
|
|
544
567
|
}
|
|
545
568
|
// 前面filterOption 不区分大小写,这里用i
|
|
546
569
|
const regexp = new RegExp(heightTxt, 'gi')
|
|
547
|
-
return
|
|
570
|
+
return text.replace(regexp, `<span style="color:red">${heightTxt}</span>`)
|
|
548
571
|
}
|
|
549
572
|
return (
|
|
550
573
|
<Tooltip title={text}>
|
|
@@ -575,37 +598,19 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
575
598
|
};
|
|
576
599
|
|
|
577
600
|
const onChangeSelectedKeys = (selectKeys, selectRows) => {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
let filterRows = []; // 存放拼接后的一维数组的变量
|
|
581
|
-
let sksResult = [];
|
|
601
|
+
let sksResult = selectRows.map((i) => i.value);
|
|
582
602
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
// console.log(doubleArr)
|
|
588
|
-
setDoubleArr(doubleArr)
|
|
589
|
-
// 这块扁平化成为一位数组
|
|
590
|
-
filterRows = mapRows(doubleArr);
|
|
591
|
-
// console.log(filterRows)
|
|
592
|
-
|
|
593
|
-
sksResult = filterRows.map((i) => i.value)
|
|
594
|
-
} else {
|
|
595
|
-
// 处理单选
|
|
596
|
-
filterRows = selectRows;
|
|
597
|
-
sksResult = selectRows.map((i) => i.value)
|
|
598
|
-
// 单选 默认直接选中 不需要确定 配置了modalRadioNeedFooter就需要确定
|
|
599
|
-
if(!modalTableProps?.modalRadioNeedFooter) {
|
|
600
|
-
handleSelectOver(filterRows)
|
|
601
|
-
handleCancel();
|
|
602
|
-
}
|
|
603
|
+
// 单选 默认直接选中 不需要确定 配置了modalRadioNeedFooter就需要确定
|
|
604
|
+
if(!selectMode && !modalTableProps?.modalRadioNeedFooter) {
|
|
605
|
+
handleSelectOver(selectRows)
|
|
606
|
+
handleCancel();
|
|
603
607
|
}
|
|
604
608
|
|
|
605
609
|
setSelectedRowKeys(sksResult)
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
610
|
+
setSelectedRows(selectRows)
|
|
611
|
+
setPopValue(selectRows);
|
|
612
|
+
setIndeterminate(!!selectRows.length && selectRows.length < tablePagination?.total);
|
|
613
|
+
setCheckedAll(selectRows.length === tablePagination?.total);
|
|
609
614
|
}
|
|
610
615
|
|
|
611
616
|
// 生成唯一值
|
|
@@ -618,8 +623,13 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
618
623
|
const rowSelection = {
|
|
619
624
|
type: selectMode ? 'checkbox' : 'radio',
|
|
620
625
|
selectedRowKeys,
|
|
626
|
+
preserveSelectedRowKeys: true,
|
|
621
627
|
onChange: (sks, srs) => {
|
|
622
|
-
|
|
628
|
+
// 处理翻页后,之前存储的selectedRows变为undefined
|
|
629
|
+
// selectedRows合并新数组,过滤undefined,过滤留下对应selectedRowKeys的集合
|
|
630
|
+
let tmpSelectedRows = selectedRows.concat(srs).filter(item => item != undefined);
|
|
631
|
+
let totalSelectedRows = sks.map(key => tmpSelectedRows.filter(item => item[mappingValueField] == key)[0]).filter(item => item != undefined)
|
|
632
|
+
onChangeSelectedKeys(sks, totalSelectedRows)
|
|
623
633
|
},
|
|
624
634
|
getCheckboxProps: () => {
|
|
625
635
|
return ({
|
|
@@ -725,6 +735,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
725
735
|
)
|
|
726
736
|
}
|
|
727
737
|
|
|
738
|
+
const handleSelectOptionsShowValue = (specialBracket: boolean, item: object) => {
|
|
739
|
+
let showText = Array.isArray(item.textShowText) &&
|
|
740
|
+
item.textShowText.join(' ') || item.textShowText;
|
|
741
|
+
return specialBracket
|
|
742
|
+
? `【${item.textShowKey}】${showText}`
|
|
743
|
+
: `${item.textShowKey} ${showText}`
|
|
744
|
+
};
|
|
745
|
+
|
|
728
746
|
return (
|
|
729
747
|
<div className={'search_select'}>
|
|
730
748
|
{fieldComponent ?
|
|
@@ -774,7 +792,10 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
774
792
|
>
|
|
775
793
|
{items.map(item => (
|
|
776
794
|
<Option key={item.value} label={item.text}>
|
|
777
|
-
{LightHeightOption({
|
|
795
|
+
{LightHeightOption({
|
|
796
|
+
text: handleSelectOptionsShowValue(specialBracket, item),
|
|
797
|
+
filterTxt: searchValue
|
|
798
|
+
})}
|
|
778
799
|
</Option>
|
|
779
800
|
))}
|
|
780
801
|
</Select>
|
|
@@ -19,7 +19,8 @@ const TreeSearchSelect = (props: any) => {
|
|
|
19
19
|
showSearch = true,
|
|
20
20
|
maxTagCount = 1,
|
|
21
21
|
multiple = false,
|
|
22
|
-
isChoose = false,
|
|
22
|
+
isChoose = false, // 默认父节点不可选;传true则不限制
|
|
23
|
+
rootDisabled = false, // 默认根节点可选
|
|
23
24
|
mode,
|
|
24
25
|
getPopupContainer,
|
|
25
26
|
labelInValue = false,
|
|
@@ -41,7 +42,8 @@ const TreeSearchSelect = (props: any) => {
|
|
|
41
42
|
} = remoteSource;
|
|
42
43
|
|
|
43
44
|
const mapSearchTree = (treeDataItem: any) => {
|
|
44
|
-
const haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0;
|
|
45
|
+
const haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0; // 盘算是否为父节点
|
|
46
|
+
const isRoot = treeDataItem?.id == '0'; // 判断是否为根节点
|
|
45
47
|
return {
|
|
46
48
|
title: treeDataItem[resKeyValue[1]],
|
|
47
49
|
key: treeDataItem[resKeyValue[0]],
|
|
@@ -49,16 +51,19 @@ const TreeSearchSelect = (props: any) => {
|
|
|
49
51
|
parentId: treeDataItem.parent,
|
|
50
52
|
data: { ...treeDataItem },
|
|
51
53
|
isLeaf: !haveChildren,
|
|
52
|
-
disabled: isDisabled(haveChildren),
|
|
54
|
+
disabled: isDisabled(haveChildren,isRoot),
|
|
53
55
|
children: haveChildren ? treeDataItem.children.map((i: any) => mapSearchTree(i)) : [],
|
|
54
56
|
};
|
|
55
57
|
};
|
|
56
58
|
|
|
57
|
-
const isDisabled = (
|
|
59
|
+
const isDisabled = (isParent: boolean,isRoot: boolean) => {
|
|
58
60
|
if (isChoose) {
|
|
61
|
+
if(rootDisabled && isRoot){
|
|
62
|
+
return rootDisabled
|
|
63
|
+
}
|
|
59
64
|
return false;
|
|
60
65
|
}
|
|
61
|
-
return
|
|
66
|
+
return isParent;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/* 实时查询 但是目前用的直接是完整数据源, 所以没有使用 */
|
|
@@ -97,9 +102,40 @@ const TreeSearchSelect = (props: any) => {
|
|
|
97
102
|
return formatResult
|
|
98
103
|
}
|
|
99
104
|
}
|
|
105
|
+
const parallelData = (data: any,result: any) => {
|
|
106
|
+
data.forEach((i: any) => {
|
|
107
|
+
result.push(i);
|
|
108
|
+
if (i.children) {
|
|
109
|
+
parallelData(i.children, result);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
const getSelectItem = (tData: any,selectValue: any) => {
|
|
115
|
+
const handleList = tData||[];
|
|
116
|
+
let result = [];
|
|
117
|
+
if(labelInValue) {
|
|
118
|
+
result = multiple||treeCheckable ? (selectValue?.map((i: any) => {
|
|
119
|
+
if(handleList.some((s: any) => s.key == i.value)){
|
|
120
|
+
return handleList.find((s: any) => s.key == i.value)
|
|
121
|
+
}
|
|
122
|
+
}) || []) : (handleList?.find((s: any) => s.key == selectValue?.value)||{})
|
|
123
|
+
} else {
|
|
124
|
+
const cValue = _.get(selectValue?.[0], 'value', selectValue);
|
|
125
|
+
result = multiple||treeCheckable ? (selectValue?.map((i: any) => {
|
|
126
|
+
if(handleList.some((s: any) => s.key == i)){
|
|
127
|
+
return handleList.find((s: any) => s.key == i)
|
|
128
|
+
}
|
|
129
|
+
}) || []) : (handleList?.find((s: any) => s.key == cValue)||{})
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
100
133
|
const handleChange = (data: any, dataName: any) => {
|
|
101
134
|
const handleData = formatData(data);
|
|
102
|
-
|
|
135
|
+
// 获取选中树节点当条数据,并返回给调用业务
|
|
136
|
+
const parallelTreeData = parallelData(treeData,[])
|
|
137
|
+
const currentItem = getSelectItem(parallelTreeData,data)
|
|
138
|
+
onChange(handleData,data,currentItem,parallelTreeData);
|
|
103
139
|
onChangeName && onChangeName(dataName);
|
|
104
140
|
getTreeData && getTreeData(treeData); // 把树节点暴露出去
|
|
105
141
|
ctx?.form?.setFieldValue(ctx.name, handleData);
|
|
@@ -630,7 +630,7 @@ class RuleObjectComponent extends Component {
|
|
|
630
630
|
const parallelTreeData = this.coverToParallel(ruleTreeData, []) || [];
|
|
631
631
|
const currentTreeItem =
|
|
632
632
|
itemDetail?.elementId &&
|
|
633
|
-
parallelTreeData.find((i) => i.key === itemDetail?.elementId);
|
|
633
|
+
parallelTreeData.find((i) => (i?.key?.indexOf('.') > -1 ? i.id : i.key) === itemDetail?.elementId);
|
|
634
634
|
const dataChoiceBusinessType = currentTreeItem?.dataChoiceBusinessType;
|
|
635
635
|
const dataInputBusinessType = currentTreeItem?.dataInputBusinessType;
|
|
636
636
|
return (
|
|
@@ -896,10 +896,12 @@ class RuleObjectComponent extends Component {
|
|
|
896
896
|
);
|
|
897
897
|
};
|
|
898
898
|
|
|
899
|
-
handleEditExtraInfoResponse = (code, val, parentDetail) => {
|
|
899
|
+
handleEditExtraInfoResponse = (code, val, parentDetail,classDataIndex) => {
|
|
900
900
|
const { ruleClassData } = this.state;
|
|
901
901
|
const { callBack } = this.props;
|
|
902
902
|
parentDetail.extraInfo.response[code] = val;
|
|
903
|
+
ruleClassData[classDataIndex].extraInfo.response[code] = val;
|
|
904
|
+
|
|
903
905
|
this.setState(
|
|
904
906
|
{
|
|
905
907
|
ruleClassData,
|
|
@@ -914,6 +916,7 @@ class RuleObjectComponent extends Component {
|
|
|
914
916
|
itemDetail,
|
|
915
917
|
parentDetail,
|
|
916
918
|
ruleReturnConfig,
|
|
919
|
+
classDataIndex,
|
|
917
920
|
disabled,
|
|
918
921
|
boxStyle,
|
|
919
922
|
) => {
|
|
@@ -932,7 +935,7 @@ class RuleObjectComponent extends Component {
|
|
|
932
935
|
let value = val;
|
|
933
936
|
if (isObj(code)) {
|
|
934
937
|
Object.keys(code).forEach((ite) => {
|
|
935
|
-
this.handleEditExtraInfoResponse(ite, code[ite], parentDetail);
|
|
938
|
+
this.handleEditExtraInfoResponse(ite, code[ite], parentDetail,classDataIndex);
|
|
936
939
|
});
|
|
937
940
|
return;
|
|
938
941
|
}
|
|
@@ -942,7 +945,7 @@ class RuleObjectComponent extends Component {
|
|
|
942
945
|
if (isObj(val)) {
|
|
943
946
|
value = val.value || val.PCDCode?.join('/');
|
|
944
947
|
}
|
|
945
|
-
this.handleEditExtraInfoResponse('value', value, parentDetail);
|
|
948
|
+
this.handleEditExtraInfoResponse('value', value, parentDetail,classDataIndex);
|
|
946
949
|
};
|
|
947
950
|
|
|
948
951
|
return (
|
|
@@ -959,7 +962,7 @@ class RuleObjectComponent extends Component {
|
|
|
959
962
|
<MinusCircleOutlined
|
|
960
963
|
className={'icon_btn_style'}
|
|
961
964
|
onClick={() => {
|
|
962
|
-
this.handleEditExtraInfoResponse('enable', false, parentDetail);
|
|
965
|
+
this.handleEditExtraInfoResponse('enable', false, parentDetail,classDataIndex);
|
|
963
966
|
}}
|
|
964
967
|
style={{
|
|
965
968
|
color: 'gray',
|
|
@@ -1755,7 +1758,7 @@ class RuleObjectComponent extends Component {
|
|
|
1755
1758
|
type="link"
|
|
1756
1759
|
onClick={() => {
|
|
1757
1760
|
if (isHaveRuleReturnConfig) {
|
|
1758
|
-
this.handleEditExtraInfoResponse('enable', true, parentDetail);
|
|
1761
|
+
this.handleEditExtraInfoResponse('enable', true, parentDetail,classDataIndex);
|
|
1759
1762
|
} else {
|
|
1760
1763
|
message.warn('未配置返回');
|
|
1761
1764
|
}
|
|
@@ -1769,6 +1772,7 @@ class RuleObjectComponent extends Component {
|
|
|
1769
1772
|
itemDetail,
|
|
1770
1773
|
parentDetail,
|
|
1771
1774
|
ruleReturnConfig,
|
|
1775
|
+
classDataIndex,
|
|
1772
1776
|
disabled,
|
|
1773
1777
|
RuleActionItemStyle,
|
|
1774
1778
|
)) ||
|