Commit a476d46e authored by 张俊's avatar 张俊

菜单处理

parent 298b81c6
<template>
<ul class="nav-list" v-if="list&&list.length">
<li v-for="(item, index) in list" v-show="item.show" :key="'nav_' + index">
<template v-if="item.children && item.children.length">
<li v-for="(item, index) in list" v-show="item.menuType!==2" :key="'nav_' + index">
<template v-if="item.children && item.children.length&&item.menuType==0">
<div
class="nav-item nav-more text-clip"
:class="{ current: isCurrent([item.path]) }"
......@@ -9,8 +9,10 @@
>
<span :style="{ paddingLeft: `${deep*2}em` }">
<!-- <img v-if="item.icon" :src="item.icon" alt=""> -->
<bg-icon v-if="item.icon" :icon="item.icon"></bg-icon>
<bg-icon v-if="item.icon" style="color:#7c8292;" :icon="'#'+item.icon"></bg-icon>
{{ item.menuName }}
<bg-icon v-show="showMore[index] !== false" style="font-size:8px;position: absolute;right: 10px;top: 20px;" icon="#bg-ic-arrow-up"></bg-icon>
<bg-icon v-show="showMore[index] == false" style="font-size:8px;position: absolute;right: 10px;top: 20px;" icon="#bg-ic-arrow-down"></bg-icon>
</span>
&ensp;
</div>
......@@ -26,7 +28,7 @@
<template v-else>
<div
class="nav-item text-clip"
:class="{current:isCurrent(item.linkPath&&item.linkPath.length?[...item.linkPath,item.path]:[item.path])}"
:class="{current:isCurrent(item.children&&item.children.length?[...getChildrenPath(item.children),item.path]:[item.path])}"
@click="$router.push(item.path)"
>
<span :style="{ paddingLeft: `${deep*2}em` }">{{ item.menuName }}</span>
......@@ -67,6 +69,15 @@ export default {
this.showMore[index] = !flag
},
getChildrenPath(arr,temp=[]){
arr.forEach(e => {
temp.push(e.path)
if(e.children&&e.children.length){
this.getChildrenPath(e.children,temp)
}
});
return temp
},
isCurrent(path) {
return (
(this.highlightParentRule && this.highlightParentRule(path)) || false
......
......@@ -8,36 +8,36 @@
>
<!-- LOGO -->
<div class="bg-logo" @click="gotoPage">
<router-link to="/" class="bg-logo">
<img style="width:140px;height:22px;" src="../assets/imgs/img_logo.png"/>
</div>
</router-link>
<!-- 菜单 -->
<div class="main-menu" v-if="userInfo&& userInfo.system_id">
<!-- 前台菜单 -->
<div class="font-menu" v-if="fontMenu&&fontMenu.length">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.show" v-for="(item,index) in fontMenu" :key="'font'+index">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.menuType!==2" v-for="(item,index) in fontMenu" :key="'font'+index">
<span @click="menuAction(item.path,item)">
{{item.menuName}}
<bg-icon v-if="item.children&&item.children.length" icon="#bg-ic-arrow-down" style="font-size:8px;margin-left: 3px;"></bg-icon>
</span>
<div class="menu-virtual"></div>
<div class="menu-list" v-if="item.children&&item.children.length">
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.show" v-for="(it,idx) in item.children" :key="'font-children'+idx">{{it.menuName}}</div>
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.menuType!==2" v-for="(it,idx) in item.children" :key="'font-children'+idx">{{it.menuName}}</div>
</div>
</div>
</div>
<!-- 后管菜单 -->
<div class="manager-menu" v-if="managerMenu&&managerMenu.length">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.show" v-for="(item,index) in managerMenu" :key="'manager'+index">
<div class="nav-item" :style="path==item.path?{backgroundColor:'#2b4695'}:''" v-show="item.menuType!==2" v-for="(item,index) in managerMenu" :key="'manager'+index">
<span @click="menuAction(item.path,item)">
{{item.menuName}}
<bg-icon v-if="item.children&&item.children.length" icon="#bg-ic-arrow-down" style="font-size:8px;margin-left: 3px;"></bg-icon>
</span>
<div class="menu-virtual"></div>
<div class="menu-list" v-if="item.children&&item.children.length">
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.show" v-for="(it,idx) in item.children" :key="'manager-children'+idx">{{it.menuName}}</div>
<div class="menu-item text_clip" @click="childMenuAction(it,item)" v-show="it.menuType!==2" v-for="(it,idx) in item.children" :key="'manager-children'+idx">{{it.menuName}}</div>
</div>
</div>
</div>
......@@ -129,7 +129,7 @@ export default {
fontMenu (state) {
let temp = []
// state.menu.forEach(e => {
// if(e.menuType=='font'){
// if(e.dict_group_id=='2cb4f767-fad7-44f2-afa3-f055e15dd2b6'){//font
// temp.push(e)
// }
// });
......@@ -138,7 +138,7 @@ export default {
managerMenu(state){
let temp = []
// state.menu.forEach(e => {
// if(e.menuType=='system'){
// if(e.dict_group_id=='64c156e0-bfff-4bfc-a63a-56effe130a25'){//system
// temp.push(e)
// }
// });
......@@ -147,7 +147,7 @@ export default {
systemMenu(state){
let temp = []
state.menu.forEach(e => {
if(e.menuType=='manager'){
if(e.dict_group_id=='09938937-3db9-47de-b967-7777ea4ebb2d'){//manager
temp.push(e)
}
});
......@@ -192,14 +192,10 @@ export default {
// })
},
menuAction(n,parent) {
//不存在则不跳转
if(!n){
return
}
if (n == "logout") {
this.$axios.post(`/apaas/system/v5/user/logout`).then(res=>{
if(res.data.code=='200'){
this.$router.push('/login')
window.location.href = `/apaas/manage/ui/#/login`;
this.$store.commit('setUserInfo',null)
clearCookie('bgToken')
this.$message.success('退出成功')
......@@ -210,7 +206,7 @@ export default {
})
} else if (n == "login") {
let path = this.$route.path;
window.location.href = `/login?redirect=${path}`;
window.location.href = `/apaas/manage/ui/#/login?redirect=${path}`;
} else {
//是否有子路由,有则寻找子路由的第一个进行跳转,无则直接进行跳转
//使用childMenuAction是模拟template中,子路径点击跳转使用childMenuAction,
......@@ -223,16 +219,15 @@ export default {
}
},
childMenuAction(v,parent) {
//最多只有2层目录,childMenuAction已经进入第一层,只需判断是否还有第二层即可
//有第二层则继续找第二层的第一个跳转
//无第二层则直接跳转
if(v.children&&v.children.length){
if(v.children[0].children){
this.pathToUrl(v.children[0].children[0].path,parent)
}else{
for (let index = 0; index < v.children.length; index++) {
const e = v.children[index];
if(e.show){
this.pathToUrl(e.path,parent)
break
}
for (let index = 0; index < v.children.length; index++) {
const e = v.children[index];
if(e.menuType!==2){
this.pathToUrl(e.path,parent)
break
}
}
}else{
......@@ -246,22 +241,19 @@ export default {
}else{
//判断是否是同区域内跳转
//非同区域跳转需要改前缀,如apaas/portal/ui跳转到apaas/manage/ui
if(this.$store.state.menuObj[this.path]&&(parent.menuType==this.$store.state.menuObj[this.path].menuType||(['font','system'].includes(parent.menuType)&&['font','system'].includes(this.$store.state.menuObj[this.path].menuType)))){
if(this.$store.state.menuObj[this.path]&&(parent.dict_group_id==this.$store.state.menuObj[this.path].dict_group_id||(['2cb4f767-fad7-44f2-afa3-f055e15dd2b6','64c156e0-bfff-4bfc-a63a-56effe130a25'].includes(parent.dict_group_id)&&['2cb4f767-fad7-44f2-afa3-f055e15dd2b6','64c156e0-bfff-4bfc-a63a-56effe130a25'].includes(this.$store.state.menuObj[this.path].dict_group_id)))){
this.$router.push(path);
}else{
let temp = ''
if(this.$store.state.menuObj[path].menuType=='font'||this.$store.state.menuObj[path].menuType=='system'){
if(this.$store.state.menuObj[path].dict_group_id=='2cb4f767-fad7-44f2-afa3-f055e15dd2b6'||this.$store.state.menuObj[path].dict_group_id=='64c156e0-bfff-4bfc-a63a-56effe130a25'){
temp = '/apaas/portal/ui/#'
}else if(this.$store.state.menuObj[path].menuType=='manager'){
}else if(this.$store.state.menuObj[path].dict_group_id=='09938937-3db9-47de-b967-7777ea4ebb2d'){
temp = '/apaas/manage/ui/#'
}
window.open(temp+path)
}
}
},
gotoPage(){
window.open(`/apaas/portal/ui/#/`)
},
intoCartDetail() {
this.$router.push({ name: "shopCart" });
},
......@@ -458,7 +450,6 @@ export default {
line-height: 1;
margin: 0 50px 0 20px;
text-decoration: none;
cursor: pointer;
> span {
font-size: 24px;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment