laboratoryInfo.vue 36 KB

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