@skyfox2000/webui 1.3.9 → 1.3.11
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/lib/assets/modules/{file-upload-Bkrnsn-c.js → file-upload-CwyUkWwi.js} +1 -1
- package/lib/assets/modules/{index-DpVh0k1G.js → index-BRWQ6SRp.js} +1 -1
- package/lib/assets/modules/{index-BOBTPmiP.js → index-DHWlaZL2.js} +2 -2
- package/lib/assets/modules/{index-D9o5XTiu.js → index-Dd8HdGOL.js} +68 -65
- package/lib/assets/modules/{menuTabs-D0MJJye5.js → menuTabs-NoNLt_B5.js} +2 -2
- package/lib/assets/modules/{toolIcon-jkoAB1WI.js → toolIcon-BSjgzw0G.js} +1 -1
- package/lib/assets/modules/{uploadList-Bwj7G7OA.js → uploadList-1Zmhwr0q.js} +4 -4
- package/lib/assets/modules/{uploadList-D80ld89N.js → uploadList-B4wb8I9a.js} +279 -275
- package/lib/es/AceEditor/index.js +3 -3
- package/lib/es/BasicLayout/index.js +3 -3
- package/lib/es/Error403/index.js +1 -1
- package/lib/es/Error404/index.js +1 -1
- package/lib/es/ExcelForm/index.js +112 -113
- package/lib/es/UploadForm/index.js +4 -4
- package/lib/utils/form-excel.d.ts +2 -1
- package/lib/webui.es.js +12 -12
- package/package.json +1 -1
- package/src/components/content/dialog/excelForm.vue +12 -13
- package/src/utils/form-excel.ts +18 -8
- package/src/utils/page.ts +15 -9
|
@@ -451,32 +451,31 @@ const performDataValidation = async (buffer: ArrayBuffer): Promise<void> => {
|
|
|
451
451
|
|
|
452
452
|
// 统一验证(格式验证和重复验证)
|
|
453
453
|
const {
|
|
454
|
-
hasError,
|
|
455
454
|
errBlob,
|
|
456
455
|
validationMsg: valMsg,
|
|
457
456
|
duplicateMsg: dupMsg,
|
|
457
|
+
hasFormatError,
|
|
458
|
+
hasDuplicateError
|
|
458
459
|
} = await validateExcelUnified(buffer, excelCtrl.formRules.value, duplicateRules.value, duplicateUrl.value);
|
|
459
460
|
|
|
460
461
|
// 更新验证状态
|
|
461
462
|
validationMsg.value = valMsg;
|
|
462
463
|
duplicateMsg.value = dupMsg;
|
|
463
464
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
465
|
+
// 根据验证结果设置正确的状态类型
|
|
466
|
+
validationType.value = hasFormatError ? 'error' : (excelCtrl.formRules.value && Object.keys(excelCtrl.formRules.value).length > 0 ? 'success' : 'warning');
|
|
467
|
+
duplicateType.value = hasDuplicateError ? 'error' : (duplicateRules.value && duplicateRules.value.length > 0 ? 'success' : 'warning');
|
|
468
|
+
|
|
469
|
+
// 有验证错误
|
|
470
|
+
if (errBlob) {
|
|
471
|
+
excelError.value = hasFormatError ?? false;
|
|
472
|
+
duplicateError.value = hasDuplicateError ?? false;
|
|
473
|
+
const blobUrl = URL.createObjectURL(errBlob);
|
|
474
|
+
excelUrl.value = blobUrl;
|
|
474
475
|
} else {
|
|
475
476
|
// 验证成功
|
|
476
477
|
excelError.value = false;
|
|
477
478
|
duplicateError.value = false;
|
|
478
|
-
validationType.value = 'success';
|
|
479
|
-
duplicateType.value = 'success';
|
|
480
479
|
// 验证成功时,excelUrl会在beforeUpload中设置
|
|
481
480
|
}
|
|
482
481
|
} catch (error) {
|
package/src/utils/form-excel.ts
CHANGED
|
@@ -316,22 +316,23 @@ export const validateExcelUnified = async (
|
|
|
316
316
|
duplicateRules?: string[],
|
|
317
317
|
duplicateUrl?: IUrlInfo,
|
|
318
318
|
): Promise<{
|
|
319
|
-
hasError: boolean;
|
|
320
319
|
errBlob?: Blob;
|
|
321
320
|
validationMsg: string;
|
|
322
321
|
duplicateMsg: string;
|
|
322
|
+
hasFormatError?: boolean;
|
|
323
|
+
hasDuplicateError?: boolean;
|
|
323
324
|
}> => {
|
|
324
325
|
const allMarkCells: Array<{ row: number; col: number; color: string }> = [];
|
|
325
326
|
const allMarkHeaders: string[] = [];
|
|
326
|
-
let
|
|
327
|
+
let hasFormatError = false;
|
|
327
328
|
let hasDuplicateError = false;
|
|
328
329
|
let validationMsg = '数据验证成功';
|
|
329
|
-
let duplicateMsg = '
|
|
330
|
+
let duplicateMsg = '待验证重复数据';
|
|
330
331
|
|
|
331
332
|
// 1. 格式验证
|
|
332
333
|
const validationResult = await validateExcel(excelBuffer, rules);
|
|
333
334
|
if (validationResult.hasError) {
|
|
334
|
-
|
|
335
|
+
hasFormatError = true;
|
|
335
336
|
validationMsg = '数据验证失败';
|
|
336
337
|
if (validationResult.markCells) {
|
|
337
338
|
allMarkCells.push(...validationResult.markCells);
|
|
@@ -339,6 +340,8 @@ export const validateExcelUnified = async (
|
|
|
339
340
|
if (validationResult.markHeaders) {
|
|
340
341
|
allMarkHeaders.push(...validationResult.markHeaders);
|
|
341
342
|
}
|
|
343
|
+
} else if (rules && Object.keys(rules).length > 0) {
|
|
344
|
+
validationMsg = '数据验证通过';
|
|
342
345
|
}
|
|
343
346
|
|
|
344
347
|
// 2. 重复验证
|
|
@@ -363,11 +366,15 @@ export const validateExcelUnified = async (
|
|
|
363
366
|
if (duplicateResult.markHeaders) {
|
|
364
367
|
allMarkHeaders.push(...duplicateResult.markHeaders);
|
|
365
368
|
}
|
|
369
|
+
} else {
|
|
370
|
+
duplicateMsg = '重复性检验通过';
|
|
366
371
|
}
|
|
367
372
|
}
|
|
368
373
|
|
|
374
|
+
const hasError = hasFormatError || hasDuplicateError;
|
|
375
|
+
|
|
369
376
|
// 3. 如果有任何错误,创建统一的标记Excel
|
|
370
|
-
if (
|
|
377
|
+
if (hasError) {
|
|
371
378
|
const markResult = await createMarkedExcelView(
|
|
372
379
|
excelBuffer,
|
|
373
380
|
{
|
|
@@ -381,24 +388,27 @@ export const validateExcelUnified = async (
|
|
|
381
388
|
const response = await fetch(markResult.blobUrl);
|
|
382
389
|
const errBlob = await response.blob();
|
|
383
390
|
return {
|
|
384
|
-
hasError: true,
|
|
385
391
|
errBlob,
|
|
386
392
|
validationMsg,
|
|
387
393
|
duplicateMsg,
|
|
394
|
+
hasFormatError,
|
|
395
|
+
hasDuplicateError
|
|
388
396
|
};
|
|
389
397
|
} else {
|
|
390
398
|
return {
|
|
391
|
-
hasError: true,
|
|
392
399
|
validationMsg,
|
|
393
400
|
duplicateMsg,
|
|
401
|
+
hasFormatError,
|
|
402
|
+
hasDuplicateError
|
|
394
403
|
};
|
|
395
404
|
}
|
|
396
405
|
}
|
|
397
406
|
|
|
398
407
|
return {
|
|
399
|
-
hasError: false,
|
|
400
408
|
validationMsg,
|
|
401
409
|
duplicateMsg,
|
|
410
|
+
hasFormatError: false,
|
|
411
|
+
hasDuplicateError: false
|
|
402
412
|
};
|
|
403
413
|
};
|
|
404
414
|
|
package/src/utils/page.ts
CHANGED
|
@@ -85,6 +85,17 @@ export const initPageFactory = (options: {
|
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
const initUrls = (apiUrls: ApiUrls) => {
|
|
89
|
+
for (let urlKey in apiUrls.urls) {
|
|
90
|
+
if (!apiUrls.urls[urlKey]!.api) {
|
|
91
|
+
apiUrls.urls[urlKey]!.api = apiUrls.api;
|
|
92
|
+
}
|
|
93
|
+
if (!apiUrls.urls[urlKey]!.authorize) {
|
|
94
|
+
apiUrls.urls[urlKey]!.authorize = apiUrls.authorize;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
88
99
|
/**
|
|
89
100
|
* 编辑器工厂处理
|
|
90
101
|
*
|
|
@@ -100,6 +111,7 @@ export const useEditorFactory = <T, E>(
|
|
|
100
111
|
defaultData?: Partial<E>,
|
|
101
112
|
formRules?: Record<string, ValidateRule>,
|
|
102
113
|
) => {
|
|
114
|
+
initUrls(urls);
|
|
103
115
|
/**
|
|
104
116
|
* 表单数据交互控制
|
|
105
117
|
*/
|
|
@@ -133,6 +145,7 @@ export const useEditorFactory = <T, E>(
|
|
|
133
145
|
* @returns
|
|
134
146
|
*/
|
|
135
147
|
export const useGridFactory = <T, G>(urls: ApiUrls, pageCtrl: PageControl<T>, columns?: Record<string, any>[]) => {
|
|
148
|
+
initUrls(urls);
|
|
136
149
|
/**
|
|
137
150
|
* 表格数据交互控制
|
|
138
151
|
*/
|
|
@@ -194,6 +207,7 @@ export const useGridFactory = <T, G>(urls: ApiUrls, pageCtrl: PageControl<T>, co
|
|
|
194
207
|
* @returns
|
|
195
208
|
*/
|
|
196
209
|
export const useTreeFactory = <T>(urls: ApiUrls, pageCtrl: PageControl<T>) => {
|
|
210
|
+
initUrls(urls);
|
|
197
211
|
/**
|
|
198
212
|
* 树数据交互控制
|
|
199
213
|
*/
|
|
@@ -306,15 +320,7 @@ export const usePageFactory = <T>(
|
|
|
306
320
|
defaultData?: Partial<T>,
|
|
307
321
|
formRules?: Record<string, ValidateRule>,
|
|
308
322
|
) => {
|
|
309
|
-
|
|
310
|
-
// api 默认
|
|
311
|
-
// authorize 默认
|
|
312
|
-
for (const key in urls.urls) {
|
|
313
|
-
if (urls.urls[key]) {
|
|
314
|
-
if (!urls.urls[key].api) urls.urls[key].api = urls.api;
|
|
315
|
-
if (urls.urls[key].authorize === undefined) urls.urls[key].authorize = urls.authorize;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
323
|
+
initUrls(urls);
|
|
318
324
|
|
|
319
325
|
/**
|
|
320
326
|
* 页面交互主数据
|