|
@@ -101,12 +101,12 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 一键灭火 -->
|
|
|
- <view class="outfire" v-if='outfireData.isexist'>
|
|
|
- <view class="outfire_li" v-if="outfireData.online">
|
|
|
+ <view class="outfire" v-if='fireType'>
|
|
|
+ <view class="outfire_li" v-if="!fireListType">
|
|
|
<img src="@/images/icon_sy_wt.png">
|
|
|
<text style="color: #FF7B1A;">设备已离线,请及时处理。</text>
|
|
|
</view>
|
|
|
- <view class="outfire_li" v-if="outfireData.outfireing">
|
|
|
+ <view class="outfire_li" v-if="fireStartType">
|
|
|
<img src="@/images/icon_sy_mhwc.png">
|
|
|
<text style="color: #FF2333;">灭火中,灭火程序将于<text>{{conductCountdown}}</text>秒后结束</text>
|
|
|
</view>
|
|
@@ -114,7 +114,7 @@
|
|
|
<img src="@/images/icon_sy_mhwc.png">
|
|
|
<text style="color: #FF2333;">灭火完成,请您及时补充灭火设备耗材</text>
|
|
|
</view>
|
|
|
- <template v-if="!outfireData.online && !outfireData.outfireing && !outfireEnd">
|
|
|
+ <template v-if="fireListType">
|
|
|
<view class="outfire_li">
|
|
|
<img v-if='!outfireData.smoke' src="@/images/icon_yw_zc.png">
|
|
|
<img v-if='outfireData.smoke' src="@/images/icon_yw_yc.png">
|
|
@@ -133,8 +133,8 @@
|
|
|
<text :class="outfireData.fire?'abnormal':'normal'">{{outfireData.fire?'发现火焰':'无火焰'}}</text>
|
|
|
</view>
|
|
|
</template>
|
|
|
- <view v-if="!outfireData.online && !outfireData.outfireing && !outfireEnd"
|
|
|
- :class="!outfireData.online?'outfire_yes_btn':'outfire_no_btn'" @click="outfireFun()">一键灭火
|
|
|
+ <view v-if="fireListType"
|
|
|
+ :class="!fireListType?'outfire_yes_btn':'outfire_no_btn'" @click="outfireFun()">一键灭火
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 视频部分 -->
|
|
@@ -214,7 +214,8 @@
|
|
|
GetStartList,
|
|
|
firedeviceStatus,
|
|
|
firedeviceStatusTiming,
|
|
|
- firedeviceStart
|
|
|
+ firedeviceStart,
|
|
|
+ firedeviceCancel
|
|
|
} from '@/api/index.js'
|
|
|
import {
|
|
|
getBuildOrFloorList,
|
|
@@ -309,7 +310,7 @@
|
|
|
broadcastType: false,
|
|
|
address: "",
|
|
|
videoHardwareNUM: [], //实验室和楼道摄像头编码
|
|
|
- outfireData: {}, //一键灭火
|
|
|
+
|
|
|
|
|
|
countdown: '', //倒计时
|
|
|
timer2: null, //倒计时
|
|
@@ -327,13 +328,25 @@
|
|
|
//新MQTT
|
|
|
floorClient: {},
|
|
|
evacuationTopic: "lab/newexit/line", //疏散
|
|
|
+ //灭火设备MQTT相关
|
|
|
+ fireClient:{},
|
|
|
+ fireTopic:"lab/fireDevice/Warn/",//传感器状态异常
|
|
|
+ fireOnlineTopic:"lab/fireDevice/isOnline/",//设备是否在线
|
|
|
+ firePerformTopic:"lab/fireDevice/executing/",//是否正在执行灭火操作
|
|
|
+
|
|
|
+
|
|
|
+ fireType:false,//有无火焰设备状态
|
|
|
+ fireListType:false,//灭火设备在线离线
|
|
|
+ fireCode:'',// //灭火设备code
|
|
|
+ fireStartType:false, //灭火启动状态
|
|
|
+ outfireData: {}, //一键灭火
|
|
|
}
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
this.treeselectByUser();
|
|
|
- //一键灭火正式使用需要注销
|
|
|
- this.itemData.subjectId=85
|
|
|
- this.firedeviceStatus();
|
|
|
+ //一键灭火正式使用需要注销
|
|
|
+ this.itemData.subjectId=85
|
|
|
+ this.firedeviceStatus();
|
|
|
},
|
|
|
onShow() {
|
|
|
|
|
@@ -356,53 +369,69 @@
|
|
|
async firedeviceStatus() {
|
|
|
let _this = this;
|
|
|
|
|
|
- const {
|
|
|
- data
|
|
|
- } = await firedeviceStatus(_this.itemData.subjectId)
|
|
|
+ const {data} = await firedeviceStatus(_this.itemData.subjectId)
|
|
|
if (data.code == 200) {
|
|
|
- _this.outfireData = data.data
|
|
|
- //灭火进行中倒计时
|
|
|
- if (_this.conductCountdown == 30) {
|
|
|
- _this.conductCountdown += data.data.fireDevice.deviceCountDown
|
|
|
- _this.sendCode2()
|
|
|
+
|
|
|
+ if(data.data.isexist){//是否有灭火设备
|
|
|
+ this.$set(this,'fireType',data.data.isexist);
|
|
|
+ if(data.data.online){
|
|
|
+ _this.outfireData = data.data
|
|
|
+ _this.$set(this,'fireListType',data.data.online);
|
|
|
+ _this.$set(this,'fireCode',data.data.fireDevice.deviceCode);
|
|
|
+ _this.offMQTT('on');
|
|
|
+ if(data.data.temperature && data.data.smoke){
|
|
|
+ if(!this.fireStartType){
|
|
|
+ this.$set(this,'fireStartType',true);
|
|
|
+ this.sendCode2(data.data.timeDifference);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.$set(this,'fireListType',false);
|
|
|
+ this.$set(this,'fireCode',null);
|
|
|
+ this.offMQTT('on');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.$set(this,'fireType',false);
|
|
|
+ this.offMQTT('on');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
},
|
|
|
- //一键灭火-查询设备状态
|
|
|
- async firedeviceStatusTiming() {
|
|
|
- let _this = this;
|
|
|
- const {
|
|
|
- data
|
|
|
- } = await firedeviceStatusTiming(_this.outfireData.fireDevice.deviceCode)
|
|
|
- if (data.code == 200) {
|
|
|
- _this.outfireData.fire = data.data.fire
|
|
|
- _this.outfireData.online = data.data.online
|
|
|
- _this.outfireData.smoke = data.data.smoke
|
|
|
- _this.outfireData.temperature = data.data.temperature
|
|
|
- }
|
|
|
- },
|
|
|
//启动灭火设备
|
|
|
async firedeviceStart() {
|
|
|
let _this = this;
|
|
|
- const {
|
|
|
- data
|
|
|
- } = await firedeviceStart(_this.itemData.subjectId)
|
|
|
+ let obj={
|
|
|
+ subjectId:_this.itemData.subjectId,
|
|
|
+ deviceCode:_this.fireCode
|
|
|
+ }
|
|
|
+ const {data} = await firedeviceStart(obj)
|
|
|
if (data.code == 200) {
|
|
|
- if (data.data.flg) {
|
|
|
- _this.conductCountdown = 30;
|
|
|
- _this.firedeviceStatus();
|
|
|
+ if (data.data.online) {
|
|
|
+ _this.dialogVisible = true;
|
|
|
+ _this.countdown = data.data.waitTime;//灭火倒计时
|
|
|
+ _this.sendCode() //倒计时
|
|
|
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
- title: '灭火失败!',
|
|
|
+ title: '一键灭火启动失败!',
|
|
|
icon: "none",
|
|
|
duration: 6000
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+ //取消灭火设备
|
|
|
+ async firedeviceCancel() {
|
|
|
+ let _this = this;
|
|
|
+ const {data} = await firedeviceCancel(_this.itemData.subjectId)
|
|
|
+ if (data.code == 200) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '放弃一键灭火失败!',
|
|
|
+ icon: "none",
|
|
|
+ duration: 6000
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
//一键灭火按钮
|
|
|
outfireFun() {
|
|
|
let _this = this;
|
|
@@ -414,9 +443,8 @@
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
console.log('用户点击确定');
|
|
|
- _this.dialogVisible = true;
|
|
|
- _this.countdown = 6;
|
|
|
- _this.sendCode() //倒计时
|
|
|
+ _this.firedeviceStart(); //启动灭火设备
|
|
|
+
|
|
|
} else if (res.cancel) {
|
|
|
console.log('用户点击取消');
|
|
|
}
|
|
@@ -433,6 +461,7 @@
|
|
|
cancelOutfire() {
|
|
|
this.dialogVisible = false;
|
|
|
this.clearTimer(); //关闭定时器
|
|
|
+ this.firedeviceCancel()
|
|
|
},
|
|
|
//倒计时
|
|
|
sendCode() {
|
|
@@ -442,8 +471,6 @@
|
|
|
//创建定时器
|
|
|
if (_this.countdown === 1) {
|
|
|
_this.clearTimer(); //关闭定时器
|
|
|
- _this.firedeviceStart(); //启动灭火设备
|
|
|
-
|
|
|
} else {
|
|
|
_this.loading();
|
|
|
}
|
|
@@ -459,10 +486,12 @@
|
|
|
this.timer2 = null;
|
|
|
this.dialogVisible = false;
|
|
|
this.countdown = 6;
|
|
|
+
|
|
|
},
|
|
|
//进行中倒计时
|
|
|
- sendCode2() {
|
|
|
+ sendCode2(time) {
|
|
|
let _this = this;
|
|
|
+ _this.$set(self,'conductCountdown',time);
|
|
|
_this.loading2(); //启动定时器
|
|
|
_this.timer3 = setInterval(() => {
|
|
|
//创建定时器
|
|
@@ -1128,6 +1157,21 @@
|
|
|
this.getBuildingData();
|
|
|
}
|
|
|
});
|
|
|
+ this.floorClient.subscribe(this.fireTopic+this.fireCode, (err) => {
|
|
|
+ if (!err) {
|
|
|
+ console.log("火灾传感器状态-订阅成功:" + this.fireTopic+this.fireCode);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.floorClient.subscribe(this.fireOnlineTopic+this.fireCode, (err) => {
|
|
|
+ if (!err) {
|
|
|
+ console.log("火灾设备是否在线-订阅成功:" + this.fireOnlineTopic+this.fireCode);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.floorClient.subscribe(this.firePerformTopic+this.fireCode, (err) => {
|
|
|
+ if (!err) {
|
|
|
+ console.log("火灾是否正在执行灭火操作-订阅成功:" + this.firePerformTopic+this.fireCode);
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
// 自动重连
|
|
|
this.floorClient.on('reconnect', (msg) => {
|
|
@@ -1165,6 +1209,24 @@
|
|
|
self.getBuildingData();
|
|
|
}, 2000);
|
|
|
}
|
|
|
+ }else if(topic == (self.fireTopic + self.fireCode)){
|
|
|
+ //传感器状态
|
|
|
+ console.log('传感器状态');
|
|
|
+ self.firedeviceStatus();
|
|
|
+ }else if(topic == (self.fireOnlineTopic + self.fireCode)){
|
|
|
+ //设备在线状态
|
|
|
+ console.log('设备在线状态');
|
|
|
+ }else if(topic == (self.firePerformTopic + self.fireCode)){
|
|
|
+ //灭火执行操作
|
|
|
+ if(data.fireStatus == 1){
|
|
|
+ if(!self.fireStartType){
|
|
|
+ self.$set(self,'fireStartType',true);
|
|
|
+ self.$set(self,'fireStartText','灭火中');
|
|
|
+ self.fireStartTimeFunction(data.direTime);
|
|
|
+ }else if(data.fireStatus == 0){
|
|
|
+ self.msgError('一键灭火启动失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -1175,12 +1237,28 @@
|
|
|
},
|
|
|
//关闭MQTT连接
|
|
|
offMQTT(type) {
|
|
|
+ let self = this;
|
|
|
if (this.floorClient.unsubscribe) {
|
|
|
this.floorClient.unsubscribe(this.evacuationTopic + this.floorId, error => {
|
|
|
if (error) {
|
|
|
console.log('疏散连接-关闭错误', error)
|
|
|
}
|
|
|
});
|
|
|
+ this.floorClient.unsubscribe(self.fireTopic+self.fireCode, error => {
|
|
|
+ if (error) {
|
|
|
+ console.log('火灾传感器状态-MQTT断开报错=>', error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.floorClient.unsubscribe(self.fireOnlineTopic+self.fireCode, error => {
|
|
|
+ if (error) {
|
|
|
+ console.log('火灾设备是否在线-MQTT断开报错=>', error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.floorClient.unsubscribe(self.firePerformTopic+self.fireCode, error => {
|
|
|
+ if (error) {
|
|
|
+ console.log('火灾是否正在执行灭火操作-MQTT断开报错=>', error)
|
|
|
+ }
|
|
|
+ })
|
|
|
this.floorClient.end(true);
|
|
|
this.$set(this, 'floorClient', {});
|
|
|
}
|