Files
emsfront/src/views/ems/dzjk/index.vue

80 lines
2.3 KiB
Vue

<template>
<div class="ems-dashboard-editor-container">
<zd-select :get-list-by-store="true" :default-site-id="$route.query.siteId" @submitSite="submitSite"/>
<!-- 这里是单站监控的二级菜单栏 需要循环拿到数据 显示在页面上-->
<div class="router-container">
<div class="route-link" :class="{'active':item.name === $route.meta.activeSecondMenuName}" v-for="(item,index) in childrenRoute" :key="index+'dzjkChildrenRoute'">
<router-link style="height: 100%;width: 100%;display: block" :to="{path:item.path,query:$route.query}">
{{item.meta.title}}
</router-link>
</div>
</div>
<div class="ems-content-container ems-content-container-padding dzjk-ems-content-container">
<keep-alive>
<router-view></router-view>
</keep-alive>
</div>
</div>
</template>
<script>
import { dzjk } from '@/router/ems'
const childrenRoute = dzjk[0].children[0].children//获取到单站监控下面的字路由
console.log('childrenRoute',childrenRoute)
import ZdSelect from '@/components/Ems/ZdSelect/index.vue'
export default {
components:{ZdSelect},
data(){
return {
childrenRoute,
activeMenu:''
}
},
methods:{
submitSite(id){
if(id != this.$route.query.siteId){
console.log('单站监控选择了其他的站点id=',id,'并更新页面地址参数')
this.$router.push({query:{...this.$route.query,siteId:id}})
}else{
console.log('单站监控选择了相同的其他的站点id=',id,'页面地址不发生改变')
}
}
},
beforeRouteLeave(to,from, next){
//从单站监控下面的所有子页面跳出时会触发
// 清空store中的zdList 保障下次进入到单站监控会重新调用接口获取数据
this.$store.commit('SET_ZD_LIST',[])
next()
},
mounted() {
console.log('单站监控一级页面路由',this.$route)
}
}
</script>
<style scoped lang="scss">
.router-container{
display: flex;
.route-link{
width: 104px;
height: 40px;
line-height: 40px;
background-color: #FFBE29 ;
color: #666666;
font-size: 14px;
text-align: center;
}
.route-link.active{
background-color: #ffffff;
color: #333333;
font-weight: 500;
}
}
.dzjk-ems-content-container{
margin-top:0;
}
</style>