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.
Files changed (76) hide show
  1. package/README.md +5 -1
  2. package/components/Cascader/Area/index.js +11 -11
  3. package/components/Cascader/Basic/index.js +23 -30
  4. package/components/Cascader/Dictionary/index.js +42 -42
  5. package/components/Cascader/Industry/index.js +12 -11
  6. package/components/Editor/index.js +43 -63
  7. package/components/FormBuilder/FormBuilder.js +97 -87
  8. package/components/FormBuilder/FormItemsRenderer.js +579 -581
  9. package/components/FormBuilder/index.js +5 -3
  10. package/components/HeaderBack/index.js +39 -32
  11. package/components/HiddenInfo/gwj/index.js +507 -439
  12. package/components/Icon/AddIcon/index.js +6 -6
  13. package/components/Icon/BackIcon/index.js +6 -6
  14. package/components/Icon/DeleteIcon/index.js +6 -6
  15. package/components/Icon/DownloadIcon/index.js +6 -6
  16. package/components/Icon/EditIcon/index.js +6 -6
  17. package/components/Icon/ExportIcon/index.js +6 -6
  18. package/components/Icon/ImportIcon/index.js +6 -6
  19. package/components/Icon/LocationIcon/index.js +6 -6
  20. package/components/Icon/PrintIcon/index.js +6 -6
  21. package/components/Icon/ResetIcon/index.js +6 -6
  22. package/components/Icon/SearchIcon/index.js +6 -6
  23. package/components/Icon/VideoIcon/index.js +6 -6
  24. package/components/Icon/ViewIcon/index.js +6 -6
  25. package/components/ImportFile/index.js +94 -91
  26. package/components/LeftTree/Area/index.js +15 -15
  27. package/components/LeftTree/Basic/index.js +54 -65
  28. package/components/LeftTree/Department/Gwj/index.js +29 -32
  29. package/components/LeftTree/Dictionary/index.js +42 -42
  30. package/components/Map/MapSelector.js +280 -254
  31. package/components/Map/index.js +90 -77
  32. package/components/Page/index.d.ts +2 -0
  33. package/components/Page/index.js +44 -34
  34. package/components/Pdf/index.js +92 -90
  35. package/components/PreviewImg/index.js +26 -32
  36. package/components/PreviewPdf/index.js +78 -86
  37. package/components/Search/index.js +147 -141
  38. package/components/Select/Basic/index.js +70 -76
  39. package/components/Select/Dictionary/index.js +42 -42
  40. package/components/Select/Personnel/Gwj/index.js +45 -49
  41. package/components/SelectCreate/index.js +33 -40
  42. package/components/SelectTree/Area/index.js +11 -17
  43. package/components/SelectTree/Basic/index.js +105 -102
  44. package/components/SelectTree/Department/Gwj/index.js +40 -46
  45. package/components/SelectTree/Dictionary/index.js +42 -42
  46. package/components/SelectTree/HiddenLevel/Gwj/index.js +33 -35
  47. package/components/SelectTree/HiddenPart/Gwj/index.js +16 -19
  48. package/components/SelectTree/Industry/index.js +12 -18
  49. package/components/Signature/index.js +68 -62
  50. package/components/Table/index.js +77 -73
  51. package/components/Table/index.less +7 -1
  52. package/components/TooltipPreviewImg/index.js +28 -27
  53. package/components/Upload/index.js +229 -275
  54. package/components/Video/AliPlayer.js +182 -160
  55. package/components/Video/index.js +71 -90
  56. package/css/common.less +4 -0
  57. package/enum/dictionary/index.js +5 -3
  58. package/enum/formItemRender/index.js +37 -35
  59. package/enum/hidden/gwj/index.js +65 -26
  60. package/enum/uploadFile/gwj/index.js +166 -84
  61. package/hooks/useDeleteFile/index.js +24 -30
  62. package/hooks/useDictionary/index.js +28 -30
  63. package/hooks/useDownloadBlob/index.js +78 -77
  64. package/hooks/useDownloadFile/index.js +76 -79
  65. package/hooks/useGetFile/index.js +32 -32
  66. package/hooks/useGetUrlQuery/index.js +1 -2
  67. package/hooks/useGetUserInfo/index.js +19 -26
  68. package/hooks/useIdle/index.js +9 -11
  69. package/hooks/useImportFile/index.js +30 -28
  70. package/hooks/useIsExistenceDuplicateSelection/index.js +25 -18
  71. package/hooks/useTable/index.js +49 -38
  72. package/hooks/useUploadFile/index.js +142 -147
  73. package/hooks/useUrlQueryCriteria/index.js +20 -13
  74. package/package.json +14 -1
  75. package/regular/index.js +34 -39
  76. package/utils/index.js +515 -511
