From d0112d085dcca047ec9aa41725820cc20a1c9cd4 Mon Sep 17 00:00:00 2001 From: xuhuajiao <13476289682@163.com> Date: Fri, 21 Aug 2026 09:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E7=82=B9=E7=A6=BB=E7=BA=BF=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/assetManage/monitor/index.vue | 45 +++++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/views/assetManage/monitor/index.vue b/src/views/assetManage/monitor/index.vue index 0b00ecf..1cdf88b 100644 --- a/src/views/assetManage/monitor/index.vue +++ b/src/views/assetManage/monitor/index.vue @@ -17,7 +17,7 @@ -
+
@@ -79,12 +79,11 @@
-
+
{{ warn.warnValue }}
-
{{ warn.warnValue }}
@@ -212,7 +211,9 @@ export default { alarmTableData: [], alarmPageNum: 1, alarmPageSize: 10, - alarmTotal: 0 + alarmTotal: 0, + loading: false, + refreshTimer: null } }, created() { @@ -228,38 +229,58 @@ export default { this.selectFirstWarehouseNode() }) }).catch(() => {}) + + // 新增:1分钟定时刷新 + this.refreshTimer = setInterval(() => { + this.crud.toQuery() + }, 60 * 1000) }, beforeDestroy() { this.clearAllWarningScroll() + // 清除轮询定时器 + if (this.refreshTimer) { + clearInterval(this.refreshTimer) + this.refreshTimer = null + } }, methods: { [CRUD.HOOK.beforeRefresh]() { + this.loading = true this.crud.params.page = null this.crud.params.size = null }, [CRUD.HOOK.afterRefresh]() { + this.loading = false const apiList = this.crud.data || [] this.buildWarehouseCardList(apiList) }, buildWarehouseCardList(apiResult) { - const apiList = this.crud.data || [] - - if (!Array.isArray(apiList) || apiList.length === 0) { + if (!Array.isArray(apiResult) || apiResult.length === 0) { this.warehouseCardList = [] return } let filterList = [] if (this.selectedTreeKey?.id === 0) { - filterList = apiList + filterList = apiResult } else { const selectFondsNo = this.selectedTreeKey?.fondsNo - filterList = apiList.filter(item => item.warehouse.fondsNo === selectFondsNo) + filterList = apiResult.filter(item => item.warehouse.fondsNo === selectFondsNo) } const cardList = filterList.map(item => { + // 计算离线条件:lastTime为空 / 距离当前超过10分钟 + let isOffline = true + const lastTimeStr = item.warehouse.lastTime + if (lastTimeStr) { + const lastDate = new Date(lastTimeStr) + const diffMs = Date.now() - lastDate.getTime() + isOffline = diffMs > 10 * 60 * 1000 + } + // isWarningActive:离线 或者 存在报警,任意一个满足即为true + // const hasWarn = Array.isArray(item.warnList) && item.warnList.length > 0 return { ...item, - isWarningActive: Array.isArray(item.warnList) && item.warnList.length > 0 + isWarningActive: isOffline } }) this.warehouseCardList = cardList @@ -292,7 +313,9 @@ export default { }) this.warehouseCardList.forEach((card, idx) => { - if (!card.isWarningActive || !card.warnList || card.warnList.length <= 0) return + // ----------删掉 !card.isWarningActive 判断,只看报警数据---------- + if (!card.warnList || card.warnList.length <= 0) return + const boxDom = this.warningRefs[idx] if (!boxDom) return const wrapDom = boxDom.querySelector('.scroll-wrap')