feat: 添加活动告警自动刷新功能

This commit is contained in:
TsMask
2025-09-19 15:38:45 +08:00
parent ae171a2a82
commit b55b4ad49d
2 changed files with 34 additions and 6 deletions

View File

@@ -208,6 +208,7 @@ let serverTime = reactive({
zone: 'UTC', // 时区 UTC
interval: null as any, // 定时器
});
let activeAlarmRefresh = 0;
// 获取服务器时间
function fnGetServerTime() {
@@ -221,6 +222,7 @@ function fnGetServerTime() {
serverTime.timestamp = parseInt(res.data.timestamp);
serverTime.interval = setInterval(() => {
serverTime.timestamp += 1000;
activeAlarmRefresh += 1;
// serverTimeStr.value = parseDateToStr(serverTime.timestamp);
// 用DOM直接修改
if (serverTimeDom) {
@@ -229,6 +231,10 @@ function fnGetServerTime() {
YYYY_MM_DD_HH_MM_SSZ
);
}
if (activeAlarmRefresh === 5) {
useAlarmStore().fnGetActiveAlarmInfo();
activeAlarmRefresh = 0;
}
}, 1000);
}
});

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { reactive, ref, onMounted, toRaw } from 'vue';
import { reactive, ref, onMounted, toRaw, onUnmounted } from 'vue';
import { PageContainer } from 'antdv-pro-layout';
import { ProModal } from 'antdv-pro-modal';
import { message, Modal } from 'ant-design-vue/es';
@@ -748,6 +748,22 @@ function fnGetList(pageNum?: number) {
});
}
let interval: any = null;
/**自动刷新 */
function AutoRefresh() {
interval = setInterval(() => {
listAct(toRaw(queryParams), '').then((res: any) => {
if (res.code === RESULT_CODE_SUCCESS) {
tablePagination.total = res.total;
tableState.data = res.rows;
} else {
tablePagination.total = 0;
tableState.data = [];
}
});
}, 5_000);
}
onMounted(() => {
// 初始字典数据
Promise.allSettled([
@@ -769,9 +785,12 @@ onMounted(() => {
dict.activeAlarmSeverity = resArr[3].value;
}
});
// 获取网元网元列表
useNeInfoStore().fnNelist();
fnGetList();
// 自动刷新
AutoRefresh();
});
onUnmounted(() => {
clearInterval(interval);
});
</script>
@@ -1201,7 +1220,7 @@ onMounted(() => {
>
{{ modalState.from.alarmType }}
</a-form-item>
</a-col>
</a-col>
</a-row>
<a-form-item
@@ -1211,7 +1230,7 @@ onMounted(() => {
>
{{ modalState.from.locationInfo }}
</a-form-item>
<a-row>
<a-col :lg="12" :md="12" :xs="24">
<a-form-item
@@ -1261,7 +1280,10 @@ onMounted(() => {
:label="t('views.faultManage.activeAlarm.ackState')"
name="ackState"
>
<DictTag :options="dict.activeAckState" :value="modalState.from.ackState" />
<DictTag
:options="dict.activeAckState"
:value="modalState.from.ackState"
/>
</a-form-item>
</a-col>
</a-row>