projects/mesxc-zhp
в projects/mesxc-test
5 месяцев назад
@@ -1,10 +1,3 @@ | |||
/* | |||
* @Author: zhp | |||
* @Date: 2024-01-29 17:05:25 | |||
* @LastEditTime: 2024-01-29 17:05:25 | |||
* @LastEditors: zhp | |||
* @Description: | |||
*/ | |||
/** | |||
* 发起websocket请求函数 | |||
* @param {string} url ws连接地址 | |||
@@ -49,7 +42,7 @@ export function WsConnect(url, agentData, successCallback, errCallback) { | |||
this.lockReconnect = true; | |||
this.wsCreateHandler && clearTimeout(this.wsCreateHandler); | |||
// 关闭心跳检查 | |||
// heartCheck.stop(); | |||
heartCheck.stop(); | |||
} | |||
}; | |||
const initWsEventHandle = () => { | |||
@@ -57,13 +50,13 @@ export function WsConnect(url, agentData, successCallback, errCallback) { | |||
// 连接成功 | |||
this.wsObj.onopen = (event) => { | |||
onWsOpen(event); | |||
// heartCheck.start(); | |||
heartCheck.start(); | |||
}; | |||
// 监听服务器端返回的信息 | |||
this.wsObj.onmessage = (event) => { | |||
onWsMessage(event); | |||
// heartCheck.start(); | |||
heartCheck.start(); | |||
}; | |||
this.wsObj.onclose = (event) => { | |||
@@ -130,7 +123,7 @@ export function WsConnect(url, agentData, successCallback, errCallback) { | |||
if (this.lockReconnect) { | |||
return; | |||
} | |||
writeToScreen("3秒后重连"); | |||
writeToScreen("5秒后重连"); | |||
this.lockReconnect = true; | |||
// 没连接上会一直重连,设置延迟避免请求过多 | |||
this.wsCreateHandler && clearTimeout(this.wsCreateHandler); | |||
@@ -139,10 +132,40 @@ export function WsConnect(url, agentData, successCallback, errCallback) { | |||
this.createWebSoket(); | |||
this.lockReconnect = false; | |||
writeToScreen("重连完成"); | |||
}, 3000); | |||
}, 5000); | |||
}; | |||
// 心跳检查(看看websocket是否还在正常连接中) | |||
// 心跳检查(看看websocket是否还在正常连接中,不需要服务端返回,单向的) | |||
let _this = this | |||
let heartCheck = { | |||
timeout: 55000, | |||
timeoutObj: null, | |||
// 重启 | |||
reset() { | |||
clearTimeout(this.timeoutObj); | |||
this.start(); | |||
}, | |||
// 停止 | |||
stop() { | |||
clearTimeout(this.timeoutObj); | |||
}, | |||
// 开启定时器 | |||
start() { | |||
this.timeoutObj && clearTimeout(this.timeoutObj); | |||
this.timeoutObj = setTimeout(() => { | |||
writeToScreen("心跳检查,发送ping到后台"); | |||
try { | |||
const datas = { ping: true }; | |||
_this.wsObj.send(JSON.stringify(datas)); | |||
} catch (err) { | |||
writeToScreen("发送ping异常"); | |||
} | |||
}, this.timeout); | |||
}, | |||
}; | |||
// 心跳检查(看看websocket是否还在正常连接中,和服务端通信,双向的) | |||
// let heartCheck = { | |||
// timeout: 15000, | |||
// timeoutObj: null, | |||
@@ -167,7 +190,7 @@ export function WsConnect(url, agentData, successCallback, errCallback) { | |||
// writeToScreen("心跳检查,发送ping到后台"); | |||
// try { | |||
// const datas = { ping: true }; | |||
// this.wsObj.send(JSON.stringify(datas)); | |||
// _this.wsObj.send(JSON.stringify(datas)); | |||
// } catch (err) { | |||
// writeToScreen("发送ping异常"); | |||
// } | |||
@@ -1,7 +1,7 @@ | |||
<!-- | |||
* @Author: zhp | |||
* @Date: 2024-01-24 15:15:24 | |||
* @LastEditTime: 2024-03-26 17:56:11 | |||
* @LastEditTime: 2024-03-27 09:27:23 | |||
* @LastEditors: zhp | |||
* @Description: | |||
--> | |||
@@ -16,9 +16,9 @@ | |||
</el-date-picker> | |||
</el-form-item> | |||
<el-form-item> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-month:query')" type="primary" size="small" | |||
<el-button v-if="this.$auth.hasPermi('base:report-auto-original-glass:query')" type="primary" size="small" | |||
@click="getDataList">查询</el-button> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-month:export')" type="primary" size="small" plain | |||
<el-button v-if="this.$auth.hasPermi('report:glass-day:export')" type="primary" size="small" plain | |||
@click="handleExport">导出</el-button> | |||
</el-form-item> | |||
</el-form> | |||
@@ -1,7 +1,7 @@ | |||
<!-- | |||
* @Author: Do not edit | |||
* @Date: 2023-12-13 14:10:04 | |||
* @LastEditTime: 2024-03-22 09:45:23 | |||
* @LastEditTime: 2024-03-27 09:22:51 | |||
* @LastEditors: zhp | |||
* @Description: | |||
--> | |||
@@ -206,12 +206,10 @@ const cols = [ | |||
}, | |||
methods: { | |||
handleReturn() { | |||
// this.disabled = true | |||
this.edit = false | |||
console.log(this.$parent.getDataList()); | |||
}, | |||
handleChange(e) { | |||
// console.log(q) | |||
console.log(e); | |||
}, | |||
updateData() { | |||
let obj = {} | |||
@@ -7,7 +7,7 @@ | |||
</el-date-picker> | |||
</el-form-item> | |||
<el-form-item> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-month:query')" type="primary" size="small" | |||
<el-button v-if="this.$auth.hasPermi('base:report-auto-original-glass:query')" type="primary" size="small" | |||
@click="getDataList">查询</el-button> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-month:export')" type="primary" size="small" plain | |||
@click="handleExport">导出</el-button> | |||
@@ -14,7 +14,7 @@ | |||
</el-date-picker> | |||
</el-form-item> | |||
<el-form-item> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-weekly:query')" type="primary" size="small" | |||
<el-button v-if="this.$auth.hasPermi('base:report-auto-original-glass:query')" type="primary" size="small" | |||
@click="getDataList">查询</el-button> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-weekly:export')" type="primary" size="small" plain | |||
@click="handleExport">导出</el-button> | |||
@@ -9,7 +9,7 @@ | |||
</el-date-picker> | |||
</el-form-item> | |||
<el-form-item> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-year:query')" type="primary" size="small" | |||
<el-button v-if="this.$auth.hasPermi('base:report-auto-original-glass:query')" type="primary" size="small" | |||
@click="getDataList">查询</el-button> | |||
<el-button v-if="this.$auth.hasPermi('report:glass-year:export')" type="primary" size="small" plain | |||
@click="handleExport">导出</el-button> | |||
@@ -1,7 +1,7 @@ | |||
<!-- | |||
* @Author: zhp | |||
* @Date: 2023-12-12 13:45:25 | |||
* @LastEditTime: 2024-03-26 09:41:07 | |||
* @LastEditTime: 2024-03-27 09:21:00 | |||
* @LastEditors: zhp | |||
* @Description: | |||
--> | |||
@@ -456,6 +456,8 @@ export default { | |||
handleReturn() { | |||
this.disabled = true | |||
this.isSave = false | |||
this.getDataList() | |||
}, | |||
format(shijianchuo) { | |||
//shijianchuo是整数,否则要parseInt转换 | |||