Przeglądaj źródła

04/07 提交测试

1
mo 4 lat temu
rodzic
commit
dcc7d1a273

+ 16 - 1
src/components/tab-router/index.vue

@@ -60,7 +60,21 @@ export default {
       }
       this.panelsByName = data;
     },
-    tab(item, evt) {
+    async tab(item, evt) {
+
+      if(this.$attrs['before-leave']){
+        try{
+
+            await this.$attrs['before-leave']().then(res=>{
+              console.log(res)
+            })
+
+        }catch(e){
+          console.log(e)
+        }
+
+
+      }
       let { query } = this.$route;
       const search = qs.stringify({
         ...query,
@@ -77,6 +91,7 @@ export default {
       this.$store.dispatch("addVisitedViews",  this.$route);
       const parentClick = this.$listeners["tab-click"];
       if (parentClick) {
+
         parentClick(item, evt);
       }
     },

+ 16 - 9
src/views/resetTeaming/index.vue

@@ -8,14 +8,15 @@
         <img :src="stepImgs[team_status]" alt="" />
         {{ musicGroupType[team_status] }}
       </p>
-      <!-- navMenu   @tab-click="handleClick" -->
+      <!-- navMenu    -->
       <tab-router
         v-model="activeIndex"
         type="card"
         ref="tab"
         :before-leave="checkGoTo"
+
       >
-        <!-- -->
+        <!--  @tab-click="handleClick" -->
         <el-tab-pane
           label="基本信息"
           lazy
@@ -251,8 +252,10 @@ export default {
   },
   async beforeRouteLeave(to, from, next) {
     if (this.activeIndex == 1) {
-      await this.$refs.teamBaseInfo.setStore();
-      next();
+      console.log(await this.$refs.teamBaseInfo.setStore('go'))
+      if (await this.$refs.teamBaseInfo.setStore('go')) {
+        next();
+      }
     } else {
       next();
     }
@@ -287,8 +290,8 @@ export default {
           this.teamName = baseInfo?.musicGroup?.name;
         }
         this.musicGroupInfo = baseInfo?.musicGroup;
-      }else{
-        this.__init()
+      } else {
+        this.__init();
       }
     },
     handleClick(val) {
@@ -301,8 +304,9 @@ export default {
       // }
       // this.team_status = this.$route.query.team_status;
       // console.log('切换tab',val)
+
       this.$refs.tab.tab(val);
-      // this.activeIndex = val.name;
+
     },
     permission(str) {
       return permission(str);
@@ -318,10 +322,13 @@ export default {
       //  if (val.name != 1 && this.$refs.teamBaseInfo) {
       //   await this.$refs.teamBaseInfo.setStore();
       // }
+         console.log('checkGoTo')
       var p = new Promise(async (resolve, reject) => {
         if (this.activeIndex == 1 && this.$refs.teamBaseInfo) {
-          await this.$refs.teamBaseInfo.setStore();
-          resolve();
+          if (await this.$refs.teamBaseInfo.setStore('go')) {
+            console.log('进来了')
+            resolve();
+          }
         } else {
           resolve();
         }

+ 16 - 6
src/views/teamBuild/components/teamBaseInfo.vue

@@ -507,7 +507,7 @@ export default {
   // },
 
   methods: {
-    setStore() {
+    setStore(str) {
       if (this.teamid) {
         let loadash = this.$helpers.lodash;
         let sotrage = JSON.parse(localStorage.getItem(`${this.teamid}base`));
@@ -523,16 +523,18 @@ export default {
                 `${this.teamid}base`,
                 JSON.stringify(this.topFrom)
               );
-              return this.gotoNext();
+              return this.gotoNext(str);
             })
             .catch(() => {
               // localStorage.setItem(`${this.teamid}base`,JSON.stringify(this.topFrom));
             });
         } else {
+          return true
           // localStorage.setItem(`${this.teamid}base`,JSON.stringify(this.topFrom));
         }
       } else {
         localStorage.setItem(`newTeambase`, JSON.stringify(this.topFrom));
+         return true
       }
     },
     //|| this.teamStatus === 'teamAudit'
@@ -711,10 +713,11 @@ export default {
       });
     },
     chioseSchool(val) {},
-    gotoNext() {
+    gotoNext(str) {
       this.$refs["topinfo"].validate(async (valid, object) => {
         if (!valid) {
           this.$message.error("请填写建团必要参数");
+          return false
         } else {
           // 判断一下是否勾选了课程类型而没有输入金额
           // 验证通过
@@ -724,13 +727,13 @@ export default {
             this.$emit("handleClick", { name: "2" });
           } else {
                this.$emit("getName", this.topFrom.name);
-            await this.resetSubmit();
+           return await this.resetSubmit(str);
 
           }
         }
       });
     },
-    resetSubmit() {
+    resetSubmit(str) {
       this.$refs["topinfo"].validate((valid, object) => {
         if (!valid) {
           this.$message.error("请填写必要参数");
@@ -797,6 +800,7 @@ export default {
           if (this.teamStatus != "newTeam") {
             resetTeamBaseInfo(obj).then((res) => {
               if (res.code == 200) {
+
                 localStorage.setItem(
                   `${this.teamid}base`,
                   JSON.stringify(this.topFrom)
@@ -804,13 +808,17 @@ export default {
                 this.$emit("getBaseInfo");
                 if (this.teamStatus == "teamDraft") {
                   this.$message.success("保存成功");
-                  this.$emit("handleClick", { name: "2" });
+                  if(!str){
+                     this.$emit("handleClick", { name: "2" });
+                  }
+                  return true
                   // 跳到第二页
                 } else {
                   this.$message.success("修改乐团成功");
 
                   // this.$router.push({ path: '/teamLists', query: { id: this.teamid, name: this.topFrom.name } })
                 }
+                return true
               }
             });
           } else {
@@ -849,6 +857,7 @@ export default {
 
                     this.$emit("getName", this.topFrom.name);
                     this.$emit("handleClick", { name: "2" });
+                    return true
                   })
                   .catch(() => {
                     this.$router.push(
@@ -866,6 +875,7 @@ export default {
                     );
                     this.$emit("getName", this.topFrom.name);
                     this.init();
+                     return true
                   });
               }
             });