修改路由状态

This commit is contained in:
zyy 2019-11-14 17:58:21 +08:00
parent 8ff33b479a
commit d782d7e151

View File

@ -10,7 +10,7 @@
active-text-color="#ffd04b"
>
<system-title />
<template v-for="(item,idx) in routers">
<template v-for="(item, idx) in routers">
<template v-if="!item.hidden&&item.children">
<template v-if="hasOneScreenShowingChildren(item.children) &&!item.alwaysShow">
<template>
@ -25,7 +25,6 @@
</template>
<template v-else-if="hasOneShowingChildren(item.children) &&!item.alwaysShow">
<template :to="item.path+'/'+item.children[0].path">
<!-- -->
<el-menu-item :key="idx" :index="item.redirect ? item.redirect : (item.path+'/'+item.children[0].path)">
<span
v-if="item.children[0].meta&&item.children[0].meta.i18n"
@ -34,14 +33,14 @@
</el-menu-item>
</template>
</template>
<el-submenu v-else :key="idx" :index="item.name||item.path" :show-timeout="100">
<el-submenu v-else :key="idx" :index="item.path" :show-timeout="100">
<template slot="title">
<span v-if="item.meta" slot="title">{{ $t(item.meta.i18n) }}</span>
</template>
<template v-for="(child,cdx) in item.children">
<template v-if="!child.hidden">
<template v-if="child.children&&child.children.length>0&&hasShowingChildren(child.children)">
<el-submenu :key="cdx" :index="child.name||child.path" :show-timeout="100">
<el-submenu :key="cdx" :index="child.path" :show-timeout="100">
<template slot="title">
<span v-if="child.meta" slot="title">{{ $t(child.meta.i18n) }}</span>
</template>
@ -106,6 +105,7 @@ export default {
if (val.path === '/orderauthor/rules/manage') {
this.$refs.keMenu.activeIndex = val.path;
}
this.refreshRoute(val);
}
},
mounted() {
@ -119,6 +119,20 @@ export default {
}
},
methods: {
//
refreshRoute(val) {
let routePath = '';
if (val.path.indexOf('design/userlist') >= 0) {
routePath = '/design/userlist/home';
} else if (val.path.includes('design/lesson') || val.path.includes('design/script') || val.path.includes('design/runPlan') || val.path.includes('design/mapPreview')) {
routePath = '/design/home';
} else {
routePath = this.$route.path;
}
setTimeout(() => { //
this.$refs.keMenu.activeIndex = routePath;
}, 100);
},
toggleSideBar() {
this.$store.dispatch('ToggleSideBar');
},
@ -133,9 +147,7 @@ export default {
},
hasOneScreenShowingChildren(children) {
const showingChildren = children.filter(item => {
if (!item.hidden && item.target) {
return item;
}
if (!item.hidden && item.target) { return item; }
});
if (showingChildren.length === 1) {
return true;