Procházet zdrojové kódy

校验触发重复提交

DESKTOP-SVI9JE1\muzen před 2 roky
rodič
revize
fcb2ca0c1f
1 změnil soubory, kde provedl 23 přidání a 19 odebrání
  1. 23 19
      src/views/operation/recommend/detail.vue

+ 23 - 19
src/views/operation/recommend/detail.vue

@@ -526,31 +526,35 @@ export default {
       this.form.list[index].childList.splice(e, 1)
     },
 
-
     // 提交
     getSubmit() {
+      let isValid = true
+      
       this.$refs.list.map(i => i.validate((valid) => {
-        if (valid) {
-          // 区分2级新增 还是 3级编辑
-          this.$route.query.secondId ? this.form.secondId = this.$route.query.secondId : this.form.threeId = this.$route.query.threeId
-          // 删除仅作展示的缓存数据
-          for (const index in this.form.list) {
-            delete this.form.list[index].contentId
-            if ('description' in this.form.list[index]) {
-              this.form.list[index].module.description = this.form.list[index].description
-              delete this.form.list[index].description
-            }
-          }
-          submitThree(this.form).then(res => {
-            if (res.code === 0) {
-              this.$message.success('提交成功!')
-              this.cancel()
-            }
-          })
-        } else {
+        if (!valid) {
+          isValid = false
           return false
         }
       }))
+
+      if (isValid) {
+        // 区分2级新增 还是 3级编辑
+        this.$route.query.secondId ? this.form.secondId = this.$route.query.secondId : this.form.threeId = this.$route.query.threeId
+        // 删除仅作展示的缓存数据
+        for (const index in this.form.list) {
+          delete this.form.list[index].contentId
+          if ('description' in this.form.list[index]) {
+            this.form.list[index].module.description = this.form.list[index].description
+            delete this.form.list[index].description
+          }
+        }
+        submitThree(this.form).then(res => {
+          if (res.code === 0) {
+            this.$message.success('提交成功!')
+            this.cancel()
+          }
+        })
+      }
     },
 
     // 返回