浏览代码

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