From cbec6e3f120344f6f2d69808aaabb447bb52a693 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期四, 22 八月 2024 09:45:32 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
UI-Project/src/views/Identify/identify.vue | 95 ++++++++++++++++++++++++++++++++++++-----------
1 files changed, 73 insertions(+), 22 deletions(-)
diff --git a/UI-Project/src/views/Identify/identify.vue b/UI-Project/src/views/Identify/identify.vue
index d973668..cfac9d0 100644
--- a/UI-Project/src/views/Identify/identify.vue
+++ b/UI-Project/src/views/Identify/identify.vue
@@ -21,7 +21,7 @@
@click="showDialog(rect.glass_id)"
:style="{ position: 'absolute',
top: `${rect.y_axis}px`, left: `${rect.x_axis}px`, width: `${rect.width}px`, height: `${rect.height}px`,
- backgroundColor: getRectColor(rect.glass_state)
+ backgroundColor: rect.isActive ? '#ADFF2F' : getRectColor(rect.glass_state)
}"
>
<!-- 绠ご -->
@@ -34,7 +34,7 @@
</div>
</div>
</el-scrollbar>
- <el-dialog v-model="blind" top="30vh" width="15%" style="text-align: center;">
+ <el-dialog v-model="blind" top="30vh" width="15%" style="text-align: center;" @close="handleDialogClose">
<el-button type="warning" plain :icon="Delete" @click="handleDamage(currentGlassId)" style="width: 140px;margin-left: 10px;">
{{ $t('order.dilapidation') }}
</el-button>
@@ -76,7 +76,16 @@
function showDialog(glassId: number) {
currentGlassId.value = glassId;
blind.value = true;
+ adjustedRects.value = adjustedRects.value.map(rect =>
+ rect.glass_id === glassId ? { ...rect, isActive: true } : rect
+ );
}
+const handleDialogClose = () => {
+ adjustedRects.value = adjustedRects.value.map(rect => ({
+ ...rect,
+ isActive: false
+ }));
+}
// 鐮存崯
const handleDamage = async () => {
try {
@@ -206,32 +215,74 @@
}
});
}
+// const connectWebSocket = () => {
+// if (!webSocket) {
+// 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
+// }));
+// };
+// webSocket.onerror = (error) => {
+// console.error('WebSocket Error:', error);
+// };
+// webSocket.onclose = () => {
+// console.log('WebSocket Connection Closed');
+// // 鍙互閫夋嫨閲嶆柊杩炴帴
+// };
+// }
+// };
const connectWebSocket = () => {
if (!webSocket) {
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
- }));
+ const data = JSON.parse(event.data);
+ const scaleFactor = 1621.78 / 6000;
+ 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;
};
- webSocket.onerror = (error) => {
- console.error('WebSocket Error:', error);
- };
- webSocket.onclose = () => {
- console.log('WebSocket Connection Closed');
- // 鍙互閫夋嫨閲嶆柊杩炴帴
- };
- }
+ }
};
onMounted(() => {
--
Gitblit v1.8.0