|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
<template> |
|
|
|
|
<div> |
|
|
|
|
<el-menu |
|
|
|
|
class="sidebar-el-menu" |
|
|
|
|
<el-menu class="sidebar-el-menu" |
|
|
|
|
:default-active="onRoutes" |
|
|
|
|
background-color="#324157" |
|
|
|
|
text-color="#bfcbd9" |
|
|
|
@ -9,38 +8,33 @@ |
|
|
|
|
unique-opened |
|
|
|
|
mode="horizontal" |
|
|
|
|
router |
|
|
|
|
@select="handleSelect" |
|
|
|
|
> |
|
|
|
|
@select="handleSelect"> |
|
|
|
|
<template v-for="item in menus"> |
|
|
|
|
<template v-if="item.subs"> |
|
|
|
|
<el-submenu :index="item.index" :key="item.index"> |
|
|
|
|
<el-submenu :index="item.index" |
|
|
|
|
:key="item.index"> |
|
|
|
|
<template slot="title"> |
|
|
|
|
<i :class="item.icon"></i> |
|
|
|
|
<span slot="title">{{ item.title }}</span> |
|
|
|
|
</template> |
|
|
|
|
<template v-for="subItem in item.subs"> |
|
|
|
|
<el-submenu |
|
|
|
|
v-if="subItem.subs" |
|
|
|
|
<el-submenu v-if="subItem.subs" |
|
|
|
|
:index="subItem.index" |
|
|
|
|
:key="subItem.index" |
|
|
|
|
> |
|
|
|
|
:key="subItem.index"> |
|
|
|
|
<template slot="title">{{ subItem.title }}</template> |
|
|
|
|
<el-menu-item |
|
|
|
|
v-for="(threeItem,i) in subItem.subs" |
|
|
|
|
<el-menu-item v-for="(threeItem,i) in subItem.subs" |
|
|
|
|
:key="i" |
|
|
|
|
:index="threeItem.index" |
|
|
|
|
>{{ threeItem.title }}</el-menu-item> |
|
|
|
|
:index="threeItem.index">{{ threeItem.title }}</el-menu-item> |
|
|
|
|
</el-submenu> |
|
|
|
|
<el-menu-item |
|
|
|
|
v-else |
|
|
|
|
<el-menu-item v-else |
|
|
|
|
:index="subItem.index" |
|
|
|
|
:key="subItem.index" |
|
|
|
|
>{{ subItem.title }}</el-menu-item> |
|
|
|
|
:key="subItem.index">{{ subItem.title }}</el-menu-item> |
|
|
|
|
</template> |
|
|
|
|
</el-submenu> |
|
|
|
|
</template> |
|
|
|
|
<template v-else> |
|
|
|
|
<el-menu-item :index="item.index" :key="item.index"> |
|
|
|
|
<el-menu-item :index="item.index" |
|
|
|
|
:key="item.index"> |
|
|
|
|
<i :class="item.icon"></i> |
|
|
|
|
<span slot="title">{{ item.title }}</span> |
|
|
|
|
</el-menu-item> |
|
|
|
@ -54,7 +48,7 @@ |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import addRoutes from '@/libs/route/addRoutes' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
menuList: [ |
|
|
|
|
{ |
|
|
|
@ -127,29 +121,29 @@ export default { |
|
|
|
|
onRoutes: this.$route.path |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch:{ |
|
|
|
|
"$route.path":function(val){ |
|
|
|
|
this.menuList.map(e=>{ |
|
|
|
|
if(val.replace('/', '')===e.index){ |
|
|
|
|
watch: { |
|
|
|
|
"$route.path": function (val) { |
|
|
|
|
this.menuList.map(e => { |
|
|
|
|
if (val.replace('/', '') === e.index) { |
|
|
|
|
this.handleSelect(val.replace('/', '')) |
|
|
|
|
this.$forceUpdate(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
sessionStorage.getItem('sideBar') && this.handleSelect(sessionStorage.getItem('sideBar')) |
|
|
|
|
mounted () { |
|
|
|
|
// sessionStorage.getItem('sideBar') && this.handleSelect(sessionStorage.getItem('sideBar')) |
|
|
|
|
sessionStorage.getItem('token') && this.getPer() // 登录了才获取权限 |
|
|
|
|
}, |
|
|
|
|
methods:{ |
|
|
|
|
handleSelect(index){ |
|
|
|
|
methods: { |
|
|
|
|
handleSelect (index) { |
|
|
|
|
this.onRoutes = index |
|
|
|
|
this.$store.commit('setOrderParam', null) |
|
|
|
|
this.$store.commit('setInfoTab', '1') |
|
|
|
|
this.$store.commit('setColumnId', '') |
|
|
|
|
sessionStorage.setItem('sideBar',index) |
|
|
|
|
sessionStorage.setItem('sideBar', index) |
|
|
|
|
}, |
|
|
|
|
initMenu() { |
|
|
|
|
initMenu () { |
|
|
|
|
if (Setting.dynamicRoute) { |
|
|
|
|
const routes = this.$store.state.routes |
|
|
|
|
const menus = [] |
|
|
|
@ -162,7 +156,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 获取权限列表 |
|
|
|
|
getPer() { |
|
|
|
|
getPer () { |
|
|
|
|
this.$get(`${this.api.getUserRolesPermissionMenu}?platformId=${Setting.platformId}`).then(res => { |
|
|
|
|
const routes = res.permissionMenu[0].children |
|
|
|
|
addRoutes(routes) |
|
|
|
|