<template>
  <div class="navbar" :style="{...obj,'height': this.$store.getters.isMain ? '22vh' : '8vh'}">
    <div class="header-top">
      <div class="header-top-item"><img src="@/assets/login/logo-white.png" alt=""> </div>
      <div v-if="!$store.getters.isMain"><img class="log-img" src="@/assets/rms/主概览-白-60px.png" alt=""></div>
      <div class="header-top-item">
        <el-badge :value="39">
          <img style="height: 23px" src="@/assets/0-常用/预警管理-白.png" alt="">
        </el-badge>
        <el-select v-model="$store.state.user.classification" placeholder="请选择" @change="selectChange">
          <el-option
            v-for="item in $store.getters.opts"
            :key="item.title"
            :label="item.title"
            :value="item.name"
          />
          <el-option value="loginout" label="注销登录" />
        </el-select>
      </div>
    </div>
    <div v-if="$store.getters.isMain" class="header-title">
      <img src="@/assets/rms/主概览-白-60px.png" alt="">
    </div>
    <div v-if="$store.getters.isMain" class="header-desc">
      为您提供基于物联网的智慧实验室物资管理解决方案
    </div>
  </div>
</template>

<script>
// import { mapGetters } from 'vuex'
// import Breadcrumb from '@/components/Breadcrumb'
// import Hamburger from '@/components/Hamburger'

export default {
  components: {
    // Breadcrumb
    // Hamburger
  },
  // computed: {
  //   ...mapGetters([
  //     'sidebar',
  //     'avatar'
  //   ])
  // },
  data() {
    return {
      obj: {
        'background-image': 'url(' + require('@/assets/3-主概览/主概览背景.png') + ')',
        'background-size': '100%'
      }
    }
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch('app/toggleSideBar')
    },
    selectChange(val) {
      if (val === 'loginout') {
        this.$store.commit('user/RESET_STATE')
        this.$store.commit('permission/RESET_STATE')
        this.$router.push('/login')
        return
      }
      this.$router.push(this.$store.getters.opts.find(item => item.name === val).router.path)
    }
  }
}
</script>

<style lang="scss" scoped>
.navbar {
  height: 10rem;
  overflow: hidden;
  position: relative;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,21,41,.08);
  .header-title{
    width: 100%;
    text-align: center;
    img{
      height: 4.375rem;
    }
  }
  .header-desc{
    width: 100%;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 100;
    color: #C4C4C4;
  }
  .header-top{
    margin-left: 2rem;
    margin-right: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .mid {
      font-size: 2rem;
      font-weight: 400;
      color: #FFFFFF;
    }
    .header-top-item{
      img{
        height: 4.6875rem;
      }
      .el-select{
        margin-left: 2rem;
        width: 7.8125rem;
        ::v-deep .el-input__inner{
          background-color: rgba(255,255,255,0.0800);
          font-size: 14px;
          font-weight: 400;
          color: #FFFFFF;
          //input{
          //  background: #20a0ff;
          //}
        }
      }
    }
  }

  .hamburger-container {
    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background .3s;
    -webkit-tap-highlight-color:transparent;

    &:hover {
      background: rgba(0, 0, 0, .025)
    }
  }

  .breadcrumb-container {
    float: left;
  }

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;

    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }

    .avatar-container {
      margin-right: 30px;

      .avatar-wrapper {
        margin-top: 5px;
        position: relative;

        .user-avatar {
          cursor: pointer;
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
}
.log-img{
  height: 2.5rem;
}
</style>
