t20-common-lib 0.15.25 → 0.15.27

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t20-common-lib",
3
- "version": "0.15.25",
3
+ "version": "0.15.27",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -490,6 +490,21 @@ 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 }>}
@@ -498,12 +513,17 @@ export default {
498
513
  const formRef = this.$refs.dynamicForms;
499
514
  if (!formRef || typeof formRef.validate !== "function") {
500
515
  callback(false, this.formData);
516
+ return;
501
517
  }
502
518
  const pass = await new Promise((resolve) => {
503
519
  formRef.validate((valid) => resolve(valid));
504
520
  });
505
521
  if (!pass) {
522
+ this.$nextTick(() => {
523
+ this.scrollToFirstFormError();
524
+ });
506
525
  callback(false, this.formData);
526
+ return;
507
527
  }
508
528
  const fileUploadTableData = (this.fileUploadTableData || []).filter(
509
529
  (t) => t.beid