t20-common-lib 0.15.24 → 0.15.26
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/package.json
CHANGED
|
@@ -490,31 +490,43 @@ export default {
|
|
|
490
490
|
this.isApplyingLinkage = false;
|
|
491
491
|
});
|
|
492
492
|
},
|
|
493
|
+
/**
|
|
494
|
+
* 提交校验失败时,将可视区域滚动到第一个未通过的表单项(依赖 Element 的 .is-error)。
|
|
495
|
+
*/
|
|
496
|
+
scrollToFirstFormError() {
|
|
497
|
+
const formRef = this.$refs.dynamicForms;
|
|
498
|
+
const formEl = formRef && formRef.$el;
|
|
499
|
+
if (!formEl || typeof formEl.querySelector !== "function") return;
|
|
500
|
+
const firstError = formEl.querySelector(".el-form-item.is-error");
|
|
501
|
+
if (!firstError || typeof firstError.scrollIntoView !== "function") return;
|
|
502
|
+
firstError.scrollIntoView({
|
|
503
|
+
behavior: "smooth",
|
|
504
|
+
block: "center",
|
|
505
|
+
inline: "nearest",
|
|
506
|
+
});
|
|
507
|
+
},
|
|
493
508
|
/**
|
|
494
509
|
* 触发表单校验;通过后由返回值携带表单数据与附件(与 needFile 一致时含已落档行)。
|
|
495
510
|
* @returns {Promise<{ valid: false, formData: object } | { valid: true, formData: object, operate?: string, fileUploadTableData?: array }>}
|
|
496
511
|
*/
|
|
497
|
-
async validate() {
|
|
512
|
+
async validate(callback) {
|
|
498
513
|
const formRef = this.$refs.dynamicForms;
|
|
499
514
|
if (!formRef || typeof formRef.validate !== "function") {
|
|
500
|
-
|
|
515
|
+
callback(false, this.formData);
|
|
501
516
|
}
|
|
502
517
|
const pass = await new Promise((resolve) => {
|
|
503
518
|
formRef.validate((valid) => resolve(valid));
|
|
504
519
|
});
|
|
505
520
|
if (!pass) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
formData: this.formData,
|
|
511
|
-
};
|
|
512
|
-
if (this.needFile) {
|
|
513
|
-
result.fileUploadTableData = (this.fileUploadTableData || []).filter(
|
|
514
|
-
(t) => t.beid
|
|
515
|
-
);
|
|
521
|
+
this.$nextTick(() => {
|
|
522
|
+
this.scrollToFirstFormError();
|
|
523
|
+
});
|
|
524
|
+
callback(false, this.formData);
|
|
516
525
|
}
|
|
517
|
-
|
|
526
|
+
const fileUploadTableData = (this.fileUploadTableData || []).filter(
|
|
527
|
+
(t) => t.beid
|
|
528
|
+
);
|
|
529
|
+
callback(true, this.formData, fileUploadTableData);
|
|
518
530
|
},
|
|
519
531
|
},
|
|
520
532
|
};
|