@bit-sun/business-component 2.3.17 → 2.3.19
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 +139 -46
- package/dist/index.js +138 -45
- 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/SearchSelect/index.tsx +5 -2
- package/src/components/Business/TreeSearchSelect/index.md +2 -0
- package/src/components/Business/columnSettingTable/utils.tsx +10 -10
- package/src/components/Functional/AddSelect/index.tsx +6 -3
- package/src/components/Functional/SearchSelect/index.tsx +9 -0
- 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,29 +13,29 @@ import {
|
|
|
13
13
|
//设置queryTable默认列宽
|
|
14
14
|
export const getItemDefaultWidth = (item: any) => {
|
|
15
15
|
let defaultWidth = 200;
|
|
16
|
-
let lowerCaseKey = (item.key || item.dataIndex)
|
|
16
|
+
let lowerCaseKey = (item.key || item.dataIndex)?.toLowerCase();
|
|
17
17
|
switch (true) {
|
|
18
18
|
case item?.title === '操作' || lowerCaseKey === 'operate':
|
|
19
19
|
defaultWidth = 60;
|
|
20
20
|
break;
|
|
21
|
-
case lowerCaseKey
|
|
22
|
-
case lowerCaseKey
|
|
23
|
-
case lowerCaseKey
|
|
21
|
+
case lowerCaseKey?.indexOf('number') > -1:
|
|
22
|
+
case lowerCaseKey?.indexOf('quantity') > -1:
|
|
23
|
+
case lowerCaseKey?.indexOf('amount') > -1:
|
|
24
24
|
defaultWidth = 90;
|
|
25
25
|
break;
|
|
26
|
-
case (lowerCaseKey
|
|
26
|
+
case (lowerCaseKey?.indexOf('no') > -1):
|
|
27
27
|
defaultWidth = 200;
|
|
28
28
|
break;
|
|
29
|
-
case lowerCaseKey
|
|
29
|
+
case lowerCaseKey?.indexOf('code') > -1:
|
|
30
30
|
defaultWidth = 170;
|
|
31
31
|
break;
|
|
32
|
-
case lowerCaseKey
|
|
32
|
+
case lowerCaseKey?.indexOf('time') > -1:
|
|
33
33
|
defaultWidth = 130;
|
|
34
34
|
break;
|
|
35
|
-
case lowerCaseKey
|
|
35
|
+
case lowerCaseKey?.indexOf('status') > -1:
|
|
36
36
|
defaultWidth = 100;
|
|
37
37
|
break;
|
|
38
|
-
case lowerCaseKey
|
|
38
|
+
case lowerCaseKey?.indexOf('user') > -1:
|
|
39
39
|
defaultWidth = 130;
|
|
40
40
|
break;
|
|
41
41
|
default:
|
|
@@ -66,4 +66,4 @@ export const handleTextOverflow = (
|
|
|
66
66
|
</span>
|
|
67
67
|
</Tooltip>
|
|
68
68
|
);
|
|
69
|
-
};
|
|
69
|
+
};
|
|
@@ -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,
|
|
@@ -403,6 +404,14 @@ const SearchSelect = forwardRef((props: any, ref: any) => {
|
|
|
403
404
|
makeUniqueValue();
|
|
404
405
|
}, [resultSourceKey])
|
|
405
406
|
|
|
407
|
+
useEffect(() => {
|
|
408
|
+
if (init) {
|
|
409
|
+
setItems([]);
|
|
410
|
+
setItemsTotal(0);
|
|
411
|
+
run('init')
|
|
412
|
+
}
|
|
413
|
+
},[selectBusinessType])
|
|
414
|
+
|
|
406
415
|
const showModal = () => {
|
|
407
416
|
getData({ pageSize: tableInitPageSize, currentPage: 1 }, 3)
|
|
408
417
|
setIsModalVisible(true);
|
|
@@ -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
|
)) ||
|