feat: 新增预警定时扫描器,移除附件归档字段并为角色表补充更新时间

This commit is contained in:
SunYF
2026-10-31 15:41:27 +08:00
parent 11dbdaae75
commit 0c03d32682
107 changed files with 10790 additions and 1844 deletions
@@ -1,7 +1,7 @@
<script setup>
import { ref, computed, onMounted, onBeforeUnmount, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { ElMessage, ElNotification } from 'element-plus'
import {
HomeFilled, Download, Upload, Search, CircleCheck, List, Bell,
Box, Monitor, EditPen, Fold, Expand, Location, Goods, Key, Operation, Van, Clock, RefreshLeft, Folder, WarningFilled, Tools, Setting
@@ -63,11 +63,45 @@ onMounted(() => {
onScreenChange()
window.addEventListener('resize', onScreenChange)
loadMe()
// 顶部预警铃铛:立即拉一次未读数,随后每 30s 轮询
pollAlerts()
alertTimer = setInterval(pollAlerts, 30000)
})
// 说明:数据归档清理提醒已从顶栏角标移除,统一在「数据归档」页内展示
// (页面加载时会查询 /backup/reminder,超期即在页内给出醒目提示)。
onBeforeUnmount(() => window.removeEventListener('resize', onScreenChange))
// 说明:数据归档清理提醒已从顶栏角标移除,统一由「预警中心」承载
// (后端在备份超期时写入 backup_overdue 预警,处理入口为「预警中心」页)。
onBeforeUnmount(() => {
window.removeEventListener('resize', onScreenChange)
if (alertTimer) clearInterval(alertTimer)
})
// 顶部预警铃铛未读数。
const unreadAlerts = ref(0)
let alertTimer = null
let alertInited = false
async function pollAlerts() {
try {
const data = await request.get('/api/alerts', { params: { status: 'unread', pageSize: 1 } })
const n = (data && data.unreadCount) || 0
// 首轮仅初始化角标;之后未读数增加时弹提示,避免反复骚扰
if (alertInited && n > unreadAlerts.value) {
ElNotification({
title: '新预警',
message: `有 ${n - unreadAlerts.value} 条新的未读预警,请及时处理`,
type: 'warning',
duration: 5000,
position: 'bottom-right'
})
}
unreadAlerts.value = n
alertInited = true
} catch { /* 忽略轮询异常 */ }
}
function goAlertCenter() {
router.push('/alert-center')
}
// 侧栏菜单:按业务域分组。分组无权限码,子项各自带 code(无 code 的常驻),
// 组内子项全部被过滤掉则整组隐藏。
@@ -85,7 +119,9 @@ const menuGroups = [
title: '仓储作业', icon: Operation, children: [
{ path: '/inbound', title: '入库管理', icon: Download, code: 'inbound:view' },
{ path: '/finished-inbound', title: '成品入库', icon: Box, code: 'wms.finished:edit' },
{ path: '/outbound', title: '出库管理', icon: Upload, code: 'outbound:view' },
{ path: '/project-outbound', title: '科技项目出库', icon: Upload, code: 'outbound:view' },
{ path: '/general-outbound', title: '通用出库', icon: Upload, code: 'outbound:view' },
{ path: '/outbound', title: '全部出库记录', icon: List, code: 'outbound:view' },
{ path: '/call-queue', title: '叫料队列', icon: Bell, code: 'call:view' },
{ path: '/return-order', title: '退库确认', icon: RefreshLeft, code: 'return:view' },
{ path: '/production-return', title: '生产退不良', icon: WarningFilled, code: 'prodreturn:manage' },
@@ -105,6 +141,7 @@ const menuGroups = [
{ path: '/event-log', title: '操作日志', icon: Clock, code: 'eventlog:manage' },
{ path: '/attachment', title: '附件中心', icon: Folder, code: 'attachment:view' },
{ path: '/data-archive', title: '数据归档', icon: Tools, code: 'backup:manage' },
{ path: '/alert-center', title: '预警中心', icon: Bell },
{ path: '/settings', title: '基础设置', icon: Setting, code: 'sys.settings:view' }
]
}
@@ -214,6 +251,13 @@ function openDisplay() {
<span class="title">{{ pageTitle }}</span>
</div>
<div class="spacer"></div>
<el-badge :value="unreadAlerts" :hidden="unreadAlerts === 0" :max="99" class="alert-badge">
<el-tooltip content="预警中心" placement="bottom">
<el-button class="alert-btn" text @click="goAlertCenter">
<el-icon :size="18" :class="{ 'alert-ring': unreadAlerts > 0 }"><Bell /></el-icon>
</el-button>
</el-tooltip>
</el-badge>
<el-button text type="primary" @click="openDisplay">
<el-icon style="margin-right:4px"><Monitor /></el-icon>免登录大屏
</el-button>