From 5649c793fd60cbdae34b2b62a87374a81335fd22 Mon Sep 17 00:00:00 2001
From: wang <3597712270@qq.com>
Date: 星期二, 04 六月 2024 16:46:19 +0800
Subject: [PATCH] 上片机停止任务隐藏,钢化模块接口

---
 UI-Project/src/views/Caching/cachingun.vue             |   26 +++++-
 UI-Project/src/views/Returns/returns.vue               |    2 
 UI-Project/src/views/Identify/identify.vue             |    1 
 UI-Project/src/views/PurchaseReturn/purchaseReturn.vue |  201 ++++++++++++++++++++++++++++++--------------------
 4 files changed, 144 insertions(+), 86 deletions(-)

diff --git a/UI-Project/src/views/Caching/cachingun.vue b/UI-Project/src/views/Caching/cachingun.vue
index a22e37e..d454956 100644
--- a/UI-Project/src/views/Caching/cachingun.vue
+++ b/UI-Project/src/views/Caching/cachingun.vue
@@ -68,7 +68,17 @@
     console.error('鍙戠敓閿欒:', error);  
   }  
 };   
-
+const toggleEnableState = async (row) => {  
+  const newState = row.enable_state === 1 ? 0 : 1;  
+  // 鍙戦�佽姹傚埌鍚庣鏇存柊鐘舵�侊紙杩欓噷鐪佺暐浜嗗疄闄呯殑璇锋眰閫昏緫锛�  
+  const response = await request.post('/unLoadGlass/downStorage/updateDownStorageCage', { id: row.id, enablestate: newState });  
+  if (response.code === 200) {
+      ElMessage.success(response.message);
+      } else {  
+      ElMessage.error(response.message);
+      }  
+  row.enable_state = newState;  
+};
 const socketUrl = `ws://${WebSocketHost}:${host}/api/unLoadGlass/api/talk/unloadglass`;
 // 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
 const handleMessage = (data) => {
@@ -108,14 +118,22 @@
           <el-table-column prop="width" align="center" label="瀹�" min-width="120" />
           <el-table-column prop="height" align="center" label="楂�" min-width="120" />
           <el-table-column
-            align="center"
+          align="center"
             label="鍚敤鐘舵��"
             min-width="80"
             prop="enable_state"
           >
-          <template #default="scope">
+          <template #default="scope">  
+          <el-tag  
+            :type="scope.row.enable_state === 1 ? 'success' : 'danger'"  
+            @click="toggleEnableState(scope.row)"  
+          >  
+            {{ scope.row.enable_state === 1 ? '鍚敤' : '绂佺敤' }}  
+          </el-tag>  
+        </template> 
+          <!-- <template #default="scope">
             <el-tag type="success" >{{ scope.row.enable_state==1?"鍚敤":"鏈惎鐢�"  }}</el-tag>
-          </template>
+          </template> -->
           </el-table-column>
           <el-table-column fixed="right" label="鎿嶄綔" align="center" width="200">
             <template #default="scope">
diff --git a/UI-Project/src/views/Identify/identify.vue b/UI-Project/src/views/Identify/identify.vue
index 5e69d9b..2e2de95 100644
--- a/UI-Project/src/views/Identify/identify.vue
+++ b/UI-Project/src/views/Identify/identify.vue
@@ -38,7 +38,6 @@
   </el-scrollbar>
   </el-card>
 </template>  
-  
 <script setup lang="ts">  
 import { Delete, Upload } from '@element-plus/icons-vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
diff --git a/UI-Project/src/views/PurchaseReturn/purchaseReturn.vue b/UI-Project/src/views/PurchaseReturn/purchaseReturn.vue
index b389719..8fd42ca 100644
--- a/UI-Project/src/views/PurchaseReturn/purchaseReturn.vue
+++ b/UI-Project/src/views/PurchaseReturn/purchaseReturn.vue
@@ -3,10 +3,10 @@
 import {reactive} from "vue";
 import {useRouter} from "vue-router"
 import request from "@/utils/request"
-
-import { ref, onMounted } from 'vue';  
 // import { ref } from 'vue'
-
+import { ref, onMounted, onBeforeUnmount } from 'vue';  
+import { WebSocketHost ,host} from '@/utils/constants'
+import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
 const dialogFormVisible = ref(true)
 const dialogFormVisiblea = ref(false)
 const dialogFormVisibleb = ref(false)
@@ -16,96 +16,137 @@
 const adjustedRectsa = ref([]);
 const adjustedRectsb = ref([]);
 // 杩涚倝涓�
-onMounted(async () => {  
-  try {  
-    const response = await request.get('/temperingGlass/temperingGlassInfo/SelectIntoGlass'); 
-    if (response.code === 200) {  
-      const rawRects = response.data; // 璁剧疆鐭╁舰鏁版嵁  
-      console.log(response.data);
-      const { height: newheight,width: newwidth  } = response.data; // 鑾峰彇灏哄  
-      height.value = newheight;  
-      width.value = newwidth;  
 
-      adjustedRects.value = rawRects.map(rect => ({  
+const socketUrl = `ws://${WebSocketHost}:${host}/api/temperingGlass/api/talk/temperingGlass`;
+// 瀹氫箟娑堟伅澶勭悊鍑芥暟锛屾洿鏂� receivedData 鍙橀噺
+const handleMessage = (data) => {
+  // 鏇存柊 tableData 鐨勬暟鎹�
+  adjustedRects.value =  data.intoGlass[0].map(rect => ({  
+        ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
+        xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
+        ycoordinate: rect.ycoordinate,
+        width: rect.width ,
+        height: rect.height ,
+      })); 
+      adjustedRectsa.value = data.waitingGlass[0].map(rect => ({  
         ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
         xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
         ycoordinate: rect.ycoordinate,
         width: rect.width ,
         height: rect.height ,
       }));  
-        console.log(rect);
+      
+      adjustedRectsb.value = data.outGlass[0].map(rect => ({  
+        ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
+        xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
+        ycoordinate: rect.ycoordinate,
+        width: rect.width ,
+        height: rect.height ,
+      }));  
+};
 
-      //   console.log( (rect.width*100) / 300 );
-    } else {  
-      // console.error('Failed to fetch rectangles from API.');  
-      console.error('Failed to fetch rects from API.'); 
-    }  
-  } catch (error) {  
-    // console.error('Error fetching rectangles :', error);
-    console.error('Error fetching rects :', error);  
-  }  
-}); 
+// 鍒濆鍖� WebSocket锛屽苟浼犻�掓秷鎭鐞嗗嚱鏁�
+
+onMounted(() => {
+  // fetchFlowCardId();
+  // fetchTableData(); // 鑾峰彇鏁版嵁
+  initializeWebSocket(socketUrl, handleMessage);
+});
+
+onBeforeUnmount(() => {
+  console.log("鍏抽棴浜�")
+  closeWebSocket();
+});
+// onMounted(async () => {  
+//   try {  
+//     const response = await request.get('/temperingGlass/temperingGlassInfo/SelectIntoGlass'); 
+//     if (response.code === 200) {  
+//       const rawRects = response.data; // 璁剧疆鐭╁舰鏁版嵁  
+//       console.log(response.data);
+//       const { height: newheight,width: newwidth  } = response.data; // 鑾峰彇灏哄  
+//       height.value = newheight;  
+//       width.value = newwidth;  
+
+//       adjustedRects.value = rawRects.map(rect => ({  
+//         ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
+//         xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
+//         ycoordinate: rect.ycoordinate,
+//         width: rect.width ,
+//         height: rect.height ,
+//       }));  
+//         console.log(rect);
+
+//       //   console.log( (rect.width*100) / 300 );
+//     } else {  
+//       // console.error('Failed to fetch rectangles from API.');  
+//       console.error('Failed to fetch rects from API.'); 
+//     }  
+//   } catch (error) {  
+//     // console.error('Error fetching rectangles :', error);
+//     console.error('Error fetching rects :', error);  
+//   }  
+// }); 
 // 杩涚倝鍓�
-const handleConfirm = async () => {
-  try {
-    const response = await request.post('/temperingGlass/temperingGlassInfo/SelectWaitingGlass'); 
-    if (response.code === 200) {  
-      const rawRects = response.data; // 璁剧疆鐭╁舰鏁版嵁  
-      console.log(response.data);
-      const { height: newheight,width: newwidth  } = response.data; // 鑾峰彇灏哄  
-      height.value = newheight;  
-      width.value = newwidth;  
+// const handleConfirm = async () => {
+//   try {
+//     const response = await request.post('/temperingGlass/temperingGlassInfo/SelectWaitingGlass'); 
+//     if (response.code === 200) {  
+//       const rawRects = response.data; // 璁剧疆鐭╁舰鏁版嵁  
+//       console.log(response.data);
+//       const { height: newheight,width: newwidth  } = response.data; // 鑾峰彇灏哄  
+//       height.value = newheight;  
+//       width.value = newwidth;  
 
-      adjustedRectsa.value = rawRects.map(rect => ({  
-        ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
-        xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
-        ycoordinate: rect.ycoordinate,
-        width: rect.width ,
-        height: rect.height ,
-      }));  
-        console.log(rect);
+//       adjustedRectsa.value = rawRects.map(rect => ({  
+//         ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
+//         xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
+//         ycoordinate: rect.ycoordinate,
+//         width: rect.width ,
+//         height: rect.height ,
+//       }));  
+//         console.log(rect);
 
-      //   console.log( (rect.width*100) / 300 );
-    } else {  
-      // console.error('Failed to fetch rectangles from API.');  
-      console.error('Failed to fetch rects from API.'); 
-    }  
-  } catch (error) {  
-    // console.error('Error fetching rectangles :', error);
-    console.error('Error fetching rects :', error);  
-  }  
-}; 
+//       //   console.log( (rect.width*100) / 300 );
+//     } else {  
+//       // console.error('Failed to fetch rectangles from API.');  
+//       console.error('Failed to fetch rects from API.'); 
+//     }  
+//   } catch (error) {  
+//     // console.error('Error fetching rectangles :', error);
+//     console.error('Error fetching rects :', error);  
+//   }  
+// }; 
 
 // 宸插嚭鐐�
-const handleConfirma = async () => {
-  try {
-    const response = await request.get('/temperingGlass/temperingGlassInfo/SelectOutGlass'); 
-    if (response.code === 200) {  
-      const rawRects = response.data; // 璁剧疆鐭╁舰鏁版嵁  
-      console.log(response.data);
-      const { height: newheight,width: newwidth  } = response.data; // 鑾峰彇灏哄  
-      height.value = newheight;  
-      width.value = newwidth;  
+// const handleConfirma = async () => {
+//   try {
+//     const response = await request.get('/temperingGlass/temperingGlassInfo/SelectOutGlass'); 
+//     if (response.code === 200) {  
+//       const rawRects = response.data; // 璁剧疆鐭╁舰鏁版嵁  
+//       console.log(response.data);
+//       const { height: newheight,width: newwidth  } = response.data; // 鑾峰彇灏哄  
+//       height.value = newheight;  
+//       width.value = newwidth;  
 
-      adjustedRectsb.value = rawRects.map(rect => ({  
-        ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
-        xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
-        ycoordinate: rect.ycoordinate,
-        width: rect.width ,
-        height: rect.height ,
-      }));  
-        console.log(rect);
+//       adjustedRectsb.value = rawRects.map(rect => ({  
+//         ...rect, // 澶嶅埗鍘熷瀵硅薄鐨勫叾浠栧睘鎬�  
+//         xcoordinate: rect.xcoordinate, // 灏唜鍊奸櫎浠�3  
+//         ycoordinate: rect.ycoordinate,
+//         width: rect.width ,
+//         height: rect.height ,
+//       }));  
+//         console.log(rect);
 
-      //   console.log( (rect.width*100) / 300 );
-    } else {  
-      // console.error('Failed to fetch rectangles from API.');  
-      console.error('Failed to fetch rects from API.'); 
-    }  
-  } catch (error) {  
-    // console.error('Error fetching rectangles :', error);
-    console.error('Error fetching rects :', error);  
-  }  
-}; 
+//       //   console.log( (rect.width*100) / 300 );
+//     } else {  
+//       // console.error('Failed to fetch rectangles from API.');  
+//       console.error('Failed to fetch rects from API.'); 
+//     }  
+//   } catch (error) {  
+//     // console.error('Error fetching rectangles :', error);
+//     console.error('Error fetching rects :', error);  
+//   }  
+// }; 
 const gridOptions = reactive({
   border:  "full",//琛ㄦ牸鍔犺竟妗�
   keepSource: true,//淇濇寔婧愭暟鎹�
@@ -173,7 +214,7 @@
       <el-scrollbar height="630px">
     <div  style="position: relative;width: 1400px;">  
       <div  
-      v-for="(rect, index) in adjustedRects"  
+      v-for="(rect, index) in adjustedRectsa"  
       :key="index"  
       class="rect"  
       :style="{ position: 'absolute',  top: `${rect.ycoordinate}px`, left: `${rect.xcoordinate}px`, width: `${rect.width}px`, height: `${rect.height}px`  }"  
@@ -191,7 +232,7 @@
       <el-scrollbar height="630px">
     <div  style="position: relative;width: 1400px;">  
       <div  
-      v-for="(rect, index) in adjustedRects"  
+      v-for="(rect, index) in adjustedRectsb"  
       :key="index"  
       class="rect"  
       :style="{ position: 'absolute',  top: `${rect.ycoordinate}px`, left: `${rect.xcoordinate}px`, width: `${rect.width}px`, height: `${rect.height}px`  }"  
diff --git a/UI-Project/src/views/Returns/returns.vue b/UI-Project/src/views/Returns/returns.vue
index 3888531..2aadf11 100644
--- a/UI-Project/src/views/Returns/returns.vue
+++ b/UI-Project/src/views/Returns/returns.vue
@@ -575,7 +575,7 @@
     <el-button style="margin-top: 5px;margin-left: 15px;"   id="searchButton" type="primary" @click="dialogFormVisible = true">閫夋嫨宸ョ▼</el-button>
     <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="primary" @click="handleBind">寮�濮嬩笂鐗�</el-button>
     <el-button style="margin-top: 5px;margin-left: 20px;"  id="searchButton" type="warning" @click="handleBinda">鏆傚仠</el-button>
-    <el-button style="margin-top: 5px;margin-left: 20px;"  id="searchButton" type="danger" @click="handleBindb">鍋滄浠诲姟</el-button>
+    <!-- <el-button style="margin-top: 5px;margin-left: 20px;"  id="searchButton" type="danger" @click="handleBindb">鍋滄浠诲姟</el-button> -->
     
     <el-card style="flex: 1;margin-left: 10px;margin-top: 15px;" v-loading="loading">
       <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">

--
Gitblit v1.8.0