【前端】智能库房综合管理系统前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
10 KiB

  1. <template>
  2. <div class="warehouse">
  3. <div class="warehouse-left">
  4. <div class="left-3d">
  5. <iframe id="myIframe" ref="myIframe" name="iframeMap" class="iframe_box" src="/webD/index.html" frameborder="0" scrolling="no" />
  6. <ul class="msg-list">
  7. <li v-show="topDisplayData.XXW_DIV_TOP_001.show" :class="{ 'li-warn': topDisplayData.XXW_DIV_TOP_001.curstatus > 0 }">
  8. <svg-icon icon-class="temperature" class-name="msg-list-svg" />
  9. <div class="msg-txt">
  10. <span class="msg-list-num">{{ topDisplayData.XXW_DIV_TOP_001.curValue }}</span>
  11. <p class="msg-list-unit">温度 {{ topDisplayData.XXW_DIV_TOP_001.unit }}</p>
  12. </div>
  13. </li>
  14. <li v-show="topDisplayData.XXW_DIV_TOP_002.show" :class="{ 'li-warn': topDisplayData.XXW_DIV_TOP_002.curstatus > 0 }">
  15. <svg-icon icon-class="shidu" class-name="msg-list-svg" />
  16. <div class="msg-txt">
  17. <span class="msg-list-num">{{ topDisplayData.XXW_DIV_TOP_002.curValue }}</span>
  18. <p class="msg-list-unit">湿度 {{ topDisplayData.XXW_DIV_TOP_002.unit }}</p>
  19. </div>
  20. </li>
  21. <li v-show="topDisplayData.XXW_DIV_TOP_003.show" :class="{ 'li-warn': topDisplayData.XXW_DIV_TOP_003.curstatus > 0 }">
  22. <svg-icon icon-class="co2" class-name="msg-list-svg" />
  23. <div class="msg-txt">
  24. <span class="msg-list-num">{{ topDisplayData.XXW_DIV_TOP_003.curValue }}</span>
  25. <p class="msg-list-unit">CO2 {{ topDisplayData.XXW_DIV_TOP_003.unit }}</p>
  26. </div>
  27. </li>
  28. <li v-show="topDisplayData.XXW_DIV_TOP_004.show" :class="{ 'li-warn': topDisplayData.XXW_DIV_TOP_004.curstatus > 0 }">
  29. <svg-icon icon-class="voc" class-name="msg-list-svg" />
  30. <div class="msg-txt">
  31. <span class="msg-list-num">{{ topDisplayData.XXW_DIV_TOP_004.curValue }}</span>
  32. <p class="msg-list-unit">TVOC {{ topDisplayData.XXW_DIV_TOP_004.unit }}</p>
  33. </div>
  34. </li>
  35. <li v-show="topDisplayData.XXW_DIV_TOP_005.show" :class="{ 'li-warn': topDisplayData.XXW_DIV_TOP_005.curstatus > 0 }" class="msg-pm">
  36. <svg-icon icon-class="pm25" class-name="msg-list-svg" />
  37. <div class="msg-txt">
  38. <span class="msg-list-num">{{ topDisplayData.XXW_DIV_TOP_005.curValue }}</span>
  39. <p class="msg-list-unit">PM2.5 {{ topDisplayData.XXW_DIV_TOP_005.unit }}</p>
  40. </div>
  41. </li>
  42. <li v-show="topDisplayData.XXW_DIV_TOP_006.show" :class="{ 'li-warn': topDisplayData.XXW_DIV_TOP_006.curstatus > 0 }" class="msg-pm">
  43. <svg-icon icon-class="pm10" class-name="msg-list-svg" />
  44. <div class="msg-txt">
  45. <span class="msg-list-num">{{ topDisplayData.XXW_DIV_TOP_006.curValue }}</span>
  46. <p class="msg-list-unit">PM10 {{ topDisplayData.XXW_DIV_TOP_006.unit }}</p>
  47. </div>
  48. </li>
  49. </ul>
  50. </div>
  51. </div>
  52. <div class="warehouse-right">
  53. <!-- 报警记录 -->
  54. <warehouse-warning :height="'calc(100% - 40px)'" :storeroom-id="roomId" />
  55. <!-- 门禁记录 -->
  56. <security-door :height="'calc(100% - 40px)'" />
  57. </div>
  58. </div>
  59. </template>
  60. <script>
  61. import WarehouseWarning from '@/views/components/WarehouseWarning'
  62. import SecurityDoor from '@/views/components/SecurityDoor'
  63. import displayConfigApi from '@/api/storeManage/displayConfig'
  64. import thirdApi from '@/api/thirdApi'
  65. export default {
  66. name: 'InfoRoom',
  67. components: { WarehouseWarning, SecurityDoor },
  68. data() {
  69. return {
  70. roomId: '1B2DADD8499058954C0CAC ',
  71. allDisplayConfigData: [],
  72. displayConfigData: [],
  73. url: '',
  74. allDeviceIds: [],
  75. oaoMessage: [],
  76. timer: '',
  77. topDisplayData: {
  78. XXW_DIV_TOP_001: {
  79. show: false,
  80. curValue: '',
  81. unit: '',
  82. curstatus: 0
  83. },
  84. XXW_DIV_TOP_002: {
  85. show: false,
  86. curValue: '',
  87. unit: '',
  88. curstatus: 0
  89. },
  90. XXW_DIV_TOP_003: {
  91. show: false,
  92. curValue: '',
  93. unit: '',
  94. curstatus: 0
  95. },
  96. XXW_DIV_TOP_004: {
  97. show: false,
  98. curValue: '',
  99. unit: '',
  100. curstatus: 0
  101. },
  102. XXW_DIV_TOP_005: {
  103. show: false,
  104. curValue: '',
  105. unit: '',
  106. curstatus: 0
  107. },
  108. XXW_DIV_TOP_006: {
  109. show: false,
  110. curValue: '',
  111. unit: '',
  112. curstatus: 0
  113. }
  114. }
  115. // ,
  116. // iframeWin: null,
  117. // timer: null, // 定时器id 滚动表格
  118. // isScroll: false // 是否滚动
  119. }
  120. },
  121. async created() {
  122. window.getIframeLoading = this.getIframeLoading // 把vue实例中的方法引用给window对象
  123. this.allDisplayConfigData = await displayConfigApi.list({ storeroomId: this.roomId })
  124. this.allDisplayConfigData.forEach(element => {
  125. if (element.isDisplay && element.bindState && element.deviceInfo && (element.divPosition.includes('OAO') || element.divPosition.includes('TOP'))) {
  126. this.allDeviceIds.push(element.deviceInfo.deviceId)
  127. if (!this.url) {
  128. this.url = 'http://' + element.deviceInfo.deviceIp + ':' + element.deviceInfo.devicePort
  129. }
  130. }
  131. })
  132. this.displayConfigData = this.allDisplayConfigData.filter((item) => { return item.isDisplay && item.bindState && item.deviceInfo && (item.divPosition.includes('OAO') || item.divPosition.includes('TOP')) })
  133. await this.getRealTimeData()
  134. },
  135. mounted() {
  136. const _this = this
  137. _this.iframeWin = this.$refs.myIframe.contentWindow
  138. // inframe 加载完成之后
  139. document.getElementById('myIframe').onload = function() {
  140. _this.deviceState()
  141. }
  142. window.addEventListener('message', this.handleMessageDevice)
  143. // 定时请求第三方数据,更新页面数据
  144. this.timer = setInterval(async() => {
  145. await _this.getRealTimeData()
  146. _this.handleAQI()
  147. }, 10000)
  148. },
  149. beforeDestroy() {
  150. if (this.timer) {
  151. clearInterval(this.timer)
  152. }
  153. },
  154. methods: {
  155. // 加载完成状态传值
  156. getIframeLoading(value) {
  157. // console.log(`我是iframe传过来的参数:${value}`)
  158. if (value === 'false') {
  159. this.allDisplayConfigData.forEach(element => {
  160. if ((!element.isDisplay || !element.bindState) && element.divPosition.includes('OAO')) {
  161. this.handleHide(element.divPosition)
  162. }
  163. })
  164. // this.handleAlarm('DAK_MO_OAO_003')
  165. this.deviceState()
  166. this.handleAQI()
  167. }
  168. },
  169. // 传入设备状态data / 给iframe传初始值
  170. deviceState(e) {
  171. this.iframeWin.postMessage({
  172. data: this.oaoMessage
  173. }, '*')
  174. },
  175. // 点击查看设备状况 / 密集架列号
  176. handleMessageDevice(event) {
  177. const _this = this
  178. if (event.data && event.data.data) {
  179. const data = event.data.data
  180. if (data.includes('cabinet')) {
  181. _this.deviceId = data.slice(data.length - 2)
  182. _this.$router.push('/storeManage/deseCabinet')
  183. localStorage.setItem('cabinetNum', _this.deviceId)
  184. }
  185. }
  186. },
  187. // 设置温湿度
  188. handleAQI() {
  189. this.oaoMessage.forEach(element => {
  190. window.frames['iframeMap'].setAlertValue(element.id, element.wendu, element.sidu)
  191. })
  192. },
  193. // 设置温湿度报警状况
  194. handleAlarm(deviceId) {
  195. // true 报警 false 不报警
  196. window.frames['iframeMap'].Myalert(deviceId, true)
  197. },
  198. // 设置是否显示
  199. handleHide(deviceId) {
  200. // true 显示 false 隐藏
  201. window.frames['iframeMap'].setYangGanCanshow(deviceId, false)
  202. },
  203. // 表格隔行变色
  204. rowBgColor({ row, rowIndex }) {
  205. if (rowIndex % 2 === 1) {
  206. return 'light-blue'
  207. } else {
  208. return ''
  209. }
  210. },
  211. getRealTimeData() {
  212. if (this.allDeviceIds.length > 0) {
  213. thirdApi.getRealTimeData({ ids: this.allDeviceIds, url: this.url }).then((data) => {
  214. this.oaoMessage.splice(0, this.oaoMessage.length)
  215. this.displayConfigData.forEach(element => {
  216. if (element.divPosition.includes('TOP') && element.deviceSpecParams[0]) {
  217. // 获取页面div显示的数据
  218. const result = data.find((item) => {
  219. return item.property_id === element.deviceSpecParams[0].paramId && item.device_id === element.deviceInfo.deviceId
  220. })
  221. console.log(result)
  222. this.$set(this.topDisplayData, element.divPosition, {
  223. show: true,
  224. curValue: result.curvalue,
  225. unit: result.unit,
  226. curstatus: result.curstatus
  227. })
  228. } else {
  229. // 获取3D弹窗显示的数据
  230. const wenduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '温度' })?.paramId
  231. const siduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '湿度' })?.paramId
  232. let wendu = {}
  233. let sidu = {}
  234. if (wenduParamId) {
  235. wendu = data.find((item) => {
  236. return item.property_id === wenduParamId && item.device_id === element.deviceInfo.deviceId
  237. })
  238. }
  239. if (siduParamId) {
  240. sidu = data.find((item) => {
  241. return item.property_id === siduParamId && item.device_id === element.deviceInfo.deviceId
  242. })
  243. }
  244. console.log(wendu?.curstatus, sidu?.curstatus)
  245. this.oaoMessage.push({
  246. id: element.divPosition,
  247. wendu: (wendu?.curvalue) ? (Math.round(wendu?.curvalue)) : '-',
  248. sidu: (sidu?.curvalue) ? (Math.round(sidu?.curvalue)) : '-',
  249. alarmState: (wendu && wendu.curstatus > 0) || (sidu && sidu.curstatus > 0)
  250. })
  251. }
  252. })
  253. })
  254. }
  255. }
  256. }
  257. }
  258. </script>
  259. <style lang="scss" scoped>
  260. @import "~@/assets/styles/lend-manage.scss";
  261. .warehouse-left {
  262. position: relative;
  263. }
  264. .container-wrap {
  265. min-height: auto;
  266. height: calc(100% / 2 - 10px);
  267. overflow: hidden;
  268. }
  269. .container-wrap {
  270. margin-bottom: 20px;
  271. }
  272. </style>