|  |  | 
 |  |  | <template> | 
 |  |  |     <div> | 
 |  |  |         常温库 | 
 |  |  |     </div> | 
 |  |  |   <el-row> | 
 |  |  |     <el-col :span="3"> | 
 |  |  |       <device-stacker v-for="stacker in Stackers" :key="stacker.deviceName" :Stacker="stacker"></device-stacker> | 
 |  |  |     </el-col> | 
 |  |  |     <el-col :span="21"> | 
 |  |  |       <DeviceLineVo v-for="device in devices" :key="device.deviceName" :device="device" /> | 
 |  |  |     </el-col> | 
 |  |  |   </el-row> | 
 |  |  | </template> | 
 |  |  | <script setup> | 
 |  |  | import { onMounted, ref, reactive, toRaw } from "vue"; | 
 |  |  | import eventBus from "@/uitils/eventBus"; | 
 |  |  | import DeviceLineVo from "@/components/DeviceLineVo.vue"; | 
 |  |  | import DeviceStacker from "@/components/DeviceStacker.vue"; | 
 |  |  | // 堆垛机 | 
 |  |  | const Stackers = reactive([]); | 
 |  |  | var  i=0; | 
 |  |  | // 设备列表(修改重复设备名称) | 
 |  |  | const devices = reactive([]); | 
 |  |  | const num = reactive([]) | 
 |  |  | onMounted(() => { | 
 |  |  |   eventBus.on('stackerData', eventData => { | 
 |  |  |     // console.log(eventData) | 
 |  |  |     | 
 |  |  |       console.log(eventData) | 
 |  |  |      | 
 |  |  |     if (eventData.deviceName === "常温入库输送线") { | 
 |  |  |     if (devices.length <= 0) { | 
 |  |  |         devices.push({ deviceName: eventData.deviceName, data: eventData.data, childDeviceCode: eventData.data.childDeviceCode }); | 
 |  |  |       } | 
 |  |  |       else { | 
 |  |  |         const device = devices.find(c => c.childDeviceCode == eventData.data.childDeviceCode) | 
 |  |  |         if(device){ | 
 |  |  |           device.data = eventData.data | 
 |  |  |         }else{ | 
 |  |  |           devices.push({ deviceName: eventData.deviceName, data: eventData.data, childDeviceCode: eventData.data.childDeviceCode }); | 
 |  |  |         } | 
 |  |  |       } | 
 |  |  |      | 
 |  |  |     } | 
 |  |  |   }) | 
 |  |  |   eventBus.on('stackerData', eventData => { | 
 |  |  |     if (eventData.deviceName == "常温1号堆垛机"||eventData.deviceName == "常温2号堆垛机"||eventData.deviceName == "常温3号堆垛机"||eventData.deviceName == "常温4号堆垛机") { | 
 |  |  |       if (Stackers.length == 0) { | 
 |  |  |         Stackers.push({ deviceName: eventData.deviceName, data: eventData.data }); | 
 |  |  |       } | 
 |  |  |       else { | 
 |  |  |         const Stacker = Stackers.find(c => c.deviceName == eventData.deviceName); | 
 |  |  |         if (Stacker) { | 
 |  |  |           Stacker.data = eventData.data | 
 |  |  |         } | 
 |  |  |         else { | 
 |  |  |           Stackers.push({ deviceName: eventData.deviceName, data: eventData.data }); | 
 |  |  |         } | 
 |  |  |       } | 
 |  |  |     } | 
 |  |  |   }) | 
 |  |  | }) | 
 |  |  | </script> | 
 |  |  | <style scoped> | 
 |  |  |  | 
 |  |  |  | 
 |  |  | </script> | 
 |  |  | </style> |