|
@@ -57,10 +57,7 @@
|
|
|
style="width: 100%"
|
|
|
v-loading="loading"
|
|
|
element-loading-text="Loading..."
|
|
|
- :element-loading-spinner="svg"
|
|
|
- element-loading-svg-view-box="-10, -10, 50, 50"
|
|
|
element-loading-background="rgba(0, 10, 0, 0.1)"
|
|
|
- @size-change="handleSizeChange"
|
|
|
:row-class-name="tableRowClassName"
|
|
|
:header-cell-style="{'background':' #375A88'}"
|
|
|
@select="projectsSelectionSelect"
|
|
@@ -84,7 +81,6 @@
|
|
|
layout="prev, total,pager, next, jumpe,"
|
|
|
:total="parseInt(total)"
|
|
|
class="mt-4"
|
|
|
- @size-change="handleSizeChange2"
|
|
|
@current-change="handleCurrentChange2"
|
|
|
/>
|
|
|
</div>
|
|
@@ -153,7 +149,6 @@
|
|
|
<template #title>
|
|
|
<el-icon class="iconimg Frame2" fit="contain" ></el-icon>
|
|
|
火灾<el-icon class="header-icon">
|
|
|
- <info-filled />
|
|
|
</el-icon>
|
|
|
</template>
|
|
|
<div class="asides_content">
|
|
@@ -254,7 +249,6 @@
|
|
|
<template #title>
|
|
|
<el-icon class="iconimg Frame3" fit="contain" ></el-icon>
|
|
|
突水<el-icon class="header-icon">
|
|
|
- <info-filled />
|
|
|
</el-icon>
|
|
|
</template>
|
|
|
<div class="asides_content">
|
|
@@ -353,7 +347,14 @@ const props= defineProps({
|
|
|
}
|
|
|
|
|
|
});
|
|
|
-
|
|
|
+ let websock=ref(null);
|
|
|
+ let times=ref({
|
|
|
+ lockReconnect: false, //是否真正建立连接
|
|
|
+ timeout: 28 * 1000, //30秒一次心跳
|
|
|
+ timeoutObj: null, //心跳倒计时
|
|
|
+ serverTimeout0bj: null, //
|
|
|
+ timeoutnum: null, //断开重连倒计时
|
|
|
+ })
|
|
|
let zqname=ref({});
|
|
|
let shiguobj=ref({
|
|
|
source:'自荐',
|
|
@@ -547,9 +548,6 @@ aid.value=val.aid;
|
|
|
idobj.value.name=val.name;
|
|
|
idobj.value.time=val.time;
|
|
|
}
|
|
|
-
|
|
|
-function handleSizeChange2(val) {
|
|
|
-}
|
|
|
function handleCurrentChange2(val){
|
|
|
currentPage4.value=val;
|
|
|
getdata();
|
|
@@ -692,6 +690,107 @@ const calculate=()=>{
|
|
|
ElMessage.error(err.returnMsg)
|
|
|
})
|
|
|
}
|
|
|
+const projectsSelectionSelect=()=>{
|
|
|
+}
|
|
|
+// 日志
|
|
|
+
|
|
|
+function initWebSocket() {
|
|
|
+ //初始化weosocket
|
|
|
+
|
|
|
+ // const wsuri = "ws://192.168.0.43:8087//websocket?projectId="+this.pid; ws://192.168.0.131/diswebsocket?projectId=5
|
|
|
+ const wsurl =
|
|
|
+ "ws://" +
|
|
|
+ process.env.VUE_APP_BASE_websokt +
|
|
|
+ "/diswebsocket?projectId=" +'5'
|
|
|
+ // aid.value;
|
|
|
+ websock = new WebSocket(wsurl);
|
|
|
+ websock.onopen = websocketonopen;
|
|
|
+ websock.onmessage = websocketonmessage;
|
|
|
+ websock.onerror = websocketonerror;
|
|
|
+ websock.onclose = websocketclose;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Websoket连接成功事件
|
|
|
+ const websocketonopen = (res) => {
|
|
|
+ console.log("WebSocket连接成功", res);
|
|
|
+ start();
|
|
|
+ beginprocess();
|
|
|
+ };
|
|
|
+ // Websoket接收消息事件
|
|
|
+ const websocketonmessage = (res) => {
|
|
|
+ // console.log("数据", res);
|
|
|
+ logs.value=res.data;
|
|
|
+ emit('getthislog',logs.value);
|
|
|
+ if(res.data.includes("Simulating")){
|
|
|
+ let data=res.data.replace(/\s/g, "");
|
|
|
+ console.log(data);
|
|
|
+ let num=data.match(/hour(\S*)minute/)[1];///hour(\S*)minut/
|
|
|
+ console.log(num)
|
|
|
+ }
|
|
|
+
|
|
|
+ reset();
|
|
|
+ };
|
|
|
+ // Websoket连接错误事件
|
|
|
+ const websocketonerror = (res) => {
|
|
|
+ console.log("连接错误", res);
|
|
|
+ socket.close();
|
|
|
+ reconnect();
|
|
|
+ };
|
|
|
+ // Websoket断开事件
|
|
|
+ const websocketclose = (res) => {
|
|
|
+ console.log("断开连接", res);
|
|
|
+ };
|
|
|
+ // 创建 websocket 的实例
|
|
|
+
|
|
|
+ // 心跳包
|
|
|
+ const reconnect = () => {
|
|
|
+ if (times.value.lockReconnect) return;
|
|
|
+ times.value.lockReconnect = true;
|
|
|
+ //没连接上会一直重连,设置延迟避免请求过多
|
|
|
+ times.value.timeoutnum && clearTimeout(times.value.timeoutnum);
|
|
|
+ times.value.timeoutnum = setTimeout(function () {
|
|
|
+ //新连接
|
|
|
+ initWebSocket();
|
|
|
+ times.value.lockReconnect = false;
|
|
|
+ }, 10000);
|
|
|
+ }
|
|
|
+ const reset = () => {
|
|
|
+ //重置心跳
|
|
|
+ clearTimeout(times.value.timeoutObj);
|
|
|
+ clearTimeout(times.value.serverTimeoutObj);
|
|
|
+ start();
|
|
|
+ }
|
|
|
+ const start = () => {
|
|
|
+ //开启心跳
|
|
|
+ times.value.timeoutObj && clearTimeout(times.value.timeoutObj);
|
|
|
+ times.value.serverTimeoutObj && clearTimeout(times.value.serverTimeoutObj);
|
|
|
+ times.value.timeoutObj = setTimeout(function () {
|
|
|
+ //这里发送一个心跳,后端收到后,返回一个心跳消息
|
|
|
+ if (websock.readyState == 1) {
|
|
|
+ //如果连接正常
|
|
|
+ websock.send("heartCheck");
|
|
|
+ } else {
|
|
|
+ //否则重连
|
|
|
+ reconnect();
|
|
|
+ }
|
|
|
+ times.value.serverTimeoutObj = setTimeout(function () {
|
|
|
+ // 超时关闭
|
|
|
+ websock.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
|
|
|
+ }, times.value.timeout);
|
|
|
+ }, times.value.timeout);
|
|
|
+ }
|
|
|
+ onMounted(()=>{
|
|
|
+ init();
|
|
|
+ //getdata();
|
|
|
+ })
|
|
|
+ // 组件被销毁之前,清空 sock 对象
|
|
|
+ onBeforeUnmount(() => {
|
|
|
+ // 关闭连接
|
|
|
+ websocketclose;
|
|
|
+ // 销毁 websocket 实例对象
|
|
|
+ websock.value = null;
|
|
|
+ });
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
});
|
|
|
|