|
@@ -8,7 +8,10 @@
|
|
|
<template v-if="index < 6">
|
|
|
<div class="alarmTitle">{{ item.alarmName }}</div>
|
|
|
<div class="alarmContent">
|
|
|
- <div class="contentItem">报警描述: {{ item.description }}</div>
|
|
|
+ <div class="contentItem" @click="goToAlertDescPage(item)">
|
|
|
+ 报警描述:
|
|
|
+ <span class="alertDescCursor">{{ item.description }}</span>
|
|
|
+ </div>
|
|
|
<div class="contentItem">报警时间: {{ item.tsName }}</div>
|
|
|
</div>
|
|
|
<div class="btnBox" :class="`lv${item.lv}BdColor`">
|
|
@@ -36,10 +39,11 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { confirmAlart } from "@api/api.js";
|
|
|
+import { confirmAlart, getAlartConfig } from "@api/api.js";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ alarmConfigArray: [],
|
|
|
alarmList: [],
|
|
|
seriousWarning: false,
|
|
|
audioElement: null,
|
|
@@ -50,9 +54,18 @@ export default {
|
|
|
},
|
|
|
|
|
|
created() {
|
|
|
- this.webSocketInit(
|
|
|
- `ws://10.81.3.154:6014/websocket/${this.$store.state.user.authToken}`
|
|
|
- );
|
|
|
+ getAlartConfig()
|
|
|
+ .then((res) => {
|
|
|
+ this.alarmConfigArray = res.data;
|
|
|
+ this.webSocketInit(
|
|
|
+ `ws://10.81.3.154:6014/websocket/${this.$store.state.user.userId}`
|
|
|
+ );
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.BASE.showMsg({
|
|
|
+ msg: "报警配置获取失败,请重试",
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
unmounted() {
|
|
@@ -142,6 +155,7 @@ export default {
|
|
|
type: "success",
|
|
|
msg: "全部确认成功",
|
|
|
});
|
|
|
+ this.alarmList = [];
|
|
|
this.$store.commit("emptyWarning");
|
|
|
this.playAudioEffect();
|
|
|
}
|
|
@@ -150,26 +164,57 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- getRandomNumber(min, max) {
|
|
|
- return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
|
- },
|
|
|
-
|
|
|
playAudioEffect() {
|
|
|
- const fiveLvWarning = this.alarmList.some((ele) => {
|
|
|
- return ele.lv === 5 && !ele.confirm;
|
|
|
- });
|
|
|
+ const lv1Config = this.getConfigItem(1);
|
|
|
+ let lv1Play = false;
|
|
|
+ if (lv1Config.isAlarmSound) {
|
|
|
+ lv1Play = this.alarmList.some((ele) => {
|
|
|
+ return ele.lv === 1 && !ele.confirm;
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- const fourLvWarning = this.alarmList.some((ele) => {
|
|
|
- return ele.lv === 4 && !ele.confirm;
|
|
|
- });
|
|
|
+ const lv2Config = this.getConfigItem(2);
|
|
|
+ let lv2Play = false;
|
|
|
+ if (lv2Config.isAlarmSound) {
|
|
|
+ lv2Play = this.alarmList.some((ele) => {
|
|
|
+ return ele.lv === 2 && !ele.confirm;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const lv3Config = this.getConfigItem(3);
|
|
|
+ let lv3Play = false;
|
|
|
+ if (lv3Config.isAlarmSound) {
|
|
|
+ lv3Play = this.alarmList.some((ele) => {
|
|
|
+ return ele.lv === 3 && !ele.confirm;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const lv4Config = this.getConfigItem(4);
|
|
|
+ let lv4Play = false;
|
|
|
+ if (lv4Config.isAlarmSound) {
|
|
|
+ lv4Play = this.alarmList.some((ele) => {
|
|
|
+ return ele.lv === 4 && !ele.confirm;
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- if (fiveLvWarning && !this.seriousWarning) {
|
|
|
+ const lv5Config = this.getConfigItem(5);
|
|
|
+ let lv5Play = false;
|
|
|
+ if (lv5Config.isAlarmSound) {
|
|
|
+ lv5Play = this.alarmList.some((ele) => {
|
|
|
+ return ele.lv === 5 && !ele.confirm;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (lv5Play && !this.seriousWarning) {
|
|
|
this.seriousWarning = true;
|
|
|
this.audioElement = new Audio();
|
|
|
this.audioElement.src = "./static/sound/lv5.mp3";
|
|
|
this.audioElement.loop = true;
|
|
|
this.audioElement?.play();
|
|
|
- } else if (fourLvWarning && !this.seriousWarning) {
|
|
|
+ } else if (
|
|
|
+ (lv1Play || lv2Play || lv3Play || lv4Play) &&
|
|
|
+ !this.seriousWarning
|
|
|
+ ) {
|
|
|
this.audioElement = new Audio();
|
|
|
this.audioElement.src = "./static/sound/lv4.mp3";
|
|
|
this.audioElement.addEventListener("ended", () => {
|
|
@@ -202,6 +247,7 @@ export default {
|
|
|
this.ws.onmessage = (res) => {
|
|
|
let alarmItem = JSON.parse(res.data);
|
|
|
if (alarmItem) {
|
|
|
+ const configItem = this.getConfigItem(alarmItem.rank);
|
|
|
const alarmOption = {
|
|
|
id: alarmItem.id,
|
|
|
lv: alarmItem.rank,
|
|
@@ -210,6 +256,7 @@ export default {
|
|
|
class: `animate__bounceInRight lv${alarmItem.rank}`,
|
|
|
isClose: alarmItem.isClose,
|
|
|
isCloseName: alarmItem.isClose ? "是" : "否",
|
|
|
+ alarmId: alarmItem.alarmId,
|
|
|
alarmType: alarmItem.alarmType,
|
|
|
alarmName: this.getAlarmName(alarmItem),
|
|
|
description: alarmItem.description,
|
|
@@ -225,7 +272,14 @@ export default {
|
|
|
characteristic: alarmItem.characteristic,
|
|
|
code: alarmItem.code,
|
|
|
};
|
|
|
- this.alarmList.push(alarmOption);
|
|
|
+ if (
|
|
|
+ configItem.isAlarmSound ||
|
|
|
+ configItem.isAlart ||
|
|
|
+ configItem.isContinuousAlarm
|
|
|
+ ) {
|
|
|
+ this.alarmList.push(alarmOption);
|
|
|
+ }
|
|
|
+
|
|
|
this.$store.commit("setWarning", alarmOption);
|
|
|
this.alarmList.sort((a, b) => {
|
|
|
return b.lv - a.lv;
|
|
@@ -269,6 +323,32 @@ export default {
|
|
|
this.ws?.close();
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ goToAlertDescPage({ deviceId, alarmId }) {
|
|
|
+ this.$router.push(`/safe/historywaring/${deviceId}/${alarmId}`);
|
|
|
+ },
|
|
|
+
|
|
|
+ getConfigItem(lv) {
|
|
|
+ return (
|
|
|
+ this.alarmConfigArray.find((ele) => {
|
|
|
+ return ele.alarmLevel === lv;
|
|
|
+ }) || {}
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+
|
|
|
+ watch: {
|
|
|
+ "$store.state.alarmResetFlg"() {
|
|
|
+ getAlartConfig()
|
|
|
+ .then((res) => {
|
|
|
+ this.alarmConfigArray = res.data;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.BASE.showMsg({
|
|
|
+ msg: "报警配置获取失败,请重试",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -330,6 +410,17 @@ export default {
|
|
|
margin-bottom: 2px;
|
|
|
word-wrap: break-word;
|
|
|
|
|
|
+ .alertDescCursor {
|
|
|
+ cursor: pointer;
|
|
|
+ transition: 0.2s;
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ color: var(--el-color-primary);
|
|
|
+ text-decoration: underline;
|
|
|
+ transition: 0.2s;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
&:last-child {
|
|
|
margin-bottom: 0;
|
|
|
}
|