Browse Source

修改bug

QuKatie 3 years ago
parent
commit
b393d9fbf1
3 changed files with 64 additions and 14 deletions
  1. 11 3
      src/cache.js
  2. 15 0
      src/router/views/index.js
  3. 38 11
      src/store/modules/tags.js

+ 11 - 3
src/cache.js

@@ -10,6 +10,14 @@ Vue.mixin({
     })
   },
   beforeRouteLeave: function (to, from, next) {
+    if (store.getters.tagList.length >= 8 && !store.getters.tagList.find(res => to.fullPath == res.value)) {
+      this.$confirm('tab页面数量已超出限制,请关闭tab页再打开', '温馨提示', {
+        confirmButtonText: '确定',
+        showCancelButton: false,
+        type: 'warning'
+      })
+      return
+    }
     let avueView = document.getElementById('avue-view');
     if (from && from.meta.keepAlive) {
       if (avueView) {
@@ -22,9 +30,9 @@ Vue.mixin({
         from.meta.savedPosition = 0
         if (this.$vnode.parent && this.$vnode.parent.componentInstance && this.$vnode.parent.componentInstance.cache) {
           if (this.$vnode.componentOptions) {
-            let key = this.$vnode.key == null
-              ? this.$vnode.componentOptions.Ctor.cid + (this.$vnode.componentOptions.tag ? `::${this.$vnode.componentOptions.tag}` : '')
-              : this.$vnode.key;
+            let key = this.$vnode.key == null ?
+              this.$vnode.componentOptions.Ctor.cid + (this.$vnode.componentOptions.tag ? `::${this.$vnode.componentOptions.tag}` : '') :
+              this.$vnode.key;
             let cache = this.$vnode.parent.componentInstance.cache;
             let keys = this.$vnode.parent.componentInstance.keys;
             if (cache[key]) {

+ 15 - 0
src/router/views/index.js

@@ -795,4 +795,19 @@ export default [{
       }
     ]
   },
+  {
+    path: '/salaryManagement/primarySchool/index',
+    component: Layout,
+    hidden: true,
+    children: [
+      {
+        path: '/salaryManagement/primarySchool/index',
+        name:'小学部',
+        meta: {
+          keepAlive: true,
+        },
+        component: () => import( /* webpackChunkName: "views" */ '@/views/salaryManagement/primarySchool/index')
+      }
+    ]
+  },
 ]

+ 38 - 11
src/store/modules/tags.js

@@ -1,5 +1,10 @@
-import {setStore, getStore} from '@/util/store'
-import {diff} from '@/util/util'
+import {
+  setStore,
+  getStore
+} from '@/util/store'
+import {
+  diff
+} from '@/util/util'
 import website from '@/config/website'
 
 const isFirstPage = website.isFirstPage;
@@ -9,7 +14,7 @@ const tagObj = {
   value: '', //标题的路径
   params: '', //标题的路径参数
   query: '', //标题的参数
-  meta: {},//额外参数
+  meta: {}, //额外参数
   group: [], //分组
 }
 
@@ -31,30 +36,46 @@ function setFistTag(list) {
 
 const navs = {
   state: {
-    tagList: getStore({name: 'tagList'}) || [],
-    tag: getStore({name: 'tag'}) || tagObj,
+    tagList: getStore({
+      name: 'tagList'
+    }) || [],
+    tag: getStore({
+      name: 'tag'
+    }) || tagObj,
     tagWel: tagWel
   },
   actions: {},
   mutations: {
     ADD_TAG: (state, action) => {
       state.tag = action;
-      setStore({name: 'tag', content: state.tag})
+      setStore({
+        name: 'tag',
+        content: state.tag
+      })
       if (state.tagList.some(ele => diff(ele, action))) return
       state.tagList.push(action)
       setFistTag(state.tagList);
-      setStore({name: 'tagList', content: state.tagList})
+      setStore({
+        name: 'tagList',
+        content: state.tagList
+      })
     },
     DEL_TAG: (state, action) => {
       state.tagList = state.tagList.filter(item => {
         return !diff(item, action);
       })
       setFistTag(state.tagList);
-      setStore({name: 'tagList', content: state.tagList})
+      setStore({
+        name: 'tagList',
+        content: state.tagList
+      })
     },
     DEL_ALL_TAG: (state) => {
       state.tagList = [state.tagWel];
-      setStore({name: 'tagList', content: state.tagList})
+      setStore({
+        name: 'tagList',
+        content: state.tagList
+      })
     },
     DEL_TAG_OTHER: (state) => {
       state.tagList = state.tagList.filter(item => {
@@ -65,11 +86,17 @@ const navs = {
         }
       })
       setFistTag(state.tagList);
-      setStore({name: 'tagList', content: state.tagList})
+      setStore({
+        name: 'tagList',
+        content: state.tagList
+      })
     },
     SET_TAG_LIST(state, tagList) {
       state.tagList = tagList;
-      setStore({name: 'tagList', content: state.tagList})
+      setStore({
+        name: 'tagList',
+        content: state.tagList
+      })
     }
   }
 }