<template>
  <div class="header">
    <div class="headerNavi">
      <Clock class="time"></Clock>
      <!-- 左侧菜单 -->
      <CustomMenu :menuData="menuLeft" prefix="l" class="leftMenu">
        <!--@onChange="onChange" :activeIndex="activeIndex" -->
      </CustomMenu>
      <!-- 中间标题 -->
      <div class="vis-title">
        <img class="logo-img" src="../../images/logo.png" />
        <img class="title-img" src="../../images/title.png" />
      </div>
      <!-- 右侧菜单 -->
      <CustomMenu :menuData="menuRight" prefix="r" class="rightMenu">
        <!-- @onChange="onChange" :activeIndex="activeIndex" -->
      </CustomMenu>
      <!-- 预警 -->
      <EarlyWarning class="early_warning"></EarlyWarning>
      <UserArea class="topButton"></UserArea>
    </div>
    <RecentPages class="recent"></RecentPages>
  </div>
</template>
<script>
import menuData from "@/common/menuData";
import CustomMenu from "./CustomMenu.vue";
import Clock from "./Clock.vue";
import EarlyWarning from './EarlyWarning.vue'
import UserArea from './UserArea.vue'
import RecentPages from "../RecentPages/index.vue";
export default {
  name: "HeaderMenu",
  data() {
    return {
      menuLeft: [],
      menuRight: [],
      activeIndex: "l-0"
    };
  },
  components: {
    EarlyWarning,
    CustomMenu,
    Clock,
    UserArea,
    RecentPages
  },
  // emit: ["change"],
  created() {
    this.activeIndex = this.$route.meta.menuId;
    this.menuLeft = [];
    this.menuRight = [];
    menuData.forEach(item => {
      if (item.position == "left") {
        this.menuLeft.push(item);
      } else {
        this.menuRight.push(item);
      }
    });
    // this.changeMenu(this.menuLeft[0]);
  },
  computed:{
  },
  mounted(){
    // this.activeIndex = "l_2-0-3";
    // console.log(this.activeIndex);
  },
  methods: {
    // onChange(item, activeIndex) {
    //   this.activeIndex = activeIndex;
    //   // this.$router.push(item.name);
    //   this.$emit("onChange", item)
    // }
  }
};
</script>
<style lang="less" scoped>
.header{
  .headerNavi { height: 68px;
    display: flex;
    //   justify-content: space-between;
    align-items: center;
    background: url("../../images/header-bg.png") no-repeat;
    background-size: 100% 100%;

    .time {
      width: 120px;
      margin-right: 20px;
    }



    .vis-title {
      flex: 1;
      width: 0;
      display: flex;
      justify-content: center;
      align-items: center;

      .logo-img {
        display: inline-block;
        //   margin-left: 100px;
        width: 48px;
        height: 37px;
      }

      .title-img {
        display: inline-block;
        margin-left: 10px;
        width: 370px;
        height: 37px;
      }
    }

    .leftMenu {
      width: 550px;
    }

    .rightMenu {
      width: 500px;
    }

    .early_warning{ width: 26px; overflow: hidden;}
    .topButton{
      width: 164px;
    }
  }
  .recent{
    height: 32px;
  }
}
</style>
