From 5bd56f3ebf96aa9a71e4a452cd2402df59d17384 Mon Sep 17 00:00:00 2001
From: 严智鑫 <test>
Date: 星期四, 04 九月 2025 09:28:27 +0800
Subject: [PATCH] 1.全部页面增加线下数据查询 2.增加一键删除线下玻璃按钮
---
UI-Project/src/views/GlueDispenser/glueDispenser.vue | 118 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 79 insertions(+), 39 deletions(-)
diff --git a/UI-Project/src/views/GlueDispenser/glueDispenser.vue b/UI-Project/src/views/GlueDispenser/glueDispenser.vue
index 096c6d5..b2d2db2 100644
--- a/UI-Project/src/views/GlueDispenser/glueDispenser.vue
+++ b/UI-Project/src/views/GlueDispenser/glueDispenser.vue
@@ -22,48 +22,91 @@
const downLineTask = ref([]);
const userInfo=JSON.parse(window.localStorage.getItem('userInfo'));
-const pageParams=userInfo.user.menus[0].pages[2].params;
+const pageParams=userInfo.user.menus[0].pages[8].params;
const pageParamsJson=JSON.parse(pageParams);
+
+
const machineId = pageParamsJson.machineId;//褰撳墠椤甸潰鐨勮澶嘔D
console.log(machineId);
-//浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
-let socket = null;
-let socketDownLineTask = null;
-const socketUrl = `ws://${WebSocketHost}:${host}/api/deviceInteraction/api/talk/glueDispenser`;
-const socketDownLineTaskUrl = `ws://${WebSocketHost}:${host}/api/deviceInteraction/api/talk/downLineTask`;
-// 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
-const handleMessage = (data) => {
- // 鏇存柊 tableData 鐨勬暟鎹�
- let dataJson = data[""+machineId][0];
+// 鏂板锛氬畾鏃朵换鍔D锛堢敤浜庢竻闄ゅ畾鏃跺櫒锛�
+const timerId = ref(null);
+/**
+ * 鍗曟鎺ュ彛璇锋眰鍑芥暟
+ * 浣滅敤锛氳皟鐢ㄥ悗绔帴鍙o紝鑾峰彇鏁版嵁鍚庝氦缁� handleMessage 澶勭悊
+ */
+const fetchMachineData = async () => {
+ try {
+ // 浠诲姟鏁版嵁
+ request.post("/deviceInteraction/tasking/findMachineTask",{
+ "id": machineId
+ }).then((res) => { // 鏇挎崲涓轰綘鐨凙PI绔偣
+ if (res.code === 200) {
+ // 鍋囪鍚庣杩斿洖鐨勬暟鎹牸寮忎笌 handleMessage 棰勬湡涓�鑷�
+ const responseData = res.data || {};
+ loadData.value =responseData;
+ }
+ });
- loadData.value = dataJson.taskingList[0];
- findMachine.value = dataJson.machine[0];
- sendRecords.value = dataJson.sendRecords[0].reverse();
-
+ // 璁惧鏁版嵁
+ request.post("/deviceInteraction/machine/findMachine",{
+ "id": machineId
+ }).then((res) => { // 鏇挎崲涓轰綘鐨凙PI绔偣
+ if (res.code === 200) {
+ // 鍋囪鍚庣杩斿洖鐨勬暟鎹牸寮忎笌 handleMessage 棰勬湡涓�鑷�
+ const responseData = res.data || {};
+ findMachine.value =responseData;
+ }
+ });
+
+ // 绾夸笅鏁版嵁
+ request.post("/deviceInteraction/tasking/selectGlassDownLine").then((res) => { // 鏇挎崲涓轰綘鐨凙PI绔偣
+ if (res.code === 200) {
+ // 鍋囪鍚庣杩斿洖鐨勬暟鎹牸寮忎笌 handleMessage 棰勬湡涓�鑷�
+ const responseData = res.data || {};
+ downLineTask.value =responseData;
+ }
+ });
+ } catch (err) {
+ console.error('瀹氭椂璇锋眰鍚庣鎺ュ彛澶辫触锛�', err);
+ }
};
-// 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
-const handleMessage2 = (data) => {
- downLineTask.value = data.downLineTask[0];
- // console.log(data);
+
+/**
+ * 鍚姩瀹氭椂鍣�
+ * @param {number} interval - 瀹氭椂闂撮殧锛堟绉掞紝榛樿500ms锛屼笌鍚庣浠诲姟棰戠巼瀵归綈锛�
+ */
+const startTimer = (interval = 500) => {
+ // 鍏堟竻闄ゅ凡鏈夊畾鏃跺櫒锛堥伩鍏嶉噸澶嶅垱寤猴級
+ if (timerId.value) clearInterval(timerId.value);
+ // 绔嬪嵆鎵ц涓�娆★紙閬垮厤棣栨绛夊緟闂撮殧锛�
+ fetchMachineData();
+ // 鍒涘缓鏂板畾鏃跺櫒
+ timerId.value = setInterval(() => {
+ fetchMachineData();
+ }, interval);
};
+
+/**
+ * 娓呴櫎瀹氭椂鍣紙閬垮厤鍐呭瓨娉勬紡锛�
+ */
+const clearTimer = () => {
+ if (timerId.value) {
+ clearInterval(timerId.value);
+ timerId.value = null; // 閲嶇疆ID
+ }
+};
+
+// 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒锛堝叧閿細閬垮厤缁勪欢閿�姣佸悗瀹氭椂鍣ㄤ粛杩愯锛�
onUnmounted(() => {
- if (socket) {
- closeWebSocket(socket);
- }
- if (socketDownLineTask) {
- closeWebSocket(socketDownLineTask);
- }
-});
-onBeforeUnmount(() => {
- console.log("鍏抽棴浜�")
- closeWebSocket();
+ clearTimer();
});
onMounted(async () => {
- //浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
- socket = initializeWebSocket(socketUrl, handleMessage);// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
- //浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
- socketDownLineTask = initializeWebSocket(socketDownLineTaskUrl, handleMessage2);// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
+ startTimer(500); // 500ms 闂撮殧锛堝彲鏍规嵁涓氬姟璋冩暣锛屽1000ms锛�
+ // //浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
+ // socket = initializeWebSocket(socketUrl, handleMessage);// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
+ // //浣跨敤WebSocket鏂瑰紡灞曠ず鏁版嵁
+ // socketDownLineTask = initializeWebSocket(socketDownLineTaskUrl, handleMessage2);// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
});
//鎶ヨ鎻愮ず
const errorInfoFuntion = async (info) => {
@@ -331,7 +374,7 @@
</div>
<div id="main-body">
<!-- 琛ㄦ牸鍐呭 -->
- <el-table :data="loadData" stripe style="height:260px"
+ <el-table :data="loadData" stripe style="height:560px"
:header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }">
<!-- <el-table-column type="selection" min-width="30" /> -->
@@ -360,12 +403,9 @@
</el-table>
</div>
- <div id="main-body" style="width: 100%; height: 460px;min-width: 1200px;">
+ <!-- <div id="main-body" style="width: 100%; height: 460px;min-width: 1200px;">
<img style="width: 70%;min-width: 900px; height: 460px;float: left;" src="../../assets/缈荤墖鍙�.png">
- <!-- <el-image style="width: 70%;min-width: 900px; height: 460px;float: left;" src="../../src/assets/缈荤墖鍙�.png"></el-image> -->
- <!-- <div style="width: 70%;min-width: 900px; height: 460px;background-image: url(../../src/assets/缈荤墖鍙�.png) ;background-size: 100% 100%;float: left;">
-
- </div> -->
+
<div style="width: 30%;min-width: 300px; height: 460px;float: left;padding: 20px;;">
<el-table :data="sendRecords" stripe
:header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center', height: '30px' }"
@@ -375,7 +415,7 @@
</div>
<div style="clear锛歜oth"></div>
- </div>
+ </div> -->
</div>
</template>
--
Gitblit v1.8.0