t20-common-lib 0.15.37 → 0.15.39
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
|
@@ -492,6 +492,25 @@ export default {
|
|
|
492
492
|
this.isApplyingLinkage = false;
|
|
493
493
|
});
|
|
494
494
|
},
|
|
495
|
+
/**
|
|
496
|
+
* 校验失败后滚动到第一个展示校验错误的表单项(ElementUI 会为失败项加上 .is-error)。
|
|
497
|
+
*/
|
|
498
|
+
scrollToFirstFormError() {
|
|
499
|
+
const formRef = this.$refs.dynamicForms;
|
|
500
|
+
const root = formRef && formRef.$el;
|
|
501
|
+
if (!root || typeof root.querySelectorAll !== "function") return;
|
|
502
|
+
const nodes = root.querySelectorAll(".el-form-item.is-error");
|
|
503
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
504
|
+
const el = nodes[i];
|
|
505
|
+
const cs = window.getComputedStyle(el);
|
|
506
|
+
if (cs.display === "none" || cs.visibility === "hidden") continue;
|
|
507
|
+
if (el.offsetParent === null && cs.position !== "fixed") continue;
|
|
508
|
+
if (typeof el.scrollIntoView === "function") {
|
|
509
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
510
|
+
}
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
},
|
|
495
514
|
/**
|
|
496
515
|
* 触发表单校验;通过后由返回值携带表单数据与附件(与 needFile 一致时含已落档行)。
|
|
497
516
|
* @returns {Promise<{ valid: false, formData: object } | { valid: true, formData: object, operate?: string, fileUploadTableData?: array }>}
|