Navbar.vue 4.75 KB
<template>
  <div class="navbar-con">
    <div class="navbar">
      <div class="title">
        {{ logoName[0] && logoName[0].DNAME }}
      </div>
      <div class="user">
        欢迎进入系统 {{ userName }}
        <span @click="onCancel">
          <svg-icon icon-class="close" class="closeStyle" />退出系统</span>
      </div>
      <div class="sidebarLeft">
        <sidebarLeft />
      </div>
      <div class="sidebarRight d-center">
        <sidebarRight />
      </div>
    </div>
  </div>
</template>
<script>
import sidebarLeft from "./Sidebar/sidebarLeft";
import sidebarRight from "./Sidebar/sidebarRight";
import { logout } from "@/api/login.js";
import { mapGetters } from "vuex";
export default {
  components: {
    sidebarLeft,
    sidebarRight,
  },
  computed: {
    ...mapGetters(["sidebar", "dicData", , "permission_routes", "userInfo"]),
    logoName () {
      return this.dicData['sysCode'] && this.dicData['sysCode'].filter(item =>
        item.DCODE == "systemTitle"
      )
    },
    userName () {
      return this.userInfo ? this.userInfo.name : ""
    }
  },
  methods: {
    onCancel () {
      logout()
        .then((res) => {
          sessionStorage.removeItem("token");
          this.$store.dispatch("user/resetState");
          this.$store.dispatch("permission/resetRoutes");
          this.$router.replace({
            path: "/jg",
            query: {
              redirect: this.$route.fullPath,
            },
          });
        })
        .catch((error) => {
          // console.dir(error);
        })
    }
  }
};
</script>
<style lang="scss" scoped>
.menubg {
  height: 34px;
  width: 130px !important;
  text-align: center;
  color: #ffffff;
  background: url("~@/image/navbar.png") no-repeat;
  background-size: 100% 100%;
}

/deep/.el-menu-item {
  @extend .menubg;
}

/deep/.el-submenu {
  @extend .menubg;
}

/deep/.el-submenu__title {
  height: 34px;
  color: #ffffff;
}

/deep/.el-submenu__title span {
  font-size: 14px;
}

.sidebarLeft {
  position: relative;
  top: 13px;
  width: 30%;
}

/deep/.el-menu {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background: transparent !important;
}

/deep/.el-menu-item {
  flex: 1;
  width: 100%;
}

.sidebarRight {
  position: relative;
  top: 13px;
  width: 30%;
}

// 导航选中背景色
.xuanzhong {
  background: url("~@/image/selNavbar.png") no-repeat;
  background-size: 100% 100%;
  color: #ffffff !important;
  font-weight: 700;
}

/deep/.el-menu-item:hover {
  @extend .xuanzhong;
}

/deep/.el-submenu__title:hover {
  @extend .xuanzhong;
}

/deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus {
  @extend .xuanzhong;
}

/deep/.is-active {
  @extend .xuanzhong;
}

.navbar {
  height: $headerHeight;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 20px;
  justify-content: space-between;
  background: url("~@/image/header.png") no-repeat;
  background-size: 100% 100%;

  .user {
    font-size: 12px;
    color: #ffffff;
    position: absolute;
    right: 20px;
    top: 0;
    cursor: pointer;

    .closeStyle {
      margin-right: 5px;
    }
  }

  .title {
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 0;
    right: 0;
    margin: 0 auto;
    font-size: 32px;
    color: #ffffff;
    font-weight: 700;
    text-align: center;
  }

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;
    display: flex;
    align-items: center;

    .shutdown {
      font-size: 20px;
      margin-left: 15px;
      cursor: pointer;
    }

    .organization-item {
      margin-right: 40px;
      margin-top: -40px !important;
    }

    .item {
      margin-right: 40px;
      margin-top: -20px;
      line-height: 18.4px;
      cursor: pointer;
      position: relative;

      .item-box {
        position: absolute;
        top: -5px;
        left: 3px;
        width: 100%;
        min-width: 25px;
        height: 25px;
        cursor: pointer;
        z-index: 100;
      }
    }

    &:focus {
      outline: none;
    }

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

      &.hover-effect {
        cursor: pointer;
        transition: background 0.3s;
        display: flex;
        align-items: center;

        &:hover {
          background: rgba(0, 0, 0, 0.025);
        }
      }
    }

    .avatar-wrapper {
      position: relative;
      display: flex;
      height: 40px;
      align-items: center;

      .user-avatar {
        cursor: pointer;
        width: 35px;
        height: 35px;
        border-radius: 50%;
      }

      .el-icon-caret-bottom {
        cursor: pointer;
        position: absolute;
        right: -15px;
        top: 17px;
        font-size: 12px;
      }
    }
  }
}
</style>