feat: 全端体验与稳定性整改(帮助文档清理/收集式报错/操作列统一/托盘与WS通知/物料同步重推)
- 移除 bj_power_dashboard 旧 React 大屏源码(迁移至 2D SVG 方案) - MES/WMS/工位终端前端:清理 help.js 与 PageHelp 帮助文档,统一操作列与布局,接入请求拦截器 - 新增收集式校验错误弹窗(ErrorListDialog 统一拦截 3015,逐条列现象+建议) - 新增托盘程序(tray)与 WebSocket(ws) 实时通知模块(三端共用) - MES/WMS 物料档案新增同步状态字段,补齐双向失败重推与默认角色 seed - 工单/产能/产品工艺/日排产逻辑调整;拧紧枪按工位配置 - 新增迁移 SQL:扭矩按工位、sysconfig 序列修复 - 更新 技术约束/案例/部署手册/项目说明 等文档
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-container class="layout" style="min-height:100vh">
|
||||
<el-container class="layout">
|
||||
<!-- 移动端遮罩 -->
|
||||
<div v-if="isMobile && mobileOpen" class="drawer-mask" @click="mobileOpen = false"></div>
|
||||
<el-aside :width="asideWidth" class="aside"
|
||||
@@ -19,6 +19,7 @@
|
||||
<el-menu-item v-for="m in g.children" :key="m.path" :index="m.path">
|
||||
<el-icon style="margin-right:8px"><component :is="m.icon" /></el-icon>
|
||||
<span>{{ m.name }}</span>
|
||||
<span v-if="badgeOf(m.path) > 0" class="todo-badge">{{ badgeOf(m.path) }}</span>
|
||||
</el-menu-item>
|
||||
</el-sub-menu>
|
||||
</el-menu>
|
||||
@@ -45,6 +46,7 @@
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</el-badge>
|
||||
<el-button class="board-btn" text @click="openBoard">生产看板大屏</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>
|
||||
@@ -57,7 +59,7 @@
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main style="padding:14px">
|
||||
<el-main class="main">
|
||||
<router-view />
|
||||
</el-main>
|
||||
</el-container>
|
||||
@@ -68,7 +70,7 @@
|
||||
import { ref, computed, onMounted, onBeforeUnmount, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import {
|
||||
Document, Calendar, Box, Goods, ShoppingCart, Monitor, Tools,
|
||||
Document, Calendar, Box, ShoppingCart, Monitor, Tools,
|
||||
Operation, Link, DataLine, Search, CircleCheck, Clock, User,
|
||||
Key, Fold, Expand, Warning, Paperclip, Tickets, Bell, Setting, Van
|
||||
} from '@element-plus/icons-vue'
|
||||
@@ -111,6 +113,7 @@ onMounted(() => {
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', onScreenChange)
|
||||
if (alertTimer) clearInterval(alertTimer)
|
||||
closeTodoWs()
|
||||
})
|
||||
|
||||
const menus = computed(() => {
|
||||
@@ -154,7 +157,6 @@ const menuGroups = [
|
||||
title: '现场作业', icon: Monitor, children: [
|
||||
{ code: 'produce.wip', name: '在制品', path: '/wip', icon: Clock },
|
||||
{ code: 'produce.trace', name: '工件追溯', path: '/trace', icon: Search },
|
||||
{ code: 'produce.virtualstation', name: '虚拟工位作业', path: '/virtual-station', icon: Goods },
|
||||
{ code: 'produce.processcard', name: '生产流程卡', path: '/process-card', icon: Tickets },
|
||||
{ code: 'produce.audit', name: '待审核签字', path: '/audit-pending', icon: CircleCheck },
|
||||
{ code: 'sys.inspect', name: '巡检终端', path: '/inspect', icon: CircleCheck },
|
||||
@@ -173,9 +175,9 @@ const menuGroups = [
|
||||
{ code: 'sys.syncfailure', name: '同步失败台账', path: '/sync-failure', icon: Warning },
|
||||
{ code: 'sys.attachment', name: '附件中心', path: '/attachment', icon: Paperclip },
|
||||
{ code: 'sys.backup', name: '数据归档', path: '/data-archive', icon: Tools },
|
||||
{ code: 'sys.settings', name: '基础设置', path: '/settings', icon: Setting },
|
||||
// 拧紧枪配置(2026-11-09):控制器地址 + 三把枪通道号仅展示,不参与拧紧数据收集
|
||||
{ code: 'sys.torqueconfig', name: '拧紧枪配置', path: '/torque-gun-config', icon: Setting }
|
||||
// 2026-11-10:拧紧枪配置移到基础设置上面(基础设置保持系统管理最后一项)
|
||||
{ code: 'sys.torqueconfig', name: '拧紧枪配置', path: '/torque-gun-config', icon: Setting },
|
||||
{ code: 'sys.settings', name: '基础设置', path: '/settings', icon: Setting }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -210,6 +212,10 @@ onMounted(async () => {
|
||||
// 顶部预警铃铛:立即拉一次未读数,随后每 30s 轮询
|
||||
pollAlerts()
|
||||
alertTimer = setInterval(pollAlerts, 30000)
|
||||
|
||||
// 菜单待办角标:先拉一次全量统计,再建立 WebSocket 增量通道
|
||||
await loadTodoStats()
|
||||
connectTodoWs()
|
||||
})
|
||||
|
||||
// 说明:数据归档清理提醒已从顶栏角标移除,统一由「预警中心」承载
|
||||
@@ -238,6 +244,102 @@ async function pollAlerts() {
|
||||
} catch { /* 忽略轮询异常 */ }
|
||||
}
|
||||
|
||||
// ===== 菜单待办角标:初始化拉全量 + WebSocket 增量推送 =====
|
||||
// 6 个固定 menuCode → 菜单 path;只给已渲染(即有权限)的菜单项挂角标
|
||||
const TODO_PATH = {
|
||||
'produce.call': '/material-request',
|
||||
'produce.return': '/transfer-return',
|
||||
'produce.shortage': '/shortage',
|
||||
'produce.qtyreport': '/qty-report',
|
||||
'produce.sign': '/audit-pending',
|
||||
'produce.alert': '/alert-center',
|
||||
}
|
||||
const todoCounts = ref({}) // menuCode -> 待办数
|
||||
|
||||
function badgeOf(path) {
|
||||
let n = 0
|
||||
for (const code in TODO_PATH) {
|
||||
if (TODO_PATH[code] === path) n += todoCounts.value[code] || 0
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
function applyTodoItems(items) {
|
||||
const map = {}
|
||||
if (Array.isArray(items)) {
|
||||
for (const it of items) {
|
||||
if (it && typeof it.menuCode === 'string') map[it.menuCode] = Number(it.count) || 0
|
||||
}
|
||||
}
|
||||
todoCounts.value = map
|
||||
}
|
||||
|
||||
async function loadTodoStats() {
|
||||
try {
|
||||
// request baseURL=/api/v1 → GET /api/v1/todos/stats
|
||||
const res = await request.get('/todos/stats')
|
||||
if (res && Array.isArray(res.items)) applyTodoItems(res.items)
|
||||
} catch { /* 待办统计不可用时不阻塞布局 */ }
|
||||
}
|
||||
|
||||
function todoWsUrl() {
|
||||
// token 字段名与 utils/auth.js 一致(localStorage 'token')
|
||||
const token = localStorage.getItem('token') || ''
|
||||
const proto = window.location.protocol === 'https:' ? 'wss' : 'ws'
|
||||
return `${proto}://${window.location.host}/api/v1/todos/ws?token=${encodeURIComponent(token)}`
|
||||
}
|
||||
|
||||
let todoWs = null
|
||||
let todoReconnectTimer = null
|
||||
let todoRetry = 0
|
||||
let todoAlive = true
|
||||
|
||||
function connectTodoWs() {
|
||||
if (!todoAlive) return
|
||||
const token = localStorage.getItem('token') || ''
|
||||
if (!token) return
|
||||
let ws
|
||||
try {
|
||||
ws = new WebSocket(todoWsUrl())
|
||||
} catch {
|
||||
scheduleTodoReconnect()
|
||||
return
|
||||
}
|
||||
todoWs = ws
|
||||
ws.onopen = () => { todoRetry = 0 }
|
||||
ws.onmessage = (ev) => {
|
||||
try {
|
||||
const msg = JSON.parse(ev.data)
|
||||
if (msg && Array.isArray(msg.items)) applyTodoItems(msg.items)
|
||||
} catch { /* 忽略单条异常推送 */ }
|
||||
}
|
||||
ws.onerror = () => { /* 交由 onclose 统一重连 */ }
|
||||
ws.onclose = () => {
|
||||
if (todoWs === ws) todoWs = null
|
||||
if (todoAlive) scheduleTodoReconnect()
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleTodoReconnect() {
|
||||
if (todoReconnectTimer || !todoAlive) return
|
||||
const delay = Math.min(30000, 2000 * Math.pow(2, todoRetry))
|
||||
todoRetry = Math.min(todoRetry + 1, 5)
|
||||
todoReconnectTimer = setTimeout(() => {
|
||||
todoReconnectTimer = null
|
||||
connectTodoWs()
|
||||
}, delay)
|
||||
}
|
||||
|
||||
function closeTodoWs() {
|
||||
todoAlive = false
|
||||
if (todoReconnectTimer) { clearTimeout(todoReconnectTimer); todoReconnectTimer = null }
|
||||
if (todoWs) {
|
||||
todoWs.onclose = null
|
||||
todoWs.close()
|
||||
todoWs = null
|
||||
}
|
||||
}
|
||||
|
||||
function goAlertCenter() {
|
||||
router.push('/alert-center')
|
||||
}
|
||||
@@ -254,6 +356,11 @@ function openHelp() {
|
||||
window.dispatchEvent(new CustomEvent('mes:open-page-help'))
|
||||
}
|
||||
|
||||
// 生产看板大屏:/board 在路由免登录白名单 publicPaths,无需登录
|
||||
function openBoard() {
|
||||
window.open('/board', '_blank')
|
||||
}
|
||||
|
||||
function onUserCmd(cmd) {
|
||||
if (cmd === 'password') {
|
||||
router.push('/change-password')
|
||||
@@ -264,7 +371,9 @@ function onUserCmd(cmd) {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.aside { background: #001529; transition: width .2s ease; }
|
||||
.layout { height: 100vh; }
|
||||
.aside { background: #001529; transition: width .2s ease; overflow: auto; }
|
||||
.main { background: #f0f2f5; padding: 14px; overflow: auto; }
|
||||
.drawer { position: fixed; left: 0; top: 0; bottom: 0; z-index: 1001; transform: translateX(-100%); transition: transform .3s ease; }
|
||||
.drawer-open { transform: translateX(0); }
|
||||
.drawer-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 1000; }
|
||||
@@ -290,8 +399,12 @@ function onUserCmd(cmd) {
|
||||
40% { transform: rotate(-6deg); }
|
||||
50% { transform: rotate(0); }
|
||||
}
|
||||
.board-btn { font-size: 13px; color: #1668dc; }
|
||||
.board-btn:hover { background: #f2f6fc; }
|
||||
.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; }
|
||||
</style>
|
||||
/* 菜单待办角标:靠右、数量 0 时由 v-if 隐藏 */
|
||||
.todo-badge { margin-left: auto; flex-shrink: 0; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; border-radius: 9px; background: #f56c6c; color: #fff; font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user