|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div
|
|
|
class="alarmBox"
|
|
|
- :class="alarmList?.length ? 'notEmpty' : ''"
|
|
|
+ :class="getAlarmBoxClass()"
|
|
|
:style="`width: ${getAlarmBoxWidth()}px;`"
|
|
|
>
|
|
|
<div
|
|
@@ -57,10 +57,28 @@
|
|
|
</template>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div
|
|
|
+ class="collapseBtn"
|
|
|
+ v-if="alarmList?.[0]?.id && $store.state.alarmShowNumber > 0"
|
|
|
+ @click="
|
|
|
+ () => {
|
|
|
+ isCollapse = !isCollapse;
|
|
|
+ }
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-link type="primary" href="kacvascript:;">
|
|
|
+ <!-- <el-icon color="#909399"><CaretBottom /></el-icon> -->
|
|
|
+ <span style="margin-left: 6px" v-if="!isCollapse">点此折叠报警</span>
|
|
|
+ <span style="margin-left: 6px; color: var(--el-color-danger)" v-else
|
|
|
+ >报警已折叠,点此恢复</span
|
|
|
+ >
|
|
|
+ </el-link>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { confirmAlart, getAlartConfig, alarm_history } from "@api/api.js";
|
|
|
+import { confirmAlart, alarm_history } from "@api/api.js";
|
|
|
import { ElNotification } from "element-plus";
|
|
|
import dayJs from "dayjs";
|
|
|
export default {
|
|
@@ -75,6 +93,7 @@ export default {
|
|
|
limitConnect: 5,
|
|
|
columnNumber: 2,
|
|
|
showSocketLog: false,
|
|
|
+ isCollapse: false,
|
|
|
requestAlarmHistoryParams: [
|
|
|
{
|
|
|
alarmType: "booststation",
|
|
@@ -140,53 +159,45 @@ export default {
|
|
|
},
|
|
|
|
|
|
created() {
|
|
|
- getAlartConfig()
|
|
|
- .then((res) => {
|
|
|
- this.alarmConfigArray = res.data;
|
|
|
- let requestResult = [];
|
|
|
- this.requestAlarmHistoryParams.forEach(({ alarmType, deviceType }) => {
|
|
|
- requestResult.push(this.getAlarmHistory(alarmType, deviceType));
|
|
|
+ this.getAlarmConfig();
|
|
|
+ let requestResult = [];
|
|
|
+ this.requestAlarmHistoryParams.forEach(({ alarmType, deviceType }) => {
|
|
|
+ requestResult.push(this.getAlarmHistory(alarmType, deviceType));
|
|
|
+ });
|
|
|
+
|
|
|
+ Promise.all(requestResult)
|
|
|
+ .then((promiseResult) => {
|
|
|
+ promiseResult.forEach(({ data }) => {
|
|
|
+ data?.ls?.forEach((ele) => {
|
|
|
+ this.pushALarmItem(ele);
|
|
|
+ });
|
|
|
});
|
|
|
-
|
|
|
- Promise.all(requestResult)
|
|
|
- .then((promiseResult) => {
|
|
|
- promiseResult.forEach(({ data }) => {
|
|
|
+ // this.webSocketInit(
|
|
|
+ // `ws://10.81.3.154:6014/websocket/${this.$store.state.user.userId}_${this.$store.state.user.authToken}`
|
|
|
+ // );
|
|
|
+ this.createWebSocket();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ requestResult.forEach((ele, index) => {
|
|
|
+ ele
|
|
|
+ .then(({ data }) => {
|
|
|
data?.ls?.forEach((ele) => {
|
|
|
this.pushALarmItem(ele);
|
|
|
});
|
|
|
- });
|
|
|
- // this.webSocketInit(
|
|
|
- // `ws://10.81.3.154:6014/websocket/${this.$store.state.user.userId}_${this.$store.state.user.authToken}`
|
|
|
- // );
|
|
|
- this.createWebSocket();
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- requestResult.forEach((ele, index) => {
|
|
|
- ele
|
|
|
- .then(({ data }) => {
|
|
|
- data?.ls?.forEach((ele) => {
|
|
|
- this.pushALarmItem(ele);
|
|
|
- });
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- ElNotification({
|
|
|
- type: "error",
|
|
|
- title: "查询历史未处理报警请求出错!",
|
|
|
- dangerouslyUseHTMLString: true,
|
|
|
- message: `<div class="currentRequestErrorNotification">
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ ElNotification({
|
|
|
+ type: "error",
|
|
|
+ title: "查询历史未处理报警请求出错!",
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ message: `<div class="currentRequestErrorNotification">
|
|
|
<p><span>主要参数:</p>
|
|
|
<p style="color:var(--el-color-primary)"><span class="errorTitle">alarmType:</span><span class="errorDesc">"${this.requestAlarmHistoryParams[index].alarmType}"</span></p>
|
|
|
<p style="color:var(--el-color-primary)"><span class="errorTitle">deviceType:</span><span class="errorDesc">"${this.requestAlarmHistoryParams[index].deviceType}"</span></p>
|
|
|
<p style="color:var(--el-color-danger)"><span class="errorTitle">错误正文:</span><span class="errorDesc">${error}</span></p>
|
|
|
</div>`,
|
|
|
- });
|
|
|
- });
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- this.BASE.showMsg({
|
|
|
- msg: "报警配置获取失败,请重试",
|
|
|
});
|
|
|
});
|
|
|
},
|
|
@@ -406,6 +417,7 @@ export default {
|
|
|
this.socketReconnect();
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
// websocket事件绑定
|
|
|
socketEventBind() {
|
|
|
// 连接成功建立的回调
|
|
@@ -424,6 +436,7 @@ export default {
|
|
|
this.socketObj.close();
|
|
|
};
|
|
|
},
|
|
|
+
|
|
|
// websocket重连
|
|
|
socketReconnect() {
|
|
|
if (this.socketReconnectLock) {
|
|
@@ -438,20 +451,23 @@ export default {
|
|
|
this.createWebSocket();
|
|
|
}, 4000);
|
|
|
},
|
|
|
+
|
|
|
// 连接成功建立的回调
|
|
|
- onopenCallback: function (event) {
|
|
|
+ onopenCallback(event) {
|
|
|
this.showSocketLog && console.log("WebSocket:已连接");
|
|
|
// 心跳检测重置
|
|
|
this.heartCheck.reset().start();
|
|
|
},
|
|
|
+
|
|
|
// 连接发生错误的回调
|
|
|
- onerrorCallback: function (event) {
|
|
|
+ onerrorCallback(event) {
|
|
|
this.showSocketLog && console.log("WebSocket:发生错误");
|
|
|
// websocket重连
|
|
|
this.socketReconnect();
|
|
|
},
|
|
|
+
|
|
|
// 连接关闭的回调
|
|
|
- oncloseCallback: function (event) {
|
|
|
+ oncloseCallback(event) {
|
|
|
this.showSocketLog && console.log("WebSocket:已关闭");
|
|
|
// 心跳检测重置
|
|
|
this.heartCheck.reset();
|
|
@@ -463,12 +479,14 @@ export default {
|
|
|
this.socketObj.close();
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
// 向后端发送数据的回调
|
|
|
- onsendCallback: function () {
|
|
|
+ onsendCallback() {
|
|
|
this.showSocketLog && console.log("WebSocket:发送信息给后端");
|
|
|
},
|
|
|
+
|
|
|
// 接收到消息的回调
|
|
|
- getMessageCallback: function (msg) {
|
|
|
+ getMessageCallback(msg) {
|
|
|
// console.log(msg);
|
|
|
if (Object.keys(msg) && msg.data == "ok") {
|
|
|
// 心跳回复——心跳检测重置
|
|
@@ -486,6 +504,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
// webSocketInit(serveIP) {
|
|
|
// if ("WebSocket" in window) {
|
|
|
// this.ws = new WebSocket(serveIP);
|
|
@@ -587,6 +606,13 @@ export default {
|
|
|
);
|
|
|
},
|
|
|
|
|
|
+ getAlarmBoxClass() {
|
|
|
+ let classList = [];
|
|
|
+ if (this.alarmList?.length) classList.push("notEmpty");
|
|
|
+ if (this.isCollapse) classList.push("collapseAlarmBox");
|
|
|
+ return classList.join(" ");
|
|
|
+ },
|
|
|
+
|
|
|
getAlarmBoxWidth() {
|
|
|
const baseWIdth = 240;
|
|
|
let widthStep = 0;
|
|
@@ -597,19 +623,70 @@ export default {
|
|
|
}
|
|
|
return widthStep * baseWIdth;
|
|
|
},
|
|
|
+
|
|
|
+ getAlarmConfig() {
|
|
|
+ if (localStorage.getItem("alarmConfigArray")) {
|
|
|
+ this.alarmConfigArray = JSON.parse(
|
|
|
+ localStorage.getItem("alarmConfigArray")
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.alarmConfigArray = [
|
|
|
+ {
|
|
|
+ id: "1",
|
|
|
+ alarmLevel: 1,
|
|
|
+ isAlart: false,
|
|
|
+ isAlarmSound: false,
|
|
|
+ isContinuousAlarm: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "2",
|
|
|
+ alarmLevel: 2,
|
|
|
+ isAlart: false,
|
|
|
+ isAlarmSound: false,
|
|
|
+ isContinuousAlarm: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "3",
|
|
|
+ alarmLevel: 3,
|
|
|
+ isAlart: true,
|
|
|
+ isAlarmSound: false,
|
|
|
+ isContinuousAlarm: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "4",
|
|
|
+ alarmLevel: 4,
|
|
|
+ isAlart: true,
|
|
|
+ isAlarmSound: true,
|
|
|
+ isContinuousAlarm: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "5",
|
|
|
+ alarmLevel: 5,
|
|
|
+ isAlart: true,
|
|
|
+ isAlarmSound: true,
|
|
|
+ isContinuousAlarm: true,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ localStorage.setItem(
|
|
|
+ "alarmConfigArray",
|
|
|
+ JSON.stringify(this.alarmConfigArray)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
"$store.state.alarmResetFlg"() {
|
|
|
- getAlartConfig()
|
|
|
- .then((res) => {
|
|
|
- this.alarmConfigArray = res.data;
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- this.BASE.showMsg({
|
|
|
- msg: "报警配置获取失败,请重试",
|
|
|
- });
|
|
|
- });
|
|
|
+ // getAlartConfig()
|
|
|
+ // .then((res) => {
|
|
|
+ // this.alarmConfigArray = res.data;
|
|
|
+ // })
|
|
|
+ // .catch(() => {
|
|
|
+ // this.BASE.showMsg({
|
|
|
+ // msg: "报警配置获取失败,请重试",
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ this.getAlarmConfig();
|
|
|
},
|
|
|
},
|
|
|
};
|
|
@@ -617,7 +694,7 @@ export default {
|
|
|
<style lang="scss" scoped>
|
|
|
.alarmBox {
|
|
|
height: calc(100% - 180px);
|
|
|
- padding: 0 12px 0 30px;
|
|
|
+ padding: 0 12px 15px 30px;
|
|
|
position: absolute;
|
|
|
right: 0;
|
|
|
bottom: 0;
|
|
@@ -789,11 +866,33 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ .collapseBtn {
|
|
|
+ right: 12px;
|
|
|
+ bottom: 0;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #909399;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ white-space: nowrap;
|
|
|
+ position: absolute;
|
|
|
+ pointer-events: auto;
|
|
|
+ user-select: none;
|
|
|
+ cursor: pointer;
|
|
|
+ transition: 0.2s;
|
|
|
+ }
|
|
|
+
|
|
|
&.notEmpty:hover {
|
|
|
// background: rgba(0, 0, 0, 0.12);
|
|
|
// box-shadow: 0 0 12px rgba(0, 0, 0, 0.12);
|
|
|
transition: 0.2s;
|
|
|
}
|
|
|
+
|
|
|
+ &.collapseAlarmBox {
|
|
|
+ width: 0;
|
|
|
+ height: 0;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|
|
|
<style lang="scss">
|