diff --git a/src/views/management/monitoringEquipment/photographicDevice/components/parameterSetDialog.vue b/src/views/management/monitoringEquipment/photographicDevice/components/parameterSetDialog.vue index 21c090e..31751a8 100644 --- a/src/views/management/monitoringEquipment/photographicDevice/components/parameterSetDialog.vue +++ b/src/views/management/monitoringEquipment/photographicDevice/components/parameterSetDialog.vue @@ -186,19 +186,19 @@ > @@ -216,14 +216,14 @@ label-width="124px" > - + - + @@ -391,16 +391,17 @@ export default { }, //id参数 idParameter: { - newcmdid: "", - compid: "", - orgid: "", + newCmdId: "", + componentId: "", + originalId: "", }, runStatusForm: {}, gpsForm: {}, //gps位置 tabsActive: "first", rowData: {}, requestid: "", - uptimer: null, + + timer: null, i: 0, }; }, @@ -410,6 +411,9 @@ export default { methods: { //tab被触发 handleClick(tab, event) { + window.clearInterval(this.timer); + this.timer = null; + this.i = 0; console.log(tab, event); //每次切换重置选项卡 this.tabsActive = "first"; @@ -431,22 +435,22 @@ export default { samphandleClick() { this.samplingForm = {}; this.i = 0; - clearInterval(this.uptimer); - this.uptimer = null; + this.timer = null; + clearInterval(this.timer); }, //上位机重置数据 uphandleClick() { this.upperComputer = {}; this.i = 0; - clearInterval(this.uptimer); - this.uptimer = null; + this.timer = null; + clearInterval(this.timer); }, //id重置数据 idhandleClick() { this.idParameter = {}; this.i = 0; - clearInterval(this.uptimer); - this.uptimer = null; + this.timer = null; + clearInterval(this.timer); }, //采样参数查询 // -act=sampling [0xA4 ] --flag=[Request Set Flag, default is set=1, 0: request] --rf=[Request Flag] --reqtype=[Request Type] --maintime=[Main Time] --samplecount=[Sample Count] --samplingfreq=[Sample Frequency] --heartbeat=[Heartbeat Time] @@ -677,15 +681,15 @@ export default { }, { name: "newcmdid", - value: this.idParameter.newcmdid, + value: this.idParameter.newCmdId, }, { name: "compid", - value: this.idParameter.compid, + value: this.idParameter.componentId, }, { name: "orgid", - value: this.idParameter.orgid, + value: this.idParameter.originalId, }, ]; this.setTermFn(params); @@ -718,44 +722,60 @@ export default { .then((res) => { console.log(res); this.requestid = res.data.requestId; - this.getinfo(); - this.uptimer = window.setInterval(() => { + //this.getinfo1(); + + clearInterval(this.timer); + this.timer = window.setInterval(() => { this.getinfo(); this.i++; }, 1000); + // this.timer = setInterval(() => { + // this.getinfo(); + // this.i++; + // }, 1000); }) .catch((err) => {}); }, + getinfo1() { + console.log("jinlaile"); + if (this.i > 10) { + console.log(this.i); + // console.log(this.i); + window.clearInterval(this.timer); + this.timer = null; + this.i = 0; + } + }, getinfo() { getTermCameraRequest({ requestid: this.requestid }) .then((res) => { if (res.data.success == 1) { + window.clearInterval(this.timer); + this.timer = null; this.i = 0; - clearInterval(this.uptimer); - this.uptimer = null; console.log("终止轮询"); // && res.data.result == 255 console.log(JSON.parse(res.data.data)); this.samplingForm = JSON.parse(res.data.data); - console.log(this.tabsActive); + //ip地址解析开始 this.upperComputer = JSON.parse(res.data.data); - console.log(this.upperComputer); + //修改cmdid + this.idParameter = JSON.parse(res.data.data); let hexArray = this.upperComputer.ip .toString(16) .match(/.{1,2}/g) .reverse(); console.log(hexArray); - - for (let i = 0; i < hexArray.length; i++) { - console.log(hexArray[i]); - console.log(parseInt(hexArray[i], 16)); - hexArray[i] = parseInt(hexArray[i], 16); + for (let j = 0; j < hexArray.length; j++) { + console.log(hexArray[j]); + console.log(parseInt(hexArray[j], 16)); + hexArray[j] = parseInt(hexArray[j], 16); } console.log(hexArray); this.upperComputer.ip = hexArray.join("."); + //ip地址解析结束 - this.idParameter = JSON.parse(res.data.data); - + console.log(this.idParameter); this.$message({ duration: 1500, showClose: true, @@ -763,10 +783,9 @@ export default { type: "success", }); } else if (this.i > 9) { - this.loading = false; + window.clearInterval(this.timer); + this.timer = null; this.i = 0; - clearInterval(this.uptimer); - this.uptimer = null; this.$message({ duration: 1500, showClose: true, @@ -850,10 +869,18 @@ export default { this.idParameter = {}; this.gpsForm = {}; this.i = 0; - clearInterval(this.uptimer); - this.uptimer = null; + clearInterval(this.timer); + this.timer = null; }, }, + destroyed() { + if (this.timer) { + console.log(this.timer); + clearInterval(this.timer); + this.timer = null; + this.i = 0; + } //利用vue的生命周期函数 + }, };