2026-05-15 18:18:51 +08:00
|
|
|
<template>
|
|
|
|
|
<div :class="['sidebar-container', { 'is-collapse': !sidebar.opened }]">
|
|
|
|
|
<div class="sidebar-header">
|
|
|
|
|
<div class="logo-wrapper">
|
|
|
|
|
<span class="logo-icon">📊</span>
|
|
|
|
|
<span v-show="sidebar.opened" class="logo-text">数据管理平台</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<el-scrollbar class="sidebar-scroll">
|
|
|
|
|
<el-menu
|
|
|
|
|
:default-active="activeMenu"
|
|
|
|
|
:collapse="!sidebar.opened"
|
2026-05-17 17:24:43 +08:00
|
|
|
:collapse-transition="false"
|
2026-05-15 18:18:51 +08:00
|
|
|
mode="vertical"
|
|
|
|
|
class="sidebar-menu"
|
|
|
|
|
router
|
|
|
|
|
unique-opened
|
|
|
|
|
>
|
|
|
|
|
<template v-for="item in menuItems" :key="item.path">
|
|
|
|
|
<el-menu-item v-if="!item.children || item.children.length === 0" :index="item.path">
|
|
|
|
|
<el-icon :size="14"><component :is="getIcon(item.meta?.icon)" /></el-icon>
|
|
|
|
|
<span>{{ item.meta?.title }}</span>
|
|
|
|
|
</el-menu-item>
|
|
|
|
|
<el-sub-menu v-else :index="item.path">
|
|
|
|
|
<template #title>
|
|
|
|
|
<el-icon :size="14"><component :is="getIcon(item.meta?.icon)" /></el-icon>
|
|
|
|
|
<span>{{ item.meta?.title }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-for="child in item.children" :key="child.path">
|
|
|
|
|
<el-menu-item v-if="!child.children || child.children.length === 0" :index="child.path">
|
|
|
|
|
<el-icon :size="12"><component :is="getIcon(child.meta?.icon)" /></el-icon>
|
|
|
|
|
<span>{{ child.meta?.title }}</span>
|
|
|
|
|
</el-menu-item>
|
|
|
|
|
</template>
|
|
|
|
|
</el-sub-menu>
|
|
|
|
|
</template>
|
|
|
|
|
</el-menu>
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { computed } from 'vue'
|
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
import { useStore } from 'vuex'
|
2026-05-17 17:24:43 +08:00
|
|
|
import { Refresh, Monitor, PieChart, Document, List, Plus, Bell, Setting } from '@element-plus/icons-vue'
|
2026-05-15 18:18:51 +08:00
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const store = useStore()
|
|
|
|
|
|
|
|
|
|
const sidebar = computed(() => store.state.app.sidebar)
|
|
|
|
|
const activeMenu = computed(() => route.path)
|
|
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
const iconMap = {
|
|
|
|
|
'dashboard': Monitor,
|
|
|
|
|
'monitor': Monitor,
|
|
|
|
|
'example': PieChart,
|
|
|
|
|
'order': Document,
|
|
|
|
|
'cost': PieChart,
|
|
|
|
|
'energy': Monitor,
|
|
|
|
|
'pie-chart': PieChart,
|
|
|
|
|
'list': List,
|
|
|
|
|
'plus': Plus,
|
|
|
|
|
'document': Document,
|
|
|
|
|
'output': PieChart,
|
|
|
|
|
'stop': Bell,
|
|
|
|
|
'system': Setting,
|
|
|
|
|
'user': Refresh,
|
|
|
|
|
'role': Refresh,
|
|
|
|
|
'menu': List,
|
|
|
|
|
'config': Setting,
|
|
|
|
|
'database': Monitor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getIcon = (iconName) => {
|
|
|
|
|
return iconMap[iconName] || Monitor
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 18:18:51 +08:00
|
|
|
const menuItems = [
|
|
|
|
|
{
|
|
|
|
|
path: '/index',
|
2026-05-17 17:24:43 +08:00
|
|
|
meta: { title: '工作台', icon: 'dashboard' },
|
|
|
|
|
children: []
|
2026-05-15 18:18:51 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/dashboard',
|
|
|
|
|
meta: { title: '数据大屏', icon: 'monitor' },
|
|
|
|
|
children: [
|
2026-05-17 17:24:43 +08:00
|
|
|
{ path: '/dashboard/demo', meta: { title: '示例大屏', icon: 'example' }, children: [] },
|
|
|
|
|
{ path: '/dashboard/order', meta: { title: '订单大屏', icon: 'order' }, children: [] },
|
|
|
|
|
{ path: '/dashboard/cost', meta: { title: '成本大屏', icon: 'cost' }, children: [] },
|
|
|
|
|
{ path: '/dashboard/energy', meta: { title: '能源大屏', icon: 'energy' }, children: [] },
|
|
|
|
|
{ path: '/dashboard/acid-rolling', meta: { title: '酸轧数据大屏', icon: 'example' }, children: [] }
|
2026-05-15 18:18:51 +08:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-05-17 17:24:43 +08:00
|
|
|
path: '/screen-manage',
|
|
|
|
|
meta: { title: '大屏管理', icon: 'pie-chart' },
|
2026-05-15 18:18:51 +08:00
|
|
|
children: [
|
2026-05-17 17:24:43 +08:00
|
|
|
{ path: '/screen-manage', meta: { title: '大屏列表', icon: 'list' }, children: [] },
|
|
|
|
|
{ path: '/screen-manage/create', meta: { title: '新建大屏', icon: 'plus' }, children: [] }
|
2026-05-15 18:18:51 +08:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/reports',
|
|
|
|
|
meta: { title: '报表管理', icon: 'document' },
|
|
|
|
|
children: [
|
2026-05-17 17:24:43 +08:00
|
|
|
{ path: '/reports', meta: { title: '报表列表', icon: 'list' }, children: [] },
|
|
|
|
|
{ path: '/reports/acid-rolling', meta: { title: '酸轧产出报表', icon: 'output' }, children: [] },
|
|
|
|
|
{ path: '/reports/acid-stop', meta: { title: '酸轧停机报表', icon: 'stop' }, children: [] }
|
2026-05-15 18:18:51 +08:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/system',
|
2026-05-17 17:24:43 +08:00
|
|
|
meta: { title: '系统管理', icon: 'system' },
|
2026-05-15 18:18:51 +08:00
|
|
|
children: [
|
2026-05-17 17:24:43 +08:00
|
|
|
{ path: '/system/menu', meta: { title: '菜单管理', icon: 'menu' }, children: [] },
|
|
|
|
|
{ path: '/system/config', meta: { title: '系统配置', icon: 'config' }, children: [] }
|
2026-05-15 18:18:51 +08:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/data-source',
|
2026-05-17 17:24:43 +08:00
|
|
|
meta: { title: '数据源配置', icon: 'database' },
|
|
|
|
|
children: []
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.sidebar-container {
|
2026-05-17 17:24:43 +08:00
|
|
|
flex-shrink: 0;
|
2026-05-15 18:18:51 +08:00
|
|
|
width: 200px;
|
2026-05-17 17:24:43 +08:00
|
|
|
height: 100vh;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
border-right: 1px solid #e8e8e8;
|
|
|
|
|
box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.15);
|
2026-05-15 18:18:51 +08:00
|
|
|
transition: width 0.28s ease;
|
2026-05-17 17:24:43 +08:00
|
|
|
overflow: hidden;
|
2026-05-15 18:18:51 +08:00
|
|
|
|
|
|
|
|
&.is-collapse {
|
|
|
|
|
width: 54px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar-header {
|
2026-05-17 17:24:43 +08:00
|
|
|
height: 50px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
background: linear-gradient(135deg, #3A71A8, #324157);
|
|
|
|
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
2026-05-15 18:18:51 +08:00
|
|
|
|
|
|
|
|
.logo-wrapper {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2026-05-17 17:24:43 +08:00
|
|
|
gap: 8px;
|
2026-05-15 18:18:51 +08:00
|
|
|
|
|
|
|
|
.logo-icon {
|
2026-05-17 17:24:43 +08:00
|
|
|
font-size: 20px;
|
|
|
|
|
color: #ffffff;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logo-text {
|
2026-05-17 17:24:43 +08:00
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: bold;
|
2026-05-15 18:18:51 +08:00
|
|
|
color: #ffffff;
|
2026-05-17 17:24:43 +08:00
|
|
|
transition: opacity 0.2s ease;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar-scroll {
|
2026-05-17 17:24:43 +08:00
|
|
|
height: calc(100% - 50px);
|
2026-05-15 18:18:51 +08:00
|
|
|
overflow-y: auto;
|
2026-05-17 17:24:43 +08:00
|
|
|
overflow-x: hidden;
|
2026-05-15 18:18:51 +08:00
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
&::-webkit-scrollbar {
|
|
|
|
|
width: 8px;
|
|
|
|
|
height: 8px;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
&::-webkit-scrollbar-track {
|
|
|
|
|
background: #f1f1f1;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
2026-05-15 18:18:51 +08:00
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
&::-webkit-scrollbar-thumb {
|
|
|
|
|
background: #c1c1c1;
|
2026-05-15 18:18:51 +08:00
|
|
|
border-radius: 4px;
|
2026-05-17 17:24:43 +08:00
|
|
|
transition: background 0.2s;
|
2026-05-15 18:18:51 +08:00
|
|
|
|
|
|
|
|
&:hover {
|
2026-05-17 17:24:43 +08:00
|
|
|
background: #a8a8a8;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
2026-05-17 17:24:43 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-05-15 18:18:51 +08:00
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
.sidebar-menu {
|
|
|
|
|
border-right: none;
|
|
|
|
|
background: transparent;
|
|
|
|
|
padding: 4px;
|
|
|
|
|
|
|
|
|
|
:deep(.el-menu) {
|
|
|
|
|
border-right: none;
|
|
|
|
|
background: transparent;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
:deep(.el-menu-item),
|
2026-05-15 18:18:51 +08:00
|
|
|
:deep(.el-sub-menu__title) {
|
2026-05-17 17:24:43 +08:00
|
|
|
height: 38px;
|
|
|
|
|
line-height: 38px;
|
|
|
|
|
color: #333333;
|
|
|
|
|
margin: 2px 0;
|
|
|
|
|
padding: 0 8px;
|
|
|
|
|
border-radius: 0;
|
2026-05-15 18:18:51 +08:00
|
|
|
position: relative;
|
|
|
|
|
border-left: 3px solid transparent;
|
2026-05-17 17:24:43 +08:00
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
|
|
|
|
|
.el-icon {
|
|
|
|
|
color: #8c8c8c;
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
2026-05-15 18:18:51 +08:00
|
|
|
|
|
|
|
|
&:hover {
|
2026-05-17 17:24:43 +08:00
|
|
|
background: rgba(0, 0, 0, 0.06);
|
|
|
|
|
color: #1a1a1a;
|
|
|
|
|
|
|
|
|
|
.el-icon {
|
|
|
|
|
color: #555555;
|
|
|
|
|
}
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.is-active {
|
2026-05-17 17:24:43 +08:00
|
|
|
border-left: 3px solid #409eff;
|
|
|
|
|
background: rgba(64, 158, 255, 0.1);
|
|
|
|
|
color: #1a1a1a;
|
2026-05-15 18:18:51 +08:00
|
|
|
font-weight: 600;
|
2026-05-17 17:24:43 +08:00
|
|
|
|
|
|
|
|
.el-icon {
|
|
|
|
|
color: #409eff;
|
|
|
|
|
}
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
:deep(.el-sub-menu__title) {
|
|
|
|
|
&::after {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #8c8c8c;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
2026-05-17 17:24:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.el-sub-menu .el-menu-item) {
|
|
|
|
|
padding-left: 18px !important;
|
|
|
|
|
font-size: 13px;
|
2026-05-15 18:18:51 +08:00
|
|
|
|
|
|
|
|
&.is-active {
|
2026-05-17 17:24:43 +08:00
|
|
|
padding-left: 18px !important;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
:deep(.el-sub-menu .el-sub-menu .el-menu-item) {
|
|
|
|
|
padding-left: 28px !important;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
2026-05-15 18:18:51 +08:00
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
&.is-collapse {
|
|
|
|
|
:deep(.el-menu-item),
|
|
|
|
|
:deep(.el-sub-menu__title) {
|
|
|
|
|
padding: 0;
|
|
|
|
|
text-align: center;
|
2026-05-15 18:18:51 +08:00
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
span {
|
|
|
|
|
display: none;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-17 17:24:43 +08:00
|
|
|
.el-icon {
|
|
|
|
|
margin-right: 0;
|
2026-05-15 18:18:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-17 17:24:43 +08:00
|
|
|
|
|
|
|
|
:deep(.el-menu--popup) {
|
|
|
|
|
border: 1px solid #e8e8e8;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
|
|
|
|
|
|
|
|
.el-menu-item {
|
|
|
|
|
padding: 0 20px;
|
|
|
|
|
border-left: none;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
background: rgba(64, 158, 255, 0.08);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.is-active {
|
|
|
|
|
border-left: none;
|
|
|
|
|
background: rgba(64, 158, 255, 0.12);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|