<template>
  <div class="header">
    <div class="leftLogo">
      <!-- <img src="../assets/stateGridCorporation.png" /> -->
      <img src="../assets/logo.png" />
      <p>运维管理系统</p>
    </div>
    <div class="menuBox">
      <vSidebar></vSidebar>
    </div>
    <div class="userInfo">
      <div class="header-user-con">
        <!-- 用户头像 -->
        <div class="user-avator">
          <!-- <img src="../assets/user.jpeg" /> -->
          <!-- 显示当前时间 -->
          <span>{{ $moment(currentTime).format("YYYY-MM-DD HH:mm:ss") }}</span>
        </div>
        <!-- 用户名下拉菜单 -->
        <el-dropdown class="user-name" trigger="click" @command="handleCommand">
          <span class="el-dropdown-link">
            {{ userName }}
            <!-- 系统 -->
            <i class="el-icon-caret-bottom"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <!-- <el-dropdown-item command="changePwd"> 修改密码</el-dropdown-item> -->
            <el-dropdown-item command="loginout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script>
import vSidebar from "./Sidebar.vue";
// import passwordDialog from "../components/passwordDialog.vue";
export default {
  components: {
    vSidebar,
    // passwordDialog,
  },
  data() {
    return {
      currentTime: null,
      userName: localStorage.getItem("userName"),
      role: localStorage.getItem("role"),
    };
  },
  methods: {
    // 用户名下拉菜单选择事件
    handleCommand(command) {
      switch (command) {
        case "noticeShow": //公告
          console.log(command);
          break;
        case "changePwd": //修改密码
          this.$refs.passwordref.display();
          break;
        case "loginout": //退出登录
          this.$message({
            duration: 1500,
            showClose: true,
            message: "退出成功",
            type: "success",
          });
          this.$store.commit("REMOVE_INFO");
          this.$router.push("/login");
          break;
      }
    },
  },
  created() {},
  mounted() {
    this.currentTime = new Date();
    setInterval(() => {
      this.currentTime = new Date();
    }, 1000);
  },
};
</script>
<style lang="less">
.header {
  width: 100%;
  height: 52px;
  box-sizing: border-box;
  background: #169e8c;
  -webkit-backdrop-filter: blur(0.41667vw);
  backdrop-filter: blur(0.41667vw);
  line-height: 52px;
  padding: 0px 16px;
  display: flex;
  .leftLogo {
    display: flex;
    align-items: center;
    justify-content: center;
    img {
      margin-right: 16px;
    }
    p {
      font-size: 16px;
      color: #fff;
      height: 40px;
      line-height: 40px;
      overflow: hidden;
    }
  }
  .menuBox {
    flex: 1;
    display: flex;
    justify-content: space-between;
    margin: 0px 32px;
  }
  .userInfo {
    .header-user-con {
      display: flex;
      height: 52px;
      align-items: center;
      .user-avator {
        margin-left: 16px;
        height: 40px;
        line-height: 40px;
        overflow: hidden;
        // img {
        //   display: block;
        //   width: 40px;
        //   height: 40px;
        //   border-radius: 50%;
        // }
        span {
          color: #fff;
          font-size: 14px;
          margin-right: 8px;
        }
      }
      .user-name {
        margin-left: 8px;
        height: 40px;
        line-height: 40px;
        overflow: hidden;
        .el-dropdown-link {
          color: #fff;
          cursor: pointer;
        }
      }

      .el-select {
        width: 90px;
      }
    }
  }
}
</style>