package/utils/index.js CHANGED
@@ -1,587 +1,591 @@
1
- import { ID_NUMBER } from "../regular";
2
- import dayjs from "dayjs";
3
-
1
+ import { ID_NUMBER } from '../regular/index.js';
2
+ import dayjs from 'dayjs';
3
+
4
4
  /**
5
5
  * 计算序号
6
- */
7
- export function serialNumber(pagination, index) {
8
- return (pagination.current - 1) * pagination.pageSize + (index + 1);
9
- }
10
-
6
+ */
7
+ function serialNumber(pagination, index) {
8
+ return (pagination.current - 1) * pagination.pageSize + (index + 1);
9
+ }
10
+
11
11
  /**
12
12
  * 字符串数组转数组
13
- */
14
- export function toArrayString(value) {
15
- // eslint-disable-next-line no-eval
16
- return value ? eval(value).map(String) : [];
17
- }
18
-
13
+ */
14
+ function toArrayString(value) {
15
+ // eslint-disable-next-line no-eval
16
+ return value ? eval(value).map(String) : [];
17
+ }
18
+
19
19
  /**
20
20
  * 判断文件后缀名是否符合
21
- */
22
- export function interceptTheSuffix(name, suffix) {
23
- return (
24
- name.substring(name.lastIndexOf("."), name.length).toLowerCase()
25
- === suffix.toLowerCase()
26
- );
27
- }
28
-
21
+ */
22
+ function interceptTheSuffix(name, suffix) {
23
+ return name.substring(name.lastIndexOf("."), name.length).toLowerCase() === suffix.toLowerCase();
24
+ }
25
+
29
26
  /**
30
27
  * 图片转base64
31
- */
32
- export function image2Base64(imgUrl) {
33
- return new Promise((resolve) => {
34
- const img = new Image();
35
- img.src = imgUrl;
36
- img.crossOrigin = "Anonymous";
37
- img.onload = function () {
38
- const canvas = document.createElement("canvas");
39
- canvas.width = img.width;
40
- canvas.height = img.height;
41
- const ctx = canvas.getContext("2d");
42
- ctx.drawImage(img, 0, 0, img.width, img.height);
43
- const ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
44
- resolve(canvas.toDataURL(`image/${ext}`));
45
- };
46
- });
47
- }
48
-
28
+ */
29
+ function image2Base64(imgUrl) {
30
+ return new Promise(resolve => {
31
+ const img = new Image();
32
+ img.src = imgUrl;
33
+ img.crossOrigin = "Anonymous";
34
+ img.onload = function () {
35
+ const canvas = document.createElement("canvas");
36
+ canvas.width = img.width;
37
+ canvas.height = img.height;
38
+ const ctx = canvas.getContext("2d");
39
+ ctx.drawImage(img, 0, 0, img.width, img.height);
40
+ const ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
41
+ resolve(canvas.toDataURL(`image/${ext}`));
42
+ };
43
+ });
44
+ }
45
+
49
46
  /**
50
47
  图片转base64 (File对象版本)
51
- */
52
- export function image2Base642(file) {
53
- return new Promise((resolve, reject) => {
54
- const reader = new FileReader();
55
- reader.readAsDataURL(file);
56
- reader.onload = (e) => {
57
- resolve(e.target.result); // 返回 base64
58
- };
59
- reader.onerror = (error) => {
60
- reject(error); // 处理错误
61
- };
62
- });
63
- }
64
-
48
+ */
49
+ function image2Base642(file) {
50
+ return new Promise((resolve, reject) => {
51
+ const reader = new FileReader();
52
+ reader.readAsDataURL(file);
53
+ reader.onload = e => {
54
+ resolve(e.target.result); // 返回 base64
55
+ };
56
+ reader.onerror = error => {
57
+ reject(error); // 处理错误
58
+ };
59
+ });
60
+ }
61
+
65
62
  /**
66
63
  base64转File对象
67
- */
68
- export function base642File(base64, filename = 'file') {
69
- const arr = base64.split(",");
70
- const mime = arr[0].match(/:(.*?);/)[1];
71
- const ext = mime.split('/')[1];
72
- const bstr = atob(arr[1]);
73
- let n = bstr.length;
74
- const u8arr = new Uint8Array(n);
75
-
76
- while (n--) {
77
- u8arr[n] = bstr.charCodeAt(n);
78
- }
79
-
80
- return new File([u8arr], `${filename}.${ext}`, { type: mime });
81
- }
82
-
64
+ */
65
+ function base642File(base64, filename = 'file') {
66
+ const arr = base64.split(",");
67
+ const mime = arr[0].match(/:(.*?);/)[1];
68
+ const ext = mime.split('/')[1];
69
+ const bstr = atob(arr[1]);
70
+ let n = bstr.length;
71
+ const u8arr = new Uint8Array(n);
72
+ while (n--) {
73
+ u8arr[n] = bstr.charCodeAt(n);
74
+ }
75
+ return new File([u8arr], `${filename}.${ext}`, {
76
+ type: mime
77
+ });
78
+ }
79
+
83
80
  /**
84
81
  * 判断图片是否可访问成功
85
- */
86
- export function checkImgExists(imgUrl) {
87
- return new Promise((resolve, reject) => {
88
- const ImgObj = new Image();
89
- ImgObj.src = imgUrl;
90
- ImgObj.onload = function (res) {
91
- resolve(res);
92
- };
93
- ImgObj.onerror = function (err) {
94
- reject(err);
95
- };
96
- });
97
- }
98
-
82
+ */
83
+ function checkImgExists(imgUrl) {
84
+ return new Promise((resolve, reject) => {
85
+ const ImgObj = new Image();
86
+ ImgObj.src = imgUrl;
87
+ ImgObj.onload = function (res) {
88
+ resolve(res);
89
+ };
90
+ ImgObj.onerror = function (err) {
91
+ reject(err);
92
+ };
93
+ });
94
+ }
95
+
99
96
  /**
100
97
  * 获取数据类型
101
- */
102
- export function getDataType(data) {
103
- return Object.prototype.toString.call(data).slice(8, -1);
104
- }
105
-
98
+ */
99
+ function getDataType(data) {
100
+ return Object.prototype.toString.call(data).slice(8, -1);
101
+ }
102
+
106
103
  /**
107
104
  * 数组去重
108
- */
109
- export function ArrayDeduplication(arr) {
110
- return [...new Set(arr)];
111
- }
112
-
105
+ */
106
+ function ArrayDeduplication(arr) {
107
+ return [...new Set(arr)];
108
+ }
109
+
113
110
  /**
114
111
  * 数组对象去重
115
- */
116
- export function arrayObjectDeduplication(arr, key) {
117
- const obj = {};
118
- arr = arr.reduce((previousValue, currentValue) => {
119
- if (!obj[currentValue[key]]) {
120
- obj[currentValue[key]] = true;
121
- previousValue.push(currentValue);
122
- }
123
- return previousValue;
124
- }, []);
125
- return arr;
126
- }
127
-
112
+ */
113
+ function arrayObjectDeduplication(arr, key) {
114
+ const obj = {};
115
+ arr = arr.reduce((previousValue, currentValue) => {
116
+ if (!obj[currentValue[key]]) {
117
+ obj[currentValue[key]] = true;
118
+ previousValue.push(currentValue);
119
+ }
120
+ return previousValue;
121
+ }, []);
122
+ return arr;
123
+ }
124
+
128
125
  /**
129
126
  * 查找字符串中指定的值第几次出现的位置
130
- */
131
- export function findCharIndex(options) {
132
- const { str, char, num } = options;
133
- let index = str.indexOf(char);
134
- if (index === -1)
135
- return -1;
136
- for (let i = 0; i < num - 1; i++) {
137
- index = str.indexOf(char, index + 1);
138
- if (index === -1)
139
- return -1;
140
- }
141
- return index;
142
- }
143
-
127
+ */
128
+ function findCharIndex(options) {
129
+ const {
130
+ str,
131
+ char,
132
+ num
133
+ } = options;
134
+ let index = str.indexOf(char);
135
+ if (index === -1) return -1;
136
+ for (let i = 0; i < num - 1; i++) {
137
+ index = str.indexOf(char, index + 1);
138
+ if (index === -1) return -1;
139
+ }
140
+ return index;
141
+ }
142
+
144
143
  /**
145
144
  * 生成指定两个值之间的随机数
146
- */
147
- export function randoms(min, max) {
148
- return Math.random() * (max - min + 1) + min;
149
- }
150
-
145
+ */
146
+ function randoms(min, max) {
147
+ return Math.random() * (max - min + 1) + min;
148
+ }
149
+
151
150
  /**
152
151
  * 千位分隔符
153
- */
154
- export function numFormat(num) {
155
- if (num) {
156
- const numArr = num.toString().split(".");
157
- const arr = numArr[0].split("").reverse();
158
- let res = [];
159
- for (let i = 0; i < arr.length; i++) {
160
- if (i % 3 === 0 && i !== 0) {
161
- res.push(",");
162
- }
163
- res.push(arr[i]);
164
- }
165
- res.reverse();
166
- if (numArr[1]) {
167
- res = res.join("").concat(`.${numArr[1]}`);
168
- }
169
- else {
170
- res = res.join("");
171
- }
172
- return res;
173
- }
174
- }
175
-
152
+ */
153
+ function numFormat(num) {
154
+ if (num) {
155
+ const numArr = num.toString().split(".");
156
+ const arr = numArr[0].split("").reverse();
157
+ let res = [];
158
+ for (let i = 0; i < arr.length; i++) {
159
+ if (i % 3 === 0 && i !== 0) {
160
+ res.push(",");
161
+ }
162
+ res.push(arr[i]);
163
+ }
164
+ res.reverse();
165
+ if (numArr[1]) {
166
+ res = res.join("").concat(`.${numArr[1]}`);
167
+ } else {
168
+ res = res.join("");
169
+ }
170
+ return res;
171
+ }
172
+ }
173
+
176
174
  /**
177
175
  * 验证是否为空
178
- */
179
- export function isEmpty(value) {
180
- return (
181
- value === undefined
182
- || value === null
183
- || (typeof value === "object" && Object.keys(value).length === 0)
184
- || (typeof value === "string" && value.trim().length === 0)
185
- );
186
- }
187
-
176
+ */
177
+ function isEmpty(value) {
178
+ return value === undefined || value === null || typeof value === "object" && Object.keys(value).length === 0 || typeof value === "string" && value.trim().length === 0;
179
+ }
180
+
188
181
  /**
189
182
  * 获取url参数
190
- */
191
- export function getUrlParam(key) {
192
- const reg = new RegExp(`(^|&)${key}=([^&]*)(&|$)`);
193
- const r = window.location.search.substr(1).match(reg);
194
- if (r != null)
195
- return decodeURI(r[2]);
196
- return "";
197
- }
198
-
183
+ */
184
+ function getUrlParam(key) {
185
+ const reg = new RegExp(`(^|&)${key}=([^&]*)(&|$)`);
186
+ const r = window.location.search.substr(1).match(reg);
187
+ if (r != null) return decodeURI(r[2]);
188
+ return "";
189
+ }
190
+
199
191
  /**
200
192
  * 数据分页
201
- */
202
- export function paging(options) {
203
- const { list, currentPage, pageSize } = options;
204
- return list.filter((item, index) => {
205
- return (
206
- index < +currentPage * +pageSize
207
- && index >= (+currentPage - 1) * +pageSize
208
- );
209
- });
210
- }
211
-
193
+ */
194
+ function paging(options) {
195
+ const {
196
+ list,
197
+ currentPage,
198
+ pageSize
199
+ } = options;
200
+ return list.filter((item, index) => {
201
+ return index < +currentPage * +pageSize && index >= (+currentPage - 1) * +pageSize;
202
+ });
203
+ }
204
+
212
205
  /**
213
206
  * 获取文件后缀
214
- */
215
- export function getFileSuffix(name) {
216
- return name.substring(name.lastIndexOf(".") + 1);
217
- }
218
-
207
+ */
208
+ function getFileSuffix(name) {
209
+ return name.substring(name.lastIndexOf(".") + 1);
210
+ }
211
+
219
212
  /**
220
213
  * 获取文件名称
221
- */
222
- export function getFileName(name) {
223
- if (!name)
224
- return "";
225
- return name.substring(name.lastIndexOf("/") + 1);
226
- }
227
-
214
+ */
215
+ function getFileName(name) {
216
+ if (!name) return "";
217
+ return name.substring(name.lastIndexOf("/") + 1);
218
+ }
219
+
228
220
  /**
229
221
  * 读取txt文档
230
- */
231
- export function readTxtDocument(filePah) {
232
- return new Promise((resolve) => {
233
- const FILE_URL = getFileUrl();
234
- const file_url = FILE_URL + filePah;
235
- const xhr = new XMLHttpRequest();
236
- xhr.open("get", file_url, true);
237
- xhr.responseType = "blob";
238
- xhr.onload = function (event) {
239
- const reader = new FileReader();
240
- reader.readAsText(event.target.response, "GB2312");
241
- reader.onload = function () {
242
- resolve(reader.result);
243
- };
244
- };
245
- xhr.send();
246
- });
247
- }
248
-
222
+ */
223
+ function readTxtDocument(filePah) {
224
+ return new Promise(resolve => {
225
+ const FILE_URL = getFileUrl();
226
+ const file_url = FILE_URL + filePah;
227
+ const xhr = new XMLHttpRequest();
228
+ xhr.open("get", file_url, true);
229
+ xhr.responseType = "blob";
230
+ xhr.onload = function (event) {
231
+ const reader = new FileReader();
232
+ reader.readAsText(event.target.response, "GB2312");
233
+ reader.onload = function () {
234
+ resolve(reader.result);
235
+ };
236
+ };
237
+ xhr.send();
238
+ });
239
+ }
240
+
249
241
  /**
250
242
  * 将秒转换成时分秒
251
- */
252
- export function secondConversion(second) {
253
- if (!second)
254
- return 0;
255
- const h = Number.parseInt(second / 60 / 60, 10);
256
- const m = Number.parseInt((second / 60) % 60, 10);
257
- const s = Number.parseInt(second % 60, 10);
258
- if (h) {
259
- return `${h}小时${m}分钟${s}秒`;
260
- }
261
- else {
262
- if (m) {
263
- return `${m}分钟${s}秒`;
264
- }
265
- else {
266
- return `${s}秒`;
267
- }
268
- }
269
- }
270
-
243
+ */
244
+ function secondConversion(second) {
245
+ if (!second) return 0;
246
+ const h = Number.parseInt(second / 60 / 60, 10);
247
+ const m = Number.parseInt(second / 60 % 60, 10);
248
+ const s = Number.parseInt(second % 60, 10);
249
+ if (h) {
250
+ return `${h}小时${m}分钟${s}秒`;
251
+ } else {
252
+ if (m) {
253
+ return `${m}分钟${s}秒`;
254
+ } else {
255
+ return `${s}秒`;
256
+ }
257
+ }
258
+ }
259
+
271
260
  /**
272
261
  * 附件添加前缀
273
- */
274
- export function addingPrefixToFile(list, options = {}) {
275
- if (!list)
276
- return [];
277
- const {
278
- pathKey = "filePath",
279
- nameKey = "fileName",
280
- idKey = "id",
281
- } = options;
282
- const FILE_URL = getFileUrl();
283
- for (let i = 0; i < list.length; i++) {
284
- list[i].url = FILE_URL + list[i][pathKey];
285
- list[i].name = list[i][nameKey] || getFileName(list[i][pathKey]);
286
- list[i].id = list[i][idKey];
287
- }
288
- return list;
289
- }
290
-
262
+ */
263
+ function addingPrefixToFile(list, options = {}) {
264
+ if (!list) return [];
265
+ const {
266
+ pathKey = "filePath",
267
+ nameKey = "fileName",
268
+ idKey = "id"
269
+ } = options;
270
+ const FILE_URL = getFileUrl();
271
+ for (let i = 0; i < list.length; i++) {
272
+ list[i].url = FILE_URL + list[i][pathKey];
273
+ list[i].name = list[i][nameKey] || getFileName(list[i][pathKey]);
274
+ list[i].id = list[i][idKey];
275
+ }
276
+ return list;
277
+ }
278
+
291
279
  /**
292
280
  * 翻译状态
293
- */
294
- export function getLabelName(options) {
295
- const { status, list, idKey = "bianma", nameKey = "name" } = options;
296
- for (let i = 0; i < list.length; i++) {
297
- if (status?.toString() === list[i][idKey]?.toString()) {
298
- return list[i][nameKey];
299
- }
300
- }
301
- }
302
-
281
+ */
282
+ function getLabelName(options) {
283
+ const {
284
+ status,
285
+ list,
286
+ idKey = "bianma",
287
+ nameKey = "name"
288
+ } = options;
289
+ for (let i = 0; i < list.length; i++) {
290
+ if (status?.toString() === list[i][idKey]?.toString()) {
291
+ return list[i][nameKey];
292
+ }
293
+ }
294
+ }
295
+
303
296
  /**
304
297
  * 计算文件大小
305
- */
306
- export function calculateFileSize(size) {
307
- return size > 1024
308
- ? `${(`${size / 1024}`).substring(0, (`${size / 1024}`).lastIndexOf(".") + 3)
309
- }MB`
310
- : `${size}KB`;
311
- }
312
-
298
+ */
299
+ function calculateFileSize(size) {
300
+ return size > 1024 ? `${`${size / 1024}`.substring(0, `${size / 1024}`.lastIndexOf(".") + 3)}MB` : `${size}KB`;
301
+ }
302
+
313
303
  /**
314
304
  * 根据身份证号获取出生日期和性别
315
- */
316
- export function idCardGetDateAndGender(idCard) {
317
- let sex = "";
318
- let date = "";
319
- if (ID_NUMBER.test(idCard)) {
320
- const org_birthday = idCard.substring(6, 14);
321
- const org_gender = idCard.substring(16, 17);
322
- const birthday
323
- = `${org_birthday.substring(0, 4)
324
- }-${
325
- org_birthday.substring(4, 6)
326
- }-${
327
- org_birthday.substring(6, 8)}`;
328
- const birthdays = new Date(birthday.replace(/-/g, "/"));
329
- const Month = birthdays.getMonth() + 1;
330
- let MonthDate;
331
- const DayDate = birthdays.getDate();
332
- let Day;
333
- if (Month < 10)
334
- MonthDate = `0${Month}`;
335
- else MonthDate = Month;
336
- if (DayDate < 10)
337
- Day = `0${DayDate}`;
338
- else Day = DayDate;
339
- sex = org_gender % 2 === 1 ? "1" : "0";
340
- date = `${birthdays.getFullYear()}-${MonthDate}-${Day}`;
341
- }
342
- return { sex, date };
343
- }
344
-
305
+ */
306
+ function idCardGetDateAndGender(idCard) {
307
+ let sex = "";
308
+ let date = "";
309
+ if (ID_NUMBER.test(idCard)) {
310
+ const org_birthday = idCard.substring(6, 14);
311
+ const org_gender = idCard.substring(16, 17);
312
+ const birthday = `${org_birthday.substring(0, 4)}-${org_birthday.substring(4, 6)}-${org_birthday.substring(6, 8)}`;
313
+ const birthdays = new Date(birthday.replace(/-/g, "/"));
314
+ const Month = birthdays.getMonth() + 1;
315
+ let MonthDate;
316
+ const DayDate = birthdays.getDate();
317
+ let Day;
318
+ if (Month < 10) MonthDate = `0${Month}`;else MonthDate = Month;
319
+ if (DayDate < 10) Day = `0${DayDate}`;else Day = DayDate;
320
+ sex = org_gender % 2 === 1 ? "1" : "0";
321
+ date = `${birthdays.getFullYear()}-${MonthDate}-${Day}`;
322
+ }
323
+ return {
324
+ sex,
325
+ date
326
+ };
327
+ }
328
+
345
329
  /**
346
330
  * 获取select中指定项组成的数组
347
- */
348
- export function getSelectAppointItemList(options) {
349
- const { list, value, idKey = "bianma" } = options;
350
- return list.filter(item => value.includes(item[idKey]));
351
- }
352
-
331
+ */
332
+ function getSelectAppointItemList(options) {
333
+ const {
334
+ list,
335
+ value,
336
+ idKey = "bianma"
337
+ } = options;
338
+ return list.filter(item => value.includes(item[idKey]));
339
+ }
340
+
353
341
  /**
354
342
  * json转换为树形结构
355
- */
356
- export function listTransTree(options) {
357
- const { json, idKey, parentIdKey, childrenKey } = options;
358
- const r = [];
359
- const hash = {};
360
- let i = 0;
361
- let j = 0;
362
- const len = json.length;
363
- for (; i < len; i++) {
364
- hash[json[i][idKey]] = json[i];
365
- }
366
- for (; j < len; j++) {
367
- const aVal = json[j];
368
- const hashVP = hash[aVal[parentIdKey]];
369
- if (hashVP) {
370
- !hashVP[childrenKey] && (hashVP[childrenKey] = []);
371
- hashVP[childrenKey].push(aVal);
372
- }
373
- else {
374
- r.push(aVal);
375
- }
376
- }
377
- return r;
378
- }
379
-
343
+ */
344
+ function listTransTree(options) {
345
+ const {
346
+ json,
347
+ idKey,
348
+ parentIdKey,
349
+ childrenKey
350
+ } = options;
351
+ const r = [];
352
+ const hash = {};
353
+ let i = 0;
354
+ let j = 0;
355
+ const len = json.length;
356
+ for (; i < len; i++) {
357
+ hash[json[i][idKey]] = json[i];
358
+ }
359
+ for (; j < len; j++) {
360
+ const aVal = json[j];
361
+ const hashVP = hash[aVal[parentIdKey]];
362
+ if (hashVP) {
363
+ !hashVP[childrenKey] && (hashVP[childrenKey] = []);
364
+ hashVP[childrenKey].push(aVal);
365
+ } else {
366
+ r.push(aVal);
367
+ }
368
+ }
369
+ return r;
370
+ }
371
+
380
372
  /**
381
373
  * 将值转换为"是"/"否"显示文本
382
- */
383
- export function isEmptyToWhether(value, options = {}) {
384
- const { yesText = "是", noText = "否", yesValue = "1" } = options;
385
- return !isEmpty(value)
386
- ? value.toString() === yesValue.toString()
387
- ? yesText
388
- : noText
389
- : "";
390
- }
391
-
374
+ */
375
+ function isEmptyToWhether(value, options = {}) {
376
+ const {
377
+ yesText = "是",
378
+ noText = "否",
379
+ yesValue = "1"
380
+ } = options;
381
+ return !isEmpty(value) ? value.toString() === yesValue.toString() ? yesText : noText : "";
382
+ }
383
+
392
384
  /**
393
385
  * 生成指定长度的guid
394
- */
395
- export function createGuid(len = 32) {
396
- const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
397
- let result = "";
398
- for (let i = 0; i < len; i++) {
399
- result += chars.charAt(Math.floor(Math.random() * chars.length));
400
- }
401
- return result;
402
- }
403
-
386
+ */
387
+ function createGuid(len = 32) {
388
+ const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
389
+ let result = "";
390
+ for (let i = 0; i < len; i++) {
391
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
392
+ }
393
+ return result;
394
+ }
395
+
404
396
  /**
405
397
  * 获取序号列
406
- */
407
- export function getIndexColumn(pagination) {
408
- return {
409
- title: "序号",
410
- key: "index",
411
- width: 70,
412
- render: (_, __, index) => pagination === false ? index + 1 : serialNumber(pagination, index),
413
- };
414
- }
415
-
398
+ */
399
+ function getIndexColumn(pagination) {
400
+ return {
401
+ title: "序号",
402
+ key: "index",
403
+ width: 70,
404
+ render: (_, __, index) => pagination === false ? index + 1 : serialNumber(pagination, index)
405
+ };
406
+ }
407
+
416
408
  /**
417
409
  * 获取树形节点路径
418
- */
419
- export function getTreeNodePaths(options) {
420
- const { data, targetId, idKey, childrenKey, path = [], isIncludeOneself } = options;
421
- for (let i = 0; i < data.length; i++) {
422
- const node = data[i];
423
- const newPath = [...path, node];
424
-
425
- // 找到目标节点,根据isIncludeOneself决定是否包含自身
426
- if (node[idKey] === targetId) {
427
- if (isIncludeOneself)
428
- return newPath; // 包含自身
429
- else
430
- return path; // 不包含自身,只返回父节点路径
431
- }
432
-
433
- // 递归查找子节点
434
- if (node[childrenKey] && node[childrenKey].length > 0) {
435
- const result = getTreeNodePaths({
436
- data: node[childrenKey],
437
- targetId,
438
- idKey,
439
- childrenKey,
440
- path: newPath,
441
- isIncludeOneself,
442
- });
443
- if (result) {
444
- return result;
445
- }
446
- }
447
- }
448
-
449
- return null;
450
- }
451
-
410
+ */
411
+ function getTreeNodePaths(options) {
412
+ const {
413
+ data,
414
+ targetId,
415
+ idKey,
416
+ childrenKey,
417
+ path = [],
418
+ isIncludeOneself
419
+ } = options;
420
+ for (let i = 0; i < data.length; i++) {
421
+ const node = data[i];
422
+ const newPath = [...path, node];
423
+
424
+ // 找到目标节点,根据isIncludeOneself决定是否包含自身
425
+ if (node[idKey] === targetId) {
426
+ if (isIncludeOneself) return newPath; // 包含自身
427
+ else return path; // 不包含自身,只返回父节点路径
428
+ }
429
+
430
+ // 递归查找子节点
431
+ if (node[childrenKey] && node[childrenKey].length > 0) {
432
+ const result = getTreeNodePaths({
433
+ data: node[childrenKey],
434
+ targetId,
435
+ idKey,
436
+ childrenKey,
437
+ path: newPath,
438
+ isIncludeOneself
439
+ });
440
+ if (result) {
441
+ return result;
442
+ }
443
+ }
444
+ }
445
+ return null;
446
+ }
447
+
452
448
  /**
453
449
  * 根据 level 属性处理树数据,添加 isLeaf 属性控制节点是否可展开
454
- */
455
- export const processTreeDataByLevel = (options) => {
456
- const { data, level, childrenKey, currentLevel = 1 } = options;
457
- return data.map((item) => {
458
- const processedItem = { ...item };
459
-
460
- // 如果指定了 level 且当前层级达到指定层级,则标记为叶子节点
461
- if (level && currentLevel >= level) {
462
- processedItem.isLeaf = true;
463
- // 移除子节点
464
- delete processedItem[childrenKey];
465
- }
466
- else if (item[childrenKey] && item[childrenKey].length > 0) {
467
- // 未达到指定层级,继续处理子节点
468
- processedItem[childrenKey] = processTreeDataByLevel({
469
- data: item[childrenKey],
470
- currentLevel: currentLevel + 1,
471
- level,
472
- childrenKey,
473
- });
474
- }
475
- else {
476
- // 没有子节点,标记为叶子节点
477
- processedItem.isLeaf = true;
478
- }
479
-
480
- return processedItem;
481
- });
482
- };
483
-
450
+ */
451
+ const processTreeDataByLevel = options => {
452
+ const {
453
+ data,
454
+ level,
455
+ childrenKey,
456
+ currentLevel = 1
457
+ } = options;
458
+ return data.map(item => {
459
+ const processedItem = {
460
+ ...item
461
+ };
462
+
463
+ // 如果指定了 level 且当前层级达到指定层级,则标记为叶子节点
464
+ if (level && currentLevel >= level) {
465
+ processedItem.isLeaf = true;
466
+ // 移除子节点
467
+ delete processedItem[childrenKey];
468
+ } else if (item[childrenKey] && item[childrenKey].length > 0) {
469
+ // 未达到指定层级,继续处理子节点
470
+ processedItem[childrenKey] = processTreeDataByLevel({
471
+ data: item[childrenKey],
472
+ currentLevel: currentLevel + 1,
473
+ level,
474
+ childrenKey
475
+ });
476
+ } else {
477
+ // 没有子节点,标记为叶子节点
478
+ processedItem.isLeaf = true;
479
+ }
480
+ return processedItem;
481
+ });
482
+ };
483
+
484
484
  /**
485
485
  * 根据 onlyLastLevel 属性处理树数据,添加 selectable 属性控制节点是否可选择
486
- */
487
- export const processTreeDataForOnlyLastLevel = (options) => {
488
- const { data, childrenKey, onlyLastLevel = false } = options;
489
- if (!onlyLastLevel)
490
- return data;
491
-
492
- return data.map((item) => {
493
- // 检查是否有子节点
494
- const hasChildren = item[childrenKey] && item[childrenKey].length > 0;
495
-
496
- // 如果有子节点,则不可选择
497
- const processedItem = {
498
- ...item,
499
- selectable: !hasChildren,
500
- };
501
-
502
- // 递归处理子节点
503
- if (hasChildren) {
504
- processedItem[childrenKey] = processTreeDataForOnlyLastLevel({ data: item[childrenKey], childrenKey, onlyLastLevel });
505
- }
506
-
507
- return processedItem;
508
- });
509
- };
510
-
486
+ */
487
+ const processTreeDataForOnlyLastLevel = options => {
488
+ const {
489
+ data,
490
+ childrenKey,
491
+ onlyLastLevel = false
492
+ } = options;
493
+ if (!onlyLastLevel) return data;
494
+ return data.map(item => {
495
+ // 检查是否有子节点
496
+ const hasChildren = item[childrenKey] && item[childrenKey].length > 0;
497
+
498
+ // 如果有子节点,则不可选择
499
+ const processedItem = {
500
+ ...item,
501
+ selectable: !hasChildren
502
+ };
503
+
504
+ // 递归处理子节点
505
+ if (hasChildren) {
506
+ processedItem[childrenKey] = processTreeDataForOnlyLastLevel({
507
+ data: item[childrenKey],
508
+ childrenKey,
509
+ onlyLastLevel
510
+ });
511
+ }
512
+ return processedItem;
513
+ });
514
+ };
515
+
511
516
  /**
512
517
  * 验证结束时间是否大于开始时间
513
- */
514
- export const validatorEndTime = (timeStart, message = "结束时间不能早于开始时间") => {
515
- return {
516
- validator: (_, value) => {
517
- if (value && timeStart && value < timeStart) {
518
- return Promise.reject(message);
519
- }
520
- else {
521
- return Promise.resolve();
522
- }
523
- },
524
- }
525
- }
526
-
518
+ */
519
+ const validatorEndTime = (timeStart, message = "结束时间不能早于开始时间") => {
520
+ return {
521
+ validator: (_, value) => {
522
+ if (value && timeStart && value < timeStart) {
523
+ return Promise.reject(message);
524
+ } else {
525
+ return Promise.resolve();
526
+ }
527
+ }
528
+ };
529
+ };
530
+
527
531
  /**
528
532
  * 验证时间是否大于等于当前时间
529
- */
530
- export const validatorTimeGTCurrentDay = (message = "需要大于当前时间") => {
531
- return {
532
- validator: (_, value) => {
533
- if (value && value <= dayjs().format("YYYY-MM-DD HH:mm:ss")) {
534
- return Promise.reject(message);
535
- }
536
- else {
537
- return Promise.resolve();
538
- }
539
- },
540
- }
541
- }
542
-
533
+ */
534
+ const validatorTimeGTCurrentDay = (message = "需要大于当前时间") => {
535
+ return {
536
+ validator: (_, value) => {
537
+ if (value && value <= dayjs().format("YYYY-MM-DD HH:mm:ss")) {
538
+ return Promise.reject(message);
539
+ } else {
540
+ return Promise.resolve();
541
+ }
542
+ }
543
+ };
544
+ };
545
+
543
546
  /**
544
547
  * 动态加载js资源
545
- */
546
- export function dynamicLoadJs(url) {
547
- return new Promise((resolve, reject) => {
548
- const script = document.createElement("script");
549
- script.type = "text/javascript";
550
- script.src = url;
551
- script.onload = resolve;
552
- script.onerror = reject;
553
- document.body.appendChild(script);
554
- });
555
- }
556
-
548
+ */
549
+ function dynamicLoadJs(url) {
550
+ return new Promise((resolve, reject) => {
551
+ const script = document.createElement("script");
552
+ script.type = "text/javascript";
553
+ script.src = url;
554
+ script.onload = resolve;
555
+ script.onerror = reject;
556
+ document.body.appendChild(script);
557
+ });
558
+ }
559
+
557
560
  /**
558
561
  * 动态加载css资源
559
- */
560
- export function dynamicLoadCss(url) {
561
- return new Promise((resolve, reject) => {
562
- const link = document.createElement("link");
563
- link.rel = "stylesheet";
564
- link.type = "text/css";
565
- link.href = url;
566
- link.onload = resolve;
567
- link.onerror = reject;
568
- document.head.appendChild(link);
569
- });
570
- }
571
-
562
+ */
563
+ function dynamicLoadCss(url) {
564
+ return new Promise((resolve, reject) => {
565
+ const link = document.createElement("link");
566
+ link.rel = "stylesheet";
567
+ link.type = "text/css";
568
+ link.href = url;
569
+ link.onload = resolve;
570
+ link.onerror = reject;
571
+ document.head.appendChild(link);
572
+ });
573
+ }
574
+
572
575
  /**
573
576
  * 是否空html,用于给富文本编辑器使用
574
- */
575
- export function normalizeEmptyHtml(html) {
576
- if (!html)
577
- return "";
578
- const cleaned = html.replace(/\s+/g, "").toLowerCase();
579
- return cleaned === "<p><br></p>" || cleaned === "<p></p>" || cleaned === "" ? "" : html;
580
- }
581
-
577
+ */
578
+ function normalizeEmptyHtml(html) {
579
+ if (!html) return "";
580
+ const cleaned = html.replace(/\s+/g, "").toLowerCase();
581
+ return cleaned === "<p><br></p>" || cleaned === "<p></p>" || cleaned === "" ? "" : html;
582
+ }
583
+
582
584
  /**
583
585
  * 获取文件url
584
- */
585
- export function getFileUrl() {
586
- return process.env.app["fileUrl"];
587
- }
586
+ */
587
+ function getFileUrl() {
588
+ return process.env.app["fileUrl"];
589
+ }
590
+
591
+ export { ArrayDeduplication, addingPrefixToFile, arrayObjectDeduplication, base642File, calculateFileSize, checkImgExists, createGuid, dynamicLoadCss, dynamicLoadJs, findCharIndex, getDataType, getFileName, getFileSuffix, getFileUrl, getIndexColumn, getLabelName, getSelectAppointItemList, getTreeNodePaths, getUrlParam, idCardGetDateAndGender, image2Base64, image2Base642, interceptTheSuffix, isEmpty, isEmptyToWhether, listTransTree, normalizeEmptyHtml, numFormat, paging, processTreeDataByLevel, processTreeDataForOnlyLastLevel, randoms, readTxtDocument, secondConversion, serialNumber, toArrayString, validatorEndTime, validatorTimeGTCurrentDay };