ztxkui 2.0.0 → 2.0.1
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.
|
@@ -74,9 +74,11 @@ function EnhanceSelect(_a) {
|
|
|
74
74
|
var list = _a.list, defaultList = _a.defaultList, params = _a.params, url = _a.url, _b = _a.method, method = _b === void 0 ? 'GET' : _b, _c = _a.dataKey, dataKey = _c === void 0 ? 'id' : _c, componentKey = _a.componentKey, _d = _a.titleKey, titleKey = _d === void 0 ? 'name' : _d, showAll = _a.showAll, isCatch = _a.isCatch, onCompleted = _a.onCompleted, onChange = _a.onChange, request = _a.request, remoteSearch = _a.remoteSearch, remoteSearchKey = _a.remoteSearchKey, remoteSearchDataKey = _a.remoteSearchDataKey, transformData = _a.transformData, joinKey = _a.joinKey, _e = _a.joinStr, joinStr = _e === void 0 ? '-' : _e, restProps = __rest(_a, ["list", "defaultList", "params", "url", "method", "dataKey", "componentKey", "titleKey", "showAll", "isCatch", "onCompleted", "onChange", "request", "remoteSearch", "remoteSearchKey", "remoteSearchDataKey", "transformData", "joinKey", "joinStr"]);
|
|
75
75
|
// 下拉数据源
|
|
76
76
|
var _f = useFetchState([]), selectList = _f[0], setSelectList = _f[1];
|
|
77
|
-
|
|
77
|
+
// 多选时,自己需要合并的数据
|
|
78
|
+
var _g = useFetchState([]), multipleList = _g[0], setMultipleList = _g[1];
|
|
79
|
+
var _h = useFetchState(false), loading = _h[0], setLoading = _h[1];
|
|
78
80
|
var fetchId = useRef(0); // 请求Id,每次请求都会加1
|
|
79
|
-
var
|
|
81
|
+
var _j = useFetchState(false), firstLoading = _j[0], setFirstLoading = _j[1];
|
|
80
82
|
// 如果selectList 发生改变,那么触发onCompleted事件
|
|
81
83
|
useEffect(function () {
|
|
82
84
|
if (Array.isArray(selectList) && onCompleted) {
|
|
@@ -270,7 +272,7 @@ function EnhanceSelect(_a) {
|
|
|
270
272
|
// 如果源数组中找到了该条数据,那么不添加
|
|
271
273
|
// 否则添加
|
|
272
274
|
if (!resultData.find(function (resultItem) { return resultItem[dataKey] === item[dataKey]; })) {
|
|
273
|
-
resultData.
|
|
275
|
+
resultData.push(item);
|
|
274
276
|
}
|
|
275
277
|
});
|
|
276
278
|
}
|
|
@@ -282,7 +284,7 @@ function EnhanceSelect(_a) {
|
|
|
282
284
|
return (React.createElement(React.Fragment, null,
|
|
283
285
|
showAll && (React.createElement(Select.Option, { title: "\u5168\u90E8", value: "" }, "\u5168\u90E8")),
|
|
284
286
|
Array.isArray(selectList) &&
|
|
285
|
-
concatData(selectList, _defaultList).map(function (item) {
|
|
287
|
+
concatData(concatData(selectList, _defaultList), multipleList).map(function (item) {
|
|
286
288
|
var key = componentKey ? item[componentKey] : item[dataKey];
|
|
287
289
|
var value = item[dataKey];
|
|
288
290
|
var title = item[titleKey];
|
|
@@ -318,6 +320,7 @@ function EnhanceSelect(_a) {
|
|
|
318
320
|
currentData = value.map(function (valueItem) {
|
|
319
321
|
return selectList.find(function (item) { return item[key_1] === valueItem; });
|
|
320
322
|
});
|
|
323
|
+
setMultipleList(currentData);
|
|
321
324
|
}
|
|
322
325
|
else {
|
|
323
326
|
currentData = selectList.find(function (item) { return item[key_1] === value; });
|