Browse Source

Merge pull request 'fix:集中告警列表时间刷新bug修复,同步刷新' (#116) from dev-xjf into master

Reviewed-on: http://120.26.116.243:3000/root/alert-front/pulls/116
master
xiaojinfei 1 week ago
parent
commit
09f5208251
  1. 15
      src/views/warn/alarm/alarm.data.ts
  2. 15
      src/views/warn/alarm/index.vue

15
src/views/warn/alarm/alarm.data.ts

@ -4,6 +4,13 @@ import {h, ref} from "vue";
import {systemSelectParams} from "@/api/alert/model/model/optionsModel"; import {systemSelectParams} from "@/api/alert/model/model/optionsModel";
import {formatToDateTime, getDate} from "@/utils/dateUtil"; import {formatToDateTime, getDate} from "@/utils/dateUtil";
export const currentTime = ref(Date.now())
setInterval(() => {
currentTime.value = Date.now()
}, 1000)
function toTimestamp(time: string): number { function toTimestamp(time: string): number {
if (!time) return 0 if (!time) return 0
// 兼容:2026-01-04T09:30:15 / 2026-01-04 09:30:15 // 兼容:2026-01-04T09:30:15 / 2026-01-04 09:30:15
@ -183,8 +190,7 @@ export const columns: BasicColumn[] = [
return h('div', [ return h('div', [
h('div', record.insertTime), h('div', record.insertTime),
// h('div', '--'), // h('div', '--'),
h('div', formatToDateTime(record.currentTime)) h('div', formatToDateTime(currentTime.value))
]); ]);
}, },
@ -192,9 +198,10 @@ export const columns: BasicColumn[] = [
{ {
title: '持续时长', title: '持续时长',
dataIndex: 'timeDiffStr', dataIndex: 'timeDiffStr',
width: 85, width: 100,
customRender: ({ record }) => { customRender: ({ record }) => {
const diffMs = record.currentTime - toTimestamp(record.insertTime) if (!record.insertTime) return '-'
const diffMs = currentTime.value - toTimestamp(record.insertTime)
return getDate(diffMs) return getDate(diffMs)
}, },
}, },

15
src/views/warn/alarm/index.vue

@ -80,7 +80,10 @@ async function handleTrend(record: Recordable) {
let timer: number | null = null let timer: number | null = null
onMounted(() => { onMounted(() => {
console.log("定时器开始")
timer = window.setInterval(async() => { timer = window.setInterval(async() => {
const list = getDataSource() const list = getDataSource()
const now = Date.now() const now = Date.now()
@ -95,24 +98,14 @@ onMounted(() => {
// //
updateTableDataRecord(row.mpId, Object.assign(row, { pointValue: pointValue, outpointValue: outpointValue})) updateTableDataRecord(row.mpId, Object.assign(row, { pointValue: pointValue, outpointValue: outpointValue}))
} }
//
setTableData(
list.map(item => ({
...item,
currentTime: now,
}))
)
}, 1000) }, 1000)
}) })
onUnmounted(() => { onUnmounted(() => {
console.log("定时器销毁",timer)
if (timer) clearInterval(timer) if (timer) clearInterval(timer)
}) })
</script> </script>
<template> <template>

Loading…
Cancel
Save