循环报警修改
This commit is contained in:
parent
60f97b5ea3
commit
8149d6d6f1
@ -35,17 +35,14 @@ const watchInteract = () => {
|
||||
document.removeEventListener('click', watchInteract);
|
||||
document.removeEventListener('keydown', watchInteract);
|
||||
};
|
||||
let timer: string | number | NodeJS.Timeout | undefined = undefined;
|
||||
let alarmType: number;
|
||||
|
||||
watch(
|
||||
() => lineNetStore.alarmInfo,
|
||||
(val) => {
|
||||
if (val.length) {
|
||||
alarmType = val[0].alert_type;
|
||||
const alarmType = val[0].alert_type;
|
||||
playAlarmMusic(alarmType);
|
||||
alarm();
|
||||
timingPlayAlarmMusic();
|
||||
alarm(alarmType);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -78,23 +75,30 @@ function playAlarmMusic(type: number) {
|
||||
}
|
||||
|
||||
//不关闭弹框,每3分钟播放一次报警音乐
|
||||
function timingPlayAlarmMusic() {
|
||||
function timingPlayAlarmMusic(
|
||||
dialog: DialogChainObject,
|
||||
timer: string | number | NodeJS.Timeout | undefined
|
||||
) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
if (dialogInstance.length) {
|
||||
for (let i = 0; i < dialogInstance.length; i++) {
|
||||
if (dialogInstance[i].show) {
|
||||
playAlarmMusic(alarmType);
|
||||
timingPlayAlarmMusic();
|
||||
break;
|
||||
if (dialogInstance[i].show && dialogInstance[i].dialog == dialog) {
|
||||
playAlarmMusic(dialogInstance[i].alarmType);
|
||||
timingPlayAlarmMusic(dialog, timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 180000);
|
||||
}
|
||||
|
||||
const dialogInstance: { dialog: DialogChainObject; show: boolean }[] = [];
|
||||
function alarm() {
|
||||
const dialogInstance: {
|
||||
dialog: DialogChainObject;
|
||||
show: boolean;
|
||||
alarmType: number;
|
||||
timer: string | number | NodeJS.Timeout | undefined;
|
||||
}[] = [];
|
||||
function alarm(alarmType: number) {
|
||||
const dialogInstanceItem = $q
|
||||
.dialog({ component: alarmInfoDialog })
|
||||
.onCancel(() => {
|
||||
@ -103,7 +107,14 @@ function alarm() {
|
||||
);
|
||||
dialogInstance[index].show = false;
|
||||
});
|
||||
dialogInstance.push({ dialog: dialogInstanceItem, show: true });
|
||||
let timer: string | number | NodeJS.Timeout | undefined = undefined;
|
||||
timingPlayAlarmMusic(dialogInstanceItem, timer);
|
||||
dialogInstance.push({
|
||||
dialog: dialogInstanceItem,
|
||||
show: true,
|
||||
alarmType,
|
||||
timer,
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@ -112,9 +123,9 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
clearTimeout(timer);
|
||||
if (dialogInstance.length) {
|
||||
dialogInstance.forEach((item) => {
|
||||
clearTimeout(item.timer);
|
||||
if (item.show) {
|
||||
item.dialog.hide();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user