规则修改

jc1.0
fanluyan 11 months ago
parent cc310207e4
commit 42928bfe7f

@ -88,16 +88,16 @@ const webSocketOnMessage = (e) => {
// WebSocket关闭处理
const closeWebsocket = (e) => {
console.log("WebSocket连接已关闭:", e);
if (!hasShownNotification) {
Notification({
title: "告警",
message: "WebSocket连接已关闭",
position: "bottom-right",
type: "warning",
duration: 2000,
});
hasShownNotification = true; // 更新状态,防止再次显示
}
// if (!hasShownNotification) {
// Notification({
// title: "告警",
// message: "WebSocket连接已关闭",
// position: "bottom-right",
// type: "warning",
// duration: 2000,
// });
// hasShownNotification = true; // 更新状态,防止再次显示
// }
// 清除所有定时器
clearTimeout(timeoutObj);

@ -5,6 +5,7 @@
</template>
<script>
import socketService from "../socket/index";
export default {
data() {
return {
@ -12,14 +13,31 @@ export default {
htmlFontSize: 16, // html
};
},
mounted() {
async mounted() {
this.setRemUnit();
this.windowResize();
this.initWebSocket();
window.addEventListener("onmessageWS", this.getSocketData);
},
beforeDestroy() {
window.removeEventListener("resize", this.windowResize);
},
methods: {
async initWebSocket() {
console.log(this.$websocket);
this.$websocket.initWebSocket();
},
getSocketData(res) {
console.log(res);
this.$notify({
title: "告警",
message: res.detail.data,
position: "bottom-right",
type: "warning",
duration: 0,
});
},
setRemUnit() {
// rem
const remUnit = () => {
@ -37,6 +55,9 @@ export default {
document.documentElement.style.fontSize = `${remUnit()}px`;
},
},
destroyed() {
this.$websocket.close();
},
};
</script>
<style lang="less">

@ -6,6 +6,7 @@
:visible.sync="rulesDialogshow"
width="520px"
:close-on-click-modal="false"
@close="hide"
>
<el-form
label-position="left"
@ -31,7 +32,7 @@
</el-select>
</el-form-item>
<el-form-item label="比较器:" prop="compareVal">
<el-select v-model="formInfo.compareVal" disabled>
<el-select v-model="formInfo.compareVal" @change="changecomVal">
<el-option
v-for="item in compareOptions"
:key="item.type"
@ -220,11 +221,15 @@ export default {
console.log(err); //
});
},
changecomVal() {
this.getOperator();
},
//
getOperator() {
listOperatorApi({ name: this.formInfo.compareVal })
.then((res) => {
console.log(res);
if (res.success) {
this.operatorValOptions = Object.keys(res.data).map((key) => ({
value: key, //
label: res.data[key], //
@ -233,6 +238,9 @@ export default {
if (this.formInfo.operatorVal == "") {
this.formInfo.operatorVal = this.operatorValOptions[0].value;
}
} else {
this.formInfo.operatorVal = "";
}
})
.catch((err) => {
console.log(err); //

@ -93,7 +93,7 @@
<script>
import { warningListApi } from "@/utils/api/index";
import warnDialog from "./components/warnDialog.vue";
import socketService from "../../../../socket/index";
export default {
name: "warnmessage",
components: {
@ -125,25 +125,8 @@ export default {
this.getwarnList();
},
created() {},
async mounted() {
this.initWebSocket();
window.addEventListener("onmessageWS", this.getSocketData);
},
methods: {
async initWebSocket() {
this.$websocket.initWebSocket();
},
getSocketData(res) {
console.log(res);
this.$notify({
title: "告警",
message: res.detail.data,
position: "bottom-right",
type: "warning",
duration: 0,
});
},
methods: {
lookMore() {
this.params.startTime = this.starttime;
this.params.endTime = this.endtime;
@ -171,9 +154,6 @@ export default {
});
},
},
destroyed() {
this.$websocket.close();
},
};
</script>

Loading…
Cancel
Save