规则修改

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

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

@ -5,6 +5,7 @@
</template> </template>
<script> <script>
import socketService from "../socket/index";
export default { export default {
data() { data() {
return { return {
@ -12,14 +13,31 @@ export default {
htmlFontSize: 16, // html htmlFontSize: 16, // html
}; };
}, },
mounted() {
async mounted() {
this.setRemUnit(); this.setRemUnit();
this.windowResize(); this.windowResize();
this.initWebSocket();
window.addEventListener("onmessageWS", this.getSocketData);
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener("resize", this.windowResize); window.removeEventListener("resize", this.windowResize);
}, },
methods: { 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() { setRemUnit() {
// rem // rem
const remUnit = () => { const remUnit = () => {
@ -37,6 +55,9 @@ export default {
document.documentElement.style.fontSize = `${remUnit()}px`; document.documentElement.style.fontSize = `${remUnit()}px`;
}, },
}, },
destroyed() {
this.$websocket.close();
},
}; };
</script> </script>
<style lang="less"> <style lang="less">

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

@ -93,7 +93,7 @@
<script> <script>
import { warningListApi } from "@/utils/api/index"; import { warningListApi } from "@/utils/api/index";
import warnDialog from "./components/warnDialog.vue"; import warnDialog from "./components/warnDialog.vue";
import socketService from "../../../../socket/index";
export default { export default {
name: "warnmessage", name: "warnmessage",
components: { components: {
@ -125,25 +125,8 @@ export default {
this.getwarnList(); this.getwarnList();
}, },
created() {}, 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() { lookMore() {
this.params.startTime = this.starttime; this.params.startTime = this.starttime;
this.params.endTime = this.endtime; this.params.endTime = this.endtime;
@ -171,9 +154,6 @@ export default {
}); });
}, },
}, },
destroyed() {
this.$websocket.close();
},
}; };
</script> </script>

Loading…
Cancel
Save