zy-react-library 1.1.0 → 1.1.2
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/README.md +5 -1
- package/components/Cascader/Area/index.js +11 -11
- package/components/Cascader/Basic/index.js +23 -30
- package/components/Cascader/Dictionary/index.js +42 -42
- package/components/Cascader/Industry/index.js +12 -11
- package/components/Editor/index.js +43 -63
- package/components/FormBuilder/FormBuilder.js +97 -87
- package/components/FormBuilder/FormItemsRenderer.js +579 -581
- package/components/FormBuilder/index.js +5 -3
- package/components/HeaderBack/index.js +39 -32
- package/components/HiddenInfo/gwj/index.js +507 -439
- package/components/Icon/AddIcon/index.js +6 -6
- package/components/Icon/BackIcon/index.js +6 -6
- package/components/Icon/DeleteIcon/index.js +6 -6
- package/components/Icon/DownloadIcon/index.js +6 -6
- package/components/Icon/EditIcon/index.js +6 -6
- package/components/Icon/ExportIcon/index.js +6 -6
- package/components/Icon/ImportIcon/index.js +6 -6
- package/components/Icon/LocationIcon/index.js +6 -6
- package/components/Icon/PrintIcon/index.js +6 -6
- package/components/Icon/ResetIcon/index.js +6 -6
- package/components/Icon/SearchIcon/index.js +6 -6
- package/components/Icon/VideoIcon/index.js +6 -6
- package/components/Icon/ViewIcon/index.js +6 -6
- package/components/ImportFile/index.js +94 -91
- package/components/LeftTree/Area/index.js +15 -15
- package/components/LeftTree/Basic/index.js +54 -65
- package/components/LeftTree/Department/Gwj/index.js +29 -32
- package/components/LeftTree/Dictionary/index.js +42 -42
- package/components/Map/MapSelector.js +280 -254
- package/components/Map/index.js +90 -77
- package/components/Page/index.d.ts +2 -0
- package/components/Page/index.js +44 -34
- package/components/Pdf/index.js +92 -90
- package/components/PreviewImg/index.js +26 -32
- package/components/PreviewPdf/index.js +78 -86
- package/components/Search/index.js +147 -141
- package/components/Select/Basic/index.js +70 -76
- package/components/Select/Dictionary/index.js +42 -42
- package/components/Select/Personnel/Gwj/index.js +45 -49
- package/components/SelectCreate/index.js +33 -40
- package/components/SelectTree/Area/index.js +11 -17
- package/components/SelectTree/Basic/index.js +105 -102
- package/components/SelectTree/Department/Gwj/index.js +40 -46
- package/components/SelectTree/Dictionary/index.js +42 -42
- package/components/SelectTree/HiddenLevel/Gwj/index.js +33 -35
- package/components/SelectTree/HiddenPart/Gwj/index.js +16 -19
- package/components/SelectTree/Industry/index.js +12 -18
- package/components/Signature/index.js +68 -62
- package/components/Table/index.js +77 -73
- package/components/Table/index.less +7 -1
- package/components/TooltipPreviewImg/index.js +28 -27
- package/components/Upload/index.js +229 -275
- package/components/Video/AliPlayer.js +182 -160
- package/components/Video/index.js +71 -90
- package/css/common.less +4 -0
- package/enum/dictionary/index.js +5 -3
- package/enum/formItemRender/index.js +37 -35
- package/enum/hidden/gwj/index.js +65 -26
- package/enum/uploadFile/gwj/index.js +166 -84
- package/hooks/useDeleteFile/index.js +24 -30
- package/hooks/useDictionary/index.js +28 -30
- package/hooks/useDownloadBlob/index.js +78 -77
- package/hooks/useDownloadFile/index.js +76 -79
- package/hooks/useGetFile/index.js +32 -32
- package/hooks/useGetUrlQuery/index.js +1 -2
- package/hooks/useGetUserInfo/index.js +19 -26
- package/hooks/useIdle/index.js +9 -11
- package/hooks/useImportFile/index.js +30 -28
- package/hooks/useIsExistenceDuplicateSelection/index.js +25 -18
- package/hooks/useTable/index.js +49 -38
- package/hooks/useUploadFile/index.js +142 -147
- package/hooks/useUrlQueryCriteria/index.js +20 -13
- package/package.json +14 -1
- package/regular/index.js +34 -39
- package/utils/index.js +515 -511
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import { message
|
|
2
|
-
import { uniqBy } from
|
|
3
|
-
|
|
1
|
+
import { message } from 'antd';
|
|
2
|
+
import { uniqBy } from 'lodash-es';
|
|
3
|
+
|
|
4
4
|
/**
|
|
5
5
|
* 检查数组中是否存在重复项
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const isExistenceDuplicateSelection =
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
6
|
+
*/
|
|
7
|
+
function useIsExistenceDuplicateSelection() {
|
|
8
|
+
const isExistenceDuplicateSelection = options => {
|
|
9
|
+
const {
|
|
10
|
+
data,
|
|
11
|
+
key,
|
|
12
|
+
message: message$1 = "存在重复项,请勿重复选择"
|
|
13
|
+
} = options;
|
|
14
|
+
return new Promise(resolve => {
|
|
15
|
+
if (uniqBy(data, key).length !== data.length) {
|
|
16
|
+
message.error(message$1);
|
|
17
|
+
} else {
|
|
18
|
+
resolve();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
isExistenceDuplicateSelection
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useIsExistenceDuplicateSelection as default };
|
package/hooks/useTable/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useAntdTable } from
|
|
2
|
-
import useUrlQueryCriteria from
|
|
1
|
+
import { useAntdTable } from 'ahooks';
|
|
2
|
+
import useUrlQueryCriteria from '../useUrlQueryCriteria/index.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 获取数据
|
|
@@ -8,26 +8,29 @@ function getService(service, getExtraParams = {}, transform, usePermission) {
|
|
|
8
8
|
// 获取额外的参数
|
|
9
9
|
const extraParams = (typeof getExtraParams === "function" ? getExtraParams() : getExtraParams) || {};
|
|
10
10
|
// 获取数据
|
|
11
|
-
return async ({
|
|
11
|
+
return async ({
|
|
12
|
+
current,
|
|
13
|
+
pageSize
|
|
14
|
+
}, formData = {}) => {
|
|
12
15
|
// 如果提供了 transform 函数,则在请求之前调用它
|
|
13
16
|
let transformedFormData = formData;
|
|
14
17
|
if (typeof transform === "function") {
|
|
15
18
|
const transformResult = transform(formData);
|
|
16
19
|
// 如果 transform 函数有返回值,则将其与原始表单数据合并,transform 的优先级更高
|
|
17
20
|
if (transformResult && typeof transformResult === "object") {
|
|
18
|
-
transformedFormData = {
|
|
21
|
+
transformedFormData = {
|
|
22
|
+
...formData,
|
|
23
|
+
...transformResult
|
|
24
|
+
};
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
|
-
|
|
22
27
|
const params = {
|
|
23
28
|
pageIndex: current,
|
|
24
29
|
pageSize,
|
|
25
30
|
...transformedFormData,
|
|
26
|
-
...extraParams
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (usePermission)
|
|
30
|
-
params.menuPath = window.location.pathname;
|
|
31
|
+
...extraParams
|
|
32
|
+
};
|
|
33
|
+
if (usePermission) params.menuPath = window.location.pathname;
|
|
31
34
|
|
|
32
35
|
// 发起请求
|
|
33
36
|
const res = await service(params);
|
|
@@ -35,7 +38,7 @@ function getService(service, getExtraParams = {}, transform, usePermission) {
|
|
|
35
38
|
return {
|
|
36
39
|
list: res.data || [],
|
|
37
40
|
total: res.totalCount || 0,
|
|
38
|
-
...res
|
|
41
|
+
...res
|
|
39
42
|
};
|
|
40
43
|
};
|
|
41
44
|
}
|
|
@@ -45,12 +48,16 @@ function getService(service, getExtraParams = {}, transform, usePermission) {
|
|
|
45
48
|
*/
|
|
46
49
|
function useTable(service, options) {
|
|
47
50
|
if (!service) {
|
|
48
|
-
console.error("请传入 service")
|
|
51
|
+
console.error("请传入 service");
|
|
49
52
|
return;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
// 获取额外参数和转换函数
|
|
53
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
params: extraParams,
|
|
58
|
+
transform,
|
|
59
|
+
...restOptions
|
|
60
|
+
} = options || {};
|
|
54
61
|
|
|
55
62
|
// 获取配置项
|
|
56
63
|
const {
|
|
@@ -60,11 +67,16 @@ function useTable(service, options) {
|
|
|
60
67
|
defaultType = "advance",
|
|
61
68
|
defaultCurrent = 1,
|
|
62
69
|
defaultPageSize = 20,
|
|
63
|
-
defaultPagination = {
|
|
70
|
+
defaultPagination = {
|
|
71
|
+
current: defaultCurrent,
|
|
72
|
+
pageSize: defaultPageSize
|
|
73
|
+
},
|
|
64
74
|
...restRestOptions
|
|
65
75
|
} = restOptions;
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
const {
|
|
77
|
+
setUrlCriteriaQuery,
|
|
78
|
+
getUrlCriteriaQuery
|
|
79
|
+
} = useUrlQueryCriteria();
|
|
68
80
|
|
|
69
81
|
// 获取存储的查询条件
|
|
70
82
|
const storageQueryCriteriaSearchForm = useStorageQueryCriteria ? getUrlCriteriaQuery("searchFormKeys", "searchFormValues") : {};
|
|
@@ -76,25 +88,20 @@ function useTable(service, options) {
|
|
|
76
88
|
const actualPagination = usePagination ? Object.keys(storageQueryCriteriaPagination).length > 0 ? storageQueryCriteriaPagination : defaultPagination : {};
|
|
77
89
|
|
|
78
90
|
// 调用 ahooks 的 useAntdTable
|
|
79
|
-
const res = useAntdTable(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
onSuccess
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
: {},
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
);
|
|
91
|
+
const res = useAntdTable(getService(service, extraParams, transform, usePermission), {
|
|
92
|
+
...restRestOptions,
|
|
93
|
+
defaultParams: [actualPagination, actualSearchForm],
|
|
94
|
+
defaultType,
|
|
95
|
+
onSuccess: (data, params) => {
|
|
96
|
+
// 执行成功回调,为了保留 ahooks 的 onSuccess 回调
|
|
97
|
+
restOptions.onSuccess && restOptions.onSuccess(data, params);
|
|
98
|
+
// 存储查询条件和分页到 URL
|
|
99
|
+
useStorageQueryCriteria && setUrlCriteriaQuery(params[1] ?? {}, usePagination ? {
|
|
100
|
+
current: res.tableProps.pagination.current,
|
|
101
|
+
pageSize: res.tableProps.pagination.pageSize
|
|
102
|
+
} : {});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
98
105
|
|
|
99
106
|
// 执行回调函数
|
|
100
107
|
restOptions.callback && restOptions.callback(res?.data?.list || [], res?.data || {});
|
|
@@ -104,10 +111,14 @@ function useTable(service, options) {
|
|
|
104
111
|
...res,
|
|
105
112
|
tableProps: {
|
|
106
113
|
...res.tableProps,
|
|
107
|
-
pagination: usePagination ? {
|
|
114
|
+
pagination: usePagination ? {
|
|
115
|
+
...res.tableProps.pagination,
|
|
116
|
+
showQuickJumper: true,
|
|
117
|
+
showSizeChanger: true
|
|
118
|
+
} : false
|
|
108
119
|
},
|
|
109
|
-
getData: res.search.submit
|
|
120
|
+
getData: res.search.submit
|
|
110
121
|
};
|
|
111
122
|
}
|
|
112
123
|
|
|
113
|
-
export default
|
|
124
|
+
export { useTable as default };
|
|
@@ -1,149 +1,144 @@
|
|
|
1
|
-
import { request } from
|
|
2
|
-
import { useState } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { request } from '@cqsjjb/jjb-common-lib/http';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { UPLOAD_FILE_TYPE_ENUM, UPLOAD_FILE_PATH_ENUM } from '../../enum/uploadFile/gwj/index.js';
|
|
4
|
+
|
|
5
5
|
/**
|
|
6
6
|
* 上传文件
|
|
7
|
-
*/
|
|
8
|
-
function useUploadFile(returnType = "object") {
|
|
9
|
-
// loading状态
|
|
10
|
-
const [loading, setLoading] = useState(false);
|
|
11
|
-
// 用于跟踪进行中的请求数量(不暴露给外部)
|
|
12
|
-
let requestCount = 0;
|
|
13
|
-
|
|
14
|
-
// 上传文件
|
|
15
|
-
const uploadFile =
|
|
16
|
-
if (!options) {
|
|
17
|
-
console.error("请传入 options");
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// 增加请求数量并设置loading状态
|
|
22
|
-
requestCount++;
|
|
23
|
-
if (requestCount > 0) {
|
|
24
|
-
setLoading(true);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const formData = new FormData();
|
|
86
|
-
|
|
87
|
-
// 将文件添加到formData中
|
|
88
|
-
files.forEach(
|
|
89
|
-
f.originFileObj && formData.append("files", f.originFileObj);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// 将额外携带的参数添加到formData中
|
|
93
|
-
Object.keys(params).forEach(
|
|
94
|
-
formData.append(key, params[key]);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// 添加path参数
|
|
98
|
-
formData.append("path", path);
|
|
99
|
-
|
|
100
|
-
// 获取待上传的文件
|
|
101
|
-
const filesLength = formData.getAll("files").length;
|
|
102
|
-
|
|
103
|
-
// 如果没有文件则返回老文件
|
|
104
|
-
if (filesLength === 0) {
|
|
105
|
-
requestCount--;
|
|
106
|
-
if (requestCount <= 0) {
|
|
107
|
-
setLoading(false);
|
|
108
|
-
}
|
|
109
|
-
resolve(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// 发送请求
|
|
118
|
-
request(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return [loading, uploadFile];
|
|
146
|
-
return { loading, uploadFile };
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export default useUploadFile;
|
|
7
|
+
*/
|
|
8
|
+
function useUploadFile(returnType = "object") {
|
|
9
|
+
// loading状态
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
// 用于跟踪进行中的请求数量(不暴露给外部)
|
|
12
|
+
let requestCount = 0;
|
|
13
|
+
|
|
14
|
+
// 上传文件
|
|
15
|
+
const uploadFile = options => {
|
|
16
|
+
if (!options) {
|
|
17
|
+
console.error("请传入 options");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 增加请求数量并设置loading状态
|
|
22
|
+
requestCount++;
|
|
23
|
+
if (requestCount > 0) {
|
|
24
|
+
setLoading(true);
|
|
25
|
+
}
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const {
|
|
28
|
+
files = [],
|
|
29
|
+
single = true,
|
|
30
|
+
params
|
|
31
|
+
} = options;
|
|
32
|
+
if (!files) {
|
|
33
|
+
console.error("请传入 files");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!Array.isArray(files)) {
|
|
37
|
+
console.error("请传入有效的 files");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!params) {
|
|
41
|
+
console.error("请传入 options.params");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!params.type) {
|
|
45
|
+
console.error("请传入 options.params.type");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 检查type是否在UPLOAD_FILE_TYPE_ENUM中
|
|
50
|
+
if (!Object.values(UPLOAD_FILE_TYPE_ENUM).includes(params.type)) {
|
|
51
|
+
console.error("传入的 type 不在 UPLOAD_FILE_TYPE_ENUM 中");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 根据type获取对应的path
|
|
56
|
+
const path = UPLOAD_FILE_PATH_ENUM[params.type];
|
|
57
|
+
if (!path) {
|
|
58
|
+
console.error(`未找到 type ${params.type} 对应的 path `);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 当single为false时,foreignKey是必需的
|
|
63
|
+
if (!single) {
|
|
64
|
+
if (!params.hasOwnProperty("foreignKey")) {
|
|
65
|
+
console.error("请传入 options.params.foreignKey");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// 如果 foreignKey 是 undefined,设置默认值为空字符串
|
|
69
|
+
if (params.foreignKey === undefined || params.foreignKey === null) params.foreignKey = "";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 如果没有文件则直接返回
|
|
73
|
+
if (files.length === 0) {
|
|
74
|
+
requestCount--;
|
|
75
|
+
if (requestCount <= 0) {
|
|
76
|
+
setLoading(false);
|
|
77
|
+
}
|
|
78
|
+
resolve(single ? {
|
|
79
|
+
filePath: ""
|
|
80
|
+
} : {
|
|
81
|
+
id: params.foreignKey
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const formData = new FormData();
|
|
86
|
+
|
|
87
|
+
// 将文件添加到formData中
|
|
88
|
+
files.forEach(f => {
|
|
89
|
+
f.originFileObj && formData.append("files", f.originFileObj);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// 将额外携带的参数添加到formData中
|
|
93
|
+
Object.keys(params).forEach(key => {
|
|
94
|
+
formData.append(key, params[key]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// 添加path参数
|
|
98
|
+
formData.append("path", path);
|
|
99
|
+
|
|
100
|
+
// 获取待上传的文件
|
|
101
|
+
const filesLength = formData.getAll("files").length;
|
|
102
|
+
|
|
103
|
+
// 如果没有文件则返回老文件
|
|
104
|
+
if (filesLength === 0) {
|
|
105
|
+
requestCount--;
|
|
106
|
+
if (requestCount <= 0) {
|
|
107
|
+
setLoading(false);
|
|
108
|
+
}
|
|
109
|
+
resolve(single ? {
|
|
110
|
+
filePath: files[0].filePath
|
|
111
|
+
} : {
|
|
112
|
+
id: params.foreignKey
|
|
113
|
+
});
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 发送请求
|
|
118
|
+
request(single ? "/basicInfo/imgFiles/save" : "/basicInfo/imgFiles/batchSave", "post", formData, {
|
|
119
|
+
"Content-Type": "multipart/form-data"
|
|
120
|
+
}).then(res => {
|
|
121
|
+
resolve(single ? {
|
|
122
|
+
filePath: res.data.filePath
|
|
123
|
+
} : {
|
|
124
|
+
id: res.data.foreignKey
|
|
125
|
+
});
|
|
126
|
+
}).catch(err => {
|
|
127
|
+
reject(err);
|
|
128
|
+
}).finally(() => {
|
|
129
|
+
// 减少请求数量并在没有进行中的请求时设置loading为false
|
|
130
|
+
requestCount--;
|
|
131
|
+
if (requestCount <= 0) {
|
|
132
|
+
setLoading(false);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
if (returnType === "array") return [loading, uploadFile];
|
|
138
|
+
return {
|
|
139
|
+
loading,
|
|
140
|
+
uploadFile
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { useUploadFile as default };
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import useUrlState from
|
|
1
|
+
import useUrlState from '@ahooksjs/use-url-state';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 处理搜索条件缓存到 URL
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
function useUrlQueryCriteria() {
|
|
7
7
|
const [state, setState] = useUrlState({
|
|
8
8
|
searchFormKeys: "",
|
|
9
9
|
searchFormValues: "",
|
|
10
10
|
paginationKeys: "",
|
|
11
|
-
paginationValues: ""
|
|
12
|
-
}, {
|
|
11
|
+
paginationValues: ""
|
|
12
|
+
}, {
|
|
13
|
+
navigateMode: "replace"
|
|
14
|
+
});
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* 将搜索表单项和分页参数缓存到 URL 中
|
|
16
18
|
*/
|
|
17
19
|
function setUrlCriteriaQuery(searchForm, pagination) {
|
|
18
20
|
// 将对象转换为键值对字符串格式
|
|
19
|
-
const getJoinString =
|
|
21
|
+
const getJoinString = data => {
|
|
20
22
|
const keys = [];
|
|
21
23
|
const values = [];
|
|
22
24
|
Object.entries(data).forEach(([key, value]) => {
|
|
@@ -25,13 +27,15 @@ export default function useUrlQueryCriteria() {
|
|
|
25
27
|
if (Array.isArray(value)) {
|
|
26
28
|
// 数组值使用方括号包裹,并用竖线分隔
|
|
27
29
|
values.push(`[${value.join("|")}]`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
+
} else {
|
|
30
31
|
values.push(value);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
|
-
return {
|
|
35
|
+
return {
|
|
36
|
+
keys: keys.join(","),
|
|
37
|
+
values: values.join(",")
|
|
38
|
+
};
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
// 获取搜索表单和分页数据的键值对字符串
|
|
@@ -43,7 +47,7 @@ export default function useUrlQueryCriteria() {
|
|
|
43
47
|
searchFormKeys: searchFormData.keys || undefined,
|
|
44
48
|
searchFormValues: searchFormData.values || undefined,
|
|
45
49
|
paginationKeys: paginationData.keys || undefined,
|
|
46
|
-
paginationValues: paginationData.values || undefined
|
|
50
|
+
paginationValues: paginationData.values || undefined
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
53
|
|
|
@@ -63,8 +67,7 @@ export default function useUrlQueryCriteria() {
|
|
|
63
67
|
if (values[index].startsWith("[") && values[index].endsWith("]")) {
|
|
64
68
|
const arrayContent = values[index].substring(1, values[index].length - 1);
|
|
65
69
|
resultMap[key] = arrayContent ? arrayContent.split("|") : [];
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
70
|
+
} else {
|
|
68
71
|
// 处理普通值
|
|
69
72
|
resultMap[key] = values[index];
|
|
70
73
|
}
|
|
@@ -72,6 +75,10 @@ export default function useUrlQueryCriteria() {
|
|
|
72
75
|
});
|
|
73
76
|
return resultMap;
|
|
74
77
|
}
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
return {
|
|
79
|
+
setUrlCriteriaQuery,
|
|
80
|
+
getUrlCriteriaQuery
|
|
81
|
+
};
|
|
77
82
|
}
|
|
83
|
+
|
|
84
|
+
export { useUrlQueryCriteria as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zy-react-library",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "",
|
|
7
7
|
"author": "LiuJiaNan",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"node": ">=18.0.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
+
"build": "rollup -c",
|
|
24
|
+
"build:watch": "rollup -c -w",
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
23
26
|
"postinstall": "echo 'Thanks for using our component library!'"
|
|
24
27
|
},
|
|
25
28
|
"dependencies": {
|
|
@@ -37,5 +40,15 @@
|
|
|
37
40
|
"react": "^18.3.1",
|
|
38
41
|
"react-pdf": "^10.2.0",
|
|
39
42
|
"react-signature-canvas": "^1.1.0-alpha.2"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@babel/core": "^7.28.5",
|
|
46
|
+
"@babel/preset-react": "^7.28.5",
|
|
47
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
48
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
49
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
50
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
51
|
+
"glob": "^13.0.0",
|
|
52
|
+
"rollup": "^4.54.0"
|
|
40
53
|
}
|
|
41
54
|
}
|