Files
bj_power/bj_power_wms_client/frontend/src/layouts/MainLayout.vue
T

116 lines
4.0 KiB
Vue
Raw Normal View History

2026-08-28 15:06:01 +08:00
<script setup>
import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import {
HomeFilled, Download, Upload, Search, CircleCheck, List,
2026-08-29 15:30:25 +08:00
Box, Tickets, Monitor, EditPen
2026-08-28 15:06:01 +08:00
} from '@element-plus/icons-vue'
import { getUser, logout } from '../utils/auth'
const route = useRoute()
const router = useRouter()
const user = getUser()
const userName = computed(() => user?.realName || user?.username || '未登录')
2026-08-28 15:06:01 +08:00
const pageTitle = computed(() => route.meta?.title || '')
const menus = [
{ path: '/', title: '工作台', icon: HomeFilled },
{ path: '/inbound', title: '入库管理', icon: Download },
{ path: '/outbound', title: '备料出库', icon: Upload },
{ path: '/inventory', title: '库存查询', icon: Search },
{ path: '/inspection', title: '质量检验', icon: CircleCheck },
{ path: '/stocktake', title: '库存盘点', icon: List },
{ path: '/semi', title: '半成品/成品', icon: Box },
{ path: '/package', title: '包装绑定', icon: Box },
2026-08-29 15:30:25 +08:00
{ path: '/ledger', title: '备料台账', icon: Tickets },
{ path: '/base-data', title: '基础数据', icon: EditPen }
2026-08-28 15:06:01 +08:00
]
// 打开当前页面帮助(各页面 PageHelp 监听 wms:open-page-help 事件弹出抽屉)
function openHelp() {
window.dispatchEvent(new CustomEvent('wms:open-page-help'))
}
function onUserCmd(cmd) {
if (cmd === 'password') {
router.push('/change-password')
} else if (cmd === 'logout') {
onLogout()
}
}
2026-08-28 15:06:01 +08:00
function onLogout() {
logout()
ElMessage.success('已退出登录')
router.push('/login')
}
</script>
<template>
<el-container class="layout">
<el-aside width="210px" class="aside">
<div class="brand">
<el-icon :size="22"><Box /></el-icon>
2026-08-29 15:30:25 +08:00
<span>库房客户端</span>
2026-08-28 15:06:01 +08:00
</div>
<el-menu :default-active="route.path" class="menu" background-color="#001529"
text-color="#c2cad8" active-text-color="#ffffff" router>
<el-menu-item v-for="m in menus" :key="m.path" :index="m.path">
<el-icon><component :is="m.icon" /></el-icon>
<span>{{ m.title }}</span>
</el-menu-item>
</el-menu>
</el-aside>
<el-container>
<el-header height="56px" class="header">
<span class="title">{{ pageTitle }}</span>
<div class="spacer"></div>
<el-button text type="primary" @click="router.push('/display')">
<el-icon style="margin-right:4px"><Monitor /></el-icon>免登录大屏
</el-button>
<el-button class="help-btn" text @click="openHelp">帮助</el-button>
<el-dropdown trigger="click" @command="onUserCmd">
<span class="user-name">{{ userName }} <span class="caret">▾</span></span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="password">修改密码</el-dropdown-item>
<el-dropdown-item divided command="logout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
2026-08-28 15:06:01 +08:00
</el-header>
<el-main class="main">
<router-view />
</el-main>
</el-container>
</el-container>
</template>
<style scoped>
.layout { height: 100vh; }
.aside { background: #001529; }
.brand {
display: flex; align-items: center; gap: 8px;
height: 56px; padding: 0 16px;
color: #fff; font-weight: 600; font-size: 15px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.menu { border-right: none; }
.header {
display: flex; align-items: center; gap: 10px;
background: #fff; border-bottom: 1px solid #ebeef5;
}
.title { font-size: 16px; font-weight: 600; }
.spacer { flex: 1; }
.help-btn { font-size: 13px; color: #606266; }
.user-name {
display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
font-size: 14px; color: #303133; outline: none; padding: 4px 6px; border-radius: 4px;
}
.user-name:hover { color: #1668dc; background: #f2f6fc; }
.caret { font-size: 10px; color: #909399; }
2026-08-28 15:06:01 +08:00
.main { background: #f0f2f5; padding: 14px; overflow: auto; }
</style>