【前端】智能库房综合管理系统前端项目
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.

162 lines
5.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="warehouse">
  3. <div class="warehouse-left">
  4. <div class="left-3d">
  5. <iframe
  6. id="myIframe"
  7. ref="myIframe"
  8. name="iframeMap"
  9. class="iframe_box"
  10. src="/webB/index.html"
  11. frameborder="0"
  12. scrolling="no"
  13. />
  14. </div>
  15. </div>
  16. <warehouse-warning :height="'calc(100vh - 235px)'" :storeroom-id="roomId" />
  17. </div>
  18. </template>
  19. <script>
  20. import WarehouseWarning from '@/views/components/WarehouseWarning'
  21. import displayConfigApi from '@/api/storeManage/displayConfig'
  22. import thirdApi from '@/api/thirdApi'
  23. export default {
  24. name: 'CollateRoom',
  25. components: { WarehouseWarning },
  26. data() {
  27. return {
  28. roomId: 'D5C48B49DF66183CF24974',
  29. allDeviceIds: [],
  30. oaoMessage: [],
  31. allDisplayConfigData: [],
  32. displayConfigData: []
  33. }
  34. },
  35. async created() {
  36. window.getIframeLoading = this.getIframeLoading // 把vue实例中的方法引用给window对象
  37. this.allDisplayConfigData = await displayConfigApi.list({ storeroomId: this.roomId })
  38. this.allDisplayConfigData.forEach(element => {
  39. if (element.isDisplay && element.bindState && element.deviceInfo && element.divPosition.includes('OAO')) {
  40. this.allDeviceIds.push(element.deviceInfo.deviceId)
  41. if (!this.url) {
  42. this.url = 'http://' + element.deviceInfo.deviceIp + ':' + element.deviceInfo.devicePort
  43. }
  44. }
  45. })
  46. this.displayConfigData = this.allDisplayConfigData.filter((item) => { return item.isDisplay && item.bindState && item.deviceInfo && item.divPosition.includes('OAO') })
  47. await this.getRealTimeData()
  48. },
  49. mounted() {
  50. const _this = this
  51. this.iframeWin = this.$refs.myIframe.contentWindow
  52. // inframe 加载完成之后
  53. document.getElementById('myIframe').onload = function() {
  54. _this.deviceState()
  55. }
  56. // window.addEventListener('message', this.handleMessageDevice)
  57. // 定时请求第三方数据,更新页面数据
  58. this.timer = setInterval(async() => {
  59. await _this.getRealTimeData()
  60. _this.handleAQI()
  61. }, 10000)
  62. },
  63. beforeDestroy() {
  64. clearInterval(this.timer)
  65. },
  66. methods: {
  67. // 加载完成状态传值
  68. getIframeLoading(value) {
  69. // console.log(`我是iframe传过来的参数:${value}`)
  70. if (value === 'false') {
  71. this.allDisplayConfigData.forEach(element => {
  72. if ((!element.isDisplay || !element.bindState) && element.divPosition.includes('OAO')) {
  73. this.handleHide(element.divPosition)
  74. }
  75. })
  76. // this.handleAlarm('DAK_MO_OAO_003')
  77. this.deviceState()
  78. }
  79. },
  80. // 传入设备状态data / 给iframe传初始值
  81. deviceState(e) {
  82. this.iframeWin.postMessage({
  83. data: this.oaoMessage
  84. }, '*')
  85. },
  86. // 设置是否显示
  87. handleHide(deviceId) {
  88. window.frames['iframeMap'].setYangGanCanshow(deviceId, false)
  89. },
  90. // 设置温湿度
  91. handleAQI(deviceId, wendu, sidu) {
  92. this.oaoMessage.forEach(element => {
  93. window.frames['iframeMap'].setAlertValue(element.id, element.wendu, element.sidu)
  94. })
  95. },
  96. getRealTimeData() {
  97. if (this.allDeviceIds.length > 0) {
  98. thirdApi.getRealTimeData({ ids: this.allDeviceIds, url: this.url }).then((data) => {
  99. this.oaoMessage.splice(0, this.oaoMessage.length)
  100. this.displayConfigData.forEach(element => {
  101. if (element.divPosition.includes('OAO') && element.deviceSpecParams[0]) {
  102. // 获取3D弹窗显示的数据
  103. const wenduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '温度' })?.paramId
  104. const siduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '湿度' })?.paramId
  105. let wendu = {}
  106. let sidu = {}
  107. if (wenduParamId) {
  108. wendu = data.find((item) => {
  109. return item.property_id === wenduParamId && item.device_id === element.deviceInfo.deviceId
  110. })
  111. }
  112. if (siduParamId) {
  113. sidu = data.find((item) => {
  114. return item.property_id === siduParamId && item.device_id === element.deviceInfo.deviceId
  115. })
  116. }
  117. this.oaoMessage.push({
  118. id: element.divPosition,
  119. wendu: (wendu?.curvalue) ? (Math.round(wendu?.curvalue)) : '-',
  120. sidu: (sidu?.curvalue) ? (Math.round(sidu?.curvalue)) : '-',
  121. alarmState: (wendu && wendu.curstatus === '1') || (sidu && sidu.curstatus === '1')
  122. })
  123. }
  124. })
  125. })
  126. }
  127. }
  128. // 点击查看设备状况
  129. // handleMessageDevice(event) {
  130. // const _this = this
  131. // if (event.data && event.data.data) {
  132. // const data = event.data.data
  133. // _this.deviceId = data
  134. // if (_this.deviceId.includes('CAM')) {
  135. // _this.$nextTick(() => {
  136. // this.$refs.camera.openVideoVisible = true
  137. // this.$refs.camera.videoTitle = _this.deviceId
  138. // })
  139. // }
  140. // }
  141. // },
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. @import '~@/assets/styles/lend-manage.scss';
  147. .warehouse-left{
  148. position: relative;
  149. h2{
  150. position: absolute;
  151. left: 50%;
  152. top: 0;
  153. transform: translateX(-50%);
  154. color: #fff;
  155. font-size: 16px;
  156. }
  157. }
  158. </style>