<template>
|
<el-menu :default-active="acTabs">
|
<template v-for="menu in rsMenus">
|
<el-submenu v-if="menu.childrens" :key="menu.name" :index="menu.name">
|
<template slot="title">
|
<i v-if="menu.icon" :class="menu.icon"></i>
|
<span>{{ menu.label }}</span>
|
</template>
|
<el-menu-item v-for="child in menu.childrens" :key="child.name" :index="child.name" @click="select(child)">
|
{{ child.label }}
|
</el-menu-item>
|
</el-submenu>
|
<el-menu-item v-else :index="menu.name" :key="menu.name" @click="select(menu)">
|
<div class="submenu__title">
|
<i class="el-icon-s-home"></i>
|
<span slot="title">{{ menu.label }}</span>
|
</div>
|
</el-menu-item>
|
</template>
|
</el-menu>
|
</template>
|
|
<script>
|
export default {
|
name: 'PageNav',
|
props: {
|
status:{
|
type:Boolean,
|
default() {
|
return false
|
},
|
},
|
menus: {
|
type: Array,
|
default() {
|
return []
|
},
|
|
},
|
},
|
data() {
|
return {
|
acTabs: this.$route.name
|
}
|
},
|
watch: {
|
'$route'(to) {
|
this.acTabs = to.name
|
}
|
},
|
methods: {
|
select(data) {
|
if(!this.status){
|
let url = window.location.hostname + ":8090/screen/index.html";
|
if (process.env.NODE_ENV == "dev") {
|
url = " http://localhost:8081/";
|
}
|
// 根据数据跳转
|
if (data.target) {
|
let userId = sessionStorage.getItem("userId");
|
window.open(url + data.src + "?userId=" + userId);
|
return;
|
}
|
if (this.$store.state.tagsView.cachedViews.indexOf(data.name) == -1) {
|
this.$router.push(data.src)
|
} else {
|
this.$store.state.tagsView.visitedViews.map(item => {
|
if (item.name == data.name) {
|
this.$router.push(item.path)
|
this.$store.dispatch('app/closeSideBar', false)
|
}
|
})
|
}
|
}
|
},
|
},
|
computed: {
|
rsMenus() {
|
let rs = [];
|
let menus = this.menus;
|
menus.forEach(menu => {
|
if (menu.enableduse) {
|
let tmp = {};
|
Object.keys(menu).forEach(key => {
|
if (key != 'childrens') {
|
tmp[key] = menu[key];
|
}
|
});
|
if (menu.childrens) {
|
tmp.childrens = [];
|
menu.childrens.forEach(children => {
|
if (children.enableduse) {
|
tmp.childrens.push(children);
|
}
|
});
|
}
|
rs.push(tmp);
|
}
|
});
|
rs = rs.filter(item => {
|
if (item.noChild || item.childrens.length > 0) {
|
return true;
|
} else {
|
return false;
|
}
|
});
|
return rs;
|
}
|
},
|
}
|
</script>
|
|
<style scoped>
|
</style>
|