弹框只能弹5个,未弹的入队列,关掉一个弹一个
This commit is contained in:
parent
1ae91da1cd
commit
3a2324b274
@ -7,8 +7,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { watch, onUnmounted, ref } from 'vue';
|
||||
import { useLineNetStore } from 'src/stores/line-net-store';
|
||||
import { watch, onUnmounted, ref, markRaw } from 'vue';
|
||||
import { AlarmInfo, useLineNetStore } from 'src/stores/line-net-store';
|
||||
import { DialogChainObject, useQuasar } from 'quasar';
|
||||
import alarmInfoDialog from 'src/components/alarm/alarmInfoDialog.vue';
|
||||
import { showAlertTypeData } from './alarmInfoEnum';
|
||||
@ -29,14 +29,20 @@ const lineNetStore = useLineNetStore();
|
||||
const audio = ref();
|
||||
const audioSrc = ref('');
|
||||
const $q = useQuasar();
|
||||
let waitShowDialog: AlarmInfo[] = [];
|
||||
|
||||
watch(
|
||||
() => lineNetStore.alarmInfo,
|
||||
(val) => {
|
||||
if (val.length) {
|
||||
const alarmType = val[0].alert_type;
|
||||
alarm(alarmType, val[0].id);
|
||||
playAlarmMusic(alarmType);
|
||||
const hasShow = countHasShowFiveDialog();
|
||||
if (!hasShow) {
|
||||
const alarmType = val[0].alert_type;
|
||||
alarm(alarmType, val[0].id);
|
||||
playAlarmMusic(alarmType);
|
||||
} else {
|
||||
waitShowDialog.unshift(markRaw(lineNetStore.alarmInfo[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -110,6 +116,18 @@ const dialogInstance: {
|
||||
id: string;
|
||||
hasHandle: boolean;
|
||||
}[] = [];
|
||||
|
||||
function countHasShowFiveDialog(): boolean {
|
||||
let hasShow = 0;
|
||||
for (let i = 0; i < dialogInstance.length; i++) {
|
||||
if (dialogInstance[i].show) {
|
||||
hasShow++;
|
||||
if (hasShow > 4) break;
|
||||
}
|
||||
}
|
||||
return hasShow > 4 ? true : false;
|
||||
}
|
||||
|
||||
function alarm(alarmType: number, id: string) {
|
||||
const dialogInstanceItem = $q
|
||||
.dialog({
|
||||
@ -129,6 +147,11 @@ function alarm(alarmType: number, id: string) {
|
||||
},
|
||||
})
|
||||
.onCancel(() => {
|
||||
if (countHasShowFiveDialog() && waitShowDialog.length) {
|
||||
alarm(alarmType, waitShowDialog[0].id);
|
||||
playAlarmMusic(waitShowDialog[0].alert_type);
|
||||
waitShowDialog.shift();
|
||||
}
|
||||
const index = dialogInstance.findIndex(
|
||||
(item) => item.dialog == dialogInstanceItem
|
||||
);
|
||||
@ -155,6 +178,7 @@ function closeAllDialog() {
|
||||
}
|
||||
});
|
||||
}
|
||||
waitShowDialog = [];
|
||||
}
|
||||
onUnmounted(() => {
|
||||
closeAllDialog();
|
||||
|
Loading…
Reference in New Issue
Block a user