|
@@ -18,6 +18,7 @@
|
|
|
<script>
|
|
|
import ScrollPane from './ScrollPane'
|
|
|
import path from 'path'
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
|
|
|
export default {
|
|
|
components: { ScrollPane },
|
|
@@ -31,12 +32,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- visitedViews () {
|
|
|
- return this.$store.state.tagsView.visitedViews
|
|
|
- },
|
|
|
- routes () {
|
|
|
- return this.$store.state.user.roles
|
|
|
- }
|
|
|
+ ...mapGetters(['visitedViews', 'roles'])
|
|
|
},
|
|
|
watch: {
|
|
|
$route () {
|
|
@@ -49,10 +45,45 @@ export default {
|
|
|
} else {
|
|
|
document.body.removeEventListener('click', this.closeMenu)
|
|
|
}
|
|
|
+ },
|
|
|
+ visitedViews: {
|
|
|
+ handler(val) {
|
|
|
+ console.log(JSON.stringify(val).length)
|
|
|
+ let authView = false
|
|
|
+ let accountGroupView = false
|
|
|
+ let orgView = false
|
|
|
+ val.forEach(view => {
|
|
|
+ switch (view.path) {
|
|
|
+ case '/authority':
|
|
|
+ authView = true
|
|
|
+ break
|
|
|
+ case '/organization':
|
|
|
+ orgView = true
|
|
|
+ break
|
|
|
+ case '/accountGroup':
|
|
|
+ accountGroupView = true
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (!authView) {
|
|
|
+ sessionStorage.removeItem('authExpandedKeys')
|
|
|
+ sessionStorage.removeItem('authCurrentKey')
|
|
|
+ }
|
|
|
+ if (!orgView) {
|
|
|
+ sessionStorage.removeItem('orgExpandedKeys')
|
|
|
+ sessionStorage.removeItem('orgCurrentKey')
|
|
|
+ }
|
|
|
+ if (!accountGroupView) {
|
|
|
+ sessionStorage.removeItem('accountGroupExpandedKeys')
|
|
|
+ sessionStorage.removeItem('accountGroupCurrentKey')
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
- if (this.routes && this.routes.length) {
|
|
|
+ if (this.roles && this.roles.length) {
|
|
|
this.initTags()
|
|
|
this.addTags()
|
|
|
this.beforeUnload()
|
|
@@ -86,10 +117,10 @@ export default {
|
|
|
isAffix (tag) {
|
|
|
return tag.meta && tag.meta.affix
|
|
|
},
|
|
|
- filterAffixTags (routes, basePath = '/') {
|
|
|
+ filterAffixTags (roles, basePath = '/') {
|
|
|
let tags = []
|
|
|
- if (this.routes) {
|
|
|
- routes.forEach(route => {
|
|
|
+ if (this.roles) {
|
|
|
+ roles.forEach(route => {
|
|
|
if (route.meta && route.meta.affix) {
|
|
|
const tagPath = path.resolve(basePath, route.path)
|
|
|
tags.push({
|
|
@@ -110,7 +141,7 @@ export default {
|
|
|
return tags
|
|
|
},
|
|
|
initTags () {
|
|
|
- const affixTags = this.affixTags = this.filterAffixTags(this.routes)
|
|
|
+ const affixTags = this.affixTags = this.filterAffixTags(this.roles)
|
|
|
for (const tag of affixTags) {
|
|
|
// Must have tag name
|
|
|
if (tag.name) {
|