2025-08-29 12:06:02 +08:00
|
|
|
<template>
|
2025-08-29 14:57:13 +08:00
|
|
|
<div class="main">
|
2025-09-11 16:14:55 +08:00
|
|
|
<div class="header">
|
|
|
|
|
<span class="time">
|
|
|
|
|
<span class="text" style="margin-right: 15px"> {{ dateVal }} </span>
|
|
|
|
|
<span class="text" style="width: 80px;">{{ currentTime }}</span>
|
|
|
|
|
<span class="text">{{ weekVal }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class="title text"> 能源站监控与运行管理系统 </span>
|
|
|
|
|
<span class="user">
|
|
|
|
|
<span style="margin-right: 15px"> {{ user }}</span>
|
|
|
|
|
<span class="iconfont icon-tuichu" @click="logout"></span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
2025-09-01 16:55:44 +08:00
|
|
|
|
2025-08-29 15:48:33 +08:00
|
|
|
<div class="page">
|
2025-09-01 16:55:44 +08:00
|
|
|
<div class="subMenu" v-if="subMenu.length > 0">
|
|
|
|
|
<div
|
|
|
|
|
class="subItem"
|
|
|
|
|
v-for="subItem in subMenu"
|
|
|
|
|
:key="subItem.name"
|
|
|
|
|
@click="subMenuClick(subItem)"
|
|
|
|
|
:class="subCurrentKey == subItem.path ? 'active' : ''"
|
|
|
|
|
>
|
|
|
|
|
{{ subItem.title }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div :class="[subMenu.length > 0 ? 'subcontent' : 'content']">
|
2025-09-09 09:33:14 +08:00
|
|
|
<router-view />
|
2025-09-01 16:55:44 +08:00
|
|
|
</div>
|
2025-08-29 15:48:33 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="menu">
|
2025-09-01 16:55:44 +08:00
|
|
|
<div
|
|
|
|
|
v-for="menu in menuList"
|
|
|
|
|
:key="menu.name"
|
|
|
|
|
class="menu-item"
|
|
|
|
|
@click="menuClick(menu)"
|
|
|
|
|
:class="currentKey == menu.path ? 'active' : ''"
|
|
|
|
|
>
|
2025-08-29 15:48:33 +08:00
|
|
|
<i :class="menu.icon"></i>
|
|
|
|
|
{{ menu.name }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-08-29 12:06:02 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
// @ is an alias to /src
|
2025-09-11 16:14:55 +08:00
|
|
|
import moment from 'moment'
|
|
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
|
|
|
|
import { createVNode } from 'vue'
|
2025-08-29 12:06:02 +08:00
|
|
|
export default {
|
2025-08-29 15:48:33 +08:00
|
|
|
name: 'MainView',
|
2025-08-29 12:28:33 +08:00
|
|
|
components: {},
|
2025-08-29 15:48:33 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
2025-09-01 16:55:44 +08:00
|
|
|
currentKey: '',
|
|
|
|
|
subCurrentKey: '',
|
2025-08-29 15:48:33 +08:00
|
|
|
menuList: [
|
|
|
|
|
{
|
|
|
|
|
name: '系统总览',
|
2025-09-09 09:33:14 +08:00
|
|
|
path: '/home'
|
2025-08-29 15:48:33 +08:00
|
|
|
},
|
2025-09-01 16:55:44 +08:00
|
|
|
{
|
|
|
|
|
name: '运行监控',
|
2025-09-04 13:42:48 +08:00
|
|
|
path: '/monitor'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '预测管理',
|
|
|
|
|
path: '/predict'
|
2025-09-02 17:05:10 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '统计分析',
|
2025-09-04 13:42:48 +08:00
|
|
|
path: '/statisticalAnalysis'
|
2025-09-01 16:55:44 +08:00
|
|
|
},
|
2025-08-29 15:48:33 +08:00
|
|
|
{
|
|
|
|
|
name: '系统管理',
|
2025-09-01 16:55:44 +08:00
|
|
|
path: '/system',
|
2025-08-29 15:48:33 +08:00
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
name: '用户管理',
|
2025-09-01 16:55:44 +08:00
|
|
|
path: '/user'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '角色管理',
|
|
|
|
|
path: '/role'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '权限管理',
|
|
|
|
|
icon: 'icon-caidanguanli'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '场站管理',
|
2025-09-05 16:40:35 +08:00
|
|
|
path: '/station',
|
2025-09-01 16:55:44 +08:00
|
|
|
icon: 'icon-caidanguanli'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '服务管理',
|
|
|
|
|
icon: 'icon-bumenguanli'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '策略管理',
|
|
|
|
|
path: '/policy'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '设备管理',
|
2025-09-09 09:39:15 +08:00
|
|
|
path: '/device '
|
2025-09-01 16:55:44 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '告警日志',
|
2025-09-10 09:23:47 +08:00
|
|
|
path: '/alarmlog'
|
2025-09-01 16:55:44 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '系统日志',
|
2025-09-09 09:39:15 +08:00
|
|
|
path: '/syslog'
|
2025-08-29 15:48:33 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
],
|
2025-09-11 16:14:55 +08:00
|
|
|
subMenu: [],
|
|
|
|
|
currentTime: '',
|
|
|
|
|
timer: null,
|
|
|
|
|
dateVal: moment().locale('zh-cn').format('ll') + ' ',
|
|
|
|
|
weekVal: moment().locale('zh-cn').format('dddd'),
|
|
|
|
|
user:localStorage.getItem('account').replace(/^"|"$/g, '')
|
2025-09-01 16:55:44 +08:00
|
|
|
}
|
|
|
|
|
},
|
2025-09-09 09:33:14 +08:00
|
|
|
watch: {
|
|
|
|
|
$route: {
|
|
|
|
|
handler(n) {
|
2025-09-11 16:14:55 +08:00
|
|
|
console.log(n, 'nnnnnnnnnnnnnn')
|
|
|
|
|
this.subMenu = n.matched[1].children || []
|
2025-09-09 09:33:14 +08:00
|
|
|
},
|
|
|
|
|
immediate: true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2025-09-01 16:55:44 +08:00
|
|
|
mounted() {
|
|
|
|
|
this.initRoute()
|
2025-09-11 16:14:55 +08:00
|
|
|
this.getDateTime()
|
|
|
|
|
this.timer = setInterval(() => {
|
|
|
|
|
this.getDateTime()
|
|
|
|
|
}, 1000)
|
|
|
|
|
},
|
|
|
|
|
unmounted() {
|
|
|
|
|
clearInterval(this.timer)
|
2025-09-01 16:55:44 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2025-09-11 16:14:55 +08:00
|
|
|
logout(){
|
|
|
|
|
const that=this
|
|
|
|
|
this.$Modal.confirm({
|
|
|
|
|
title: '你确认退出系统吗?',
|
|
|
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
|
|
|
|
|
|
|
|
async onOk() {
|
|
|
|
|
localStorage.clear()
|
|
|
|
|
that.$router.push('/login')
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
},
|
|
|
|
|
class: 'test'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//getDateTime
|
|
|
|
|
getDateTime() {
|
|
|
|
|
this.currentTime = moment().locale('zh-cn').format('LTS')
|
|
|
|
|
},
|
2025-09-09 09:33:14 +08:00
|
|
|
// 过滤函数:根据权限数据过滤路由并附加权限信息
|
|
|
|
|
filterRoutes(routes, permissions) {
|
|
|
|
|
return routes.filter((route) => {
|
|
|
|
|
let hasViewPermission = false
|
|
|
|
|
// 查找当前路由对应的权限项
|
|
|
|
|
const routePermissions = permissions.filter((perm) => perm.route === route.path)
|
|
|
|
|
|
|
|
|
|
// 如果有权限项,附加到路由对象
|
|
|
|
|
if (routePermissions.length > 0) {
|
2025-09-11 16:14:55 +08:00
|
|
|
route.permissions = routePermissions
|
2025-09-09 09:33:14 +08:00
|
|
|
hasViewPermission = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查是否有查看权限
|
|
|
|
|
// const hasViewPermission = routePermissions.some((perm) =>
|
|
|
|
|
// perm.is_view === '1'
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// 递归处理子路由
|
|
|
|
|
if (route.children && route.children.length) {
|
|
|
|
|
route.children = this.filterRoutes(route.children, permissions)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保留有权限的路由或包含有效子路由的父路由
|
|
|
|
|
return hasViewPermission || (route.children && route.children.length)
|
|
|
|
|
})
|
|
|
|
|
},
|
2025-09-01 16:55:44 +08:00
|
|
|
initRoute() {
|
2025-09-09 10:00:01 +08:00
|
|
|
console.log(localStorage.getItem('permission'), "localStorage.getItem('permission')")
|
2025-09-09 09:33:14 +08:00
|
|
|
// 执行过滤
|
2025-09-09 09:52:52 +08:00
|
|
|
// const filteredRoutes = this.filterRoutes(
|
|
|
|
|
// this.menuList,
|
2025-09-09 10:00:01 +08:00
|
|
|
// JSON.parse(localStorage.getItem('permission'))
|
2025-09-09 09:52:52 +08:00
|
|
|
// )
|
2025-09-11 16:14:55 +08:00
|
|
|
console.log(this.$route.matched, 'filteredRoutes')
|
2025-09-01 16:55:44 +08:00
|
|
|
this.subMenu = this.$route.matched[1].children || []
|
2025-09-09 10:00:01 +08:00
|
|
|
// this.menuList= JSON.parse(localStorage.getItem('permission'))
|
2025-09-09 09:33:14 +08:00
|
|
|
// this.subMenu =filteredRoutes[0].children||[]
|
2025-09-01 16:55:44 +08:00
|
|
|
|
|
|
|
|
this.currentKey = '/' + this.$route.fullPath.split('/')[1]
|
|
|
|
|
this.subCurrentKey = this.$route.fullPath.split('/')[2]
|
|
|
|
|
console.log(this.subCurrentKey)
|
|
|
|
|
},
|
|
|
|
|
menuClick(menu) {
|
|
|
|
|
this.currentKey = menu.path
|
|
|
|
|
this.subMenu = menu.children || []
|
|
|
|
|
this.$router.push(menu.path)
|
|
|
|
|
},
|
|
|
|
|
subMenuClick(subMenu) {
|
2025-09-09 09:33:14 +08:00
|
|
|
console.log(subMenu, subMenu.path)
|
2025-09-01 16:55:44 +08:00
|
|
|
this.subCurrentKey = subMenu.path
|
2025-09-11 16:14:55 +08:00
|
|
|
this.$router.push('/system' + subMenu.path)
|
2025-08-29 15:48:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-29 12:06:02 +08:00
|
|
|
</script>
|
2025-08-29 15:48:33 +08:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.main {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background-image: url('@/assets/images/mainBg.png');
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
.header {
|
2025-08-29 15:48:33 +08:00
|
|
|
width: 100%;
|
2025-09-01 16:55:44 +08:00
|
|
|
height: 70px;
|
2025-09-11 16:14:55 +08:00
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 0 20px;
|
|
|
|
|
.text {
|
|
|
|
|
background: linear-gradient(
|
|
|
|
|
180deg,
|
|
|
|
|
rgb(255, 255, 255) 0%,
|
|
|
|
|
rgb(227, 254, 255) 33.17%,
|
|
|
|
|
rgb(35 190 195) 100%
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
-webkit-background-clip: text; /* 兼容 WebKit 浏览器 */
|
|
|
|
|
background-clip: text;
|
|
|
|
|
color: transparent; /* 必须设置为透明 */
|
|
|
|
|
display: inline-block; /* 确保背景裁剪生效 */
|
|
|
|
|
line-height: 80px;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
}
|
|
|
|
|
.title{
|
|
|
|
|
font-size: 40px;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 50%;
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
.user{
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
.icon-tuichu{
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
.time{
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
}
|
2025-08-29 15:48:33 +08:00
|
|
|
}
|
2025-09-01 16:55:44 +08:00
|
|
|
.subMenu {
|
|
|
|
|
display: flex;
|
|
|
|
|
color: #fff;
|
2025-09-05 09:26:14 +08:00
|
|
|
// margin-left: 10px;
|
2025-09-01 16:55:44 +08:00
|
|
|
padding-bottom: 20px;
|
|
|
|
|
.subItem {
|
|
|
|
|
width: 96px;
|
|
|
|
|
height: 36px;
|
|
|
|
|
line-height: 36px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
background: #132347;
|
|
|
|
|
|
|
|
|
|
border: 1px solid #2169c3;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
margin-right: 15px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.active {
|
|
|
|
|
background: #27a188;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.page {
|
2025-08-29 15:48:33 +08:00
|
|
|
width: calc(100% - 20px);
|
2025-09-10 09:23:47 +08:00
|
|
|
height: calc(100% - 70px - 60px - 40px);
|
2025-09-01 16:55:44 +08:00
|
|
|
margin: 20px 10px;
|
2025-08-29 15:48:33 +08:00
|
|
|
border-radius: 20px;
|
2025-09-01 16:55:44 +08:00
|
|
|
}
|
2025-09-09 09:33:14 +08:00
|
|
|
.content {
|
2025-09-01 16:55:44 +08:00
|
|
|
height: 100%;
|
|
|
|
|
}
|
2025-09-09 09:33:14 +08:00
|
|
|
.subcontent {
|
2025-09-11 16:14:55 +08:00
|
|
|
height: calc(100% - 56px);
|
2025-08-29 15:48:33 +08:00
|
|
|
}
|
|
|
|
|
.menu {
|
|
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
2025-09-10 09:23:47 +08:00
|
|
|
bottom: 10px;
|
|
|
|
|
height: 50px;
|
2025-08-29 15:48:33 +08:00
|
|
|
// height: 150px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
.menu-item {
|
|
|
|
|
width: 120px;
|
|
|
|
|
height: 47px;
|
|
|
|
|
line-height: 47px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
background: #04608e;
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
font-weight: 700;
|
2025-09-11 16:14:55 +08:00
|
|
|
border: 1px solid #ffffff00;
|
2025-09-01 16:55:44 +08:00
|
|
|
cursor: pointer;
|
2025-09-09 09:33:14 +08:00
|
|
|
margin: 0 35px;
|
2025-09-01 16:55:44 +08:00
|
|
|
}
|
|
|
|
|
.active {
|
|
|
|
|
border: 1px solid $border-color;
|
|
|
|
|
color: #01b3cd;
|
2025-08-29 15:48:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|