| | |
| | | </el-scrollbar> |
| | | </el-card> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { Delete, Upload } from '@element-plus/icons-vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { ref, onMounted } from 'vue'; |
| | | import { ref, onMounted, onBeforeUnmount } from 'vue'; |
| | | import request from "@/utils/request" |
| | | import { WebSocketHost ,host} from '@/utils/constants' |
| | | import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService'; |
| | | const blind = ref(false) |
| | | const olWidth = ref(); |
| | | const olHeight = ref(); |
| | |
| | | |
| | | adjustedRects.value = rawRects.map(rect => ({ |
| | | ...rect, // 复制原始对象的其他属性 |
| | | x_axis: (rect.x_axis*100) * 0.005, // 将x值除以3 |
| | | y_axis: (rect.y_axis*100) * 0.005, |
| | | width: (rect.width*100) * 0.004 , |
| | | x_axis: (rect.x_axis*100) * 0.004, // 将x值除以3 |
| | | y_axis: (rect.y_axis*100) * 0.004, |
| | | width: (rect.width*100) * 0.002 , |
| | | widtha: rect.width , |
| | | heighta: rect.height , |
| | | height:( rect.height*100) * 0.004 , |
| | | height:( rect.height*100) * 0.002 , |
| | | glass_state: rect.glass_state |
| | | })); |
| | | console.log(adjustedRects.value); |
| | | |
| | | console.log(rect); |
| | | |
| | | // console.log( (rect.width*100) / 300 ); |
| | | } else { |
| | |
| | | } |
| | | }); |
| | | } |
| | | const socketUrl = `ws://${WebSocketHost}:${host}/api/cacheGlass/api/talk/cacheGlass`; |
| | | // 定义消息处理函数,更新 receivedData 变量 |
| | | const handleMessage = (data) => { |
| | | // 更新 tableData 的数据 |
| | | |
| | | // adjustedRects.value = data.currentCutTerritory[0] |
| | | adjustedRects.value = data.currentCutTerritory[0].map(rect => ({ |
| | | ...rect, // 复制原始对象的其他属性 |
| | | x_axis: (rect.x_axis*100) * 0.004, // 将x值除以3 |
| | | y_axis: (rect.y_axis*100) * 0.004, |
| | | width: (rect.width*100) * 0.002 , |
| | | widtha: rect.width , |
| | | heighta: rect.height , |
| | | height:( rect.height*100) * 0.002 , |
| | | glass_state: rect.glass_state |
| | | })); |
| | | // console.log("更新后数据", tableData); |
| | | |
| | | }; |
| | | |
| | | // 初始化 WebSocket,并传递消息处理函数 |
| | | |
| | | onMounted(() => { |
| | | // fetchFlowCardId(); |
| | | // fetchTableData(); // 获取数据 |
| | | initializeWebSocket(socketUrl, handleMessage); |
| | | }); |
| | | |
| | | onBeforeUnmount(() => { |
| | | console.log("关闭了") |
| | | closeWebSocket(); |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |