Files
recom-gorse/web/src/views/Index.vue

339 lines
7.7 KiB
Vue
Raw Normal View History

2023-05-09 17:53:58 +08:00
<template>
<div id="menuBox">
<div class="header-box">
<div class="logo">{{ title }}</div>
<div class="info-box">
<div class="btn-logout" @click="logout()">注销</div>
<div class="user-name-label">{{ info.userName }}</div>
</div>
</div>
<div class="menu-box">
<el-menu :default-active="activeIndex" class="el-menu-vertical-demo">
<template v-for="item in menuList">
<el-submenu :index="item.index" :key="item.index" v-if="item.list"
v-show="permission.indexOf(item.index) >= 0">
<template slot="title">
<i :class="item.icon"></i>
<span>{{ item.name }}</span>
</template>
<el-menu-item-group>
<el-menu-item :index="menu.index" v-for="menu in item.list" v-show="permission.indexOf(menu.index) >= 0"
:key="menu.index" @click="gotoMenu(menu)">{{ menu.name }}
</el-menu-item>
</el-menu-item-group>
</el-submenu>
<el-menu-item :index="item.index" v-if="!item.list" :key="item.index" @click="gotoMenu(item)"
v-show="permission.indexOf(item.index) >= 0">
<i :class="item.icon"></i>
<span slot="title">{{ item.name }}</span>
</el-menu-item>
</template>
</el-menu>
</div>
<div class="content-box">
<router-view ref="routeNode"></router-view>
</div>
</div>
</template>
<script>
import {getMenuList} from "../utils/menu";
import {title} from "@/settings";
import request from '@/utils/request';
var _this;
export default {
name: "Menu",
data() {
return {
title: title,
activeMenu: '',
menuList: [],
info: {},
activeIndex: '',
permission: ['1', '1-1', '1-2', '1-3', '2', '2-1', '2-2', '21', '21-1', '21-2', '22', '23', '24',
'3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '16-1', '16-2', '16-3', '16-4', '16-5', '16-6'],
}
},
mounted() {
_this = this;
_this.activeMenu = this.$route.path == "/" ? "/graphModel" : this.$route.path;
_this.queryInfo();
},
methods: {
gotoMenu(item) {
if (this.activeMenu != item.url) {
this.activeMenu = item.url;
this.$router.push({path: item.url, query: {}})
}
},
queryInfo() {
_this.menuList = getMenuList();
// request({
// url: "/admin/info_admin",
// method: 'post',
// data: {}
// }).then(res => {
// _this.info = res.data;
// if (_this.info.permissions == undefined || _this.info.permissions == null || _this.info.permissions == '') {
// _this.menuList = [];
// } else {
// _this.permission = _this.info.permissions.split(",");
// _this.menuList = getMenuList();
// }
// _this.initActiveIndex();
// });
_this.initActiveIndex();
},
initActiveIndex() {
this.activeIndex = null;
this.menuList.forEach(item => {
if (item.url && item.url == this.activeMenu) {
this.activeIndex = item.index;
}
if (item.list) {
item.list.forEach(menu => {
if (menu.url == this.activeMenu) {
this.activeIndex = menu.index;
}
})
}
});
if (this.activeIndex == null) {
if (this.menuList[0].url != undefined) {
this.$router.push({path: this.menuList[0].url, query: {}})
} else {
this.$router.push({path: this.menuList[0].list[0].url, query: {}})
}
}
},
logout() {
this.$store.dispatch('user/logout');
this.$router.push('/login');
}
}
}
</script>
<style lang="scss">
#menuBox {
height: 100%;
overflow: hidden;
width: 100%;
.header-box {
height: 60px;
width: 100%;
box-shadow: 0px 1px 4px 0px rgba(0, 21, 41, 0.12);
overflow: hidden;
color: #0070f7;
.logo {
float: left;
width: 50%;
overflow: hidden;
height: 100%;
line-height: 60px;
font-size: 24px;
padding-left: 30px;
/*font-weight: bold;*/
}
.info-box {
height: 60px;
float: right;
color: #ffffff;
.head-img {
height: 30px;
width: 30px;
border-radius: 100%;
overflow: hidden;
float: right;
margin-top: 20px;
border: 1px solid rgb(233, 233, 233);
}
.user-name-label {
height: 100%;
font-size: 16px;
color: rgb(170, 170, 170);
margin-left: 20px;
float: right;
line-height: 70px;
}
.btn-logout {
border-radius: 5px;
/*border: 1px solid rgb(167, 210, 249);*/
color: rgb(0, 153, 255);
background-color: rgba(236, 245, 255, 1);
margin-left: 15px;
margin-top: 20px;
margin-right: 20px;
float: right;
padding: 6px 10px;
cursor: pointer;
}
}
}
.system-menu-box {
display: flex;
background: #1652D5;
}
.system-menu-box > div {
display: inline;
padding: 10px 10px;
height: 30px;
line-height: 30px;
font-size: 18px;
text-align: center;
cursor: pointer;
color: #fff;
margin: 10px 0px 0px 50px;
border-bottom: 5px solid rgba(255, 208, 75, 0);
}
.system-menu-box > div:first-child {
margin-left: 20px;
}
.system-menu-box > div:hover, .system-menu-box > div.active {
border-bottom: 5px solid rgb(255, 208, 75);
}
.el-menu-item-group__title {
background: #1652D5 !important;
padding: 0px !important;
}
.el-menu {
border: 0px;
}
.el-menu-item-group {
.el-menu-item {
color: rgba(175, 169, 169, 0.76);
}
.el-menu-item.is-active {
color: #fff !important;
}
}
.el-menu-item-group:hover {
background: #eeeeee;
color: #fff !important;
}
.menu-box {
width: 290px;
height: calc(100% - 60px);
background: #2780ff;
float: left;
overflow-y: auto;
.system-title {
height: 70px;
line-height: 70px;
font-size: 22px;
font-weight: bold;
color: #FFFFFF;
text-align: center;
background: #2780ff;
}
ul {
background: rgba(42, 70, 170, 0.3);
.el-menu-item:hover {
background: #1c4ec8;
}
.el-menu-item.is-active {
background: #1c4ec8;
color: #ffffff;
span {
color: #ffffff;
}
}
.el-submenu.is-active .el-submenu__title i, .el-submenu.is-active .el-submenu__title span {
color: #ffffff !important;
}
li {
.el-menu {
background: #1652D5;
li {
background: #1652D5;
}
}
span {
color: rgba(255, 255, 255, 0.76);
}
i {
color: rgba(255, 255, 255, 0.76);
}
.el-submenu__title {
i {
color: rgba(255, 255, 255, 0.76);
}
span {
color: rgba(255, 255, 255, 0.76);
}
}
}
li:hover {
.el-submenu__title {
background: rgba(0, 0, 0, 0);
}
}
}
}
.content-box {
float: left;
width: calc(100% - 15.10417vw);
height: 100%;
display: block;
background: #F0F2F5;
//background: rgb(240, 242, 245);
.menu-title {
width: 100%;
/*background: #FFFFFF;*/
height: 68px;
line-height: 68px;
/*border-top: 1px solid rgb(233, 233, 233);*/
/*border-bottom: 1px solid rgb(233, 233, 233);*/
padding: 0 30px;
font-size: 18px;
font-weight: bold;
color: #4E5054;
}
}
.content-box > div {
width: 100%;
}
}
</style>