@bit-sun/business-component 2.3.17 → 2.3.18
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
CHANGED
|
@@ -9725,7 +9725,7 @@ function getStorageVale(storageKeyString) {
|
|
|
9725
9725
|
return "";
|
|
9726
9726
|
}
|
|
9727
9727
|
|
|
9728
|
-
var _excluded$5 = ["ctx", "value", "valueName", "onChange", "onChangeName", "placeholder", "remoteSource", "initialValue", "treeCheckable", "showSearch", "maxTagCount", "multiple", "isChoose", "mode", "getPopupContainer", "labelInValue", "showArrow", "allowClear", "showCheckedStrategy", "style", "getTreeData", "disabled"];
|
|
9728
|
+
var _excluded$5 = ["ctx", "value", "valueName", "onChange", "onChangeName", "placeholder", "remoteSource", "initialValue", "treeCheckable", "showSearch", "maxTagCount", "multiple", "isChoose", "rootDisabled", "mode", "getPopupContainer", "labelInValue", "showArrow", "allowClear", "showCheckedStrategy", "style", "getTreeData", "disabled"];
|
|
9729
9729
|
var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
9730
9730
|
var _useState = useState([]),
|
|
9731
9731
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -9749,6 +9749,8 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9749
9749
|
multiple = _props$multiple === void 0 ? false : _props$multiple,
|
|
9750
9750
|
_props$isChoose = props.isChoose,
|
|
9751
9751
|
isChoose = _props$isChoose === void 0 ? false : _props$isChoose,
|
|
9752
|
+
_props$rootDisabled = props.rootDisabled,
|
|
9753
|
+
rootDisabled = _props$rootDisabled === void 0 ? false : _props$rootDisabled,
|
|
9752
9754
|
mode = props.mode,
|
|
9753
9755
|
_getPopupContainer = props.getPopupContainer,
|
|
9754
9756
|
_props$labelInValue = props.labelInValue,
|
|
@@ -9775,7 +9777,8 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9775
9777
|
_remoteSource$initial = remoteSource.initialParams,
|
|
9776
9778
|
initialParams = _remoteSource$initial === void 0 ? {} : _remoteSource$initial;
|
|
9777
9779
|
var mapSearchTree = function mapSearchTree(treeDataItem) {
|
|
9778
|
-
var haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0;
|
|
9780
|
+
var haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0; // 盘算是否为父节点
|
|
9781
|
+
var isRoot = (treeDataItem === null || treeDataItem === void 0 ? void 0 : treeDataItem.id) == '0'; // 判断是否为根节点
|
|
9779
9782
|
return {
|
|
9780
9783
|
title: treeDataItem[resKeyValue[1]],
|
|
9781
9784
|
key: treeDataItem[resKeyValue[0]],
|
|
@@ -9783,17 +9786,20 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9783
9786
|
parentId: treeDataItem.parent,
|
|
9784
9787
|
data: _objectSpread2({}, treeDataItem),
|
|
9785
9788
|
isLeaf: !haveChildren,
|
|
9786
|
-
disabled: isDisabled(haveChildren),
|
|
9789
|
+
disabled: isDisabled(haveChildren, isRoot),
|
|
9787
9790
|
children: haveChildren ? treeDataItem.children.map(function (i) {
|
|
9788
9791
|
return mapSearchTree(i);
|
|
9789
9792
|
}) : []
|
|
9790
9793
|
};
|
|
9791
9794
|
};
|
|
9792
|
-
var isDisabled = function isDisabled(
|
|
9795
|
+
var isDisabled = function isDisabled(isParent, isRoot) {
|
|
9793
9796
|
if (isChoose) {
|
|
9797
|
+
if (rootDisabled && isRoot) {
|
|
9798
|
+
return rootDisabled;
|
|
9799
|
+
}
|
|
9794
9800
|
return false;
|
|
9795
9801
|
}
|
|
9796
|
-
return
|
|
9802
|
+
return isParent;
|
|
9797
9803
|
};
|
|
9798
9804
|
/* 实时查询 但是目前用的直接是完整数据源, 所以没有使用 */
|
|
9799
9805
|
var handleSearch = function handleSearch(q) {
|
|
@@ -9866,10 +9872,53 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9866
9872
|
return _formatResult;
|
|
9867
9873
|
}
|
|
9868
9874
|
};
|
|
9875
|
+
var parallelData = function parallelData(data, result) {
|
|
9876
|
+
data.forEach(function (i) {
|
|
9877
|
+
result.push(i);
|
|
9878
|
+
if (i.children) {
|
|
9879
|
+
parallelData(i.children, result);
|
|
9880
|
+
}
|
|
9881
|
+
});
|
|
9882
|
+
return result;
|
|
9883
|
+
};
|
|
9884
|
+
var getSelectItem = function getSelectItem(tData, selectValue) {
|
|
9885
|
+
var handleList = tData || [];
|
|
9886
|
+
var result = [];
|
|
9887
|
+
if (labelInValue) {
|
|
9888
|
+
result = multiple || treeCheckable ? (selectValue === null || selectValue === void 0 ? void 0 : selectValue.map(function (i) {
|
|
9889
|
+
if (handleList.some(function (s) {
|
|
9890
|
+
return s.key == i.value;
|
|
9891
|
+
})) {
|
|
9892
|
+
return handleList.find(function (s) {
|
|
9893
|
+
return s.key == i.value;
|
|
9894
|
+
});
|
|
9895
|
+
}
|
|
9896
|
+
})) || [] : (handleList === null || handleList === void 0 ? void 0 : handleList.find(function (s) {
|
|
9897
|
+
return s.key == (selectValue === null || selectValue === void 0 ? void 0 : selectValue.value);
|
|
9898
|
+
})) || {};
|
|
9899
|
+
} else {
|
|
9900
|
+
var cValue = _.get(selectValue === null || selectValue === void 0 ? void 0 : selectValue[0], 'value', selectValue);
|
|
9901
|
+
result = multiple || treeCheckable ? (selectValue === null || selectValue === void 0 ? void 0 : selectValue.map(function (i) {
|
|
9902
|
+
if (handleList.some(function (s) {
|
|
9903
|
+
return s.key == i;
|
|
9904
|
+
})) {
|
|
9905
|
+
return handleList.find(function (s) {
|
|
9906
|
+
return s.key == i;
|
|
9907
|
+
});
|
|
9908
|
+
}
|
|
9909
|
+
})) || [] : (handleList === null || handleList === void 0 ? void 0 : handleList.find(function (s) {
|
|
9910
|
+
return s.key == cValue;
|
|
9911
|
+
})) || {};
|
|
9912
|
+
}
|
|
9913
|
+
return result;
|
|
9914
|
+
};
|
|
9869
9915
|
var handleChange = function handleChange(data, dataName) {
|
|
9870
9916
|
var _ctx$form2;
|
|
9871
9917
|
var handleData = formatData(data);
|
|
9872
|
-
|
|
9918
|
+
// 获取选中树节点当条数据,并返回给调用业务
|
|
9919
|
+
var parallelTreeData = parallelData(treeData, []);
|
|
9920
|
+
var currentItem = getSelectItem(parallelTreeData, data);
|
|
9921
|
+
onChange(handleData, data, currentItem, parallelTreeData);
|
|
9873
9922
|
onChangeName && onChangeName(dataName);
|
|
9874
9923
|
getTreeData && getTreeData(treeData); // 把树节点暴露出去
|
|
9875
9924
|
ctx === null || ctx === void 0 ? void 0 : (_ctx$form2 = ctx.form) === null || _ctx$form2 === void 0 ? void 0 : _ctx$form2.setFieldValue(ctx.name, handleData);
|
package/dist/index.js
CHANGED
|
@@ -9744,7 +9744,7 @@ function getStorageVale(storageKeyString) {
|
|
|
9744
9744
|
return "";
|
|
9745
9745
|
}
|
|
9746
9746
|
|
|
9747
|
-
var _excluded$5 = ["ctx", "value", "valueName", "onChange", "onChangeName", "placeholder", "remoteSource", "initialValue", "treeCheckable", "showSearch", "maxTagCount", "multiple", "isChoose", "mode", "getPopupContainer", "labelInValue", "showArrow", "allowClear", "showCheckedStrategy", "style", "getTreeData", "disabled"];
|
|
9747
|
+
var _excluded$5 = ["ctx", "value", "valueName", "onChange", "onChangeName", "placeholder", "remoteSource", "initialValue", "treeCheckable", "showSearch", "maxTagCount", "multiple", "isChoose", "rootDisabled", "mode", "getPopupContainer", "labelInValue", "showArrow", "allowClear", "showCheckedStrategy", "style", "getTreeData", "disabled"];
|
|
9748
9748
|
var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
9749
9749
|
var _useState = React.useState([]),
|
|
9750
9750
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -9768,6 +9768,8 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9768
9768
|
multiple = _props$multiple === void 0 ? false : _props$multiple,
|
|
9769
9769
|
_props$isChoose = props.isChoose,
|
|
9770
9770
|
isChoose = _props$isChoose === void 0 ? false : _props$isChoose,
|
|
9771
|
+
_props$rootDisabled = props.rootDisabled,
|
|
9772
|
+
rootDisabled = _props$rootDisabled === void 0 ? false : _props$rootDisabled,
|
|
9771
9773
|
mode = props.mode,
|
|
9772
9774
|
_getPopupContainer = props.getPopupContainer,
|
|
9773
9775
|
_props$labelInValue = props.labelInValue,
|
|
@@ -9794,7 +9796,8 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9794
9796
|
_remoteSource$initial = remoteSource.initialParams,
|
|
9795
9797
|
initialParams = _remoteSource$initial === void 0 ? {} : _remoteSource$initial;
|
|
9796
9798
|
var mapSearchTree = function mapSearchTree(treeDataItem) {
|
|
9797
|
-
var haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0;
|
|
9799
|
+
var haveChildren = Array.isArray(treeDataItem.children) && treeDataItem.children.length > 0; // 盘算是否为父节点
|
|
9800
|
+
var isRoot = (treeDataItem === null || treeDataItem === void 0 ? void 0 : treeDataItem.id) == '0'; // 判断是否为根节点
|
|
9798
9801
|
return {
|
|
9799
9802
|
title: treeDataItem[resKeyValue[1]],
|
|
9800
9803
|
key: treeDataItem[resKeyValue[0]],
|
|
@@ -9802,17 +9805,20 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9802
9805
|
parentId: treeDataItem.parent,
|
|
9803
9806
|
data: _objectSpread2({}, treeDataItem),
|
|
9804
9807
|
isLeaf: !haveChildren,
|
|
9805
|
-
disabled: isDisabled(haveChildren),
|
|
9808
|
+
disabled: isDisabled(haveChildren, isRoot),
|
|
9806
9809
|
children: haveChildren ? treeDataItem.children.map(function (i) {
|
|
9807
9810
|
return mapSearchTree(i);
|
|
9808
9811
|
}) : []
|
|
9809
9812
|
};
|
|
9810
9813
|
};
|
|
9811
|
-
var isDisabled = function isDisabled(
|
|
9814
|
+
var isDisabled = function isDisabled(isParent, isRoot) {
|
|
9812
9815
|
if (isChoose) {
|
|
9816
|
+
if (rootDisabled && isRoot) {
|
|
9817
|
+
return rootDisabled;
|
|
9818
|
+
}
|
|
9813
9819
|
return false;
|
|
9814
9820
|
}
|
|
9815
|
-
return
|
|
9821
|
+
return isParent;
|
|
9816
9822
|
};
|
|
9817
9823
|
/* 实时查询 但是目前用的直接是完整数据源, 所以没有使用 */
|
|
9818
9824
|
var handleSearch = function handleSearch(q) {
|
|
@@ -9885,10 +9891,53 @@ var TreeSearchSelect = function TreeSearchSelect(props) {
|
|
|
9885
9891
|
return _formatResult;
|
|
9886
9892
|
}
|
|
9887
9893
|
};
|
|
9894
|
+
var parallelData = function parallelData(data, result) {
|
|
9895
|
+
data.forEach(function (i) {
|
|
9896
|
+
result.push(i);
|
|
9897
|
+
if (i.children) {
|
|
9898
|
+
parallelData(i.children, result);
|
|
9899
|
+
}
|
|
9900
|
+
});
|
|
9901
|
+
return result;
|
|
9902
|
+
};
|
|
9903
|
+
var getSelectItem = function getSelectItem(tData, selectValue) {
|
|
9904
|
+
var handleList = tData || [];
|
|
9905
|
+
var result = [];
|
|
9906
|
+
if (labelInValue) {
|
|
9907
|
+
result = multiple || treeCheckable ? (selectValue === null || selectValue === void 0 ? void 0 : selectValue.map(function (i) {
|
|
9908
|
+
if (handleList.some(function (s) {
|
|
9909
|
+
return s.key == i.value;
|
|
9910
|
+
})) {
|
|
9911
|
+
return handleList.find(function (s) {
|
|
9912
|
+
return s.key == i.value;
|
|
9913
|
+
});
|
|
9914
|
+
}
|
|
9915
|
+
})) || [] : (handleList === null || handleList === void 0 ? void 0 : handleList.find(function (s) {
|
|
9916
|
+
return s.key == (selectValue === null || selectValue === void 0 ? void 0 : selectValue.value);
|
|
9917
|
+
})) || {};
|
|
9918
|
+
} else {
|
|
9919
|
+
var cValue = ___default['default'].get(selectValue === null || selectValue === void 0 ? void 0 : selectValue[0], 'value', selectValue);
|
|
9920
|
+
result = multiple || treeCheckable ? (selectValue === null || selectValue === void 0 ? void 0 : selectValue.map(function (i) {
|
|
9921
|
+
if (handleList.some(function (s) {
|
|
9922
|
+
return s.key == i;
|
|
9923
|
+
})) {
|
|
9924
|
+
return handleList.find(function (s) {
|
|
9925
|
+
return s.key == i;
|
|
9926
|
+
});
|
|
9927
|
+
}
|
|
9928
|
+
})) || [] : (handleList === null || handleList === void 0 ? void 0 : handleList.find(function (s) {
|
|
9929
|
+
return s.key == cValue;
|
|
9930
|
+
})) || {};
|
|
9931
|
+
}
|
|
9932
|
+
return result;
|
|
9933
|
+
};
|
|
9888
9934
|
var handleChange = function handleChange(data, dataName) {
|
|
9889
9935
|
var _ctx$form2;
|
|
9890
9936
|
var handleData = formatData(data);
|
|
9891
|
-
|
|
9937
|
+
// 获取选中树节点当条数据,并返回给调用业务
|
|
9938
|
+
var parallelTreeData = parallelData(treeData, []);
|
|
9939
|
+
var currentItem = getSelectItem(parallelTreeData, data);
|
|
9940
|
+
onChange(handleData, data, currentItem, parallelTreeData);
|
|
9892
9941
|
onChangeName && onChangeName(dataName);
|
|
9893
9942
|
getTreeData && getTreeData(treeData); // 把树节点暴露出去
|
|
9894
9943
|
ctx === null || ctx === void 0 ? void 0 : (_ctx$form2 = ctx.form) === null || _ctx$form2 === void 0 ? void 0 : _ctx$form2.setFieldValue(ctx.name, handleData);
|
package/package.json
CHANGED
|
@@ -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);
|