Explorar o código

MultiTab bug修复

chenrui %!s(int64=3) %!d(string=hai) anos
pai
achega
03fef29837
Modificáronse 1 ficheiros con 9 adicións e 3 borrados
  1. 9 3
      src/components/MultiTab/MultiTab.vue

+ 9 - 3
src/components/MultiTab/MultiTab.vue

@@ -122,9 +122,11 @@ export default {
   },
   watch: {
     '$route': function (newVal, oldVal) {
-      // 父页面(列表)进入子页面(编辑、详情)再返回至父页面时关闭子页面页签
+      // 父页面(列表)进入子页面(编辑、详情)再返回至父页面时关闭子页面页签   子页面点击“返回列表”
       if (oldVal && oldVal.name && newVal.query.closeLastOldTab) {
-        this.remove(oldVal.name) // 关闭子页面
+        if (oldVal.name.indexOf('List') == -1) { // 要关闭的页面不能是列表页
+          this.remove(oldVal.name) // 关闭子页面
+        }
       }
       this.activeKey = newVal.name
       const index = this.tabsList.indexOf(newVal.name)
@@ -139,7 +141,11 @@ export default {
     activeKey: function (newPathKey) {
       const row = this.pages.find(item => item.name == newPathKey)
       // console.log(row.fullPath)
-      this.$router.push({ path: row.fullPath })
+      if (row.fullPath.indexOf('/list') == -1) {
+        this.$router.push({ path: row.fullPath })
+      } else {
+        this.$router.push({ path: row.fullPath, query: { closeLastOldTab: true } })
+      }
     }
   },
   render () {