Browse Source

加载菜单调整

daxiongYang 7 years ago
parent
commit
a5395031d7
1 changed files with 7 additions and 7 deletions
  1. 7 7
      src/views/layout/sidebar.vue

+ 7 - 7
src/views/layout/sidebar.vue

27
  import API from '@/api'
27
  import API from '@/api'
28
  import { mapMutations } from 'vuex'
28
  import { mapMutations } from 'vuex'
29
  import { getRouteNameByUrl } from '@/utils'
29
  import { getRouteNameByUrl } from '@/utils'
30
  import isNil from 'lodash/isNil'
30
  import isEmpty from 'lodash/isEmpty'
31
  export default {
31
  export default {
32
    data () {
32
    data () {
33
      return {
33
      return {
63
        if (/^\/n\/.*$/.test(route.path)) {
63
        if (/^\/n\/.*$/.test(route.path)) {
64
          var tab = this.$store.state.contentTabs.filter(item => item.name === route.name)[0]
64
          var tab = this.$store.state.contentTabs.filter(item => item.name === route.name)[0]
65
          // tab不存在, 先添加
65
          // tab不存在, 先添加
66
          if (isNil(tab)) {
66
          if (isEmpty(tab)) {
67
            var menuNav = this.getMenuNavByRouteName(route.name, this.$store.state.menuNavList)
67
            var menuNav = this.getMenuNavByRouteName(route.name, this.$store.state.menuNavList)
68
            if (!isNil(menuNav)) {
68
            if (!isEmpty(menuNav)) {
69
              tab = {
69
              tab = {
70
                id: menuNav.menuId,
70
                id: menuNav.menuId,
71
                name: route.name,
71
                name: route.name,
74
                url: menuNav.url
74
                url: menuNav.url
75
              }
75
              }
76
              this.ADD_CONTENT_TAB(tab)
76
              this.ADD_CONTENT_TAB(tab)
77
            } else {
78
              return console.error('未能找到可用tab标签页!')
77
            }
79
            }
78
          }
80
          }
79
          this.menuNavActive = tab.id + ''
81
          this.menuNavActive = tab.id + ''
85
        for (var i = 0; i < menuNavList.length; i++) {
87
        for (var i = 0; i < menuNavList.length; i++) {
86
          if (menuNavList[i].list && menuNavList[i].list.length >= 1) {
88
          if (menuNavList[i].list && menuNavList[i].list.length >= 1) {
87
            return this.getMenuNavByRouteName(name, menuNavList[i].list)
89
            return this.getMenuNavByRouteName(name, menuNavList[i].list)
88
          } else {
89
            if (getRouteNameByUrl(menuNavList[i].url) === name) {
90
              return menuNavList[i]
91
            }
90
          } else if (getRouteNameByUrl(menuNavList[i].url) === name) {
91
            return menuNavList[i]
92
          }
92
          }
93
        }
93
        }
94
      },
94
      },