Quellcode durchsuchen

fix(warehouseManagement): 添加表单验证规则并完善派单确认逻辑

liujt vor 6 Monaten
Ursprung
Commit
531bf7d9a8

+ 27 - 19
src/views/warehouseManagement/stocktaking/plan/components/assignDialog.vue

@@ -8,7 +8,7 @@
       width="80vw"
     >
       <div class="search_box">
-        <el-form :model="formData" ref="formRef" label-width="110px">
+        <el-form :model="formData" :rules="rules" ref="formRef" label-width="110px">
           <el-row :gutter="15">
             <el-col :span="8">
               <el-form-item label="工单编号" prop="code">
@@ -203,7 +203,11 @@
         curType: '',
         classificationId: '',
         memoSelection: [],
-        newColumns: [] // 动态表头
+        newColumns: [], // 动态表头
+        rules: {
+          executeGroupId: [{ required: true, message: '请选择执行部门', trigger: 'blur' }],
+          executorId: [{ required: true, message: '请选择执行人员', trigger: 'blur' }],
+        }
       };
     },
     created() {
@@ -258,23 +262,27 @@
         });
       },
       onConfirm() {
-        if (this.multipleSelection.length > 0) {
-          let params = {
-            executeGroupId: this.formData.executeGroupId,
-            executeGroupName: this.formData.executeGroupName,
-            executorId: this.formData.executorId,
-            executorName: this.formData.executorName,
-            planDetailId: this.multipleSelection.map((item) => item.id),
-            planId: this.planId
-          };
-          sendOrders(params).then(() => {
-            this.$message.success('派单成功!');
-            this.$emit('flushed');
-            this.closeWindows();
-          });
-        } else {
-          this.$message.error('请选择物品!');
-        }
+        this.$refs.formRef.validate((valid) => {
+          if (valid) {
+            if (this.multipleSelection.length > 0) {
+              let params = {
+                executeGroupId: this.formData.executeGroupId,
+                executeGroupName: this.formData.executeGroupName,
+                executorId: this.formData.executorId,
+                executorName: this.formData.executorName,
+                planDetailId: this.multipleSelection.map((item) => item.id),
+                planId: this.planId
+              };
+              sendOrders(params).then(() => {
+                this.$message.success('派单成功!');
+                this.$emit('flushed');
+                this.closeWindows();
+              });
+            } else {
+              this.$message.error('请选择物品!');
+            }
+          }
+        })
       },
       handleSelectionChange(val) {
         this.multipleSelection = val;