Commit b43c852c by 无尘

fix: 修改统一路由在不同父级选中判断

parent e95a9c65
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,7 @@
"name": "@gic-test/vue-office-aside",
"description": "vue-office-aside Plugin",
"author": "fairyly <498745097@qq.com>",
"version": "1.0.31",
"version": "1.0.33",
"license": "MIT",
"private": false,
"main": "dist/vue-office-aside.js",
......
......@@ -2,23 +2,40 @@
<div class="left-aside-contain" :style="{height: asideHeight}">
<div class="leftBar-wrap" >
<div class="cardmenu" :class="{collapse: leftCollapse}">
<!-- <div class="cardtitle" v-show="!leftCollapse">
<span>{{leftModuleName}}</span>
</div> -->
<div class="cardmenu-item">
<el-menu :default-active="selectMenu" :data-path="'/' + $route.path" style="border-right: 0;" class="el-menu-vertical-demo cardmenupanel" :router="true" text-color="#606266" active-text-color="#1890ff" :collapse="leftCollapse" unique-opened @open="handleOpen" @select="handleSelect">
<el-menu
style="border-right: 0;"
class="el-menu-vertical-demo cardmenupanel"
unique-opened
text-color="#606266"
active-text-color="#1890ff"
:collapse="leftCollapse"
:default-active="selectMenu"
:data-path="'/' + $route.path"
:router="true"
@open="handleOpen"
@select="handleSelect">
<!--:default-openeds="defaultSub"-->
<template v-for="(menuItem,index) in menuLeftRouter" >
<el-submenu :index="index+''" v-if="menuItem.children.length>0 && !menuItem.levelFlag" :key="index">
<el-submenu
:index="index+''"
v-if="menuItem.children.length>0 && !menuItem.levelFlag"
:key="index">
<template slot="title" >
<i :class="['iconfont','menu-icon',menuItem.iconUrl]"></i>
<span slot="title">{{menuItem.rightName}}</span>
</template>
<!-- <el-menu-item-group > -->
<el-menu-item v-for="(childMenu,cindex) in menuItem.children" :key="cindex" :index="childMenu.url" style="padding-left: 53px;"><label slot="title" :data-index="$route.path == childMenu.url? $route.path:false" :data-path="childMenu.url">{{childMenu.rightName}}</label></el-menu-item>
<!-- </el-menu-item-group> -->
<el-menu-item
v-for="(childMenu,cindex) in menuItem.children"
:key="cindex"
:index="childMenu.url" style="padding-left: 53px;">
<label slot="title" :data-index="$route.path == childMenu.url? $route.path:false" :data-path="childMenu.url">{{childMenu.rightName}}</label>
</el-menu-item>
</el-submenu>
<el-menu-item :key="index" :index="menuItem.url" v-if="!menuItem.children.length || (menuItem.children.length>0 && !!menuItem.levelFlag)">
<el-menu-item
:key="index"
:index="menuItem.url"
v-if="!menuItem.children.length || (menuItem.children.length>0 && !!menuItem.levelFlag)">
<i :class="['iconfont','menu-icon',menuItem.iconUrl]"></i>
<span slot="title">{{menuItem.rightName}}</span>
</el-menu-item>
......@@ -27,6 +44,7 @@
</div>
</div>
</div>
</div>
</template>
<script>
import qs from 'qs';
......@@ -96,21 +114,28 @@
setSelectMenu(data) {
const that = this;
data.forEach(function(ele,index){
if (('/' + that.pathName) == ele.url) {
that.selectMenu = '/' + that.pathName;
}else {
ele.children.forEach(function(el,key){
if (('/' + that.pathName) == el.url) {
that.selectMenu = !!el.display? el.url : ele.url;
}
if (!!el.children.length) {
el.children.forEach(function(item,k){
if (item.url == that.pathName) {
that.selectMenu = el.url;
}
})
}
})
try {
if (('/' + that.pathName) == ele.url) {
that.selectMenu = '/' + that.pathName;
}else {
ele.children.forEach(function(el,key){
if (('/' + that.pathName) == el.url) {
that.selectMenu = !!el.display? el.url : ele.url;
}
if (!!el.children.length) {
el.children.forEach(function(item,k){
if (item.url == that.pathName) {
that.selectMenu = el.url;
if (!that.$route.query.type) {
throw "break"; // 跳出循环,避免重复路由判断
}
}
})
}
})
}
} catch(err) {
// console.log(err)
}
})
},
......
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