laboratoryInfo.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  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. }else{
  322. this.$set(this,'fireListType',false);
  323. this.$set(this,'fireCode',null);
  324. }
  325. }else{
  326. this.$set(this,'fireType',false);
  327. }
  328. this.mqttInfo()
  329. }
  330. },
  331. //启动灭火设备
  332. async firedeviceStart() {
  333. let _this = this;
  334. let obj={
  335. subjectId:this.subId,
  336. deviceCode:_this.fireCode
  337. }
  338. const {data} = await firedeviceStart(obj)
  339. if (data.code == 200) {
  340. if (data.data.online) {
  341. _this.dialogVisible = true;
  342. _this.$set(this,'fireListType',data.data.online);
  343. _this.countdown = data.data.waitTime;//灭火倒计时
  344. _this.sendCode() //倒计时
  345. } else {
  346. wx.showToast({
  347. title: '一键灭火启动失败!',
  348. icon: "none",
  349. duration: 6000
  350. });
  351. }
  352. }
  353. },
  354. //取消灭火设备
  355. async firedeviceCancel() {
  356. let _this = this;
  357. const {data} = await firedeviceCancel(_this.itemData.subjectId)
  358. if (data.code == 200) {
  359. wx.showToast({
  360. title: '放弃一键灭火!',
  361. icon: "none",
  362. duration: 2000
  363. });
  364. }
  365. },
  366. //一键灭火按钮
  367. outfireFun() {
  368. let _this = this;
  369. uni.showModal({
  370. title: "是否确认执行一键灭火?",
  371. content: '该操作存在风险,请您务必确认实验室内人员已安全撤离?',
  372. cancelColor: "#999",
  373. confirmColor: "#0183FA",
  374. success: function(res) {
  375. if (res.confirm) {
  376. _this.firedeviceStart(); //启动灭火设备
  377. } else if (res.cancel) {
  378. }
  379. }
  380. });
  381. },
  382. //一键灭火弹出层关闭
  383. dialogOutfire() {
  384. this.dialogVisible = !this.dialogVisible
  385. this.clearTimer(); //关闭定时器
  386. },
  387. //取消一键灭火
  388. cancelOutfire() {
  389. this.dialogVisible = false;
  390. this.clearTimer(); //关闭定时器
  391. this.firedeviceCancel()
  392. },
  393. //倒计时
  394. sendCode() {
  395. let _this = this;
  396. _this.loading(); //启动定时器
  397. _this.timer2 = setInterval(() => {
  398. //创建定时器
  399. if (_this.countdown === 1) {
  400. _this.clearTimer(); //关闭定时器
  401. } else {
  402. _this.loading();
  403. }
  404. }, 1000);
  405. },
  406. loading() {
  407. //启动定时器
  408. this.countdown--; //定时器减1
  409. },
  410. clearTimer() {
  411. //清除定时器
  412. clearInterval(this.timer2);
  413. this.timer2 = null;
  414. this.dialogVisible = false;
  415. },
  416. //进行中倒计时
  417. sendCode2(time) {
  418. let _this = this;
  419. _this.conductCountdown=time
  420. _this.loading2(); //启动定时器
  421. _this.timer3 = setInterval(() => {
  422. //创建定时器
  423. if (_this.conductCountdown === 1) {
  424. _this.clearTimer2(); //关闭定时器
  425. _this.outfireEnd = true; //灭火倒计时结束
  426. _this.fireStartType = false; //灭火状态
  427. console.log()
  428. } else {
  429. _this.loading2();
  430. }
  431. }, 1000);
  432. },
  433. loading2() {
  434. //启动定时器
  435. this.conductCountdown--; //定时器减1
  436. },
  437. clearTimer2() {
  438. //清除定时器
  439. clearInterval(this.timer3);
  440. this.timer3 = null;
  441. },
  442. //详情页面MQTT
  443. mqttInfo(){
  444. let list = [];
  445. let obj = {
  446. type:"lab/function/data",
  447. idList:[this.itemData.id],
  448. }
  449. let objOne = {
  450. type:"lab/hardware/data",
  451. idList:[this.itemData.id],
  452. }
  453. let objTow = {
  454. type:"lab/fireDevice/Warn/",
  455. fireCode:this.fireCode,
  456. }
  457. let objThree = {
  458. type:"lab/fireDevice/isOnline/",
  459. fireCode:this.fireCode,
  460. }
  461. let objFour = {
  462. type:"lab/fireDevice/executing/",
  463. fireCode:this.fireCode,
  464. }
  465. list.push(obj);
  466. list.push(objOne);
  467. list.push(objTow);
  468. list.push(objThree);
  469. list.push(objFour);
  470. // mqtt订阅因为返回数据频率问题 暂时取消列表的MQTT刷新
  471. getApp().appMqttOn(1,list);
  472. },
  473. //查询详情
  474. async laboratoryInfo(){
  475. let self = this;
  476. let id = uni.getStorageSync('saoCodeId');
  477. const {data} = await laboratoryInfo(id);
  478. if(data.code == 200){
  479. uni.removeStorageSync('saoCodeId')
  480. this.itemData = data.data[0];
  481. self.itemData.videoNum = 0;
  482. self.itemData.hardwareNUM = "";
  483. this.itemData.safeUserName = this.itemData.safeInfo.safeUserName
  484. this.itemData.safePhone = this.itemData.safeInfo.safePhone
  485. if(this.itemData.safeInfo.hazardCategory){
  486. this.itemData.hazardCategory = this.itemData.safeInfo.hazardCategory
  487. }
  488. if(this.itemData.safeInfo.riskMeasure){
  489. this.itemData.riskMeasure = this.itemData.safeInfo.riskMeasure
  490. }
  491. if(this.itemData.safeInfo.safeSigns){
  492. this.itemData.safeSigns = this.itemData.safeInfo.safeSigns
  493. }
  494. if(this.itemData.safeInfo.outfire){
  495. this.itemData.outfire = this.itemData.safeInfo.outfire
  496. }
  497. if(this.itemData.safeInfo.safeUserNameAdminPhone){
  498. let list = [];
  499. let newList = [];
  500. list = this.itemData.safeInfo.safeUserNameAdminPhone.split(",");
  501. for(let i=0;i<list.length;i++){
  502. list[i] = list[i].split("@");
  503. let obj = {
  504. name:list[i][0],
  505. phone:list[i][1]
  506. }
  507. newList.push(obj);
  508. }
  509. this.itemData.safeInfo.safeUser = newList;
  510. }
  511. if(this.itemData.safeInfo.adminNameAndPhone){
  512. let list = [];
  513. let newList = [];
  514. list = this.itemData.safeInfo.adminNameAndPhone.split(",");
  515. for(let i=0;i<list.length;i++){
  516. list[i] = list[i].split("@");
  517. let obj = {
  518. name:list[i][0],
  519. phone:list[i][1]
  520. }
  521. newList.push(obj);
  522. }
  523. this.itemData.safeInfo.subAdmin = newList;
  524. }
  525. this.infoMaxBoxType = true;
  526. }
  527. },
  528. //一键灭火-传感器状态异常
  529. getMqttfireData(val){
  530. let self = this;
  531. if(val){
  532. //传感器状态
  533. console.log('传感器状态');
  534. self.firedeviceStatus();
  535. }
  536. },
  537. //一键灭火-是否正在执行灭火操作
  538. getMqttPerformData(val){
  539. let self = this;
  540. debugger
  541. if(val){
  542. //灭火执行操作
  543. if(val.fireStatus == 1){
  544. if(!self.fireStartType){
  545. self.$set(self,'fireStartType',true);
  546. self.sendCode2(val.direTime);
  547. }else if(val.fireStatus == 0){
  548. uni.showToast({
  549. title: '一键灭火启动失败',
  550. icon: "none",
  551. mask: true,
  552. duration: 2000
  553. });
  554. }
  555. }
  556. }
  557. },
  558. //监听传感器信息
  559. getMqttSensorData(val){
  560. let self = this;
  561. if(val.subId){
  562. if(self.itemData.id == val.subId){
  563. self.$set(self.itemData,'sensorFunctionList',val.functionStatuses);
  564. }
  565. }
  566. },
  567. //监听设备信息
  568. getMqttDeviceData(val){
  569. let self = this;
  570. // console.log('页面获取的-设备信息',val)
  571. for(let i=0;i<val.length;i++){
  572. for(let k=0;k<self.itemData.labHardwareVOList.length;k++){
  573. if(val[i].num == self.itemData.labHardwareVOList[k].id){
  574. if(val[i].hardwareOperate == 'CLOSE'){
  575. self.itemData.labHardwareVOList[k].state.code = 4;
  576. }else if(val[i].hardwareOperate == 'OPEN'){
  577. self.itemData.labHardwareVOList[k].state.code = 3;
  578. }else if(val[i].hardwareOperate == 'OFFLINE'){
  579. self.itemData.labHardwareVOList[k].state.code = 0;
  580. }else if(val[i].hardwareOperate == 'ONLINE'){
  581. self.itemData.labHardwareVOList[k].state.code = 2;
  582. }
  583. }
  584. }
  585. }
  586. },
  587. infoMaxBoxClick(){
  588. this.infoMaxBoxType = !this.infoMaxBoxType;
  589. },
  590. async getSafetyWarning(){
  591. const {data} = await getDicts('sys_safety_warning');
  592. if(data.code == 200){
  593. this.safetyWarning = data.data;
  594. }
  595. },
  596. async getHazardCategory(){
  597. const {data} = await getDicts('sys_hazard_category');
  598. if(data.code == 200){
  599. this.hazardCategory = data.data;
  600. }
  601. },
  602. async getRiskMeasure(){
  603. const {data} = await getDicts('sys_risk_measure');
  604. if(data.code == 200){
  605. this.riskMeasure = data.data;
  606. }
  607. },
  608. async getExtinguishingKeyPoints(){
  609. const {data} = await getDicts('sys_extinguishing_key_points');
  610. if(data.code == 200){
  611. this.extinguishingKeyPoints = data.data;
  612. }
  613. },
  614. //MQTT订阅-传感器
  615. subscriptionMQTT(){
  616. let self = this;
  617. const mqttOptions = {
  618. keepalive: 30,
  619. clean: false,//保留会话
  620. connectTimeout: 5000, // 超时时间
  621. reconnectPeriod:5000, // 重连间隔
  622. clientId: 'lab/function/data',
  623. username: uni.getStorageSync('mqttUser'),
  624. password: uni.getStorageSync('mqttPassword'),
  625. }
  626. const connectUrl = uni.getStorageSync('mqttUrl');
  627. this.client = $mqtt.connect('wxs://' + connectUrl, mqttOptions);
  628. this.client.on('connect', () => {
  629. // 这是为了给自己发条消息,其它无作用
  630. this.client.subscribe(this.mtopic, (err) => {
  631. if (!err) {
  632. console.log("订阅传感器成功",this.mtopic)
  633. }
  634. })
  635. this.client.subscribe(this.mtopicOne, (err) => {
  636. if (!err) {
  637. console.log("订阅设备成功",this.mtopicOne)
  638. }
  639. })
  640. });
  641. // 自动重连
  642. this.client.on('reconnect', (msg) => {
  643. console.log('reconnect', msg)
  644. });
  645. // 错误
  646. this.client.on('error', () => {
  647. console.log('error')
  648. });
  649. // 断开
  650. this.client.on('end', () => {
  651. console.log('end')
  652. });
  653. // 掉线
  654. this.client.on('offline', (msg) => {
  655. console.log('offline',msg)
  656. });
  657. // 收到消息
  658. this.client.on('message', (topic, message) => {
  659. let data = JSON.parse(message)
  660. console.log('topic',topic)
  661. console.log('data',data)
  662. if(topic == this.mtopic){
  663. if(data.data.subId){
  664. if(self.itemData.id == data.data.subId){
  665. self.$set(self.itemData,'sensorFunctionList',data.data.functionStatuses);
  666. }
  667. }
  668. }else if(topic == this.mtopicOne){
  669. for(let i=0;i<data.data.length;i++){
  670. for(let k=0;k<self.itemData.labHardwareVOList.length;k++){
  671. if(data.data[i].num == self.itemData.labHardwareVOList[k].id){
  672. if(data.data[i].hardwareOperate == 'CLOSE'){
  673. self.itemData.labHardwareVOList[k].state.code = 4;
  674. }else if(data.data[i].hardwareOperate == 'OPEN'){
  675. self.itemData.labHardwareVOList[k].state.code = 3;
  676. }else if(data.data[i].hardwareOperate == 'OFFLINE'){
  677. self.itemData.labHardwareVOList[k].state.code = 0;
  678. }else if(data.data[i].hardwareOperate == 'ONLINE'){
  679. self.itemData.labHardwareVOList[k].state.code = 2;
  680. }
  681. }
  682. }
  683. }
  684. }
  685. })
  686. // 全局监听是否有关闭mqtt的消息的事件
  687. uni.$on('closeMqtt',() => {
  688. this.client.end(true); // 主动断开连接
  689. })
  690. },
  691. //取消订阅关闭MQTT连接
  692. offMQTT(){
  693. this.client.unsubscribe(this.mtopic, error => {
  694. if (error) {
  695. console.log('Unsubscribe error', error)
  696. }
  697. })
  698. this.client.end();
  699. this.client = {};
  700. },
  701. pcTypeButtonClick(id){
  702. let self = this;
  703. uni.showModal({
  704. content: '确认要操作该设备吗?',
  705. cancelColor:"#999",
  706. confirmColor:"#0183FA",
  707. success: function (res) {
  708. if (res.confirm) {
  709. self.controlSwitch(id);
  710. console.log('用户点击确定');
  711. } else if (res.cancel) {
  712. console.log('用户点击取消');
  713. }
  714. }
  715. });
  716. },
  717. async controlSwitch(id){
  718. const {data} = await controlSwitch({id:id});
  719. if(data.code == 200){
  720. uni.showToast({
  721. title: '操作成功',
  722. icon:"none",
  723. mask:true,
  724. duration: 2000
  725. });
  726. }
  727. },
  728. //设备开关按钮
  729. hardwareButton(minItem,command){
  730. let self = this;
  731. let text = '';
  732. if(command == 'close'){
  733. text = '关闭';
  734. }else if(command == 'open'){
  735. text = '开启';
  736. }
  737. uni.showModal({
  738. content: '确认要'+text+'吗?',
  739. cancelColor:"#999",
  740. confirmColor:"#0183FA",
  741. success: function (res) {
  742. if (res.confirm) {
  743. self.mangerControl(minItem,command);
  744. console.log('用户点击确定');
  745. } else if (res.cancel) {
  746. console.log('用户点击取消');
  747. }
  748. }
  749. });
  750. },
  751. //设备开关
  752. async mangerControl(minItem,command){
  753. let obj = {
  754. id:minItem.id,
  755. command:command,
  756. };
  757. const {data} = await mangerControl(obj);
  758. if(data.code == 200){
  759. if(command == 'open'){
  760. minItem.type = 3;
  761. }else if(command == 'close'){
  762. minItem.type = 4;
  763. }
  764. uni.showToast({
  765. title: '操作成功',
  766. icon:"none",
  767. mask:true,
  768. duration: 2000
  769. });
  770. }
  771. },
  772. goVideo(){
  773. this.itemData.floorId = this.itemData.subAddrr.floorId;
  774. uni.navigateTo({
  775. url:'/pages_manage/workbench/laboratory/monitor?item='+encodeURIComponent(JSON.stringify(this.itemData))+'&deptId='+this.deptId
  776. })
  777. },
  778. goWord(){
  779. uni.navigateTo({
  780. url:'/pages_manage/workbench/laboratory/word?item='+encodeURIComponent(JSON.stringify(this.itemData))
  781. })
  782. },
  783. },
  784. onHide(){
  785. // //删除传感器监听
  786. getApp().deleteSensorWatch();
  787. // //删除设备监听
  788. getApp().deleteDeviceWatch();
  789. //删除一键灭火-传感器状态
  790. getApp().deletefireData();
  791. //删除一键灭火-设备是否在线
  792. getApp().deleteOnlineData();
  793. //删除一键灭火-是否正在执行灭火
  794. getApp().deletePerformData();
  795. },
  796. beforeDestroy(){
  797. // //删除传感器监听
  798. getApp().deleteSensorWatch();
  799. // //删除设备监听
  800. getApp().deleteDeviceWatch();
  801. //删除一键灭火-传感器状态
  802. getApp().deletefireData();
  803. //删除一键灭火-设备是否在线
  804. getApp().deleteOnlineData();
  805. //删除一键灭火-是否正在执行灭火
  806. getApp().deletePerformData();
  807. }
  808. }
  809. </script>
  810. <style lang="stylus" scoped>
  811. #laboratoryInfo{
  812. height:100%;
  813. display flex;
  814. flex-direction column;
  815. /* 一键灭火 */
  816. .outfire {
  817. width: 750rpx;
  818. height: auto;
  819. background: #FFFFFF;
  820. margin: 20rpx 0;
  821. padding: 20rpx 10rpx;
  822. box-sizing: border-box;
  823. display: flex;
  824. justify-content: space-between;
  825. align-items: center;
  826. .outfire_li {
  827. display: flex;
  828. justify-content: flex-start;
  829. align-items: center;
  830. >img {
  831. width: 24rpx;
  832. height: 30rpx;
  833. margin-right: 12rpx;
  834. }
  835. .normal {
  836. font-size: 24rpx;
  837. font-family: PingFang SC;
  838. font-weight: 500;
  839. color: #333333;
  840. }
  841. .abnormal {
  842. font-size: 24rpx;
  843. font-family: PingFang SC;
  844. font-weight: 500;
  845. color: #F11C00;
  846. }
  847. }
  848. .outfire_li:nth-of-type(1) {
  849. >img {
  850. width: 30rpx;
  851. height: 28rpx;
  852. margin-right: 12rpx;
  853. }
  854. }
  855. .outfire_yes_btn {
  856. width: 120rpx;
  857. height: 40rpx;
  858. font-size: 24rpx;
  859. font-family: PingFang SC;
  860. font-weight: 500;
  861. color: #F21C00;
  862. line-height: 40rpx;
  863. border: 1px solid #F21C00;
  864. border-radius: 8rpx;
  865. text-align: center;
  866. margin-left: 54rpx;
  867. }
  868. .outfire_no_btn {
  869. width: 120rpx;
  870. height: 40rpx;
  871. font-size: 24rpx;
  872. font-family: PingFang SC;
  873. font-weight: 500;
  874. color: #CCCCCC;
  875. line-height: 40rpx;
  876. border: 1px solid #E0E0E0;
  877. border-radius: 8rpx;
  878. text-align: center;
  879. margin-left: 54rpx;
  880. }
  881. }
  882. /* 一键灭火 */
  883. .shade-outfire {
  884. height: 100%;
  885. width: 100%;
  886. position: fixed;
  887. display: flex;
  888. flex-direction: column;
  889. z-index: 10;
  890. background: rgba(0, 0, 0, 0.2);
  891. .null-box {
  892. flex: 1;
  893. }
  894. .shade-outfire-n {
  895. width: 625rpx;
  896. height: 450rpx;
  897. background: #FFFFFF;
  898. border-radius: 20rpx;
  899. position: absolute;
  900. top: 370rpx;
  901. left: 62rpx;
  902. .shade-outfire-n-t {
  903. width: 172rpx;
  904. height: 172rpx;
  905. margin: 38rpx 0 0 226rpx;
  906. }
  907. .shade-outfire-n-m {
  908. font-size: 30rpx;
  909. font-family: PingFang SC;
  910. font-weight: 500;
  911. color: #E30000;
  912. line-height: 84rpx;
  913. text-align: center;
  914. border-bottom: 1px solid #E0E0E0;
  915. >text {
  916. font-size: 40rpx;
  917. }
  918. }
  919. .shade-outfire-n-b {
  920. width: 402rpx;
  921. height: 82rpx;
  922. background: #FFFFFF;
  923. border: 2rpx solid #0183FA;
  924. border-radius: 10rpx;
  925. font-size: 28rpx;
  926. line-height: 82rpx;
  927. font-family: PingFang SC;
  928. font-weight: 500;
  929. color: #0183FA;
  930. text-align: center;
  931. margin: 30rpx 0 0 112rpx;
  932. }
  933. }
  934. }
  935. .name-max-box{
  936. background #fff
  937. .title-box{
  938. margin:20rpx 20rpx 0;
  939. display flex
  940. view:nth-child(1){
  941. height:40rpx;
  942. line-height:40rpx;
  943. font-size:20rpx;
  944. border-radius:10rpx;
  945. padding:0 20rpx;
  946. color:#fff;
  947. margin-right:20rpx;
  948. }
  949. view:nth-child(2){
  950. line-height:42rpx;
  951. font-size:30rpx;
  952. color:#0183FA;
  953. max-width:600rpx;
  954. flex:1;
  955. }
  956. img{
  957. width:12rpx;
  958. height:20rpx;
  959. margin-top:11rpx;
  960. }
  961. .colorA{
  962. background:#aa2315;
  963. }
  964. .colorB{
  965. background:#ff9b09;
  966. }
  967. .colorC{
  968. background:#3ea3e9;
  969. }
  970. .colorD{
  971. background:#3ea34c;
  972. }
  973. }
  974. .address-box{
  975. margin:20rpx 20rpx;
  976. font-size:26rpx;
  977. color:#999999;
  978. span{
  979. margin-right:60rpx;
  980. }
  981. }
  982. .address-box-two{
  983. display flex
  984. margin:0 20rpx 20rpx 20rpx;
  985. img{
  986. width:28rpx;
  987. height:30rpx;
  988. margin-right:18rpx;
  989. }
  990. view{
  991. line-height:30rpx;
  992. font-size:24rpx;
  993. color:#999999;
  994. }
  995. }
  996. }
  997. .title-max-box-none{
  998. border:none!important;
  999. }
  1000. .title-max-box{
  1001. display flex
  1002. height:80rpx;
  1003. border-bottom:1rpx solid #E0E0E0;
  1004. .left-view{
  1005. width: 4rpx;
  1006. height: 34rpx;
  1007. margin:25rpx 24rpx 0 20rpx;
  1008. background:#0D97EB;
  1009. }
  1010. .right-view{
  1011. line-height:80rpx;
  1012. font-size: 30rpx;
  1013. color: #333333;
  1014. flex:1;
  1015. }
  1016. .click-view{
  1017. display flex
  1018. padding:0 20rpx;
  1019. view{
  1020. line-height:80rpx;
  1021. font-size: 24rpx;
  1022. color: #666666;
  1023. }
  1024. img{
  1025. width:20rpx;
  1026. height:10rpx;
  1027. margin:35rpx 0 0 20rpx;
  1028. }
  1029. }
  1030. }
  1031. .sensor-max-box{
  1032. background #fff
  1033. margin-top:20rpx;
  1034. .text-box{
  1035. /*border-top:1rpx dashed #e0e0e0;*/
  1036. /*border-top:1rpx solid #E0E0E0;*/
  1037. padding:0 20rpx;
  1038. /*
  1039. overflow-x:scroll;
  1040. overflow-y:hidden;
  1041. white-space: nowrap;
  1042. */
  1043. .min-box{
  1044. display inline-block
  1045. /*padding:0 30rpx 0 10rpx;*/
  1046. width:355rpx;
  1047. .min-min-box{
  1048. display: flex
  1049. img{
  1050. width:30rpx;
  1051. height:27rpx;
  1052. margin-top:24rpx;
  1053. margin-right:10rpx;
  1054. }
  1055. view{
  1056. line-height:74rpx;
  1057. text-align center
  1058. font-size:28rpx;
  1059. color:#333;
  1060. }
  1061. .colorA{
  1062. color:#EE3A3A;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. }
  1068. .control-max-box{
  1069. background #fff
  1070. margin-top:20rpx;
  1071. .button-max-box{
  1072. .button-box:last-child{
  1073. border:none!important;
  1074. }
  1075. .button-box{
  1076. display flex
  1077. border-bottom:1rpx solid #e0e0e0;
  1078. margin:0 20rpx;
  1079. view:nth-child(1){
  1080. flex:1;
  1081. line-height:90rpx;
  1082. color:#333333;
  1083. font-size:28rpx;
  1084. }
  1085. view:nth-child(2){
  1086. width:120rpx;
  1087. line-height:42rpx;
  1088. border:4rpx solid #0183FA;
  1089. border-radius:30rpx;
  1090. color: #0183FA;
  1091. font-size: 24rpx;
  1092. text-align center;
  1093. margin:20rpx 0 20rpx 0;
  1094. }
  1095. }
  1096. .for-button-box:last-child{
  1097. border:none!important;
  1098. }
  1099. .for-button-box{
  1100. display flex
  1101. border-bottom:1rpx solid #e0e0e0;
  1102. margin:0 20rpx;
  1103. .for-button-p{
  1104. flex:1;
  1105. line-height:90rpx;
  1106. color:#333333;
  1107. font-size:28rpx;
  1108. }
  1109. img{
  1110. height:50rpx;
  1111. width:100rpx;
  1112. margin:20rpx 0 20rpx 0;
  1113. }
  1114. view:nth-child(2){
  1115. text-align right
  1116. color:#999;
  1117. }
  1118. .pcType-button{
  1119. width:120rpx;
  1120. line-height:42rpx;
  1121. border:4rpx solid #0183FA;
  1122. border-radius:30rpx;
  1123. color: #0183FA !important;
  1124. font-size: 24rpx;
  1125. text-align center !important;
  1126. margin:20rpx 0 20rpx 0;
  1127. }
  1128. }
  1129. }
  1130. }
  1131. .info-max-box{
  1132. background #fff
  1133. margin-top:20rpx;
  1134. .top-name-max-box{
  1135. background #fff
  1136. overflow hidden
  1137. .name-box{
  1138. margin:27rpx 20rpx 0;
  1139. display:flex;
  1140. view:nth-child(1){
  1141. background:#f95f5f;
  1142. color:#fff;
  1143. border-radius:6rpx;
  1144. font-size:20rpx;
  1145. padding:0 10rpx;
  1146. height:42rpx;
  1147. line-height:42rpx;
  1148. }
  1149. view:nth-child(2){
  1150. color:#333;
  1151. margin-left:20rpx;
  1152. font-size:28rpx;
  1153. height:30rpx;
  1154. line-height:42rpx;
  1155. font-weight:700;
  1156. }
  1157. }
  1158. .address-box{
  1159. margin:22rpx 20rpx;
  1160. font-size:26rpx;
  1161. }
  1162. }
  1163. .text-max-box{
  1164. background #fff
  1165. padding:8rpx 20rpx;
  1166. border-bottom:1rpx solid #e0e0e0;
  1167. .text-min-box{
  1168. display:flex;
  1169. view{
  1170. line-height:66rpx;
  1171. height:66rpx;
  1172. font-size:28rpx;
  1173. }
  1174. view:nth-child(1){
  1175. width:220rpx;
  1176. color:#333;
  1177. }
  1178. view:nth-child(2){
  1179. flex:1;
  1180. color:#999;
  1181. text-align:right;
  1182. }
  1183. }
  1184. }
  1185. .safety-max-box{
  1186. background #fff
  1187. padding:8rpx 20rpx;
  1188. .max-for-box{
  1189. .title-box{
  1190. line-height:76rpx;
  1191. font-size:30rpx;
  1192. color:#333;
  1193. }
  1194. .for-box{
  1195. line-height:48rpx;
  1196. font-size:28rpx;
  1197. color:#999;
  1198. }
  1199. }
  1200. }
  1201. .img-bottom-box{
  1202. margin-top:20rpx;
  1203. background #fff
  1204. padding:8rpx 20rpx 20rpx;
  1205. .title-box{
  1206. line-height:76rpx;
  1207. font-size:28rpx;
  1208. color:#333;
  1209. }
  1210. .for-box{
  1211. line-height:48rpx;
  1212. font-size:26rpx;
  1213. color:#999;
  1214. .img-ojb{
  1215. display inline-block
  1216. width:86rpx;
  1217. height:114rpx;
  1218. margin-left:30rpx;
  1219. }
  1220. .code-img{
  1221. width:200rpx;
  1222. height:200rpx;
  1223. margin:20rpx auto 40rpx;
  1224. }
  1225. }
  1226. }
  1227. }
  1228. }
  1229. </style>