zy-react-library 1.0.36 → 1.0.38
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/components/FormBuilder/FormBuilder.d.ts +8 -10
- package/components/FormBuilder/FormBuilder.js +9 -14
- package/components/FormBuilder/FormItemsRenderer.js +52 -49
- package/components/ImportFile/index.js +1 -1
- package/components/LeftTree/Basic/index.d.ts +25 -0
- package/components/LeftTree/Basic/index.js +184 -0
- package/components/LeftTree/Department/Gwj/index.d.ts +17 -0
- package/components/LeftTree/Department/Gwj/index.js +32 -0
- package/components/SelectTree/Basic/index.d.ts +25 -0
- package/components/SelectTree/Basic/index.js +50 -0
- package/components/SelectTree/Department/Gwj/index.d.ts +17 -0
- package/components/SelectTree/Department/Gwj/index.js +58 -0
- package/components/Upload/index.d.ts +8 -2
- package/components/Upload/index.js +103 -16
- package/enum/uploadFile/gwj/index.js +131 -0
- package/hooks/useDeleteFile/index.d.ts +22 -0
- package/hooks/useDeleteFile/index.js +46 -0
- package/hooks/useGetFile/index.d.ts +29 -0
- package/hooks/useGetFile/index.js +56 -0
- package/hooks/useUploadFile/index.d.ts +64 -0
- package/hooks/useUploadFile/index.js +99 -0
- package/package.json +1 -1
- package/utils/index.d.ts +46 -5
- package/utils/index.js +38 -2
package/utils/index.d.ts
CHANGED
|
@@ -31,6 +31,24 @@ type DataType
|
|
|
31
31
|
| "HTMLDocument"
|
|
32
32
|
| string; // 允许其他可能的类型
|
|
33
33
|
|
|
34
|
+
// 定义 getFileSuffix 函数可能返回的常见类型
|
|
35
|
+
type FileSuffix
|
|
36
|
+
= | "jpg"
|
|
37
|
+
| "jpeg"
|
|
38
|
+
| "png"
|
|
39
|
+
| "mp4"
|
|
40
|
+
| "mp3"
|
|
41
|
+
| "pdf"
|
|
42
|
+
| "doc"
|
|
43
|
+
| "docx"
|
|
44
|
+
| "xls"
|
|
45
|
+
| "xlsx"
|
|
46
|
+
| "txt"
|
|
47
|
+
| "zip"
|
|
48
|
+
| "rar"
|
|
49
|
+
| "tar"
|
|
50
|
+
| string; // 允许其他可能的类型
|
|
51
|
+
|
|
34
52
|
// 为 findCharIndex 函数定义接口类型
|
|
35
53
|
interface FindCharIndexOptions {
|
|
36
54
|
/** 查找的字符串 */
|
|
@@ -105,12 +123,28 @@ interface IsEmptyToWhetherOptions {
|
|
|
105
123
|
yesValue?: string | number;
|
|
106
124
|
}
|
|
107
125
|
|
|
126
|
+
// 为 getTreeNodePaths 函数定义接口类型
|
|
127
|
+
interface GetTreeNodePathsOptions {
|
|
128
|
+
/** 树形数据 */
|
|
129
|
+
data: any[];
|
|
130
|
+
/** 目标节点ID */
|
|
131
|
+
targetId: string | number;
|
|
132
|
+
/** id字段名 */
|
|
133
|
+
idKey: string;
|
|
134
|
+
/** 子节点字段名 */
|
|
135
|
+
childrenKey: string;
|
|
136
|
+
/** 路径数组 */
|
|
137
|
+
path?: any[];
|
|
138
|
+
/** 是否包含自身 */
|
|
139
|
+
isIncludeOneself?: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
108
142
|
/**
|
|
109
143
|
* 计算序号
|
|
110
144
|
*/
|
|
111
145
|
export function serialNumber(
|
|
112
146
|
pagination: BasePaginationConfig,
|
|
113
|
-
index: number
|
|
147
|
+
index: number,
|
|
114
148
|
): number;
|
|
115
149
|
|
|
116
150
|
/**
|
|
@@ -186,7 +220,7 @@ export function paging<T>(options: PagingOptions): T[];
|
|
|
186
220
|
/**
|
|
187
221
|
* 获取文件后缀
|
|
188
222
|
*/
|
|
189
|
-
export function getFileSuffix(name: string):
|
|
223
|
+
export function getFileSuffix(name: string): FileSuffix;
|
|
190
224
|
|
|
191
225
|
/**
|
|
192
226
|
* 获取文件名称
|
|
@@ -208,8 +242,8 @@ export function secondConversion(second: string | number): string;
|
|
|
208
242
|
*/
|
|
209
243
|
export function addingPrefixToFile<T extends Record<string, any>>(
|
|
210
244
|
list: T[],
|
|
211
|
-
options?: AddingPrefixToFileOptions
|
|
212
|
-
): (T & { url: string; name: string;
|
|
245
|
+
options?: AddingPrefixToFileOptions,
|
|
246
|
+
): (T & { url: string; name: string; id: any })[];
|
|
213
247
|
|
|
214
248
|
/**
|
|
215
249
|
* 翻译状态
|
|
@@ -241,7 +275,7 @@ export function listTransTree<T>(options: ListTransTreeOptions): T[];
|
|
|
241
275
|
*/
|
|
242
276
|
export function isEmptyToWhether(
|
|
243
277
|
value: any,
|
|
244
|
-
options?: IsEmptyToWhetherOptions
|
|
278
|
+
options?: IsEmptyToWhetherOptions,
|
|
245
279
|
): string;
|
|
246
280
|
|
|
247
281
|
/**
|
|
@@ -263,3 +297,10 @@ export function getIndexColumn(pagination: false | BasePaginationConfig): {
|
|
|
263
297
|
* 获取文件url
|
|
264
298
|
*/
|
|
265
299
|
export function getFileUrl(): string;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* 获取树形节点路径
|
|
303
|
+
*/
|
|
304
|
+
export function getTreeNodePaths<T extends Record<string, any> = Record<string, any>>(
|
|
305
|
+
options: GetTreeNodePathsOptions,
|
|
306
|
+
): T[] | null;
|
package/utils/index.js
CHANGED
|
@@ -258,13 +258,13 @@ export function addingPrefixToFile(list, options = {}) {
|
|
|
258
258
|
const {
|
|
259
259
|
pathKey = "filePath",
|
|
260
260
|
nameKey = "fileName",
|
|
261
|
-
idKey = "
|
|
261
|
+
idKey = "id",
|
|
262
262
|
} = options;
|
|
263
263
|
const FILE_URL = getFileUrl();
|
|
264
264
|
for (let i = 0; i < list.length; i++) {
|
|
265
265
|
list[i].url = FILE_URL + list[i][pathKey];
|
|
266
266
|
list[i].name = list[i][nameKey] || getFileName(list[i][pathKey]);
|
|
267
|
-
list[i].
|
|
267
|
+
list[i].id = list[i][idKey];
|
|
268
268
|
}
|
|
269
269
|
return list;
|
|
270
270
|
}
|
|
@@ -394,6 +394,42 @@ export function getIndexColumn(pagination) {
|
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
/**
|
|
398
|
+
* 获取树形节点路径
|
|
399
|
+
*/
|
|
400
|
+
export function getTreeNodePaths(options) {
|
|
401
|
+
const { data, targetId, idKey, childrenKey, path = [], isIncludeOneself } = options;
|
|
402
|
+
for (let i = 0; i < data.length; i++) {
|
|
403
|
+
const node = data[i];
|
|
404
|
+
const newPath = [...path, node];
|
|
405
|
+
|
|
406
|
+
// 找到目标节点,根据isIncludeOneself决定是否包含自身
|
|
407
|
+
if (node[idKey] === targetId) {
|
|
408
|
+
if (isIncludeOneself)
|
|
409
|
+
return newPath; // 包含自身
|
|
410
|
+
else
|
|
411
|
+
return path; // 不包含自身,只返回父节点路径
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// 递归查找子节点
|
|
415
|
+
if (node[childrenKey] && node[childrenKey].length > 0) {
|
|
416
|
+
const result = getTreeNodePaths({
|
|
417
|
+
data: node[childrenKey],
|
|
418
|
+
targetId,
|
|
419
|
+
idKey,
|
|
420
|
+
childrenKey,
|
|
421
|
+
path: newPath,
|
|
422
|
+
isIncludeOneself,
|
|
423
|
+
});
|
|
424
|
+
if (result) {
|
|
425
|
+
return result;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
|
|
397
433
|
/**
|
|
398
434
|
* 获取文件url
|
|
399
435
|
*/
|