From 06c3a1a40ac340ee8096b7c28936caa978aa40f4 Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期五, 23 八月 2024 11:09:27 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
UI-Project/src/views/Identify/identify.vue | 61 +++++++++++++++++++-----------
1 files changed, 39 insertions(+), 22 deletions(-)
diff --git a/UI-Project/src/views/Identify/identify.vue b/UI-Project/src/views/Identify/identify.vue
index d71f75c..590269c 100644
--- a/UI-Project/src/views/Identify/identify.vue
+++ b/UI-Project/src/views/Identify/identify.vue
@@ -220,30 +220,47 @@
const socketUrl = `ws://${WebSocketHost}:${host}/api/cacheGlass/api/talk/cacheGlass`;
webSocket = new WebSocket(socketUrl);
webSocket.onmessage = (event) => {
- const data = JSON.parse(event.data);
- const scaleFactor = 1621.78/6000;
- adjustedRects.value = data.currentCutTerritory[0].map(rect => ({
- ...rect,
- x_axis: (6000 -(rect.x_axis + rect.width)) * scaleFactor,
- y_axis: rect.y_axis * 0.17,
- width: rect.width * scaleFactor ,
- widtha: rect.width ,
- heighta: rect.height ,
- height: rect.height * 0.165 ,
- glass_state: rect.glass_state,
- isActive: false
- }));
+ const data = JSON.parse(event.data);
+ const scaleFactor = 1621.78 / 6000;
+ if (data.currentCutTerritory && data.currentCutTerritory.length > 0) {
+ const newRects = data.currentCutTerritory[0].map(rect => {
+ const existingRect = adjustedRects.value.find(r => r.glass_id === rect.glass_id);
+
+ if (existingRect) {
+ return {
+ ...existingRect,
+ x_axis: (6000 - (rect.x_axis + rect.width)) * scaleFactor,
+ y_axis: rect.y_axis * 0.17,
+ width: rect.width * scaleFactor,
+ height: rect.height * 0.165,
+ widtha: rect.width,
+ heighta: rect.height,
+ glass_state: rect.glass_state,
+ // 淇濇寔 isActive 鐘舵�佷笉鍙�
+ };
+ } else {
+ // 濡傛灉涓嶅瓨鍦紝鍒欐坊鍔犳柊鐭╁舰锛岄粯璁� isActive 涓� false
+ return {
+ ...rect,
+ x_axis: (6000 - (rect.x_axis + rect.width)) * scaleFactor,
+ y_axis: rect.y_axis * 0.17,
+ width: rect.width * scaleFactor,
+ height: rect.height * 0.165,
+ widtha: rect.width,
+ heighta: rect.height,
+ glass_state: rect.glass_state,
+ isActive: false,
+ glass_id: rect.glass_id,
+ };
+ }
+ });
+ adjustedRects.value = newRects;
+ } else if (data.currentCutTerritory == '') {
+ adjustedRects.value = [];
+ }
};
- webSocket.onerror = (error) => {
- console.error('WebSocket Error:', error);
- };
- webSocket.onclose = () => {
- console.log('WebSocket Connection Closed');
- // 鍙互閫夋嫨閲嶆柊杩炴帴
- };
- }
+ }
};
-
onMounted(() => {
// 鍒濆鏃讹紝濡傛灉杈撳叆妗嗕负绌猴紝鍒欒繛鎺ebSocket
if (!inputValue.value) {
--
Gitblit v1.8.0