@ebiz/designer-components 0.1.65 → 0.1.66
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/dist/index.mjs
CHANGED
|
@@ -82805,7 +82805,7 @@ const jdt = {
|
|
|
82805
82805
|
"detail-error"
|
|
82806
82806
|
],
|
|
82807
82807
|
setup(e, { expose: t, emit: n }) {
|
|
82808
|
-
const r = e, a = n, o = W(null), i = W(!1), l = W(null), u = W({}), s = W(
|
|
82808
|
+
const r = e, a = n, o = W(null), i = W(!1), l = W(null), u = W({}), s = W(r.data || {}), c = R(() => r.rules);
|
|
82809
82809
|
be(() => r.data, (C) => {
|
|
82810
82810
|
C && typeof C == "object" && (Object.keys(s.value).forEach((O) => {
|
|
82811
82811
|
delete s.value[O];
|
|
@@ -83034,7 +83034,7 @@ const jdt = {
|
|
|
83034
83034
|
_: 3
|
|
83035
83035
|
}, 8, ["class", "colon", "data", "disabled", "label-align", "label-width", "layout", "reset-type", "reset-on-semi-controlled", "rules", "scroll-to-first-error", "show-error-message", "status-icon", "style"]));
|
|
83036
83036
|
}
|
|
83037
|
-
}), Gdt = /* @__PURE__ */ mt(Ydt, [["__scopeId", "data-v-
|
|
83037
|
+
}), Gdt = /* @__PURE__ */ mt(Ydt, [["__scopeId", "data-v-53fc98bf"]]), Xdt = { class: "ebiz-tdesign-button-dialog" }, Zdt = { key: 0 }, Jdt = { key: 1 }, Qdt = { key: 0 }, eft = { key: 1 }, tft = { key: 2 }, nft = { class: "delete-confirm-content" }, rft = { class: "delete-message" }, aft = {
|
|
83038
83038
|
__name: "index",
|
|
83039
83039
|
props: {
|
|
83040
83040
|
// 弹窗类型
|
|
@@ -83253,7 +83253,7 @@ const jdt = {
|
|
|
83253
83253
|
default:
|
|
83254
83254
|
return "";
|
|
83255
83255
|
}
|
|
83256
|
-
}), i = W(r.visible), l = W(!1), u = W(null), s = W(null), c = W({}), d = W(r.formData);
|
|
83256
|
+
}), i = W(r.visible), l = W(!1), u = W(null), s = W(null), c = W({}), d = W(r.formData || {});
|
|
83257
83257
|
be(() => r.visible, (T) => {
|
|
83258
83258
|
i.value = T;
|
|
83259
83259
|
}), be(i, (T) => {
|
|
@@ -83510,7 +83510,7 @@ const jdt = {
|
|
|
83510
83510
|
}, 8, ["visible", "header", "width", "top", "attach", "destroy-on-close", "mode", "placement", "show-overlay", "close-on-esc-keydown", "close-on-overlay-click", "show-footer"])
|
|
83511
83511
|
]));
|
|
83512
83512
|
}
|
|
83513
|
-
}, Wht = /* @__PURE__ */ mt(aft, [["__scopeId", "data-v-
|
|
83513
|
+
}, Wht = /* @__PURE__ */ mt(aft, [["__scopeId", "data-v-6f573492"]]), oft = { class: "ebiz-meeting-room-selector" }, ift = { class: "selector-header" }, lft = { class: "header-content" }, uft = { class: "date-selector" }, sft = {
|
|
83514
83514
|
key: 0,
|
|
83515
83515
|
class: "loading-container"
|
|
83516
83516
|
}, cft = {
|
package/package.json
CHANGED
|
@@ -295,7 +295,7 @@ const formRef = ref(null)
|
|
|
295
295
|
const currentId = ref(null)
|
|
296
296
|
const currentParams = ref({})
|
|
297
297
|
// 本地维护一份表单数据的副本
|
|
298
|
-
const localFormData = ref(props.formData)
|
|
298
|
+
const localFormData = ref(props.formData || {})
|
|
299
299
|
// 监听props的visible变化
|
|
300
300
|
watch(() => props.visible, (newVal) => {
|
|
301
301
|
dialogVisible.value = newVal
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<t-form ref="formRef" :class="['ebiz-s-form', className]" :colon="colon" :data="localFormData" :disabled="disabled"
|
|
3
3
|
:label-align="labelAlign" :label-width="labelWidth" :layout="layout" :reset-type="resetType"
|
|
4
|
-
:reset-on-semi-controlled="resetOnSemiControlled" :rules="formRules"
|
|
5
|
-
:scroll-to-first-error="scrollToFirstError"
|
|
4
|
+
:reset-on-semi-controlled="resetOnSemiControlled" :rules="formRules" :scroll-to-first-error="scrollToFirstError"
|
|
6
5
|
:show-error-message="showErrorMessage" :status-icon="statusIcon" :style="customStyle" @reset="handleReset"
|
|
7
6
|
@submit="handleSubmit" @validate="handleValidate">
|
|
8
7
|
|
|
@@ -15,9 +14,9 @@
|
|
|
15
14
|
:disabled="loading || disabled">{{
|
|
16
15
|
cancelButtonText
|
|
17
16
|
}}</t-button>
|
|
18
|
-
<t-button v-if="showSubmitButton" theme="primary" :loading="loading"
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
<t-button v-if="showSubmitButton" theme="primary" :loading="loading" :disabled="loading || disabled"
|
|
18
|
+
type="submit">{{
|
|
19
|
+
submitButtonText }}</t-button>
|
|
21
20
|
</t-space>
|
|
22
21
|
</slot>
|
|
23
22
|
</ebiz-s-form-item>
|
|
@@ -248,7 +247,7 @@ const formRef = ref(null);
|
|
|
248
247
|
const loading = ref(false);
|
|
249
248
|
const currentId = ref(null);
|
|
250
249
|
const currentParams = ref({});
|
|
251
|
-
const localFormData = ref(
|
|
250
|
+
const localFormData = ref(props.data || {});
|
|
252
251
|
|
|
253
252
|
// 合并rules并监听变化
|
|
254
253
|
const formRules = computed(() => props.rules);
|
|
@@ -261,7 +260,7 @@ watch(() => props.data, (newData) => {
|
|
|
261
260
|
Object.keys(localFormData.value).forEach(key => {
|
|
262
261
|
delete localFormData.value[key];
|
|
263
262
|
});
|
|
264
|
-
|
|
263
|
+
|
|
265
264
|
// 写入新数据
|
|
266
265
|
Object.keys(newData).forEach(key => {
|
|
267
266
|
localFormData.value[key] = newData[key];
|
|
@@ -277,7 +276,7 @@ watch(() => props.data, (newData) => {
|
|
|
277
276
|
*/
|
|
278
277
|
const getErrorMessage = (error, prefix = '提交失败') => {
|
|
279
278
|
if (!error) return `${prefix}: 未知错误`;
|
|
280
|
-
|
|
279
|
+
|
|
281
280
|
// 处理不同类型的错误
|
|
282
281
|
if (error.response && error.response.data) {
|
|
283
282
|
// API返回的详细错误信息
|
|
@@ -301,15 +300,15 @@ const getErrorMessage = (error, prefix = '提交失败') => {
|
|
|
301
300
|
const submitFormData = async () => {
|
|
302
301
|
try {
|
|
303
302
|
loading.value = true;
|
|
304
|
-
|
|
303
|
+
|
|
305
304
|
// 准备请求参数
|
|
306
305
|
const fetchParams = { ...localFormData.value };
|
|
307
|
-
|
|
306
|
+
|
|
308
307
|
// 如果有ID,添加到请求参数中
|
|
309
308
|
if (currentId.value) {
|
|
310
309
|
fetchParams.id = currentId.value;
|
|
311
310
|
}
|
|
312
|
-
|
|
311
|
+
|
|
313
312
|
// 合并当前参数到请求参数
|
|
314
313
|
if (currentParams.value && Object.keys(currentParams.value).length > 0) {
|
|
315
314
|
Object.keys(currentParams.value).forEach(key => {
|
|
@@ -318,7 +317,7 @@ const submitFormData = async () => {
|
|
|
318
317
|
}
|
|
319
318
|
|
|
320
319
|
// 直接使用 apiConfig,不做任何处理
|
|
321
|
-
const response = await dataService.fetch({saveData: {...fetchParams}}, props.apiConfig);
|
|
320
|
+
const response = await dataService.fetch({ saveData: { ...fetchParams } }, props.apiConfig);
|
|
322
321
|
|
|
323
322
|
// 直接使用响应数据
|
|
324
323
|
const transformedResponse = response;
|
|
@@ -370,16 +369,16 @@ const handleSubmit = async (_context) => {
|
|
|
370
369
|
if (!formRef.value) return;
|
|
371
370
|
|
|
372
371
|
const validateResult = await formRef.value.validate();
|
|
373
|
-
|
|
372
|
+
|
|
374
373
|
if (validateResult !== true) {
|
|
375
374
|
// 获取第一个错误信息
|
|
376
375
|
const firstKey = Object.keys(validateResult)[0];
|
|
377
376
|
const firstError = validateResult[firstKey]?.[0]?.message || '表单验证失败';
|
|
378
|
-
|
|
377
|
+
|
|
379
378
|
if (props.showResultMessage) {
|
|
380
379
|
MessagePlugin.error(firstError);
|
|
381
380
|
}
|
|
382
|
-
|
|
381
|
+
|
|
383
382
|
emit('error', { validateResult, firstError });
|
|
384
383
|
return;
|
|
385
384
|
}
|
|
@@ -393,7 +392,7 @@ const handleSubmit = async (_context) => {
|
|
|
393
392
|
if (props.showResultMessage) {
|
|
394
393
|
MessagePlugin.error(getErrorMessage(error));
|
|
395
394
|
}
|
|
396
|
-
|
|
395
|
+
|
|
397
396
|
emit('error', error);
|
|
398
397
|
}
|
|
399
398
|
};
|
|
@@ -404,39 +403,39 @@ const handleSubmit = async (_context) => {
|
|
|
404
403
|
*/
|
|
405
404
|
const loadDetailData = async (id) => {
|
|
406
405
|
if (!props.detailApiConfig || !id) return null;
|
|
407
|
-
|
|
406
|
+
|
|
408
407
|
try {
|
|
409
408
|
loading.value = true;
|
|
410
|
-
|
|
409
|
+
|
|
411
410
|
// 准备请求参数
|
|
412
411
|
const fetchParams = { id };
|
|
413
|
-
|
|
412
|
+
|
|
414
413
|
// 合并当前参数到请求参数
|
|
415
414
|
if (currentParams.value && Object.keys(currentParams.value).length > 0) {
|
|
416
415
|
Object.keys(currentParams.value).forEach(key => {
|
|
417
416
|
fetchParams[key] = currentParams.value[key];
|
|
418
417
|
});
|
|
419
418
|
}
|
|
420
|
-
|
|
419
|
+
|
|
421
420
|
// 调用dataService进行API请求,直接使用detailApiConfig
|
|
422
421
|
const response = await dataService.fetch(fetchParams, props.detailApiConfig);
|
|
423
|
-
|
|
422
|
+
|
|
424
423
|
// 获取详情数据
|
|
425
424
|
const detailData = response.data || response;
|
|
426
|
-
|
|
425
|
+
|
|
427
426
|
// 更新本地表单数据
|
|
428
427
|
if (detailData) {
|
|
429
428
|
// 清空现有数据
|
|
430
429
|
Object.keys(localFormData.value).forEach(key => {
|
|
431
430
|
delete localFormData.value[key];
|
|
432
431
|
});
|
|
433
|
-
|
|
432
|
+
|
|
434
433
|
// 写入新数据
|
|
435
434
|
Object.keys(detailData).forEach(key => {
|
|
436
435
|
localFormData.value[key] = detailData[key];
|
|
437
436
|
});
|
|
438
437
|
}
|
|
439
|
-
|
|
438
|
+
|
|
440
439
|
// 触发加载成功事件
|
|
441
440
|
emit('detail-loaded', detailData);
|
|
442
441
|
return detailData;
|
|
@@ -445,7 +444,7 @@ const loadDetailData = async (id) => {
|
|
|
445
444
|
if (props.showResultMessage) {
|
|
446
445
|
MessagePlugin.error(`加载详情失败: ${error.message || '未知错误'}`);
|
|
447
446
|
}
|
|
448
|
-
|
|
447
|
+
|
|
449
448
|
// 触发错误事件
|
|
450
449
|
emit('detail-error', error);
|
|
451
450
|
return null;
|
|
@@ -465,7 +464,7 @@ const openForm = (params = {}) => {
|
|
|
465
464
|
Object.keys(localFormData.value).forEach(key => {
|
|
466
465
|
delete localFormData.value[key];
|
|
467
466
|
});
|
|
468
|
-
|
|
467
|
+
|
|
469
468
|
// 写入新数据
|
|
470
469
|
Object.keys(params.formData).forEach(key => {
|
|
471
470
|
localFormData.value[key] = params.formData[key];
|
|
@@ -476,11 +475,11 @@ const openForm = (params = {}) => {
|
|
|
476
475
|
delete localFormData.value[key];
|
|
477
476
|
});
|
|
478
477
|
}
|
|
479
|
-
|
|
478
|
+
|
|
480
479
|
// 存储ID
|
|
481
480
|
if (params.id) {
|
|
482
481
|
currentId.value = params.id;
|
|
483
|
-
|
|
482
|
+
|
|
484
483
|
// 如果有detailApiConfig,加载详情数据
|
|
485
484
|
if (props.detailApiConfig) {
|
|
486
485
|
loadDetailData(params.id);
|
|
@@ -488,10 +487,10 @@ const openForm = (params = {}) => {
|
|
|
488
487
|
} else {
|
|
489
488
|
currentId.value = null;
|
|
490
489
|
}
|
|
491
|
-
|
|
490
|
+
|
|
492
491
|
// 存储其他自定义参数
|
|
493
492
|
currentParams.value = params;
|
|
494
|
-
|
|
493
|
+
|
|
495
494
|
return { success: true, message: '表单已准备就绪' };
|
|
496
495
|
};
|
|
497
496
|
|
|
@@ -503,17 +502,17 @@ const setFormData = (data) => {
|
|
|
503
502
|
if (!data || typeof data !== 'object') {
|
|
504
503
|
return { success: false, message: '数据必须是一个对象' };
|
|
505
504
|
}
|
|
506
|
-
|
|
505
|
+
|
|
507
506
|
// 清空现有数据
|
|
508
507
|
Object.keys(localFormData.value).forEach(key => {
|
|
509
508
|
delete localFormData.value[key];
|
|
510
509
|
});
|
|
511
|
-
|
|
510
|
+
|
|
512
511
|
// 写入新数据
|
|
513
512
|
Object.keys(data).forEach(key => {
|
|
514
513
|
localFormData.value[key] = data[key];
|
|
515
514
|
});
|
|
516
|
-
|
|
515
|
+
|
|
517
516
|
return { success: true, message: '表单数据已设置' };
|
|
518
517
|
};
|
|
519
518
|
|
|
@@ -532,7 +531,7 @@ const clearFormData = () => {
|
|
|
532
531
|
Object.keys(localFormData.value).forEach(key => {
|
|
533
532
|
delete localFormData.value[key];
|
|
534
533
|
});
|
|
535
|
-
|
|
534
|
+
|
|
536
535
|
emit('reset', { type: 'clear' });
|
|
537
536
|
return { success: true, message: '表单数据已清空' };
|
|
538
537
|
};
|
|
@@ -545,22 +544,22 @@ const submitForm = async () => {
|
|
|
545
544
|
if (!formRef.value) {
|
|
546
545
|
return { success: false, message: '表单引用不存在' };
|
|
547
546
|
}
|
|
548
|
-
|
|
547
|
+
|
|
549
548
|
const validateResult = await formRef.value.validate();
|
|
550
|
-
|
|
549
|
+
|
|
551
550
|
if (validateResult === true) {
|
|
552
551
|
emit('submit', localFormData.value);
|
|
553
|
-
|
|
552
|
+
|
|
554
553
|
if (props.apiConfig) {
|
|
555
554
|
const response = await submitFormData();
|
|
556
555
|
return { success: true, message: '提交成功', data: response };
|
|
557
556
|
}
|
|
558
|
-
|
|
557
|
+
|
|
559
558
|
return { success: true, message: '表单验证通过', data: { ...localFormData.value } };
|
|
560
559
|
} else {
|
|
561
560
|
const firstKey = Object.keys(validateResult)[0];
|
|
562
561
|
const firstError = validateResult[firstKey]?.[0]?.message || '表单验证失败';
|
|
563
|
-
|
|
562
|
+
|
|
564
563
|
return { success: false, message: firstError, errors: validateResult };
|
|
565
564
|
}
|
|
566
565
|
} catch (error) {
|