From 0e9a24312e48b6c434934953cb74683c93c04aa6 Mon Sep 17 00:00:00 2001
From: shj <1790240199@qq.com>
Date: 星期四, 31 三月 2022 16:27:41 +0800
Subject: [PATCH] 自查

---
 src/views/safetyproduction/reviewXG.vue |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/views/safetyproduction/reviewXG.vue b/src/views/safetyproduction/reviewXG.vue
index 838d985..7fa0f75 100644
--- a/src/views/safetyproduction/reviewXG.vue
+++ b/src/views/safetyproduction/reviewXG.vue
@@ -151,8 +151,8 @@
     </div>
 
     <el-dialog title="扣分详情" :visible.sync="dialogVisible" :close-on-click-modal="false" width="30%">
-      <el-form ref="form" :model="formInline" label-width="54px">
-        <el-form-item label="说明">
+      <el-form ref="form" :rules="rules" :model="formInline" label-width="54px">
+        <el-form-item label="说明" prop="name">
           <el-input v-model="formInline.name"></el-input>
         </el-form-item>
         <el-form-item label="备注">
@@ -171,7 +171,7 @@
         <el-button type="primary" class="btns" @click="listAdd"
           >确 定</el-button
         >
-        <el-button @click="dialogVisible = false">取 消</el-button>
+        <el-button @click="bacQx">取 消</el-button>
       </span>
     </el-dialog>
   </div>
@@ -192,11 +192,14 @@
         name: "",
         remark: "",
       },
+        rules: {
+        name: [
+          { required: true, message: "说明不能为空", trigger: "change" },
+        ],}
     };
   },
   created() {
     this.id = this.$route.query.id;
-    console.log('tagee',this.$route.query)
     this.safeT(this.id);
   },
   methods: {
@@ -208,6 +211,9 @@
       });
     },
     coAdd(val, type) {
+       this.$nextTick(() => {
+        this.$refs["form"].clearValidate();
+      });
       this.titleN = type;
       if (type == "新增") {
         this.dialogVisible = true;
@@ -224,6 +230,8 @@
       }
     },
     listAdd() {
+       this.$refs["form"].validate((valid) => {
+        if (valid) {
       if (this.titleN == "新增") {
         this.form.deductionList.push(this.formInline);
         this.dialogVisible = false;
@@ -232,6 +240,8 @@
         this.form.deductionList[this.index].space = this.formInline.space;
         this.dialogVisible = false;
       }
+          }
+      });
     },
     listDel(val) {
       var i = this.form.deductionList.findIndex(
@@ -265,6 +275,10 @@
               path:"/new"
             })
     },
+    bacQx(){
+      this.dialogVisible = false;
+    this.safeT(this.id);
+    },
     handleClick() {
       this.dialogVisible = true;
     },

--
Gitblit v1.9.2