Browse Source

页面关闭/打开时表单验证未清除的问题处理

jingyuanchao 1 year ago
parent
commit
0ea00e190c

+ 6 - 0
src/views/core/drill/task/dialog.newtask.vue

@@ -261,6 +261,9 @@ export default {
     },
     async show(id, other = {}) {
       this.isShow = true;
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     imageListChanged(list) {
       this.formData.imageList = list;
@@ -345,6 +348,9 @@ export default {
       this.formData = this.reset();
       this.$refs["uploadimage"].clearFiles();
       this.$refs["upload"].clearFiles();
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     // async onSave() {
     //   if (!this.validatePerson()) {

+ 7 - 0
src/views/core/drill/task/dialog.perform.vue

@@ -209,6 +209,7 @@ export default {
         drillStartTime: null,
         drillEndTime: null,
         content: null,
+        comment: null,
         drillSite: null,
         type: null,
         presetCase: null,
@@ -269,6 +270,9 @@ export default {
       this.id = id;
       await this.refresh(id, other);
       this.isShow = true;
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     imageListChanged(list) {
       this.formData.imageList = list;
@@ -321,6 +325,9 @@ export default {
       this.formData = this.reset();
       this.$refs["uploadimage"].clearFiles();
       this.formFileListDefualtValue = [];
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     async onSave() {
       if (!this.validatePerson()) {

+ 6 - 0
src/views/core/edu/task/dialog.newTask.vue

@@ -286,6 +286,9 @@ export default {
     },*/
     async show(id, other = {}) {
       this.isShow = true;
+      this.$nextTick(() => {
+        this.$refs.newTask.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     imageListChanged(list) {
       this.formData.imageList = list;
@@ -371,6 +374,9 @@ export default {
       this.formData = this.reset();
       this.$refs["uploadimage"].clearFiles();
       this.$refs["upload"].clearFiles();
+      this.$nextTick(() => {
+        this.$refs.newTask.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     async onSave() {
       if (!this.validatePerson()) {

+ 8 - 1
src/views/core/edu/task/dialog.perform.vue

@@ -207,6 +207,8 @@ export default {
         // dueCount: null,
         // actualCount: null,
         content: null,
+        hostName: null,
+        site: null,
         title: null,
         eduJobId: null,
         imageList: "",
@@ -268,7 +270,9 @@ export default {
       this.id = id;
       await this.refresh(id, other);
       this.isShow = true;
-      console.log("show", this.formData);
+      this.$nextTick(() => {
+        this.$refs.perform.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     imageListChanged(list) {
       this.formData.imageList = list;
@@ -321,6 +325,9 @@ export default {
       this.formData = this.reset();
       this.$refs["uploadimage"].clearFiles();
       this.formFileListDefualtValue=[];
+      this.$nextTick(() => {
+        this.$refs.perform.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     async onSave() {
       if (!this.validatePerson()) {

+ 6 - 0
src/views/core/outIn/letter/dialog.addletter.vue

@@ -300,6 +300,9 @@ export default {
       if (id) {
         this.title = "编辑介绍信";
         this.isShow = true;
+        this.$nextTick(() => {
+          this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+        });
         getLetter(id).then((response) => {
           // let tempRange=[];
           // tempRange.push(dayjs(response.data.startTime));
@@ -365,6 +368,9 @@ export default {
       this.isShow = false;
       this.formData = this.reset();
       //this.$refs["uploadFile"].clearFiles();
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     onHideUser() {
       this.open = false;

+ 9 - 2
src/views/safetycheck/plan/dialog.edit.vue

@@ -729,7 +729,6 @@ export default {
         planStatus: null,
         execOrgType: null,
         roleNames: null,
-        count: null,
         description: null,
         tableData: null,
         itemList: null,
@@ -874,7 +873,7 @@ export default {
             id: selectList[i].id,
             businessType: selectList[i].businessType,
           };
-          
+
           if (tem.itemName != null && tem.itemName != undefined) {
             this.tableData.push(tem);
           }
@@ -892,6 +891,10 @@ export default {
       await this.refresh(id, other);
       this.getRolesByOrg();
       this.isShow = true;
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
+
     },
     removeRow(row) {
       this.$modal
@@ -906,6 +909,10 @@ export default {
     // 事件
     onHide() {
       this.isShow = false;
+      this.$refs["form"].clearValidate(["planName"]);
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate(); // 确保在 DOM 更新之后清除表单验证状态
+      });
     },
     getIteamF() {
       // if (this.id == null) {