laboratoryInfo.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  1. <!-- 我的实验室 -->
  2. <template>
  3. <view id="laboratoryInfo">
  4. <view class="name-max-box">
  5. <view class="title-box">
  6. <view :style="'border:1rpx solid '+itemData.fiedColor+';background:#fff;color:'+itemData.fiedColor+';'">{{itemData.levelName}}</view>
  7. <view>{{itemData.name}}</view>
  8. </view>
  9. <view class="address-box"><span>{{itemData.typeName}}</span>{{itemData.deptName}}</view>
  10. <view class="address-box-two">
  11. <img src="@/images/icon_14.png">
  12. <view>{{itemData.subAddrrStr}}</view>
  13. </view>
  14. </view>
  15. <view class="sensor-max-box" v-if="itemData.sensorFunctionList[0]&&!saoCodeType">
  16. <view class="title-max-box">
  17. <view class="left-view"></view>
  18. <view class="right-view">传感器</view>
  19. </view>
  20. <view class="text-box">
  21. <view class="min-box" v-for="(minItem,index2) in itemData.sensorFunctionList" :key="index2">
  22. <view class="min-min-box">
  23. <img v-show="minItem.hasWarn" src="@/images/icon_15.png">
  24. <view :class="{'colorA':minItem.hasWarn}">{{minItem.funcName}}:{{minItem.formatVal?minItem.formatVal:'-'}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- 一键灭火 -->
  30. <view class="outfire" v-if='fireType'>
  31. <view class="outfire_li" v-if="!fireListType">
  32. <img src="@/images/icon_sy_wt.png">
  33. <text style="color: #FF7B1A;">设备已离线,请及时处理。</text>
  34. </view>
  35. <view class="outfire_li" v-if="fireStartType">
  36. <img src="@/images/icon_sy_mhwc.png">
  37. <text style="color: #FF2333;">灭火中,灭火程序将于<text>{{conductCountdown}}</text>秒后结束</text>
  38. </view>
  39. <view class="outfire_li" v-if="outfireEnd">
  40. <img src="@/images/icon_sy_mhwc.png">
  41. <text style="color: #FF2333;">灭火完成,请您及时补充灭火设备耗材</text>
  42. </view>
  43. <template v-if="fireListType && !fireStartType && !outfireEnd">
  44. <view class="outfire_li">
  45. <img v-if='!outfireData.smoke' src="@/images/icon_yw_zc.png">
  46. <img v-if='outfireData.smoke' src="@/images/icon_yw_yc.png">
  47. <text
  48. :class="outfireData.smoke?'abnormal':'normal'">{{outfireData.smoke?'有烟雾':'无烟雾'}}</text>
  49. </view>
  50. <view class="outfire_li">
  51. <img v-if='!outfireData.temperature' src="@/images/icon_wd_zc.png">
  52. <img v-if='outfireData.temperature' src="@/images/icon_wd_yc.png">
  53. <text
  54. :class="outfireData.temperature?'abnormal':'normal'">{{outfireData.temperature?'温度异常':'温度正常'}}</text>
  55. </view>
  56. <view class="outfire_li">
  57. <img v-if='!outfireData.fire' src="@/images/icon_hy_zc.png">
  58. <img v-if='outfireData.fire' src="@/images/icon_hy_yc.png">
  59. <text :class="outfireData.fire?'abnormal':'normal'">{{outfireData.fire?'发现火焰':'无火焰'}}</text>
  60. </view>
  61. </template>
  62. <view v-if="fireListType && !fireStartType && !outfireEnd"
  63. :class="fireListType?'outfire_yes_btn':'outfire_no_btn'" @click="outfireFun()">一键灭火
  64. </view>
  65. </view>
  66. <view class="control-max-box" v-if="!saoCodeType">
  67. <view class="title-max-box">
  68. <view class="left-view"></view>
  69. <view class="right-view">智能控制</view>
  70. </view>
  71. <view class="button-max-box">
  72. <view class="button-box" v-if="itemData.videoNum>0">
  73. <view>视频监控</view>
  74. <view @click="goVideo()">查看</view>
  75. </view>
  76. <!-- <view class="button-box">
  77. <view>语音播报</view>
  78. <view @click="goWord()">播放文字</view>
  79. </view> -->
  80. <view class="for-button-box" v-for="(minItem,minIndex) in itemData.labHardwareVOList" :key="minIndex" v-if="minItem.hardwareTypeEnum.enumName!='VIDEO_MONITOR' && minItem.hardwareTypeEnum.enumName!='RFID_RECOGNIZER'&& minItem.hardwareTypeEnum.enumName!='AI_TERMINAL'&& minItem.hardwareTypeEnum.enumName!='AI_DOORLOCK'&& minItem.hardwareTypeEnum.enumName!='AI_CABINETLOCK' && minItem.hardwareName!='一键灭火' && minItem.isPcfire != '1'">
  81. <view class="for-button-p">{{minItem.hardwareName}}</view>
  82. <img v-if="minItem.state.code=='3' && minItem.pcType != 1" src="@/images/icon_10.png" @click="hardwareButton(minItem,'close')">
  83. <img v-if="minItem.state.code=='4' && minItem.pcType != 1" src="@/images/icon_11.png" @click="hardwareButton(minItem,'open')">
  84. <view class="for-button-p" v-if="minItem.state.code=='0' && minItem.pcType != 1">离线</view>
  85. <view class="for-button-p" v-if="minItem.state.code=='2' && minItem.pcType != 1" style="color:#0183FA;">在线</view>
  86. <view v-if="minItem.pcType == 1" class="pcType-button" @click="pcTypeButtonClick(minItem.id)">操作</view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="info-max-box">
  91. <view class="title-max-box" :class="{'title-max-box-none':!infoMaxBoxType}">
  92. <view class="left-view"></view>
  93. <view class="right-view">安全信息牌</view>
  94. <view class="click-view" @click="infoMaxBoxClick">
  95. <view>{{infoMaxBoxType?'收起':'展开'}}</view>
  96. <img v-if="infoMaxBoxType" src="@/images/icon_06_1.png">
  97. <img v-else src="@/images/icon_06.png">
  98. </view>
  99. </view>
  100. <view v-if="infoMaxBoxType">
  101. <view class="text-max-box">
  102. <view class="text-min-box">
  103. <view>责任单位:</view>
  104. <view>{{itemData.deptName}}</view>
  105. </view>
  106. <view class="text-min-box">
  107. <view>实验室负责人:</view>
  108. <view>{{itemData.safeInfo.subAdmin[0]?"":"未设置"}}</view>
  109. </view>
  110. <view class="text-min-box" v-for="(item,index) in itemData.safeInfo.subAdmin" :key="index">
  111. <view style="color:#999;">{{item.name}}</view>
  112. <view>{{item.phone?item.phone:'未填写'}}</view>
  113. </view>
  114. <view class="text-min-box">
  115. <view>安全负责人:</view>
  116. <view>{{itemData.safeInfo.safeUser[0]?"":"未设置"}}</view>
  117. </view>
  118. <view class="text-min-box" v-for="(item,index) in itemData.safeInfo.safeUser" :key="index">
  119. <view style="color:#999;">{{item.name}}</view>
  120. <view>{{item.phone?item.phone:'未填写'}}</view>
  121. </view>
  122. </view>
  123. <view class="safety-max-box" v-if="itemData.hazardCategory[0]||itemData.riskMeasure[0]||itemData.outfire[0]">
  124. <view class="max-for-box" v-if="itemData.hazardCategory[0]">
  125. <view class="title-box">主要危险类别</view>
  126. <view class="for-box" v-for="(item,index1) in itemData.hazardCategory" :key="index1">● {{item}}</view>
  127. </view>
  128. <view class="max-for-box" v-if="itemData.riskMeasure[0]">
  129. <view class="title-box">风险防控措施</view>
  130. <view class="for-box" v-for="(item,index1) in itemData.riskMeasure" :key="index1">● {{item}}</view>
  131. </view>
  132. <view class="max-for-box" v-if="itemData.outfire[0]">
  133. <view class="title-box">灭火要点</view>
  134. <view class="for-box" v-for="(item,index1) in itemData.outfire" :key="index1">● {{item}}</view>
  135. </view>
  136. </view>
  137. <view class="img-bottom-box" v-if="itemData.safeSigns[0]||itemData.qrCode">
  138. <view class="title-box">安全警示标识</view>
  139. <view class="for-box">
  140. <img class="img-ojb" src="@/images/icon_aqxxp_jzxy.png" v-if="item == 'xiyan'" v-for="(item,index) in itemData.safeSigns" :key="index">
  141. <img class="img-ojb" src="@/images/icon_aqxxp_jzys.png" v-if="item == 'yinshi'" v-for="(item,index) in itemData.safeSigns" :key="index">
  142. <img class="img-ojb" src="@/images/icon_aqxxp_dxaq.png" v-if="item == 'anquan'" v-for="(item,index) in itemData.safeSigns" :key="index">
  143. <img class="img-ojb" src="@/images/icon_aqxxp_gzf.png" v-if="item == 'gongzuofu'" v-for="(item,index) in itemData.safeSigns" :key="index">
  144. <img class="img-ojb" src="@/images/icon_aqxxp_gbmc.png" v-if="item == 'menchuang'" v-for="(item,index) in itemData.safeSigns" :key="index">
  145. <img class="img-ojb" src="@/images/icon_aqxxp_gbsd.png" v-if="item == 'shuidian'" v-for="(item,index) in itemData.safeSigns" :key="index">
  146. <img v-if="itemData.safeInfo.qrCode" class="code-img" :src="itemData.safeInfo.qrCode">
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. <!-- 一键灭火遮罩-->
  152. <view class="shade-outfire" v-if="dialogVisible">
  153. <view class="null-box" @click="dialogOutfire()"></view>
  154. <view class="shade-outfire-n">
  155. <img class="shade-outfire-n-t" src="@/images/icon_mh.png" />
  156. <view class="shade-outfire-n-m">一键灭火启动中,倒计时<text>{{countdown}}</text>秒</view>
  157. <view class="shade-outfire-n-b" @click="cancelOutfire()">放弃一键灭火</view>
  158. </view>
  159. </view>
  160. </view>
  161. </template>
  162. <script>
  163. import $mqtt from '@/utils/mqtt.min.js';
  164. import { config } from '@/api/request/config.js'
  165. import { mySubjectList,subject_class,listDepartments,mangerControl,getDicts,laboratoryInfo,
  166. firedeviceStatus,firedeviceStart,firedeviceCancel,controlSwitch} from '@/api/index.js'
  167. export default {
  168. data() {
  169. return {
  170. itemData:{},
  171. //MQTT请求参数-传感器
  172. mtopic:"lab/function/data",
  173. //MQTT请求参数-设备
  174. mtopicOne:"lab/hardware/data",
  175. msg:"",
  176. client:{},
  177. //安全信息牌
  178. infoMaxBoxType:false,
  179. subject:[],
  180. safetyWarning:[],
  181. hazardCategory:[],
  182. riskMeasure:[],
  183. extinguishingKeyPoints:[],
  184. deptId:"",
  185. saoCodeType:false,
  186. countdown: '', //倒计时
  187. timer2: null, //倒计时
  188. dialogVisible: false, //一键灭火弹出层
  189. conductCountdown: '',
  190. timer3: null, //倒计时
  191. outfireEnd: false, //灭火结束状态
  192. //新布局地图相关数据
  193. zoomData: null,
  194. mapType:false,
  195. mapList: [],
  196. mapWidth: null, //40边框距离
  197. mapHeight: null, //40边框距离
  198. //新MQTT
  199. floorClient: {},
  200. evacuationTopic: "lab/newexit/line", //疏散
  201. //灭火设备MQTT相关
  202. fireClient:{},
  203. fireTopic:"lab/fireDevice/Warn/",//传感器状态异常
  204. fireOnlineTopic:"lab/fireDevice/isOnline/",//设备是否在线
  205. firePerformTopic:"lab/fireDevice/executing/",//是否正在执行灭火操作
  206. fireType:false,//有无火焰设备状态
  207. fireListType:false,//灭火设备在线离线
  208. fireCode:null,// //灭火设备code
  209. fireStartType:false, //灭火启动状态
  210. outfireData: {}, //一键灭火
  211. subId:'',
  212. }
  213. },
  214. onLoad(option) {
  215. let self = this;
  216. if(uni.getStorageSync('saoCodeId')){
  217. this.saoCodeType = true;
  218. this.subId=uni.getStorageSync('saoCodeId');
  219. this.laboratoryInfo();
  220. }else{
  221. if(option.q){
  222. let text = decodeURIComponent(option.q)
  223. console.log('text',text)
  224. let codeId = "";
  225. let newList = text.split("?")[1].split("&")
  226. let list = newList[0].split("=")[1].split("-")
  227. codeId = list[0];
  228. uni.setStorageSync('saoCodeId',codeId)
  229. this.subId=uni.getStorageSync('saoCodeId');
  230. this.saoCodeType = true;
  231. this.laboratoryInfo();
  232. }else{
  233. this.deptId = JSON.parse(decodeURIComponent(option.deptId));
  234. this.itemData = JSON.parse(decodeURIComponent(option.item));
  235. this.subId=this.itemData.id;
  236. self.itemData.videoNum = 0;
  237. self.itemData.hardwareNUM = "";
  238. for(let i=0;i<self.itemData.labHardwareVOList.length;i++){
  239. if(self.itemData.labHardwareVOList[i].hardwareTypeEnum.enumName=='VIDEO_MONITOR'){
  240. self.itemData.hardwareNUM = self.itemData.hardwareNUM+self.itemData.labHardwareVOList[i].hardwareNUM+',';
  241. self.itemData.videoNum++
  242. }
  243. }
  244. this.itemData.safeUserName = this.itemData.safeInfo.safeUserName
  245. this.itemData.safePhone = this.itemData.safeInfo.safePhone
  246. if(this.itemData.safeInfo.hazardCategory){
  247. this.itemData.hazardCategory = this.itemData.safeInfo.hazardCategory
  248. }
  249. if(this.itemData.safeInfo.riskMeasure){
  250. this.itemData.riskMeasure = this.itemData.safeInfo.riskMeasure
  251. }
  252. if(this.itemData.safeInfo.safeSigns){
  253. this.itemData.safeSigns = this.itemData.safeInfo.safeSigns
  254. }
  255. if(this.itemData.safeInfo.outfire){
  256. this.itemData.outfire = this.itemData.safeInfo.outfire
  257. }
  258. if(this.itemData.safeInfo.safeUserNameAdminPhone){
  259. let list = [];
  260. let newList = [];
  261. list = this.itemData.safeInfo.safeUserNameAdminPhone.split(",");
  262. for(let i=0;i<list.length;i++){
  263. list[i] = list[i].split("@");
  264. let obj = {
  265. name:list[i][0],
  266. phone:list[i][1]
  267. }
  268. newList.push(obj);
  269. }
  270. this.itemData.safeInfo.safeUser = newList;
  271. }
  272. if(this.itemData.safeInfo.adminNameAndPhone){
  273. let list = [];
  274. let newList = [];
  275. list = this.itemData.safeInfo.adminNameAndPhone.split(",");
  276. for(let i=0;i<list.length;i++){
  277. list[i] = list[i].split("@");
  278. let obj = {
  279. name:list[i][0],
  280. phone:list[i][1]
  281. }
  282. newList.push(obj);
  283. }
  284. this.itemData.safeInfo.subAdmin = newList;
  285. }
  286. this.saoCodeType = false;
  287. }
  288. }
  289. this.firedeviceStatus();
  290. },
  291. onShow(){
  292. if(!this.saoCodeType){
  293. // //监听传感器信息
  294. getApp().watch(this.getMqttSensorData,'mqttSensorData')
  295. // //监听设备信息
  296. getApp().watch(this.getMqttDeviceData,'mqttDeviceData')
  297. //一键灭火-灭火传感器状态异常
  298. getApp().watch(this.getMqttfireData,'mqttfireData')
  299. //一键灭火-是否正在执行灭火操作
  300. getApp().watch(this.getMqttPerformData,'mqttPerformData')
  301. }
  302. },
  303. methods: {
  304. //一键灭火-查询设备状态
  305. async firedeviceStatus() {
  306. let _this = this;
  307. const {data} = await firedeviceStatus(_this.subId)
  308. if (data.code == 200) {
  309. if(data.data.isexist){//是否有灭火设备
  310. this.$set(this,'fireType',data.data.isexist);
  311. if(data.data.online){
  312. _this.outfireData = data.data
  313. _this.$set(this,'fireListType',data.data.online);
  314. _this.$set(this,'fireCode',data.data.fireDevice.deviceCode);
  315. if(data.data.temperature && data.data.smoke){
  316. if(!this.fireStartType){
  317. this.$set(this,'fireStartType',true);
  318. this.sendCode2(data.data.timeDifference);
  319. }
  320. }
  321. if(data.data.timeDifference != -1){
  322. if(!this.fireStartType){
  323. this.$set(this,'fireStartType',true);
  324. this.sendCode2(data.data.timeDifference);
  325. }
  326. }
  327. }else{
  328. this.$set(this,'fireListType',false);
  329. this.$set(this,'fireCode',null);
  330. }
  331. }else{
  332. this.$set(this,'fireType',false);
  333. }
  334. this.mqttInfo()
  335. }
  336. },
  337. //启动灭火设备
  338. async firedeviceStart() {
  339. let _this = this;
  340. let obj={
  341. subjectId:this.subId,
  342. deviceCode:_this.fireCode
  343. }
  344. const {data} = await firedeviceStart(obj)
  345. if (data.code == 200) {
  346. if (data.data.online) {
  347. _this.dialogVisible = true;
  348. _this.$set(this,'fireListType',data.data.online);
  349. _this.countdown = data.data.waitTime;//灭火倒计时
  350. _this.sendCode() //倒计时
  351. } else {
  352. wx.showToast({
  353. title: '一键灭火启动失败!',
  354. icon: "none",
  355. duration: 6000
  356. });
  357. }
  358. }
  359. },
  360. //取消灭火设备
  361. async firedeviceCancel() {
  362. let _this = this;
  363. const {data} = await firedeviceCancel(_this.itemData.subjectId)
  364. if (data.code == 200) {
  365. wx.showToast({
  366. title: '放弃一键灭火!',
  367. icon: "none",
  368. duration: 2000
  369. });
  370. }
  371. },
  372. //一键灭火按钮
  373. outfireFun() {
  374. let _this = this;
  375. uni.showModal({
  376. title: "是否确认执行一键灭火?",
  377. content: '该操作存在风险,请您务必确认实验室内人员已安全撤离?',
  378. cancelColor: "#999",
  379. confirmColor: "#0183FA",
  380. success: function(res) {
  381. if (res.confirm) {
  382. _this.firedeviceStart(); //启动灭火设备
  383. } else if (res.cancel) {
  384. }
  385. }
  386. });
  387. },
  388. //一键灭火弹出层关闭
  389. dialogOutfire() {
  390. this.dialogVisible = !this.dialogVisible
  391. this.clearTimer(); //关闭定时器
  392. },
  393. //取消一键灭火
  394. cancelOutfire() {
  395. this.dialogVisible = false;
  396. this.clearTimer(); //关闭定时器
  397. this.firedeviceCancel()
  398. },
  399. //倒计时
  400. sendCode() {
  401. let _this = this;
  402. _this.loading(); //启动定时器
  403. _this.timer2 = setInterval(() => {
  404. //创建定时器
  405. if (_this.countdown === 1) {
  406. _this.clearTimer(); //关闭定时器
  407. } else {
  408. _this.loading();
  409. }
  410. }, 1000);
  411. },
  412. loading() {
  413. //启动定时器
  414. this.countdown--; //定时器减1
  415. },
  416. clearTimer() {
  417. //清除定时器
  418. clearInterval(this.timer2);
  419. this.timer2 = null;
  420. this.dialogVisible = false;
  421. },
  422. //进行中倒计时
  423. sendCode2(time) {
  424. let _this = this;
  425. _this.conductCountdown=time
  426. _this.loading2(); //启动定时器
  427. _this.timer3 = setInterval(() => {
  428. //创建定时器
  429. if (_this.conductCountdown === 1) {
  430. _this.clearTimer2(); //关闭定时器
  431. _this.outfireEnd = true; //灭火倒计时结束
  432. _this.fireStartType = false; //灭火状态
  433. console.log()
  434. } else {
  435. _this.loading2();
  436. }
  437. }, 1000);
  438. },
  439. loading2() {
  440. //启动定时器
  441. this.conductCountdown--; //定时器减1
  442. },
  443. clearTimer2() {
  444. //清除定时器
  445. clearInterval(this.timer3);
  446. this.timer3 = null;
  447. },
  448. //详情页面MQTT
  449. mqttInfo(){
  450. let list = [];
  451. let obj = {
  452. type:"lab/function/data",
  453. idList:[this.itemData.id],
  454. }
  455. let objOne = {
  456. type:"lab/hardware/data",
  457. idList:[this.itemData.id],
  458. }
  459. let objTow = {
  460. type:"lab/fireDevice/Warn/",
  461. fireCode:this.fireCode,
  462. }
  463. let objThree = {
  464. type:"lab/fireDevice/isOnline/",
  465. fireCode:this.fireCode,
  466. }
  467. let objFour = {
  468. type:"lab/fireDevice/executing/",
  469. fireCode:this.fireCode,
  470. }
  471. list.push(obj);
  472. list.push(objOne);
  473. list.push(objTow);
  474. list.push(objThree);
  475. list.push(objFour);
  476. // mqtt订阅因为返回数据频率问题 暂时取消列表的MQTT刷新
  477. getApp().appMqttOn(1,list);
  478. },
  479. //查询详情
  480. async laboratoryInfo(){
  481. let self = this;
  482. let id = uni.getStorageSync('saoCodeId');
  483. const {data} = await laboratoryInfo(id);
  484. if(data.code == 200){
  485. uni.removeStorageSync('saoCodeId')
  486. this.itemData = data.data[0];
  487. self.itemData.videoNum = 0;
  488. self.itemData.hardwareNUM = "";
  489. this.itemData.safeUserName = this.itemData.safeInfo.safeUserName
  490. this.itemData.safePhone = this.itemData.safeInfo.safePhone
  491. if(this.itemData.safeInfo.hazardCategory){
  492. this.itemData.hazardCategory = this.itemData.safeInfo.hazardCategory
  493. }
  494. if(this.itemData.safeInfo.riskMeasure){
  495. this.itemData.riskMeasure = this.itemData.safeInfo.riskMeasure
  496. }
  497. if(this.itemData.safeInfo.safeSigns){
  498. this.itemData.safeSigns = this.itemData.safeInfo.safeSigns
  499. }
  500. if(this.itemData.safeInfo.outfire){
  501. this.itemData.outfire = this.itemData.safeInfo.outfire
  502. }
  503. if(this.itemData.safeInfo.safeUserNameAdminPhone){
  504. let list = [];
  505. let newList = [];
  506. list = this.itemData.safeInfo.safeUserNameAdminPhone.split(",");
  507. for(let i=0;i<list.length;i++){
  508. list[i] = list[i].split("@");
  509. let obj = {
  510. name:list[i][0],
  511. phone:list[i][1]
  512. }
  513. newList.push(obj);
  514. }
  515. this.itemData.safeInfo.safeUser = newList;
  516. }
  517. if(this.itemData.safeInfo.adminNameAndPhone){
  518. let list = [];
  519. let newList = [];
  520. list = this.itemData.safeInfo.adminNameAndPhone.split(",");
  521. for(let i=0;i<list.length;i++){
  522. list[i] = list[i].split("@");
  523. let obj = {
  524. name:list[i][0],
  525. phone:list[i][1]
  526. }
  527. newList.push(obj);
  528. }
  529. this.itemData.safeInfo.subAdmin = newList;
  530. }
  531. this.infoMaxBoxType = true;
  532. }
  533. },
  534. //一键灭火-传感器状态异常
  535. getMqttfireData(val){
  536. let self = this;
  537. if(val){
  538. //传感器状态
  539. console.log('传感器状态');
  540. self.firedeviceStatus();
  541. }
  542. },
  543. //一键灭火-是否正在执行灭火操作
  544. getMqttPerformData(val){
  545. let self = this;
  546. if(val){
  547. //灭火执行操作
  548. if(val.fireStatus == 1){
  549. if(!self.fireStartType){
  550. self.firedeviceStatus();
  551. }else if(val.fireStatus == 0){
  552. uni.showToast({
  553. title: '一键灭火启动失败',
  554. icon: "none",
  555. mask: true,
  556. duration: 2000
  557. });
  558. }
  559. }
  560. }
  561. },
  562. //监听传感器信息
  563. getMqttSensorData(val){
  564. let self = this;
  565. if(val.subId){
  566. if(self.itemData.id == val.subId){
  567. self.$set(self.itemData,'sensorFunctionList',val.functionStatuses);
  568. }
  569. }
  570. },
  571. //监听设备信息
  572. getMqttDeviceData(val){
  573. let self = this;
  574. // console.log('页面获取的-设备信息',val)
  575. for(let i=0;i<val.length;i++){
  576. for(let k=0;k<self.itemData.labHardwareVOList.length;k++){
  577. if(val[i].num == self.itemData.labHardwareVOList[k].id){
  578. if(val[i].hardwareOperate == 'CLOSE'){
  579. self.itemData.labHardwareVOList[k].state.code = 4;
  580. }else if(val[i].hardwareOperate == 'OPEN'){
  581. self.itemData.labHardwareVOList[k].state.code = 3;
  582. }else if(val[i].hardwareOperate == 'OFFLINE'){
  583. self.itemData.labHardwareVOList[k].state.code = 0;
  584. }else if(val[i].hardwareOperate == 'ONLINE'){
  585. self.itemData.labHardwareVOList[k].state.code = 2;
  586. }
  587. }
  588. }
  589. }
  590. },
  591. infoMaxBoxClick(){
  592. this.infoMaxBoxType = !this.infoMaxBoxType;
  593. },
  594. async getSafetyWarning(){
  595. const {data} = await getDicts('sys_safety_warning');
  596. if(data.code == 200){
  597. this.safetyWarning = data.data;
  598. }
  599. },
  600. async getHazardCategory(){
  601. const {data} = await getDicts('sys_hazard_category');
  602. if(data.code == 200){
  603. this.hazardCategory = data.data;
  604. }
  605. },
  606. async getRiskMeasure(){
  607. const {data} = await getDicts('sys_risk_measure');
  608. if(data.code == 200){
  609. this.riskMeasure = data.data;
  610. }
  611. },
  612. async getExtinguishingKeyPoints(){
  613. const {data} = await getDicts('sys_extinguishing_key_points');
  614. if(data.code == 200){
  615. this.extinguishingKeyPoints = data.data;
  616. }
  617. },
  618. //MQTT订阅-传感器
  619. subscriptionMQTT(){
  620. let self = this;
  621. const mqttOptions = {
  622. keepalive: 30,
  623. clean: false,//保留会话
  624. connectTimeout: 5000, // 超时时间
  625. reconnectPeriod:5000, // 重连间隔
  626. clientId: 'lab/function/data',
  627. username: uni.getStorageSync('mqttUser'),
  628. password: uni.getStorageSync('mqttPassword'),
  629. }
  630. const connectUrl = uni.getStorageSync('mqttUrl');
  631. this.client = $mqtt.connect('wxs://' + connectUrl, mqttOptions);
  632. this.client.on('connect', () => {
  633. // 这是为了给自己发条消息,其它无作用
  634. this.client.subscribe(this.mtopic, (err) => {
  635. if (!err) {
  636. console.log("订阅传感器成功",this.mtopic)
  637. }
  638. })
  639. this.client.subscribe(this.mtopicOne, (err) => {
  640. if (!err) {
  641. console.log("订阅设备成功",this.mtopicOne)
  642. }
  643. })
  644. });
  645. // 自动重连
  646. this.client.on('reconnect', (msg) => {
  647. console.log('reconnect', msg)
  648. });
  649. // 错误
  650. this.client.on('error', () => {
  651. console.log('error')
  652. });
  653. // 断开
  654. this.client.on('end', () => {
  655. console.log('end')
  656. });
  657. // 掉线
  658. this.client.on('offline', (msg) => {
  659. console.log('offline',msg)
  660. });
  661. // 收到消息
  662. this.client.on('message', (topic, message) => {
  663. let data = JSON.parse(message)
  664. console.log('topic',topic)
  665. console.log('data',data)
  666. if(topic == this.mtopic){
  667. if(data.data.subId){
  668. if(self.itemData.id == data.data.subId){
  669. self.$set(self.itemData,'sensorFunctionList',data.data.functionStatuses);
  670. }
  671. }
  672. }else if(topic == this.mtopicOne){
  673. for(let i=0;i<data.data.length;i++){
  674. for(let k=0;k<self.itemData.labHardwareVOList.length;k++){
  675. if(data.data[i].num == self.itemData.labHardwareVOList[k].id){
  676. if(data.data[i].hardwareOperate == 'CLOSE'){
  677. self.itemData.labHardwareVOList[k].state.code = 4;
  678. }else if(data.data[i].hardwareOperate == 'OPEN'){
  679. self.itemData.labHardwareVOList[k].state.code = 3;
  680. }else if(data.data[i].hardwareOperate == 'OFFLINE'){
  681. self.itemData.labHardwareVOList[k].state.code = 0;
  682. }else if(data.data[i].hardwareOperate == 'ONLINE'){
  683. self.itemData.labHardwareVOList[k].state.code = 2;
  684. }
  685. }
  686. }
  687. }
  688. }
  689. })
  690. // 全局监听是否有关闭mqtt的消息的事件
  691. uni.$on('closeMqtt',() => {
  692. this.client.end(true); // 主动断开连接
  693. })
  694. },
  695. //取消订阅关闭MQTT连接
  696. offMQTT(){
  697. this.client.unsubscribe(this.mtopic, error => {
  698. if (error) {
  699. console.log('Unsubscribe error', error)
  700. }
  701. })
  702. this.client.end();
  703. this.client = {};
  704. },
  705. pcTypeButtonClick(id){
  706. let self = this;
  707. uni.showModal({
  708. content: '确认要操作该设备吗?',
  709. cancelColor:"#999",
  710. confirmColor:"#0183FA",
  711. success: function (res) {
  712. if (res.confirm) {
  713. self.controlSwitch(id);
  714. console.log('用户点击确定');
  715. } else if (res.cancel) {
  716. console.log('用户点击取消');
  717. }
  718. }
  719. });
  720. },
  721. async controlSwitch(id){
  722. const {data} = await controlSwitch({id:id});
  723. if(data.code == 200){
  724. uni.showToast({
  725. title: '操作成功',
  726. icon:"none",
  727. mask:true,
  728. duration: 2000
  729. });
  730. }
  731. },
  732. //设备开关按钮
  733. hardwareButton(minItem,command){
  734. let self = this;
  735. let text = '';
  736. if(command == 'close'){
  737. text = '关闭';
  738. }else if(command == 'open'){
  739. text = '开启';
  740. }
  741. uni.showModal({
  742. content: '确认要'+text+'吗?',
  743. cancelColor:"#999",
  744. confirmColor:"#0183FA",
  745. success: function (res) {
  746. if (res.confirm) {
  747. self.mangerControl(minItem,command);
  748. console.log('用户点击确定');
  749. } else if (res.cancel) {
  750. console.log('用户点击取消');
  751. }
  752. }
  753. });
  754. },
  755. //设备开关
  756. async mangerControl(minItem,command){
  757. let obj = {
  758. id:minItem.id,
  759. command:command,
  760. };
  761. const {data} = await mangerControl(obj);
  762. if(data.code == 200){
  763. if(command == 'open'){
  764. minItem.type = 3;
  765. }else if(command == 'close'){
  766. minItem.type = 4;
  767. }
  768. uni.showToast({
  769. title: '操作成功',
  770. icon:"none",
  771. mask:true,
  772. duration: 2000
  773. });
  774. }
  775. },
  776. goVideo(){
  777. this.itemData.floorId = this.itemData.subAddrr.floorId;
  778. uni.navigateTo({
  779. url:'/pages_manage/workbench/laboratory/monitor?item='+encodeURIComponent(JSON.stringify(this.itemData))+'&deptId='+this.deptId
  780. })
  781. },
  782. goWord(){
  783. uni.navigateTo({
  784. url:'/pages_manage/workbench/laboratory/word?item='+encodeURIComponent(JSON.stringify(this.itemData))
  785. })
  786. },
  787. },
  788. onHide(){
  789. // //删除传感器监听
  790. getApp().deleteSensorWatch();
  791. // //删除设备监听
  792. getApp().deleteDeviceWatch();
  793. //删除一键灭火-传感器状态
  794. getApp().deletefireData();
  795. //删除一键灭火-设备是否在线
  796. getApp().deleteOnlineData();
  797. //删除一键灭火-是否正在执行灭火
  798. getApp().deletePerformData();
  799. },
  800. beforeDestroy(){
  801. // //删除传感器监听
  802. getApp().deleteSensorWatch();
  803. // //删除设备监听
  804. getApp().deleteDeviceWatch();
  805. //删除一键灭火-传感器状态
  806. getApp().deletefireData();
  807. //删除一键灭火-设备是否在线
  808. getApp().deleteOnlineData();
  809. //删除一键灭火-是否正在执行灭火
  810. getApp().deletePerformData();
  811. }
  812. }
  813. </script>
  814. <style lang="stylus" scoped>
  815. #laboratoryInfo{
  816. height:100%;
  817. display flex;
  818. flex-direction column;
  819. /* 一键灭火 */
  820. .outfire {
  821. width: 750rpx;
  822. height: auto;
  823. background: #FFFFFF;
  824. margin: 20rpx 0;
  825. padding: 20rpx 10rpx;
  826. box-sizing: border-box;
  827. display: flex;
  828. justify-content: space-between;
  829. align-items: center;
  830. .outfire_li {
  831. display: flex;
  832. justify-content: flex-start;
  833. align-items: center;
  834. >img {
  835. width: 24rpx;
  836. height: 30rpx;
  837. margin-right: 12rpx;
  838. }
  839. .normal {
  840. font-size: 24rpx;
  841. font-family: PingFang SC;
  842. font-weight: 500;
  843. color: #333333;
  844. }
  845. .abnormal {
  846. font-size: 24rpx;
  847. font-family: PingFang SC;
  848. font-weight: 500;
  849. color: #F11C00;
  850. }
  851. }
  852. .outfire_li:nth-of-type(1) {
  853. >img {
  854. width: 30rpx;
  855. height: 28rpx;
  856. margin-right: 12rpx;
  857. }
  858. }
  859. .outfire_yes_btn {
  860. width: 120rpx;
  861. height: 40rpx;
  862. font-size: 24rpx;
  863. font-family: PingFang SC;
  864. font-weight: 500;
  865. color: #F21C00;
  866. line-height: 40rpx;
  867. border: 1px solid #F21C00;
  868. border-radius: 8rpx;
  869. text-align: center;
  870. margin-left: 54rpx;
  871. }
  872. .outfire_no_btn {
  873. width: 120rpx;
  874. height: 40rpx;
  875. font-size: 24rpx;
  876. font-family: PingFang SC;
  877. font-weight: 500;
  878. color: #CCCCCC;
  879. line-height: 40rpx;
  880. border: 1px solid #E0E0E0;
  881. border-radius: 8rpx;
  882. text-align: center;
  883. margin-left: 54rpx;
  884. }
  885. }
  886. /* 一键灭火 */
  887. .shade-outfire {
  888. height: 100%;
  889. width: 100%;
  890. position: fixed;
  891. display: flex;
  892. flex-direction: column;
  893. z-index: 10;
  894. background: rgba(0, 0, 0, 0.2);
  895. .null-box {
  896. flex: 1;
  897. }
  898. .shade-outfire-n {
  899. width: 625rpx;
  900. height: 450rpx;
  901. background: #FFFFFF;
  902. border-radius: 20rpx;
  903. position: absolute;
  904. top: 370rpx;
  905. left: 62rpx;
  906. .shade-outfire-n-t {
  907. width: 172rpx;
  908. height: 172rpx;
  909. margin: 38rpx 0 0 226rpx;
  910. }
  911. .shade-outfire-n-m {
  912. font-size: 30rpx;
  913. font-family: PingFang SC;
  914. font-weight: 500;
  915. color: #E30000;
  916. line-height: 84rpx;
  917. text-align: center;
  918. border-bottom: 1px solid #E0E0E0;
  919. >text {
  920. font-size: 40rpx;
  921. }
  922. }
  923. .shade-outfire-n-b {
  924. width: 402rpx;
  925. height: 82rpx;
  926. background: #FFFFFF;
  927. border: 2rpx solid #0183FA;
  928. border-radius: 10rpx;
  929. font-size: 28rpx;
  930. line-height: 82rpx;
  931. font-family: PingFang SC;
  932. font-weight: 500;
  933. color: #0183FA;
  934. text-align: center;
  935. margin: 30rpx 0 0 112rpx;
  936. }
  937. }
  938. }
  939. .name-max-box{
  940. background #fff
  941. .title-box{
  942. margin:20rpx 20rpx 0;
  943. display flex
  944. view:nth-child(1){
  945. height:40rpx;
  946. line-height:40rpx;
  947. font-size:20rpx;
  948. border-radius:10rpx;
  949. padding:0 20rpx;
  950. color:#fff;
  951. margin-right:20rpx;
  952. }
  953. view:nth-child(2){
  954. line-height:42rpx;
  955. font-size:30rpx;
  956. color:#0183FA;
  957. max-width:600rpx;
  958. flex:1;
  959. }
  960. img{
  961. width:12rpx;
  962. height:20rpx;
  963. margin-top:11rpx;
  964. }
  965. .colorA{
  966. background:#aa2315;
  967. }
  968. .colorB{
  969. background:#ff9b09;
  970. }
  971. .colorC{
  972. background:#3ea3e9;
  973. }
  974. .colorD{
  975. background:#3ea34c;
  976. }
  977. }
  978. .address-box{
  979. margin:20rpx 20rpx;
  980. font-size:26rpx;
  981. color:#999999;
  982. span{
  983. margin-right:60rpx;
  984. }
  985. }
  986. .address-box-two{
  987. display flex
  988. margin:0 20rpx 20rpx 20rpx;
  989. img{
  990. width:28rpx;
  991. height:30rpx;
  992. margin-right:18rpx;
  993. }
  994. view{
  995. line-height:30rpx;
  996. font-size:24rpx;
  997. color:#999999;
  998. }
  999. }
  1000. }
  1001. .title-max-box-none{
  1002. border:none!important;
  1003. }
  1004. .title-max-box{
  1005. display flex
  1006. height:80rpx;
  1007. border-bottom:1rpx solid #E0E0E0;
  1008. .left-view{
  1009. width: 4rpx;
  1010. height: 34rpx;
  1011. margin:25rpx 24rpx 0 20rpx;
  1012. background:#0D97EB;
  1013. }
  1014. .right-view{
  1015. line-height:80rpx;
  1016. font-size: 30rpx;
  1017. color: #333333;
  1018. flex:1;
  1019. }
  1020. .click-view{
  1021. display flex
  1022. padding:0 20rpx;
  1023. view{
  1024. line-height:80rpx;
  1025. font-size: 24rpx;
  1026. color: #666666;
  1027. }
  1028. img{
  1029. width:20rpx;
  1030. height:10rpx;
  1031. margin:35rpx 0 0 20rpx;
  1032. }
  1033. }
  1034. }
  1035. .sensor-max-box{
  1036. background #fff
  1037. margin-top:20rpx;
  1038. .text-box{
  1039. /*border-top:1rpx dashed #e0e0e0;*/
  1040. /*border-top:1rpx solid #E0E0E0;*/
  1041. padding:0 20rpx;
  1042. /*
  1043. overflow-x:scroll;
  1044. overflow-y:hidden;
  1045. white-space: nowrap;
  1046. */
  1047. .min-box{
  1048. display inline-block
  1049. /*padding:0 30rpx 0 10rpx;*/
  1050. width:355rpx;
  1051. .min-min-box{
  1052. display: flex
  1053. img{
  1054. width:30rpx;
  1055. height:27rpx;
  1056. margin-top:24rpx;
  1057. margin-right:10rpx;
  1058. }
  1059. view{
  1060. line-height:74rpx;
  1061. text-align center
  1062. font-size:28rpx;
  1063. color:#333;
  1064. }
  1065. .colorA{
  1066. color:#EE3A3A;
  1067. }
  1068. }
  1069. }
  1070. }
  1071. }
  1072. .control-max-box{
  1073. background #fff
  1074. margin-top:20rpx;
  1075. .button-max-box{
  1076. .button-box:last-child{
  1077. border:none!important;
  1078. }
  1079. .button-box{
  1080. display flex
  1081. border-bottom:1rpx solid #e0e0e0;
  1082. margin:0 20rpx;
  1083. view:nth-child(1){
  1084. flex:1;
  1085. line-height:90rpx;
  1086. color:#333333;
  1087. font-size:28rpx;
  1088. }
  1089. view:nth-child(2){
  1090. width:120rpx;
  1091. line-height:42rpx;
  1092. border:4rpx solid #0183FA;
  1093. border-radius:30rpx;
  1094. color: #0183FA;
  1095. font-size: 24rpx;
  1096. text-align center;
  1097. margin:20rpx 0 20rpx 0;
  1098. }
  1099. }
  1100. .for-button-box:last-child{
  1101. border:none!important;
  1102. }
  1103. .for-button-box{
  1104. display flex
  1105. border-bottom:1rpx solid #e0e0e0;
  1106. margin:0 20rpx;
  1107. .for-button-p{
  1108. flex:1;
  1109. line-height:90rpx;
  1110. color:#333333;
  1111. font-size:28rpx;
  1112. }
  1113. img{
  1114. height:50rpx;
  1115. width:100rpx;
  1116. margin:20rpx 0 20rpx 0;
  1117. }
  1118. view:nth-child(2){
  1119. text-align right
  1120. color:#999;
  1121. }
  1122. .pcType-button{
  1123. width:120rpx;
  1124. line-height:42rpx;
  1125. border:4rpx solid #0183FA;
  1126. border-radius:30rpx;
  1127. color: #0183FA !important;
  1128. font-size: 24rpx;
  1129. text-align center !important;
  1130. margin:20rpx 0 20rpx 0;
  1131. }
  1132. }
  1133. }
  1134. }
  1135. .info-max-box{
  1136. background #fff
  1137. margin-top:20rpx;
  1138. .top-name-max-box{
  1139. background #fff
  1140. overflow hidden
  1141. .name-box{
  1142. margin:27rpx 20rpx 0;
  1143. display:flex;
  1144. view:nth-child(1){
  1145. background:#f95f5f;
  1146. color:#fff;
  1147. border-radius:6rpx;
  1148. font-size:20rpx;
  1149. padding:0 10rpx;
  1150. height:42rpx;
  1151. line-height:42rpx;
  1152. }
  1153. view:nth-child(2){
  1154. color:#333;
  1155. margin-left:20rpx;
  1156. font-size:28rpx;
  1157. height:30rpx;
  1158. line-height:42rpx;
  1159. font-weight:700;
  1160. }
  1161. }
  1162. .address-box{
  1163. margin:22rpx 20rpx;
  1164. font-size:26rpx;
  1165. }
  1166. }
  1167. .text-max-box{
  1168. background #fff
  1169. padding:8rpx 20rpx;
  1170. border-bottom:1rpx solid #e0e0e0;
  1171. .text-min-box{
  1172. display:flex;
  1173. view{
  1174. line-height:66rpx;
  1175. height:66rpx;
  1176. font-size:28rpx;
  1177. }
  1178. view:nth-child(1){
  1179. width:220rpx;
  1180. color:#333;
  1181. }
  1182. view:nth-child(2){
  1183. flex:1;
  1184. color:#999;
  1185. text-align:right;
  1186. }
  1187. }
  1188. }
  1189. .safety-max-box{
  1190. background #fff
  1191. padding:8rpx 20rpx;
  1192. .max-for-box{
  1193. .title-box{
  1194. line-height:76rpx;
  1195. font-size:30rpx;
  1196. color:#333;
  1197. }
  1198. .for-box{
  1199. line-height:48rpx;
  1200. font-size:28rpx;
  1201. color:#999;
  1202. }
  1203. }
  1204. }
  1205. .img-bottom-box{
  1206. margin-top:20rpx;
  1207. background #fff
  1208. padding:8rpx 20rpx 20rpx;
  1209. .title-box{
  1210. line-height:76rpx;
  1211. font-size:28rpx;
  1212. color:#333;
  1213. }
  1214. .for-box{
  1215. line-height:48rpx;
  1216. font-size:26rpx;
  1217. color:#999;
  1218. .img-ojb{
  1219. display inline-block
  1220. width:86rpx;
  1221. height:114rpx;
  1222. margin-left:30rpx;
  1223. }
  1224. .code-img{
  1225. width:200rpx;
  1226. height:200rpx;
  1227. margin:20rpx auto 40rpx;
  1228. }
  1229. }
  1230. }
  1231. }
  1232. }
  1233. </style>