laboratoryInfo.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  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;" class="finish">自动灭火完成,请确保在关闭灭火一体机电源后补充灭火耗材,耗材补充完毕需要打开电源并点击一体机上的复位按钮</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. margin-top: 8rpx;
  839. }
  840. .finish{
  841. flex: 1;
  842. }
  843. .normal {
  844. font-size: 24rpx;
  845. font-family: PingFang SC;
  846. font-weight: 500;
  847. color: #333333;
  848. }
  849. .abnormal {
  850. font-size: 24rpx;
  851. font-family: PingFang SC;
  852. font-weight: 500;
  853. color: #F11C00;
  854. }
  855. }
  856. .outfire_li:nth-of-type(1) {
  857. >img {
  858. width: 30rpx;
  859. height: 28rpx;
  860. margin-right: 12rpx;
  861. }
  862. }
  863. .outfire_yes_btn {
  864. width: 120rpx;
  865. height: 40rpx;
  866. font-size: 24rpx;
  867. font-family: PingFang SC;
  868. font-weight: 500;
  869. color: #F21C00;
  870. line-height: 40rpx;
  871. border: 1px solid #F21C00;
  872. border-radius: 8rpx;
  873. text-align: center;
  874. margin-left: 54rpx;
  875. }
  876. .outfire_no_btn {
  877. width: 120rpx;
  878. height: 40rpx;
  879. font-size: 24rpx;
  880. font-family: PingFang SC;
  881. font-weight: 500;
  882. color: #CCCCCC;
  883. line-height: 40rpx;
  884. border: 1px solid #E0E0E0;
  885. border-radius: 8rpx;
  886. text-align: center;
  887. margin-left: 54rpx;
  888. }
  889. }
  890. /* 一键灭火 */
  891. .shade-outfire {
  892. height: 100%;
  893. width: 100%;
  894. position: fixed;
  895. display: flex;
  896. flex-direction: column;
  897. z-index: 10;
  898. background: rgba(0, 0, 0, 0.2);
  899. .null-box {
  900. flex: 1;
  901. }
  902. .shade-outfire-n {
  903. width: 625rpx;
  904. height: 450rpx;
  905. background: #FFFFFF;
  906. border-radius: 20rpx;
  907. position: absolute;
  908. top: 370rpx;
  909. left: 62rpx;
  910. .shade-outfire-n-t {
  911. width: 172rpx;
  912. height: 172rpx;
  913. margin: 38rpx 0 0 226rpx;
  914. }
  915. .shade-outfire-n-m {
  916. font-size: 30rpx;
  917. font-family: PingFang SC;
  918. font-weight: 500;
  919. color: #E30000;
  920. line-height: 84rpx;
  921. text-align: center;
  922. border-bottom: 1px solid #E0E0E0;
  923. >text {
  924. font-size: 40rpx;
  925. }
  926. }
  927. .shade-outfire-n-b {
  928. width: 402rpx;
  929. height: 82rpx;
  930. background: #FFFFFF;
  931. border: 2rpx solid #0183FA;
  932. border-radius: 10rpx;
  933. font-size: 28rpx;
  934. line-height: 82rpx;
  935. font-family: PingFang SC;
  936. font-weight: 500;
  937. color: #0183FA;
  938. text-align: center;
  939. margin: 30rpx 0 0 112rpx;
  940. }
  941. }
  942. }
  943. .name-max-box{
  944. background #fff
  945. .title-box{
  946. margin:20rpx 20rpx 0;
  947. display flex
  948. view:nth-child(1){
  949. height:40rpx;
  950. line-height:40rpx;
  951. font-size:20rpx;
  952. border-radius:10rpx;
  953. padding:0 20rpx;
  954. color:#fff;
  955. margin-right:20rpx;
  956. }
  957. view:nth-child(2){
  958. line-height:42rpx;
  959. font-size:30rpx;
  960. color:#0183FA;
  961. max-width:600rpx;
  962. flex:1;
  963. }
  964. img{
  965. width:12rpx;
  966. height:20rpx;
  967. margin-top:11rpx;
  968. }
  969. .colorA{
  970. background:#aa2315;
  971. }
  972. .colorB{
  973. background:#ff9b09;
  974. }
  975. .colorC{
  976. background:#3ea3e9;
  977. }
  978. .colorD{
  979. background:#3ea34c;
  980. }
  981. }
  982. .address-box{
  983. margin:20rpx 20rpx;
  984. font-size:26rpx;
  985. color:#999999;
  986. span{
  987. margin-right:60rpx;
  988. }
  989. }
  990. .address-box-two{
  991. display flex
  992. margin:0 20rpx 20rpx 20rpx;
  993. img{
  994. width:28rpx;
  995. height:30rpx;
  996. margin-right:18rpx;
  997. }
  998. view{
  999. line-height:30rpx;
  1000. font-size:24rpx;
  1001. color:#999999;
  1002. }
  1003. }
  1004. }
  1005. .title-max-box-none{
  1006. border:none!important;
  1007. }
  1008. .title-max-box{
  1009. display flex
  1010. height:80rpx;
  1011. border-bottom:1rpx solid #E0E0E0;
  1012. .left-view{
  1013. width: 4rpx;
  1014. height: 34rpx;
  1015. margin:25rpx 24rpx 0 20rpx;
  1016. background:#0D97EB;
  1017. }
  1018. .right-view{
  1019. line-height:80rpx;
  1020. font-size: 30rpx;
  1021. color: #333333;
  1022. flex:1;
  1023. }
  1024. .click-view{
  1025. display flex
  1026. padding:0 20rpx;
  1027. view{
  1028. line-height:80rpx;
  1029. font-size: 24rpx;
  1030. color: #666666;
  1031. }
  1032. img{
  1033. width:20rpx;
  1034. height:10rpx;
  1035. margin:35rpx 0 0 20rpx;
  1036. }
  1037. }
  1038. }
  1039. .sensor-max-box{
  1040. background #fff
  1041. margin-top:20rpx;
  1042. .text-box{
  1043. /*border-top:1rpx dashed #e0e0e0;*/
  1044. /*border-top:1rpx solid #E0E0E0;*/
  1045. padding:0 20rpx;
  1046. /*
  1047. overflow-x:scroll;
  1048. overflow-y:hidden;
  1049. white-space: nowrap;
  1050. */
  1051. .min-box{
  1052. display inline-block
  1053. /*padding:0 30rpx 0 10rpx;*/
  1054. width:355rpx;
  1055. .min-min-box{
  1056. display: flex
  1057. img{
  1058. width:30rpx;
  1059. height:27rpx;
  1060. margin-top:24rpx;
  1061. margin-right:10rpx;
  1062. }
  1063. view{
  1064. line-height:74rpx;
  1065. text-align center
  1066. font-size:28rpx;
  1067. color:#333;
  1068. }
  1069. .colorA{
  1070. color:#EE3A3A;
  1071. }
  1072. }
  1073. }
  1074. }
  1075. }
  1076. .control-max-box{
  1077. background #fff
  1078. margin-top:20rpx;
  1079. .button-max-box{
  1080. .button-box:last-child{
  1081. border:none!important;
  1082. }
  1083. .button-box{
  1084. display flex
  1085. border-bottom:1rpx solid #e0e0e0;
  1086. margin:0 20rpx;
  1087. view:nth-child(1){
  1088. flex:1;
  1089. line-height:90rpx;
  1090. color:#333333;
  1091. font-size:28rpx;
  1092. }
  1093. view:nth-child(2){
  1094. width:120rpx;
  1095. line-height:42rpx;
  1096. border:4rpx solid #0183FA;
  1097. border-radius:30rpx;
  1098. color: #0183FA;
  1099. font-size: 24rpx;
  1100. text-align center;
  1101. margin:20rpx 0 20rpx 0;
  1102. }
  1103. }
  1104. .for-button-box:last-child{
  1105. border:none!important;
  1106. }
  1107. .for-button-box{
  1108. display flex
  1109. border-bottom:1rpx solid #e0e0e0;
  1110. margin:0 20rpx;
  1111. .for-button-p{
  1112. flex:1;
  1113. line-height:90rpx;
  1114. color:#333333;
  1115. font-size:28rpx;
  1116. }
  1117. img{
  1118. height:50rpx;
  1119. width:100rpx;
  1120. margin:20rpx 0 20rpx 0;
  1121. }
  1122. view:nth-child(2){
  1123. text-align right
  1124. color:#999;
  1125. }
  1126. .pcType-button{
  1127. width:120rpx;
  1128. line-height:42rpx;
  1129. border:4rpx solid #0183FA;
  1130. border-radius:30rpx;
  1131. color: #0183FA !important;
  1132. font-size: 24rpx;
  1133. text-align center !important;
  1134. margin:20rpx 0 20rpx 0;
  1135. }
  1136. }
  1137. }
  1138. }
  1139. .info-max-box{
  1140. background #fff
  1141. margin-top:20rpx;
  1142. .top-name-max-box{
  1143. background #fff
  1144. overflow hidden
  1145. .name-box{
  1146. margin:27rpx 20rpx 0;
  1147. display:flex;
  1148. view:nth-child(1){
  1149. background:#f95f5f;
  1150. color:#fff;
  1151. border-radius:6rpx;
  1152. font-size:20rpx;
  1153. padding:0 10rpx;
  1154. height:42rpx;
  1155. line-height:42rpx;
  1156. }
  1157. view:nth-child(2){
  1158. color:#333;
  1159. margin-left:20rpx;
  1160. font-size:28rpx;
  1161. height:30rpx;
  1162. line-height:42rpx;
  1163. font-weight:700;
  1164. }
  1165. }
  1166. .address-box{
  1167. margin:22rpx 20rpx;
  1168. font-size:26rpx;
  1169. }
  1170. }
  1171. .text-max-box{
  1172. background #fff
  1173. padding:8rpx 20rpx;
  1174. border-bottom:1rpx solid #e0e0e0;
  1175. .text-min-box{
  1176. display:flex;
  1177. view{
  1178. line-height:66rpx;
  1179. height:66rpx;
  1180. font-size:28rpx;
  1181. }
  1182. view:nth-child(1){
  1183. width:220rpx;
  1184. color:#333;
  1185. }
  1186. view:nth-child(2){
  1187. flex:1;
  1188. color:#999;
  1189. text-align:right;
  1190. }
  1191. }
  1192. }
  1193. .safety-max-box{
  1194. background #fff
  1195. padding:8rpx 20rpx;
  1196. .max-for-box{
  1197. .title-box{
  1198. line-height:76rpx;
  1199. font-size:30rpx;
  1200. color:#333;
  1201. }
  1202. .for-box{
  1203. line-height:48rpx;
  1204. font-size:28rpx;
  1205. color:#999;
  1206. }
  1207. }
  1208. }
  1209. .img-bottom-box{
  1210. margin-top:20rpx;
  1211. background #fff
  1212. padding:8rpx 20rpx 20rpx;
  1213. .title-box{
  1214. line-height:76rpx;
  1215. font-size:28rpx;
  1216. color:#333;
  1217. }
  1218. .for-box{
  1219. line-height:48rpx;
  1220. font-size:26rpx;
  1221. color:#999;
  1222. .img-ojb{
  1223. display inline-block
  1224. width:86rpx;
  1225. height:114rpx;
  1226. margin-left:30rpx;
  1227. }
  1228. .code-img{
  1229. width:200rpx;
  1230. height:200rpx;
  1231. margin:20rpx auto 40rpx;
  1232. }
  1233. }
  1234. }
  1235. }
  1236. }
  1237. </style>