<style>
.nav-right {
  height: 100%;
  margin: 0 30px;
  display: flex;
  font-family: perfectFont;
  user-select: none;
}
.nav-right .nav-right-menu,
.nav-right .nav-right-info {
  display: flex;
  align-items: center;
  height: 100%;
  flex: 1;
}
.nav-right .nav-right-menu ul {
  padding: 0;
  margin: 0;
  display: flex;
  width: 100%;
  height: 100%;
}
.nav-right .nav-right-menu ul li {
  line-height: 56px;
  display: inline-block;
  border-bottom: 3px solid rgba(13, 36, 129, 0);
  margin: 0 20px;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  font-family: perfectFont;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-right .nav-right-menu ul li:first-child {
  margin-left: 0px;
}
.nav-right .nav-right-menu ul li.active {
  color: #409efe;
  border-bottom-color: #409efe;
  font-family: pingfangR;
}
.nav-right .nav-right-menu ul li i {
  font-size: 16px;
  margin-right: 5px;
}
.nav-right .nav-right-info {
  flex: unset;
  width: 240px;
  justify-content: flex-end;
  
}
.nav-right .nav-right-info .right-item {
  text-align: right;
  padding-left: 20px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
}
/* .nav-right .nav-right-info .right-item:last-child{
    margin: 0px;
} */
.nav-right .nav-right-info .right-item img {
  width: 34px;
  height: 34px;
  border-radius: 100%;
}
.nav-right .nav-right-info .right-item .welcomne-txt {
  font-size: 12px;
  color: #bbb;
  margin-right: 5px;
  white-space: nowrap;
}
.nav-right .nav-right-info .right-item .usr-name {
  font-size: 16px;
  font-weight: bold;
  color: black;
  white-space: nowrap;
}
.nav-right .nav-right-info .right-item i {
  font-size: 20px;
  color: #409efe;
}
</style>
<template>
  <div class="nav-right">
    <div class="nav-right-menu">
      <ul>
        <li :class="{'active':chosenMenuId==item.MenuId}" v-for="(item, index) in menuList[0].ChildMenu" :key="index" @click="chosenFirstLeaveMenu(item, index)">
          <i class="iconfont" :class="[item.MenuStyle ? JSON.parse(item.MenuStyle).icon : '']"></i>{{item.MenuName}}
        </li>
      </ul>
    </div>
    <div class="nav-right-info">
      <div class="right-item">
        <i class="iconfont iconmessage"></i>
      </div>
      <div class="right-item">
        <span class="welcomne-txt">Good Job,</span>
        <span class="usr-name">{{userInfo.EmName}}</span>
      </div>
      <div class="right-item">
        <el-popover
          placement="top"
          width="160"
          trigger="click"
          v-model="visible">
          <ul style="padding:0;margin:0;display:block;">
            <li style="padding:0;margin:0;color:#000;cursor: pointer;" @click="signout">
              <i class="iconfont icontuichu"></i>
              退出
            </li>
          </ul>
          <el-avatar slot="reference" :size="34" :src="userInfo.Icon" style="background:#409efe;" @error="errorHandler">
            {{userInfo.EmName.substring(0,1)}}
          </el-avatar>
        </el-popover>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      activeIndex: 0,
      value: 0,
      menuList: [{ ChildMenu: [] }],
      chosenMenuId: 0,
      userInfo: {
        EmName: "",
        Icon: "",
      },
      visible: false,
    };
  },
  mounted() {
    let userInfo = this.getLocalStorage();
    this.userInfo = userInfo;
    this.menuList = userInfo.UserMenu;
    this.chosenMenuId = userInfo.UserMenu[0].ChildMenu[0].MenuId;
  },
  methods: {
    chosenFirstLeaveMenu(item, index) {
      this.chosenMenuId = item.MenuId;
      this.MsgBus.$emit("setLeftNav", index);
      this.$router.push({
        path: item.ChildMenu[0].MenuUrl,
      });
    },
    errorHandler() {
      return true;
    },
    signout() {
      window.localStorage.removeItem("userInfo");
      this.$router.push("/login");
    },
  },
};
</script>
