| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <template>
- <div class="box-item">
- <el-menu
- class="el-menu-vertical-demo"
- text-color="#fff"
- :default-active="activeIndex"
- :collapse="menuClose"
- @select="handleSelect"
- :router="true"
- >
- <!-- :default-openeds="[34]" -->
- <div class="logo el-menu-item">
- <el-icon :size="20"
- ><img src="@/assets/images/logo.png" style="width: 40px; height: 40px"
- /></el-icon>
- </div>
- <el-menu-item :index="`/process/${item.name}`" v-for="item in roleList" :key="item.name">
- <div class="itemSon">
- <SvgIcon :icon="item.meta.icon" :size="22" />
- <span>{{ item.meta.title }}</span>
- </div>
- </el-menu-item>
- </el-menu>
- </div>
- </template>
- <script setup>
- import { ref, onBeforeMount, onMounted, watch, reactive } from "vue";
- import { useStore } from "vuex";
- import { useRouter } from "vue-router";
- const store = useStore();
- const router = useRouter();
- const roleList = ref();
- const menuClose = ref(false);
- const activeIndex = ref('/process/user');
- const acitveItems = reactive({ list: [] });
- watch(
- () => store.state.user.collapse,
- (newValue, oldValue) => {
- menuClose.value = newValue;
- }
- );
- watch(
- () => router.currentRoute.value.fullPath,
- (newValue, oldValue) => {
- console.log(newValue);
- store.commit("indexUp", newValue);
- activeIndex.value = newValue;
- }
- );
- const handleSelect = (key, keyPath) => {
- // store.commit("indexUp", key);
- // activeIndex.value = key;
- // sessionStorage.setItem("sidevarItem", key);
- console.log(key, keyPath);
- router.push({
- path: `${key}`,
- });
- activeIndex.value = key;
- store.commit("indexUp", key);
- // if (activeIndex.value == 1) {
- // router.push({
- // path: `/jianguanCloud/order`,
- // });
- // }
- };
- onBeforeMount(() => {
- activeIndex.value = sessionStorage.getItem("sidevarItem");
- roleList.value = store.state.user.roleList;
- });
- </script>
- <style lang="scss" scoped>
- .el-menu-vertical-demo:not(.el-menu--collapse) {
- width: 220px;
- // min-height: 400px;
- }
- .box-item {
- width: 220px;
- height: calc(100vh);
- }
- .el-menu {
- width: 220px;
- height: 100%;
- overflow: auto;
- // background: rgba(55, 105, 173, 1);
- background: rgba(46, 64, 89, 1);
- box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.16);
- border: none;
- .logo {
- height: 64px;
- color: rgb(255, 255, 255);
- cursor: default;
- display: flex;
- justify-content: space-around;
- align-items: center;
- border-bottom: 1px solid rgba(255, 255, 255, 0.2);
- }
- .logo:hover {
- background-color: transparent !important;
- }
- .itemSon {
- width: 180px;
- height: 40px;
- border-radius: 10px;
- display: flex;
- // justify-content: space-around;
- align-items: center;
- // background: linear-gradient(
- // 90deg,
- // rgba(38, 151, 255, 1) 0%,
- // rgba(102, 182, 255, 1) 100%
- // );
- .svg-icon{
- margin:0 15px;
- }
- }
- .el-sub-menu {
- padding: 8px 0;
- .el-menu-item {
- padding: 0;
- background: rgba(46, 64, 89, 1);
- color: #fff;
- display: flex;
- justify-content: center;
- .img {
- width: 18px;
- margin: 0 20px;
- }
- .itemSon:hover {
- background: rgba(55, 105, 173, 1);
- color: rgba(99, 180, 255, 1);
- }
- }
- .el-menu-item:hover {
- background: rgba(46, 64, 89, 1);
- color: #fff;
- .itemSon {
- background: rgba(55, 105, 173, 1);
- color: rgba(99, 180, 255, 1);
- }
- }
- .el-menu-item.is-active {
- .itemSon {
- background: rgba(55, 105, 173, 1);
- color: rgba(99, 180, 255, 1);
- }
- }
- // 系统设置栏样式
- :deep(.el-sub-menu__title) {
- padding: 0;
- margin: 0 auto;
- width: 180px;
- height: 40px;
- border-radius: 10px;
- display: flex;
- align-items: center;
- background: rgba(55, 105, 173, 1);
- color: #fff;
- .el-icon {
- width: 18px;
- }
- }
- }
- .el-sub-menu.is-active {
- :deep(.el-sub-menu__title) {
- background: linear-gradient(
- 90deg,
- rgba(38, 151, 255, 1) 0%,
- rgba(102, 182, 255, 1) 100%
- );
- color: fff;
- }
- }
- // 单个菜单项样式
- .el-menu-item {
- padding: 10px 0 !important;
- display: flex;
- justify-content: center;
- }
- .el-menu-item:hover {
- background: rgba(46, 64, 89, 1);
- .itemSon {
- background: rgba(55, 105, 173, 1);
- color: rgba(99, 180, 255, 1);
- }
- }
- .el-menu-item.is-active {
- .itemSon {
- background: linear-gradient(
- 90deg,
- rgba(38, 151, 255, 1) 0%,
- rgba(102, 182, 255, 1) 100%
- );
- color: #fff;
- }
- }
- }
- </style>
|