فهرست منبع

fix(核价管理): 改进表单验证失败时的错误处理

liujt 2 ماه پیش
والد
کامیت
0a249ab166
1فایلهای تغییر یافته به همراه10 افزوده شده و 4 حذف شده
  1. 10 4
      src/views/purchasingManage/inquiryManage/components/addDialog.vue

+ 10 - 4
src/views/purchasingManage/inquiryManage/components/addDialog.vue

@@ -407,9 +407,9 @@
           promises.push(
             new Promise((resolve, reject) => {
               this.$refs['inquiryTable' + item.supplierId][0].validateForm(
-                (valid) => {
+                (valid, errors) => {
                   if (!valid) {
-                    reject(false);
+                    reject(`${item.supplierName} 的表单验证失败,请检查必填项`);
                   } else {
                     resolve(true);
                   }
@@ -420,9 +420,9 @@
         });
         return Promise.all([
           new Promise((resolve, reject) => {
-            this.$refs.form.validate((valid) => {
+            this.$refs.form.validate((valid, errors) => {
               if (!valid) {
-                reject(false);
+                reject('表单验证失败,请检查必填项');
               } else {
                 resolve(true);
               }
@@ -677,6 +677,12 @@
             });
         } catch (error) {
           console.log(error);
+          // 表单验证未通过,显示错误提示
+          if (typeof error === 'string') {
+            this.$message.error(error);
+          } else {
+            this.$message.error('表单验证失败,请检查必填项');
+          }
           // 表单验证未通过,不执行保存操作
         }
       },