zmdms-webui 1.5.5 → 1.5.6
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
2
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { memo, useState, useRef } from 'react';
|
|
3
|
+
import { memo, useMemo, useState, useRef } from 'react';
|
|
4
4
|
import '../config/ZtxkContext.js';
|
|
5
5
|
import useBaseContext from '../config/useBaseContext.js';
|
|
6
6
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
@@ -9,26 +9,35 @@ import { useInfiniteQuery } from '@tanstack/react-query';
|
|
|
9
9
|
* 不分页的查询逻辑
|
|
10
10
|
*/
|
|
11
11
|
var PageQuery = function (props) {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
var requestProps = props.request, url = props.url, params = props.params, _c = props.method, method = _c === void 0 ? "get" : _c, _d = props.timeout, timeout = _d === void 0 ? 120000 : _d, customRender = props.customRender, transformData = props.transformData, onClear = props.onClear, onBlur = props.onBlur, firstLoadDataKey = props.firstLoadDataKey, remoteSearchKey = props.remoteSearchKey, _e = props.pageSize, pageSize = _e === void 0 ? 10 : _e;
|
|
12
|
+
var requestProps = props.request, url = props.url, params = props.params, _a = props.method, method = _a === void 0 ? "get" : _a, _b = props.timeout, timeout = _b === void 0 ? 120000 : _b, customRender = props.customRender, transformData = props.transformData, onClear = props.onClear, onBlur = props.onBlur, firstLoadDataKey = props.firstLoadDataKey, remoteSearchKey = props.remoteSearchKey, _c = props.pageSize, pageSize = _c === void 0 ? 10 : _c;
|
|
14
13
|
var request = useBaseContext().request;
|
|
15
14
|
// 输入的值
|
|
16
|
-
var
|
|
15
|
+
var _d = useSearchValue({
|
|
17
16
|
onClear: onClear,
|
|
18
17
|
onBlur: onBlur,
|
|
19
|
-
}), firsrtRef =
|
|
18
|
+
}), firsrtRef = _d.firsrtRef, searchValue = _d.searchValue, onSearchHandle = _d.onSearchHandle, onBlurHandle = _d.onBlurHandle, onClearHandle = _d.onClearHandle;
|
|
20
19
|
// 数据请求方法(通常由业务封装),新项目可以从ZtxkContext中传入业务定义的请求方法,也可以组件单独传入
|
|
21
20
|
var requestHandle = requestProps || request;
|
|
22
21
|
// 首次回显时,使用的查询接口参数key
|
|
23
22
|
var firstSearchKey = firstLoadDataKey || props.dataKey || "id";
|
|
24
23
|
// 远程搜索时,使用的key
|
|
25
24
|
var remoteSearchUseKey = remoteSearchKey || props.titleKey || "name";
|
|
26
|
-
var transformParams =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
?
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
var transformParams = useMemo(function () {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return firsrtRef.current && props.value
|
|
28
|
+
? // 对于分页接口,首次回显的时候,需要把value作为参数传递进去。已查到该条数据
|
|
29
|
+
__assign((_a = {}, _a[firstSearchKey] = Array.isArray(props.value)
|
|
30
|
+
? props.value.join(",")
|
|
31
|
+
: props.value, _a[remoteSearchUseKey] = searchValue, _a), params) : __assign((_b = {}, _b[remoteSearchUseKey] = searchValue, _b), params);
|
|
32
|
+
}, [
|
|
33
|
+
firsrtRef,
|
|
34
|
+
firstSearchKey,
|
|
35
|
+
params,
|
|
36
|
+
props.value,
|
|
37
|
+
remoteSearchUseKey,
|
|
38
|
+
searchValue,
|
|
39
|
+
]);
|
|
40
|
+
var _e = useInfiniteQuery({
|
|
32
41
|
queryKey: [url, transformParams],
|
|
33
42
|
queryFn: function (_a) {
|
|
34
43
|
var pageParam = _a.pageParam;
|
|
@@ -70,7 +79,7 @@ var PageQuery = function (props) {
|
|
|
70
79
|
return undefined;
|
|
71
80
|
}
|
|
72
81
|
},
|
|
73
|
-
}), data =
|
|
82
|
+
}), data = _e.data, refetch = _e.refetch, isLoading = _e.isLoading, fetchNextPage = _e.fetchNextPage, hasNextPage = _e.hasNextPage, isFetchingNextPage = _e.isFetchingNextPage;
|
|
74
83
|
var getPageData = function (data) {
|
|
75
84
|
var _a;
|
|
76
85
|
var list = [];
|