ztxkui 2.5.6 → 2.5.7
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.
|
@@ -25,6 +25,10 @@ export interface IProps<T> extends Omit<SelectProps<T>, 'onChange'> {
|
|
|
25
25
|
* 请求方式
|
|
26
26
|
*/
|
|
27
27
|
method?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 超时时间
|
|
30
|
+
*/
|
|
31
|
+
timeout?: number;
|
|
28
32
|
/**
|
|
29
33
|
* 下拉框选中值对应的KEY
|
|
30
34
|
*/
|
|
@@ -111,6 +115,6 @@ export interface IProps<T> extends Omit<SelectProps<T>, 'onChange'> {
|
|
|
111
115
|
* { code: 200, data: { records: [] } } || { status: 200, data: { code: 200, data: { records: [] } } }
|
|
112
116
|
* 如果数据不能在接口层面满足以上形式,那么组件提供transformData属性,转换接口数据格式
|
|
113
117
|
*/
|
|
114
|
-
declare function EnhanceSelect<VT extends SelectValue = SelectValue>({ list, defaultList, params, url, method, dataKey, componentKey, titleKey, showAll, isCatch, onCompleted, onChange, request, remoteSearch, remoteSearchKey, remoteSearchDataKey, isRemoteSearchDataKey, transformData, joinKey, joinStr, mustHasParams, disabledValues, ...restProps }: IProps<VT>): JSX.Element;
|
|
118
|
+
declare function EnhanceSelect<VT extends SelectValue = SelectValue>({ list, defaultList, params, url, method, timeout, dataKey, componentKey, titleKey, showAll, isCatch, onCompleted, onChange, request, remoteSearch, remoteSearchKey, remoteSearchDataKey, isRemoteSearchDataKey, transformData, joinKey, joinStr, mustHasParams, disabledValues, ...restProps }: IProps<VT>): JSX.Element;
|
|
115
119
|
declare const _default: React.MemoExoticComponent<typeof EnhanceSelect>;
|
|
116
120
|
export default _default;
|
|
@@ -76,17 +76,17 @@ function getData(request, options) {
|
|
|
76
76
|
* 如果数据不能在接口层面满足以上形式,那么组件提供transformData属性,转换接口数据格式
|
|
77
77
|
*/
|
|
78
78
|
function EnhanceSelect(_a) {
|
|
79
|
-
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 =
|
|
79
|
+
var list = _a.list, defaultList = _a.defaultList, params = _a.params, url = _a.url, _b = _a.method, method = _b === void 0 ? 'GET' : _b, _c = _a.timeout, timeout = _c === void 0 ? 10000 : _c, _d = _a.dataKey, dataKey = _d === void 0 ? 'id' : _d, componentKey = _a.componentKey, _e = _a.titleKey, titleKey = _e === void 0 ? 'name' : _e, showAll = _a.showAll, isCatch = _a.isCatch, onCompleted = _a.onCompleted, onChange = _a.onChange, request = _a.request, remoteSearch = _a.remoteSearch, remoteSearchKey = _a.remoteSearchKey, remoteSearchDataKey = _a.remoteSearchDataKey, _f = _a.isRemoteSearchDataKey, isRemoteSearchDataKey = _f === void 0 ? true : _f, transformData = _a.transformData, joinKey = _a.joinKey, _g = _a.joinStr, joinStr = _g === void 0 ? '-' : _g, mustHasParams = _a.mustHasParams, disabledValues = _a.disabledValues, restProps = __rest(_a, ["list", "defaultList", "params", "url", "method", "timeout", "dataKey", "componentKey", "titleKey", "showAll", "isCatch", "onCompleted", "onChange", "request", "remoteSearch", "remoteSearchKey", "remoteSearchDataKey", "isRemoteSearchDataKey", "transformData", "joinKey", "joinStr", "mustHasParams", "disabledValues"]);
|
|
80
80
|
// 下拉数据源
|
|
81
|
-
var
|
|
81
|
+
var _h = useFetchState([]), selectList = _h[0], setSelectList = _h[1];
|
|
82
82
|
// 多选时,自己需要合并的数据
|
|
83
|
-
var
|
|
84
|
-
var
|
|
83
|
+
var _j = useFetchState([]), multipleList = _j[0], setMultipleList = _j[1];
|
|
84
|
+
var _k = useFetchState(false), loading = _k[0], setLoading = _k[1];
|
|
85
85
|
var fetchId = useRef(0); // 请求Id,每次请求都会加1
|
|
86
86
|
// 是否使用过远程搜索主键key
|
|
87
|
-
var
|
|
87
|
+
var _l = useFetchState(false), firstLoading = _l[0], setFirstLoading = _l[1];
|
|
88
88
|
// 第一次清空时,才做远程查询
|
|
89
|
-
var
|
|
89
|
+
var _m = useFetchState(false), firstClearData = _m[0], setFirstClearData = _m[1];
|
|
90
90
|
// 如果selectList 发生改变,那么触发onCompleted事件
|
|
91
91
|
useEffect(function () {
|
|
92
92
|
if (Array.isArray(selectList) && onCompleted) {
|
|
@@ -259,7 +259,7 @@ function EnhanceSelect(_a) {
|
|
|
259
259
|
}
|
|
260
260
|
else {
|
|
261
261
|
// 发送接口请求,并设置缓存数据
|
|
262
|
-
getDataHandle(request, { url: url, params: params, method: method }, {
|
|
262
|
+
getDataHandle(request, { url: url, params: params, method: method, timeout: timeout }, {
|
|
263
263
|
obj: catchData,
|
|
264
264
|
key: catchDataKey,
|
|
265
265
|
});
|
|
@@ -268,12 +268,13 @@ function EnhanceSelect(_a) {
|
|
|
268
268
|
}
|
|
269
269
|
else {
|
|
270
270
|
// 直接发送接口请求
|
|
271
|
-
getDataHandle(request, { url: url, params: params, method: method });
|
|
271
|
+
getDataHandle(request, { url: url, params: params, method: method, timeout: timeout });
|
|
272
272
|
}
|
|
273
273
|
}, [
|
|
274
274
|
url,
|
|
275
275
|
params,
|
|
276
276
|
method,
|
|
277
|
+
timeout,
|
|
277
278
|
request,
|
|
278
279
|
isCatch,
|
|
279
280
|
setSelectList,
|