<template>
  <div class="header">
        <div class="headertitle">
            <img src="../../assets/images/启东市铁路沿线综合治理信息化管理平台@2x.png" />
        </div>
        <div class="mum">
            <div :class='currentindex==1?"active":""' @click="goTarget(1)">首页</div>
            <div :class='currentindex==7?"active":""' @click="goTarget(7)">
               <!-- <div style="display:inline-flex">
                  <div>{{menuName2}}</div>
                  <div style="margin-left:0.5rem" @click="rightMenu" v-show="showMenu == 0"><i class="el-icon-arrow-right"></i></div>
                   <div style="margin-left:0.5rem" @click="leftMenu" v-show="showMenu"><i class="el-icon-arrow-left"></i></div>
                </div> -->
                铁路护路联防
            </div>
             <div :class='currentindex==13?"active":""' @click="goTarget(13)">
               <!-- <div style="display:inline-flex">
                  <div>{{menuName2}}</div>
                  <div style="margin-left:0.5rem" @click="rightMenu" v-show="showMenu == 0"><i class="el-icon-arrow-right"></i></div>
                   <div style="margin-left:0.5rem" @click="leftMenu" v-show="showMenu"><i class="el-icon-arrow-left"></i></div>
                </div> -->
                隐患处理
            </div>
            <div :class='currentindex==2?"active":""'>
                <div style="display:inline-flex">
                  <div>{{menuName}}</div>
                  <div style="margin-left:0.5rem" @click="rightMenu(1)" v-show="showMenu == 0"><i class="el-icon-arrow-right"></i></div>
                   <div style="margin-left:0.5rem" @click="leftMenu(0)" v-show="showMenu == 1"><i class="el-icon-arrow-left"></i></div>
                </div>
            </div>
<!-- 
            <div  @click="goTarget(9)" v-show="showMenu">视频监测</div>
            <div  @click="goTarget(10)" v-show="!showMenu">无人机监测</div>
            <div  @click="goTarget(11)" v-show="!showMenu">巡检监测</div>
             <div  @click="goTarget(11)" v-show="!showMenu">巡逻电车监测</div> -->


            <div :class='currentindex==9?"active":""' @click="goTarget(9)" v-show="showMenu == 1">视频监测</div>
            <div :class='currentindex==10?"active":""' @click="goTarget(10)" v-show="showMenu == 1">无人机监测</div>
            <div :class='currentindex==11?"active":""' @click="goTarget(11)" v-show="showMenu == 1">巡检监测</div>
             <div :class='currentindex==12?"active":""' @click="goTarget(12)" v-show="showMenu == 1">巡逻电车监测</div>
            
           
            <div :class='currentindex==3?"active":""' @click="goTarget(3)" v-show="showMenu == 0">治理态势</div>
            <!-- <div :class='currentindex==5?"active":""' @click="goTarget(5)" v-show="showMenu == 0">公众服务</div> -->
            <div :class='currentindex==6?"active":""' @click="goTarget(6)" v-show="showMenu == 0">综合管理</div>
            <!-- <div :class='currentindex==4?"active":""' @click="goTarget(4)" v-show="showMenu == 0">安全态势</div> -->
        </div>
<!-- 
        <div class="menu-dropDown">
                     <div class='menu_item_class'>设施监测</div>
                     <div class='menu_item_class'>无人机监测</div>
        </div> -->
        <div class="time">
            <img src="../../assets/images/图层 9@2x.png" /><span>{{ currenttime }}</span>
        </div>

        <div class="exit">
             <i class="el-icon-switch-button" @click="logout"></i>
        </div>
    </div>
</template>

<script>
import moment from "moment";
import TopNav from '@/components/TopNav'

