ztxkui 1.8.2 → 1.8.3
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,6 +74,7 @@ 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, 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", "transformData", "joinKey", "joinStr"]);
|
|
75
75
|
// 下拉数据源
|
|
76
76
|
var _f = useFetchState([]), selectList = _f[0], setSelectList = _f[1];
|
|
77
|
+
var _g = useFetchState(false), loading = _g[0], setLoading = _g[1];
|
|
77
78
|
// 如果selectList 发生改变,那么触发onCompleted事件
|
|
78
79
|
useEffect(function () {
|
|
79
80
|
if (Array.isArray(selectList) && onCompleted) {
|
|
@@ -112,6 +113,7 @@ function EnhanceSelect(_a) {
|
|
|
112
113
|
outParams = JSON.parse(params);
|
|
113
114
|
}
|
|
114
115
|
catch (err) { }
|
|
116
|
+
setLoading(true);
|
|
115
117
|
getData(request, {
|
|
116
118
|
url: url,
|
|
117
119
|
method: method,
|
|
@@ -119,6 +121,7 @@ function EnhanceSelect(_a) {
|
|
|
119
121
|
})
|
|
120
122
|
.then(function (resData) {
|
|
121
123
|
var _a, _b, _c;
|
|
124
|
+
setLoading(false);
|
|
122
125
|
var res = transformData ? transformData(resData) : resData;
|
|
123
126
|
var result;
|
|
124
127
|
if (Array.isArray(res.data)) {
|
|
@@ -135,6 +138,7 @@ function EnhanceSelect(_a) {
|
|
|
135
138
|
setSelectList(result);
|
|
136
139
|
})
|
|
137
140
|
.catch(function (err) {
|
|
141
|
+
setLoading(false);
|
|
138
142
|
console.log(err);
|
|
139
143
|
});
|
|
140
144
|
}, [
|
|
@@ -146,6 +150,7 @@ function EnhanceSelect(_a) {
|
|
|
146
150
|
titleKey,
|
|
147
151
|
setSelectList,
|
|
148
152
|
transformData,
|
|
153
|
+
setLoading,
|
|
149
154
|
]);
|
|
150
155
|
var searchHandle = function (value) {
|
|
151
156
|
// 当value有值时才进行搜索
|
|
@@ -262,6 +267,6 @@ function EnhanceSelect(_a) {
|
|
|
262
267
|
onChange && onChange(value, option);
|
|
263
268
|
}
|
|
264
269
|
};
|
|
265
|
-
return (React.createElement(Select, __assign({ defaultValue: showAll ? '' : undefined, allowClear: true, showSearch: true, filterOption: remoteSearch ? false : filterOptionHandle, onSearch: remoteSearch ? onSearchHandle : undefined, onChange: onChangeHandle, optionLabelProp: "title" }, restProps), renderSelectOption()));
|
|
270
|
+
return (React.createElement(Select, __assign({ defaultValue: showAll ? '' : undefined, allowClear: true, showSearch: true, filterOption: remoteSearch ? false : filterOptionHandle, onSearch: remoteSearch ? onSearchHandle : undefined, onChange: onChangeHandle, optionLabelProp: "title", loading: loading }, restProps), renderSelectOption()));
|
|
266
271
|
}
|
|
267
272
|
export default memo(EnhanceSelect);
|