浏览代码

提交测试

1
mo 4 年之前
父节点
当前提交
1b727ea2a2
共有 3 个文件被更改,包括 72 次插入21 次删除
  1. 0 1
      src/permission.js
  2. 35 8
      src/views/resetTeaming/index.vue
  3. 37 12
      src/views/teamBuild/components/teamBaseInfo.vue

+ 0 - 1
src/permission.js

@@ -14,7 +14,6 @@ const whiteList = ['/login'] // no redirect whitelist
 let isOpen = false
 
 router.onError((error) => {
-  console.log(error)
   if (error instanceof Error) {
     const isChunkLoadFailed = error.name.indexOf('chunk')
     const targetPath = router.history.pending.fullPath;

+ 35 - 8
src/views/resetTeaming/index.vue

@@ -9,8 +9,13 @@
         {{ musicGroupType[team_status] }}
       </p>
       <!-- navMenu -->
-      <tab-router v-model="activeIndex" type="card" ref="tab">
-        <!-- @tab-click="handleClick" -->
+      <tab-router
+        v-model="activeIndex"
+        type="card"
+        ref="tab"
+        @tab-click="handleClick"
+      >
+        <!-- -->
         <el-tab-pane
           label="基本信息"
           lazy
@@ -19,6 +24,7 @@
         >
           <!--  v-if="activeIndex == 'teamBaseInfo'" -->
           <teamBaseInfo
+            ref="teamBaseInfo"
             v-if="activeIndex == '1'"
             @getBaseInfo="getBaseInfo"
             :baseInfo="baseInfo"
@@ -243,6 +249,14 @@ export default {
     // this.handleClick(obj)
     this.__init();
   },
+  async beforeRouteLeave(to, from, next) {
+    if (this.activeIndex == 1) {
+      await this.$refs.teamBaseInfo.setStore();
+      next();
+    } else {
+      next();
+    }
+  },
   // activated () {
   //   let obj = {}
   //   obj.name = this.activeIndex
@@ -268,30 +282,43 @@ export default {
     },
     getBaseInfo(baseInfo) {
       this.baseInfo = baseInfo;
-      if(baseInfo?.musicGroup?.name){
-         this.teamName = baseInfo?.musicGroup?.name;
+      if (baseInfo?.musicGroup?.name) {
+        this.teamName = baseInfo?.musicGroup?.name;
       }
 
       this.musicGroupInfo = baseInfo?.musicGroup;
     },
-    handleClick(val) {
+    async handleClick(val) {
       this.teamid = this.$route.query.id;
+      if (val.name != 1 && this.$refs.teamBaseInfo) {
+        await this.$refs.teamBaseInfo.setStore();
+        this.activeIndex = val.name
+      }else{
+        this.activeIndex = val.name
+      }
       // this.team_status = this.$route.query.team_status;
       // console.log('切换tab',val)
-      this.$refs.tab.tab(val);
+      // this.$refs.tab.tab(val);
       // this.activeIndex = val.name;
     },
     permission(str) {
       return permission(str);
     },
     getName(val) {
-      if(val){
-         this.teamName = val;
+      if (val) {
+        this.teamName = val;
       }
 
       this.teamid = this.$route.query.id;
     },
   },
+  watch: {
+    //  async activeIndex(val){
+    //     if(val != 1&&this.$refs.teamBaseInfo){
+    //       await this.$refs.teamBaseInfo.setStore();
+    //     }
+    //   }
+  },
 };
 </script>
 <style lang="scss" scoped>

+ 37 - 12
src/views/teamBuild/components/teamBaseInfo.vue

@@ -455,6 +455,7 @@ export default {
     };
   },
   created() {},
+
   mounted() {
     if (this.$route.query.type == "newTeam") {
       this.onReset();
@@ -494,21 +495,41 @@ export default {
       this.basdisabled = false;
     }
   },
-  deactivated() {
-    console.log("laile");
-  },
-  beforeDestroy() {
-    // this.topFrom.paymentExpireDate = this.paymentExpireDate;
-    this.setStore();
-  },
+  deactivated() {},
+  // async beforeDestroy() {
+  //   await this.setStore();
+  //   // await new Promise((res, err) => {
+  //   //   setTimeout(() => {
+  //   //     res();
+  //   //   }, 1000);
+  //   // });
+  // },
 
   methods: {
     setStore() {
       if (this.teamid) {
-        localStorage.setItem(
-          `${this.teamid}base`,
-          JSON.stringify(this.topFrom)
-        );
+        let loadash = this.$helpers.lodash;
+        let sotrage = JSON.parse(localStorage.getItem(`${this.teamid}base`));
+        if (!loadash.isEqual(this.topFrom, sotrage) && sotrage) {
+          // 提示保存
+          return this.$confirm("已修改当前页面数据是否保存", "提示", {
+            confirmButtonText: "是",
+            cancelButtonText: "否",
+            type: "warning",
+          })
+            .then(() => {
+              localStorage.setItem(
+                `${this.teamid}base`,
+                JSON.stringify(this.topFrom)
+              );
+              return this.gotoNext();
+            })
+            .catch(() => {
+              // localStorage.setItem(`${this.teamid}base`,JSON.stringify(this.topFrom));
+            });
+        } else {
+          // localStorage.setItem(`${this.teamid}base`,JSON.stringify(this.topFrom));
+        }
       } else {
         localStorage.setItem(`newTeambase`, JSON.stringify(this.topFrom));
       }
@@ -575,6 +596,7 @@ export default {
       if (this.$route.query.id) {
         // 单团修改
         this.teamid = this.$route.query.id;
+
         let sotrage = JSON.parse(
           localStorage.getItem(`${this.$route.query.id}base`)
         );
@@ -608,6 +630,7 @@ export default {
         }
       } else {
         // 如果是新建团
+
         let sotrage = JSON.parse(localStorage.getItem(`newTeambase`));
         sotrage ? (this.topFrom = sotrage) : this.topFrom;
         if (this.topFrom?.section) {
@@ -697,8 +720,9 @@ export default {
           this.$store.dispatch("topinfo", this.topFrom);
           if (this.teamStatus == "teamAudit") {
             // 获取数据提交
-           this.$emit("handleClick", { name: "2" });
+            this.$emit("handleClick", { name: "2" });
           } else {
+            console.log("调用了");
             this.resetSubmit();
           }
         }
@@ -1099,6 +1123,7 @@ export default {
         : null;
       this.paymentExpireDate = res.data.musicGroup.paymentExpireDate;
       this.applyExpireDate = res.data.musicGroup.applyExpireDate;
+      localStorage.setItem(`${this.teamid}base`, JSON.stringify(this.topFrom));
     },
   },
   computed: {