export default {
   components: {   
      TopNav
    },
  name: "HeaderDiv",
   props: {
      currentindexP:Number,
      menuNameP:{
      type: String, // 约束color值的类型
      default: "设施监测",  // color变量默认值（外部不给 我color传值，使用默认值） 
    },
      menuNameP2:{
      type: String, // 约束color值的类型
      default: "交通局简介",  // color变量默认值（外部不给 我color传值，使用默认值） 
    },
    fatherMethod: {
        type: Function,
        default: null
      }
  },
  data() {
    return {
      // 版本号
      version: "3.8.1",
      currenttime: moment().format("YYYY-MM-DD HH:mm:ss"),
      currentindex:this.currentindexP,
      showMenu:0,
      menuName:this.menuNameP,
      menuName2:this.menuNameP2
    };
  },
   mounted() {
        console.log(this.currentindexP);
         console.log(this.menuNameP);
        setInterval(() => {
            this.currenttime = moment().format("YYYY-MM-DD HH:mm:ss");
        }, 1000);
    },
  methods: {
    async logout() {
      this.$confirm('确定注销并退出系统吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$store.dispatch('LogOut').then(() => {
          location.href = '#/login';
        })
      }).catch(() => {});
    },
    goTarget(index) {
      if(index == 1){
            this.$router.push('/big');
            this.fatherMethod();
      }else if(index == 9){
           this.$router.push('/video')
      }else if(index == 10){
           this.$router.push('/drone')
      }else if(index == 11){
           this.$router.push('/keepWatch')
      }else if(index == 3){
           this.$router.push('/new')
      }else if(index == 4){
           this.$router.push('/safe')
      }else if(index == 5){
           this.$router.push('/public')
      }else if(index == 6){
           this.$router.push('/plan/statics')
      }else if(index == 7){
           this.$router.push('/introduction')
      }else if(index == 12){
           this.$router.push('/electri')
      }else if(index == 13){
           this.$router.push('/trouble')
      }
    },
    rightMenu(index){
         this.showMenu = index
    },
    leftMenu(index){
         this.showMenu = index
    }
  },
};
</script>

<style rel="stylesheet/scss" lang="scss">
.header {
    background: url("../../assets/images/top@2x.png") no-repeat;
    background-size: 100% 100%;
    max-height: 5vh;
    position: relative;
    z-index: 1;
    .headertitle {
        margin-left: 1.1rem;
        img {
            width: 41.36rem;
            height: 4.2rem;
        }
    }
    .mum {
        font-size: 1.6rem;
        color: #fff;
        position: absolute;
        top: 1.2rem;
        left: 30%;
        >div {
            display: inline-block;
            margin-right: 4.9rem;
            cursor: pointer;
        }
        .active {
            color: #30FFEA;
        }
        .active::before {
            display: inline-block;
            content: "";
            background: url("../../assets/images/左@2x.png") no-repeat;
            width: 2.2rem;
            height: 1.4rem;
            background-size: 100% 100%;
            margin-right: 0.2rem;
        }
        .active::after {
            display: inline-block;
            content: "";
            background: url("../../assets/images/左@2x.png") no-repeat;
            width: 2.2rem;
            height: 1.4rem;
            background-size: 100% 100%;
            margin-left: 0.2rem;
        }
    }
    .time {
        position: absolute;
        top: 1.2rem;
        right: 5.7rem;
        font-size: 1.6rem;
        color: #fff;
        img {
            width: 2.4rem;
            height: 2.4rem;
            vertical-align: middle;
            margin-top: -0.1rem;
            margin-right: 1.6rem;
        }
    }

    .exit{
        position: absolute;
        top: 0.6rem;
        right: 2.2rem;
        font-size: 2rem;
        color: white;
    }
}
.bottombg{
  background: url("../../assets/images/底部菜单bg@2x.png");
  position: absolute;
  background-size: 100% 100%;
  z-index: 1;
  width: 85.1rem;
  height: 16.3rem;
  bottom: 0;
  left: 50%;
  transform: translate(-50%,-0%);
  display: flex;
  flex-direction: row;
  align-items: center;
  color:#fff;
  font-size:1.6rem;

  .item:hover{
    cursor: pointer;
  }

  .item{
    width: 33%;
    text-align: center;
    justify-content: center;
    position: relative;
    .num{
      font-size:3rem;
      color:#25f8bd;
    }
  }
   .item1{
    width: 33%;
  }
  .item2::after{
    content: "";
    background: url("../../assets/images/图层\ 2@2x.png");
    background-size: 100% 100%;
    width: 0.2rem;
    height: 7.3rem;
    position: absolute;
    top: 0;
    right: 0;
  }
}
.ol-zoom-in,.ol-zoom-out{
  display: none !important;

}

.menu-dropDown{
    position: absolute;
    top: 0.5rem;
    left: 95rem;
    width: 16rem;
    height: 3.2rem;
    background-color: #30FDFF;
    opacity: 1;
    padding-left:1rem;
    display: inline-flex;
    font-size:1.6rem;
    color:#D6DEE7;
    
}

.menu_item_class{
   
}

</style>

