ソースを参照

修复数据保存修改校验问题

xiebaomin 2 年 前
コミット
6008e40d4b

+ 11 - 4
pages/_template/app/center/club-detail.vue

@@ -152,10 +152,14 @@ export default {
     },
     // 修该数据
     editData() {
-      this.status = !this.status
-      if (this.status) {
-        this.$refs.clubInfoForm.validate && this.$refs.clubInfoForm.validate()
+      if (!this.status) {
+        this.$refs.clubInfoForm.validate().then(() => {
+          return this.status = true
+        }).catch(() => {
+          return this.status = false
+        })
       }
+      this.status = false
     },
     async onClubInfoFormStep(authdata) {
       console.log(authdata)
@@ -166,7 +170,10 @@ export default {
 
       try {
         await this.$http.api.authClubSave1(authdata)
-        this.$router.go(0)
+        this.$toast.loading({
+          message: '保存成功',
+          duration: 1000,
+        })
       } catch (e) {
         console.log(e)
       }

+ 5 - 1
pages/_template/app/form/components/form-club-edit.vue

@@ -444,7 +444,11 @@ export default {
     // 表单验证
     validate() {
       const data = this.genetageFormData()
-      this.$emit('step', data)
+      this.$refs.form.validate(valid => {
+        if (valid){
+          this.$emit('step', data)
+        }
+      })
       return this.$refs.form.validate()
     },
 

+ 11 - 4
pages/_template/hyt/center/club-detail.vue

@@ -212,10 +212,14 @@ export default {
     },
     // 修该数据
     editData() {
-      this.status = !this.status
-      if (this.status) {
-        this.$refs.clubInfoForm.validate && this.$refs.clubInfoForm.validate()
+      if (!this.status) {
+        this.$refs.clubInfoForm.validate().then(() => {
+          return this.status = true
+        }).catch(() => {
+          return this.status = false
+        })
       }
+      this.status = false
     },
     async onClubInfoFormStep(authdata) {
       console.log(authdata)
@@ -226,7 +230,10 @@ export default {
 
       try {
         await this.$http.api.authClubSave1(authdata)
-        this.$router.go(0)
+        this.$toast.loading({
+          message: '保存成功',
+          duration: 1000,
+        })
       } catch (e) {
         console.log(e)
       }

+ 5 - 1
pages/_template/hyt/form/components/form-club-edit.vue

@@ -440,7 +440,11 @@ export default {
     // 表单验证
     validate() {
       const data = this.genetageFormData()
-      this.$emit('step', data)
+      this.$refs.form.validate(valid => {
+        if (valid){
+          this.$emit('step', data)
+        }
+      })
       return this.$refs.form.validate()
     },
 

+ 11 - 4
pages/_template/ph/center/club-detail.vue

@@ -152,10 +152,14 @@ export default {
     },
     // 修该数据
     editData() {
-      this.status = !this.status
-      if (this.status) {
-        this.$refs.clubInfoForm.validate && this.$refs.clubInfoForm.validate()
+      if (!this.status) {
+        this.$refs.clubInfoForm.validate().then(() => {
+          return this.status = true
+        }).catch(() => {
+          return this.status = false
+        })
       }
+      this.status = false
     },
     async onClubInfoFormStep(authdata) {
       console.log(authdata)
@@ -166,7 +170,10 @@ export default {
 
       try {
         await this.$http.api.authClubSave1(authdata)
-        this.$router.go(0)
+        this.$toast.loading({
+          message: '保存成功',
+          duration: 1000,
+        })
       } catch (e) {
         console.log(e)
       }

+ 5 - 1
pages/_template/ph/form/components/form-club-edit.vue

@@ -444,7 +444,11 @@ export default {
     // 表单验证
     validate() {
       const data = this.genetageFormData()
-      this.$emit('step', data)
+      this.$refs.form.validate(valid => {
+        if (valid){
+          this.$emit('step', data)
+        }
+      })
       return this.$refs.form.validate()
     },
 

+ 11 - 4
pages/_template/ross/center/club-detail.vue

@@ -152,10 +152,14 @@ export default {
     },
     // 修该数据
     editData() {
-      this.status = !this.status
-      if (this.status) {
-        this.$refs.clubInfoForm.validate && this.$refs.clubInfoForm.validate()
+      if (!this.status) {
+        this.$refs.clubInfoForm.validate().then(() => {
+          return this.status = true
+        }).catch(() => {
+          return this.status = false
+        })
       }
+      this.status = false
     },
     async onClubInfoFormStep(authdata) {
       console.log(authdata)
@@ -166,7 +170,10 @@ export default {
 
       try {
         await this.$http.api.authClubSave1(authdata)
-        this.$router.go(0)
+        this.$toast.loading({
+          message: '保存成功',
+          duration: 1000,
+        })
       } catch (e) {
         console.log(e)
       }

+ 6 - 1
pages/_template/ross/form/components/form-club-edit.vue

@@ -255,6 +255,7 @@ export default {
           {
             required: true,
             validator: validateMobile,
+            message: "运营联系人不能为空",
             trigger: ['blur', 'change'],
           },
         ],
@@ -444,7 +445,11 @@ export default {
     // 表单验证
     validate() {
       const data = this.genetageFormData()
-      this.$emit('step', data)
+      this.$refs.form.validate(valid => {
+        if (valid){
+          this.$emit('step', data)
+        }
+      })
       return this.$refs.form.validate()
     },