|
@ -13,30 +13,49 @@ |
|
|
<script> |
|
|
<script> |
|
|
import WarehouseWarning from '@/views/components/WarehouseWarning' |
|
|
import WarehouseWarning from '@/views/components/WarehouseWarning' |
|
|
import displayConfigApi from '@/api/storeManage/displayConfig' |
|
|
import displayConfigApi from '@/api/storeManage/displayConfig' |
|
|
|
|
|
import thirdApi from '@/api/thirdApi' |
|
|
export default { |
|
|
export default { |
|
|
name: 'ReadRoom', |
|
|
name: 'ReadRoom', |
|
|
components: { WarehouseWarning }, |
|
|
components: { WarehouseWarning }, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
tableData: [], |
|
|
|
|
|
roomId: '9E0A527462BB8A060EB165', |
|
|
roomId: '9E0A527462BB8A060EB165', |
|
|
|
|
|
allDeviceIds: [], |
|
|
|
|
|
oaoMessage: [], |
|
|
|
|
|
allDisplayConfigData: [], |
|
|
displayConfigData: [] |
|
|
displayConfigData: [] |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
|
|
|
|
|
|
async created() { |
|
|
window.getIframeLoading = this.getIframeLoading // 把vue实例中的方法引用给window对象 |
|
|
window.getIframeLoading = this.getIframeLoading // 把vue实例中的方法引用给window对象 |
|
|
displayConfigApi.list({ storeroomId: this.roomId }).then((data) => { |
|
|
|
|
|
this.displayConfigData = data |
|
|
|
|
|
|
|
|
this.allDisplayConfigData = await displayConfigApi.list({ storeroomId: this.roomId }) |
|
|
|
|
|
this.allDisplayConfigData.forEach(element => { |
|
|
|
|
|
if (element.isDisplay && element.bindState && element.deviceInfo && element.divPosition.includes('OAO')) { |
|
|
|
|
|
this.allDeviceIds.push(element.deviceInfo.deviceId) |
|
|
|
|
|
if (!this.url) { |
|
|
|
|
|
this.url = 'http://' + element.deviceInfo.deviceIp + ':' + element.deviceInfo.devicePort |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
this.displayConfigData = this.allDisplayConfigData.filter((item) => { return item.isDisplay && item.bindState && item.deviceInfo && item.divPosition.includes('OAO') }) |
|
|
|
|
|
await this.getRealTimeData() |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
// const _this = this |
|
|
|
|
|
|
|
|
const _this = this |
|
|
this.iframeWin = this.$refs.myIframe.contentWindow |
|
|
this.iframeWin = this.$refs.myIframe.contentWindow |
|
|
// inframe 加载完成之后 |
|
|
// inframe 加载完成之后 |
|
|
// document.getElementById('myIframe').onload = function() { |
|
|
|
|
|
// _this.deviceState() |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
document.getElementById('myIframe').onload = function() { |
|
|
|
|
|
_this.deviceState() |
|
|
|
|
|
} |
|
|
// window.addEventListener('message', this.handleMessageDevice) |
|
|
// window.addEventListener('message', this.handleMessageDevice) |
|
|
|
|
|
// 定时请求第三方数据,更新页面数据 |
|
|
|
|
|
this.timer = setInterval(async() => { |
|
|
|
|
|
await _this.getRealTimeData() |
|
|
|
|
|
_this.handleAQI() |
|
|
|
|
|
}, 10000) |
|
|
|
|
|
}, |
|
|
|
|
|
beforeDestroy() { |
|
|
|
|
|
clearInterval(this.timer) |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
// 加载完成状态传值 |
|
|
// 加载完成状态传值 |
|
@ -47,34 +66,63 @@ export default { |
|
|
// } |
|
|
// } |
|
|
// this.deviceState() |
|
|
// this.deviceState() |
|
|
if (value === 'false') { |
|
|
if (value === 'false') { |
|
|
console.log(this.displayConfigData) |
|
|
|
|
|
this.displayConfigData.forEach(element => { |
|
|
|
|
|
if (element.divPosition.includes('OAO')) { |
|
|
|
|
|
if (element.isDisplay) { |
|
|
|
|
|
console.log(element.divPosition) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.handleHide(element.divPosition) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
console.log(this.allDisplayConfigData) |
|
|
|
|
|
this.allDisplayConfigData.forEach(element => { |
|
|
|
|
|
if ((!element.isDisplay || !element.bindState) && element.divPosition.includes('OAO')) { |
|
|
|
|
|
this.handleHide(element.divPosition) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
this.deviceState() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 传入设备状态data / 给iframe传初始值 |
|
|
// 传入设备状态data / 给iframe传初始值 |
|
|
deviceState(e) { |
|
|
deviceState(e) { |
|
|
this.iframeWin.postMessage({ |
|
|
this.iframeWin.postMessage({ |
|
|
data: [ |
|
|
|
|
|
{ |
|
|
|
|
|
id: 'YLS_MO_OAO_001', |
|
|
|
|
|
wendu: 3, |
|
|
|
|
|
sidu: 6, |
|
|
|
|
|
alarmState: false |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
data: this.oaoMessage |
|
|
}, '*') |
|
|
}, '*') |
|
|
}, |
|
|
}, |
|
|
// 设置是否显示 |
|
|
// 设置是否显示 |
|
|
handleHide(deviceId) { |
|
|
handleHide(deviceId) { |
|
|
window.frames['iframeMap'].setYangGanCanshow(deviceId, false) |
|
|
window.frames['iframeMap'].setYangGanCanshow(deviceId, false) |
|
|
|
|
|
}, |
|
|
|
|
|
// 设置温湿度 |
|
|
|
|
|
handleAQI(deviceId, wendu, sidu) { |
|
|
|
|
|
this.oaoMessage.forEach(element => { |
|
|
|
|
|
window.frames['iframeMap'].setAlertValue(element.id, element.wendu, element.sidu) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
getRealTimeData() { |
|
|
|
|
|
if (this.allDeviceIds.length > 0) { |
|
|
|
|
|
thirdApi.getRealTimeData({ ids: this.allDeviceIds, url: this.url }).then((data) => { |
|
|
|
|
|
this.oaoMessage.splice(0, this.oaoMessage.length) |
|
|
|
|
|
console.log(this.displayConfigData) |
|
|
|
|
|
this.displayConfigData.forEach(element => { |
|
|
|
|
|
if (element.divPosition.includes('OAO') && element.deviceSpecParams[0]) { |
|
|
|
|
|
// 获取3D弹窗显示的数据 |
|
|
|
|
|
const wenduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '温度' })?.paramId |
|
|
|
|
|
const siduParamId = element.deviceSpecParams.find((item) => { return item.paramName === '湿度' })?.paramId |
|
|
|
|
|
let wendu = {} |
|
|
|
|
|
let sidu = {} |
|
|
|
|
|
if (wenduParamId) { |
|
|
|
|
|
wendu = data.find((item) => { |
|
|
|
|
|
return item.property_id === wenduParamId && item.device_id === element.deviceInfo.deviceId |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if (siduParamId) { |
|
|
|
|
|
sidu = data.find((item) => { |
|
|
|
|
|
return item.property_id === siduParamId && item.device_id === element.deviceInfo.deviceId |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
this.oaoMessage.push({ |
|
|
|
|
|
id: element.divPosition, |
|
|
|
|
|
wendu: (wendu?.curvalue) ? (Math.round(wendu?.curvalue)) : '-', |
|
|
|
|
|
sidu: (sidu?.curvalue) ? (Math.round(sidu?.curvalue)) : '-', |
|
|
|
|
|
alarmState: (wendu && wendu.curstatus === '1') || (sidu && sidu.curstatus === '1') |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
// 点击查看设备状况 |
|
|
// 点击查看设备状况 |
|
|
// handleMessageDevice(event) { |
|
|
// handleMessageDevice(event) { |
|
|