Sfoglia il codice sorgente

fix(表单验证): 修复库存表格报价方式验证并优化表单验证流程

liujt 4 mesi fa
parent
commit
b7375be93c

+ 7 - 1
src/BIZComponents/inventoryTable.vue

@@ -712,7 +712,13 @@
       </template>
 
       <template v-slot:quoteWay="scope">
-        <el-form-item prop="quoteWay">
+        <el-form-item 
+          :prop="'datasource.' + scope.$index + '.quoteWay'"
+          :rules="{
+            required: true,
+            message: '请选择报价方式',
+            trigger: 'change'
+          }">
           <el-select
             v-model="scope.row.quoteWay"
             clearable

+ 14 - 19
src/views/contractManage/contractBook/components/addDialog.vue

@@ -1862,35 +1862,28 @@
       //   });
       // },
       getValidate() {
-        return Promise.all([
-          new Promise((resolve, reject) => {
+        return new Promise((resolve, reject) => {
+          const validateForm = () => {
             this.$refs.form.validate((valid) => {
               if (!valid) {
                 reject(false);
               } else {
-                resolve(true);
+                validateInventoryTable();
               }
             });
-          }),
-          new Promise((resolve, reject) => {
+          };
+
+          const validateInventoryTable = () => {
             this.$refs.inventoryTable.validateForm((valid) => {
               if (!valid) {
                 reject(false);
               } else {
-                resolve(true);
+                validatePaymentCollectionPlan();
               }
             });
-          }),
-          // new Promise((resolve, reject) => {
-          //   this.$refs.paymentListTable.validateForm((valid) => {
-          //     if (!valid) {
-          //       reject(false);
-          //     } else {
-          //       resolve(true);
-          //     }
-          //   });
-          // }),
-          new Promise((resolve, reject) => {
+          };
+
+          const validatePaymentCollectionPlan = () => {
             this.$refs.paymentCollectionPlanRef.validateForm((valid) => {
               if (!valid) {
                 reject(false);
@@ -1898,8 +1891,10 @@
                 resolve(true);
               }
             });
-          })
-        ]);
+          };
+
+          validateForm();
+        });
       },
       async save(type) {
         try {