

<template>
  <div class="ems-dashboard-editor-container">
  <zd-select :get-list-by-store="true" :default-site-id="$route.query.siteId" @submitSite="submitSite"/>
  <el-menu
    class="ems-second-menu"
    :default-active="$route.meta.activeSecondMenuName"
    background-color="#1890ff"
    text-color="#ffffff"
    active-text-color="#ffffff"
    mode="horizontal"
  >
    <el-menu-item :index="item.name" v-for="(item,index) in childrenRoute" :key="index+'dzjkChildrenRoute'">
      <router-link  style="height: 100%;width: 100%;display: block;padding:0 20px;" :to="{path:item.path,query:$route.query}">
        {{item.meta.title}}
      </router-link>
    </el-menu-item>
  </el-menu>
  <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">
  .dzjk-ems-content-container{
    margin-top:0;
  }
</style>
