前端页面点击abnormal alarm标签页面跳转到了spectrum analysis标签页面

This commit is contained in:
任珮宇 2023-11-07 13:54:45 +08:00
parent 4121038a6a
commit 30d6f111d3
2 changed files with 18 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="custom-top-menu"> <div class="custom-top-menu">
<a-menu mode="horizontal" v-model="selectedKeys" @click="onMenuSelect"> <a-menu mode="horizontal" v-model="selectedKeys" @click="onMenuSelect">
<a-menu-item v-for="(menu, index) in menus" :key="menu.name" :class="{ 'is-last': index === menus.length - 1}"> <a-menu-item v-for="(menu, index) in menus" :key="menu.name" :class="{ 'is-last': index === menus.length - 1 }">
<img <img
v-show="menu.name === selectedKeys[0]" v-show="menu.name === selectedKeys[0]"
class="menu-logo" class="menu-logo"
@ -15,7 +15,7 @@
alt="" alt=""
/> />
<span v-html="menu.meta.title.split(' ').join('<br>')"></span> <span v-html="menu.meta.title.split(' ').join('<br>')"></span>
<img v-if="index !== menus.length - 1" class="split-line" src="@/assets/images/header/split-line.png" alt=""> <img v-if="index !== menus.length - 1" class="split-line" src="@/assets/images/header/split-line.png" alt="" />
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</div> </div>
@ -26,12 +26,12 @@ export default {
props: { props: {
menus: { menus: {
type: Array, type: Array,
default: () => [] default: () => [],
} },
}, },
data() { data() {
return { return {
selectedKeys: [] selectedKeys: [],
} }
}, },
created() { created() {
@ -40,15 +40,15 @@ export default {
}, },
methods: { methods: {
onMenuSelect({ key }) { onMenuSelect({ key }) {
const childPath = this.getChildrenPath(this.menuItems.find(menu => menu.name === key)) const childPath = this.getChildrenPath(this.menuItems.find((menu) => menu.name === key))
if (key == "abnormal-alarm" ) { if (key == 'abnormal-alarm') {
const selectedKeys = window.sessionStorage.getItem('currMenu_alarm') const selectedKeys = window.sessionStorage.getItem('currMenu_alarm')
if (selectedKeys) { if (selectedKeys) {
this.$router.push(selectedKeys) this.$router.push(selectedKeys)
} else { } else {
this.$router.push(childPath) this.$router.push(childPath)
} }
} else if (key == "istatistics") { } else if (key == 'istatistics') {
const selectedKeys = window.sessionStorage.getItem('currMenu_web') const selectedKeys = window.sessionStorage.getItem('currMenu_web')
if (selectedKeys) { if (selectedKeys) {
this.$router.push(selectedKeys) this.$router.push(selectedKeys)
@ -82,19 +82,19 @@ export default {
} }
} }
} }
} },
}, },
watch: { watch: {
$route(route) { $route(route) {
const currTopMenu = this.findTopMenuByRouteName(this.menuItems, route.name) const currTopMenu = this.findTopMenuByRouteName(this.menuItems, route.name)
this.selectedKeys = [currTopMenu.name] this.selectedKeys = [currTopMenu.name]
} },
}, },
computed: { computed: {
menuItems() { menuItems() {
return this.menus.filter(item => !item.hidden) return this.menus.filter((item) => !item.hidden)
} },
} },
} }
</script> </script>

View File

@ -130,10 +130,12 @@ export default {
watch: { watch: {
$route: { $route: {
handler: function (val, oldVal) { handler: function (val, oldVal) {
this.currSlecteKey = []
console.log(val) console.log(val)
this.currSlecteKey.push(val.path) if (val.name === 'abnormal-alarm') {
window.sessionStorage.setItem('currMenu_alarm', val.path) this.currSlecteKey = []
this.currSlecteKey.push(val.path)
window.sessionStorage.setItem('currMenu_alarm', val.path)
}
}, },
deep: true, deep: true,
immediate: true, immediate: true,