ソースを参照

页签bug修复

chenrui 3 年 前
コミット
f3d54ab017
1 ファイル変更13 行追加15 行削除
  1. 13 15
      src/components/MultiTab/MultiTab.vue

+ 13 - 15
src/components/MultiTab/MultiTab.vue

@@ -36,7 +36,6 @@ export default {
       } catch (e) {
       }
     })
-    console.log('rename')
     if (this.pages.length <= this.maxTabNums) {
       this.pages.push(this.$route)
       this.tabsList.push(this.$route.name)
@@ -153,7 +152,7 @@ export default {
   watch: {
     '$route': function (newVal, oldVal) {
       if (newVal.name == oldVal.name) { return }
-      // console.log(newVal, oldVal, this.pages)
+      console.log(newVal, oldVal, this.pages)
       // 解决页面地址相同参数不同时打开多个页签问题(例 详情页id或sn不同时)
       const index = this.tabsList.indexOf(newVal.name)
 
@@ -171,18 +170,18 @@ export default {
       const molen = oldMenu.matched.length < 3
       const oldMatched = oldMenu.matched[molen ? 1 : 2]
       const hasChildren = newMatched.name == oldMatched.name
+      // 判断是否是新增,编辑,详情页
+      const na = newVal.meta.title.indexOf('详情') >= 0
+      const nb = newVal.meta.title.indexOf('新增') >= 0
+      const nc = newVal.meta.title.indexOf('编辑') >= 0
+      const nxt = newVal.meta.replaceTab
+      const oa = oldMenu.meta.title.indexOf('详情') >= 0
+      const ob = oldMenu.meta.title.indexOf('新增') >= 0
+      const oc = oldMenu.meta.title.indexOf('编辑') >= 0
+      const oxt = oldMenu.meta.replaceTab
 
       if (index < 0) { // 不存在
-        // console.log(1, hasChildren, '不存在')
-        // 判断是否是新增,编辑,详情页
-        const na = newVal.meta.title.indexOf('详情') >= 0
-        const nb = newVal.meta.title.indexOf('新增') >= 0
-        const nc = newVal.meta.title.indexOf('编辑') >= 0
-        const nxt = newVal.meta.replaceTab
-        const oa = oldMenu.meta.title.indexOf('详情') >= 0
-        const ob = oldMenu.meta.title.indexOf('新增') >= 0
-        const oc = oldMenu.meta.title.indexOf('编辑') >= 0
-        const oxt = oldMenu.meta.replaceTab
+        console.log(1, hasChildren, '不存在')
         if ((na || nb || nc || nxt || oa || ob || oc || oxt) && hasChildren) {
           // 替换当前页签
           this.replaceTab(newVal, oldMenu)
@@ -212,18 +211,17 @@ export default {
           }
         }
       } else { // 已存在
+        console.log(1, nxt, '已存在')
         this.pages.splice(index, 1, newVal)
         this.tabsList.splice(index, 1, newVal.name)
-        this.$store.state.app.isNewTab = false
+        this.$store.state.app.isNewTab = !!nxt
         if (hasEqChild) {
           this.$store.state.app.updateList = hasEqChild.name == oldVal.name
         }
-        // console.log(1, this.$store.state.app.updateList, '已存在')
         this.activeKey = newVal.name
       }
     },
     activeKey: function (newPathKey) {
-      console.log('-----' + newPathKey)
       const pages = this.pages.find(item => item.name == newPathKey)
       this.$router.push({ name: newPathKey, params: pages.params, query: pages.query })
     }