From 86d88edcc0af550fe34253fec3a782aa83f4242a Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期一, 02 九月 2024 14:09:32 +0800
Subject: [PATCH] 连接signalR

---
 Web/src/views/device/deviceInfo/index.vue |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/Web/src/views/device/deviceInfo/index.vue b/Web/src/views/device/deviceInfo/index.vue
index 86a9ab0..9bc1d57 100644
--- a/Web/src/views/device/deviceInfo/index.vue
+++ b/Web/src/views/device/deviceInfo/index.vue
@@ -65,8 +65,9 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, reactive } from 'vue';
+import { ref, reactive,onMounted } from 'vue';
 import { listStatus } from '/@/api/wcs/wcsPlc';
+import { signalR } from './signalR';
 
 const state = ref<any>({});
 const stackers = ref<any>({});
@@ -80,6 +81,28 @@
 };
 handleQuery();
 
+//杩炴帴signalR 鐩戝惉鍙樻洿
+onMounted(async () => {
+	signalR.off('PublicPlcConn');
+	signalR.on('PublicPlcConn', (data: any) => {
+		console.log(data)
+		if (data.type === 0) {
+			// 鏇挎崲 stackers 涓殑鐩稿簲椤�
+			const index = stackers.value.findIndex(item => item.id === data.id);
+			if (index !== -1) {
+				stackers.value[index] = data;
+			}
+		} else if (data.type === 1 || data.type === 4) {
+			// 鏇挎崲 conveyors 涓殑鐩稿簲椤�
+			const index = conveyors.value.findIndex(item => item.id === data.id);
+			if (index !== -1) {
+				conveyors.value[index] = data;
+			}
+		}
+		console.log(stackers.value[0].isConn)
+	});
+});
+
 const activeName = ['1', '2', '3'];
 const value1 = ref(false);
 const value2 = ref(false);

--
Gitblit v1.8.0