Browse Source

站点离线处理

master
xuhuajiao 4 weeks ago
parent
commit
d0112d085d
  1. 45
      src/views/assetManage/monitor/index.vue

45
src/views/assetManage/monitor/index.vue

@ -17,7 +17,7 @@
</el-scrollbar> </el-scrollbar>
</div> </div>
<div class="elect-cont-right" style="background-color: transparent; padding: 0 !important;">
<div v-loading="loading" class="elect-cont-right" style="background-color: transparent; padding: 0 !important;">
<div class="container-right" style="height: calc(100vh - 158px) !important;background-color: transparent !important;"> <div class="container-right" style="height: calc(100vh - 158px) !important;background-color: transparent !important;">
<span class="right-top-line" /> <span class="right-top-line" />
<span class="left-bottom-line" /> <span class="left-bottom-line" />
@ -79,12 +79,11 @@
<div class="warning-text"> <div class="warning-text">
<i class="iconfont icon-baojingjilu" /> <i class="iconfont icon-baojingjilu" />
<div v-if="item.isWarningActive" :ref="el => setWarningRef(el, index)" class="warning-text-scroll">
<div v-if="item.warnList && item.warnList.length>0" :ref="el => setWarningRef(el, index)" class="warning-text-scroll">
<div class="scroll-wrap"> <div class="scroll-wrap">
<div v-for="(warn, warnIdx) in item.warnList" :key="warnIdx" class="scroll-item"> <div v-for="(warn, warnIdx) in item.warnList" :key="warnIdx" class="scroll-item">
{{ warn.warnValue }} {{ warn.warnValue }}
</div> </div>
<!-- 复制一份用于无缝循环 -->
<div v-for="(warn, warnIdx) in item.warnList" :key="'copy_'+warnIdx" class="scroll-item"> <div v-for="(warn, warnIdx) in item.warnList" :key="'copy_'+warnIdx" class="scroll-item">
{{ warn.warnValue }} {{ warn.warnValue }}
</div> </div>
@ -212,7 +211,9 @@ export default {
alarmTableData: [], alarmTableData: [],
alarmPageNum: 1, alarmPageNum: 1,
alarmPageSize: 10, alarmPageSize: 10,
alarmTotal: 0
alarmTotal: 0,
loading: false,
refreshTimer: null
} }
}, },
created() { created() {
@ -228,38 +229,58 @@ export default {
this.selectFirstWarehouseNode() this.selectFirstWarehouseNode()
}) })
}).catch(() => {}) }).catch(() => {})
// 1
this.refreshTimer = setInterval(() => {
this.crud.toQuery()
}, 60 * 1000)
}, },
beforeDestroy() { beforeDestroy() {
this.clearAllWarningScroll() this.clearAllWarningScroll()
//
if (this.refreshTimer) {
clearInterval(this.refreshTimer)
this.refreshTimer = null
}
}, },
methods: { methods: {
[CRUD.HOOK.beforeRefresh]() { [CRUD.HOOK.beforeRefresh]() {
this.loading = true
this.crud.params.page = null this.crud.params.page = null
this.crud.params.size = null this.crud.params.size = null
}, },
[CRUD.HOOK.afterRefresh]() { [CRUD.HOOK.afterRefresh]() {
this.loading = false
const apiList = this.crud.data || [] const apiList = this.crud.data || []
this.buildWarehouseCardList(apiList) this.buildWarehouseCardList(apiList)
}, },
buildWarehouseCardList(apiResult) { buildWarehouseCardList(apiResult) {
const apiList = this.crud.data || []
if (!Array.isArray(apiList) || apiList.length === 0) {
if (!Array.isArray(apiResult) || apiResult.length === 0) {
this.warehouseCardList = [] this.warehouseCardList = []
return return
} }
let filterList = [] let filterList = []
if (this.selectedTreeKey?.id === 0) { if (this.selectedTreeKey?.id === 0) {
filterList = apiList
filterList = apiResult
} else { } else {
const selectFondsNo = this.selectedTreeKey?.fondsNo 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 => { 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 { return {
...item, ...item,
isWarningActive: Array.isArray(item.warnList) && item.warnList.length > 0
isWarningActive: isOffline
} }
}) })
this.warehouseCardList = cardList this.warehouseCardList = cardList
@ -292,7 +313,9 @@ export default {
}) })
this.warehouseCardList.forEach((card, idx) => { 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] const boxDom = this.warningRefs[idx]
if (!boxDom) return if (!boxDom) return
const wrapDom = boxDom.querySelector('.scroll-wrap') const wrapDom = boxDom.querySelector('.scroll-wrap')

Loading…
Cancel
Save