|
|
|
|
@ -310,6 +310,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
path:'ws://192.168.1.12/blade-datahttp/ws',//socket地址 |
|
|
|
|
build: "00", //楼 |
|
|
|
|
floored: null, //楼层 |
|
|
|
|
controlAll: 2, //批量控制开关 |
|
|
|
|
@ -455,8 +456,13 @@ export default { |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
this.getNavigationMap(); |
|
|
|
|
this.initSocket(); |
|
|
|
|
}, |
|
|
|
|
beforeDestroy() { |
|
|
|
|
if (this.socket) { |
|
|
|
|
this.socket.close(); |
|
|
|
|
this.socket = ""; |
|
|
|
|
} |
|
|
|
|
if (this.setInterval) { |
|
|
|
|
clearInterval(this.setInterval); |
|
|
|
|
} |
|
|
|
|
@ -465,6 +471,47 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
//socket 接收空开状态 |
|
|
|
|
initSocket() { |
|
|
|
|
if (typeof (WebSocket) === "undefined") { |
|
|
|
|
alert("您的浏览器不支持socket"); |
|
|
|
|
} else { |
|
|
|
|
this.socket = new WebSocket(this.path); |
|
|
|
|
// 监听socket连接 |
|
|
|
|
this.socket.onopen = this.open; |
|
|
|
|
// 监听socket错误信息 |
|
|
|
|
this.socket.onerror = this.error; |
|
|
|
|
// 监听socket消息 |
|
|
|
|
this.socket.onmessage = this.getMessage; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
open() { |
|
|
|
|
console.log("socket连接成功") |
|
|
|
|
}, |
|
|
|
|
error() { |
|
|
|
|
console.log("socket连接错误") |
|
|
|
|
}, |
|
|
|
|
getMessage(msg) { |
|
|
|
|
console.log('scoket 模拟',msg) |
|
|
|
|
let retData = JSON.parse(msg.data); |
|
|
|
|
if (this.tableData.floorData && this.tableData.floorData.length > 0) { |
|
|
|
|
this.tableData.floorData.map((item1,index) => { |
|
|
|
|
let lightObjIndex = item1.lightList.findIndex(item2 => item2.code == retData.code); |
|
|
|
|
if(lightObjIndex > -1 && item1.lightList[lightObjIndex].openStatus != retData.openStatus){ |
|
|
|
|
item1.lightList[lightObjIndex].openStatus = retData.openStatus; |
|
|
|
|
if(retData.openStatus == 1){ |
|
|
|
|
//开灯 |
|
|
|
|
console.log(item1.lightList[lightObjIndex].name,'开灯') |
|
|
|
|
this.getLight([{arr: item1.lightList[lightObjIndex].ctrlList.split(','),build: item1.lightList[lightObjIndex].build}]); |
|
|
|
|
}else{ |
|
|
|
|
//关灯 |
|
|
|
|
console.log(item1.lightList[lightObjIndex].name,'关灯') |
|
|
|
|
this.cleanLight([{arr: item1.lightList[lightObjIndex].ctrlList.split(','),build: item1.lightList[lightObjIndex].build}]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//关闭告警 - 重新查询告警列表 |
|
|
|
|
doCancelWarn(id) { |
|
|
|
|
getCancelWarn(id).then((res) => { |
|
|
|
|
@ -567,6 +614,7 @@ export default { |
|
|
|
|
bfHelper.setColor("#a5bbe5", offList); |
|
|
|
|
}, |
|
|
|
|
getNavigationMap() { |
|
|
|
|
// bfHelper.mapDestroy(); |
|
|
|
|
setTimeout(() => { |
|
|
|
|
commonValue.getNavigationMap("water"); |
|
|
|
|
}); |
|
|
|
|
@ -606,6 +654,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (arr.length > 0) { |
|
|
|
|
// console.log('arr', arr) |
|
|
|
|
bfHelper.setGlowEffectById(arr); //根据构件ID设置发光效果 |
|
|
|
|
bfHelper.setColor("#fff99a", arr); |
|
|
|
|
bfHelper.restoreComponentsOpacityById(arr); |
|
|
|
|
@ -693,7 +742,11 @@ export default { |
|
|
|
|
this.$message.success("指令发送成功"); |
|
|
|
|
if (res.data.data[0].status == 1) { |
|
|
|
|
// this.getSblb(); |
|
|
|
|
this.checkLight(); |
|
|
|
|
// this.checkLight(); |
|
|
|
|
//模拟 |
|
|
|
|
// setTimeout(() => { |
|
|
|
|
// this.getMessage({code: row.code, openStatus: 1, ctrlList: row.ctrlList, build: row.build}); |
|
|
|
|
// },10*1000) |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.data.data[0].msg); |
|
|
|
|
} |
|
|
|
|
@ -705,7 +758,11 @@ export default { |
|
|
|
|
this.$message.success("指令发送成功"); |
|
|
|
|
if (res.data.data[0].status == 1) { |
|
|
|
|
// this.getSblb(); |
|
|
|
|
this.checkLight(); |
|
|
|
|
// this.checkLight(); |
|
|
|
|
//模拟 |
|
|
|
|
// setTimeout(() => { |
|
|
|
|
// this.getMessage({code: row.code, openStatus: 2, ctrlList: row.ctrlList, build: row.build}); |
|
|
|
|
// },10*1000) |
|
|
|
|
} else { |
|
|
|
|
this.$message.warning(res.data.data[0].msg); |
|
|
|
|
} |
|
|
|
|
@ -734,7 +791,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// this.getSblb(); |
|
|
|
|
this.checkLight(); |
|
|
|
|
// this.checkLight(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
@ -761,7 +818,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// this.getSblb(); |
|
|
|
|
this.checkLight(); |
|
|
|
|
// this.checkLight(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
@ -786,7 +843,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// this.getSblb(); |
|
|
|
|
this.checkLight(); |
|
|
|
|
// this.checkLight(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
@ -808,13 +865,14 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// this.getSblb(); |
|
|
|
|
this.checkLight(); |
|
|
|
|
// this.checkLight(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
/** |
|
|
|
|
* 定时轮询空开状态 |
|
|
|
|
* 15秒执行一次,执行5次 |
|
|
|
|
* 废弃 - 变更使用socket 20230313 |
|
|
|
|
*/ |
|
|
|
|
checkLight() { |
|
|
|
|
if (this.intervalCheckLight == 0) { |
|
|
|
|
|