严智鑫
2024-08-05 00c4dfc5ac687c93e0b7abafc33abb693b38edd6
UI-Project/src/views/PurchaseReturn/purchaseReturn.vue
@@ -3,7 +3,7 @@
import {reactive} from "vue";
import {useRouter} from "vue-router"
import request from "@/utils/request"
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { ref, onMounted, onBeforeUnmount,onUnmounted } from 'vue';
import { WebSocketHost ,host} from '@/utils/constants'
import { ElMessage, ElMessageBox } from 'element-plus'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
@@ -22,6 +22,7 @@
const adjustedRectsb = ref([]);
const currentGlassId = ref(null);
const currenttemperingFeedSequence = ref(null);
let socket = null;
const socketUrl = `ws://${WebSocketHost}:${host}/api/temperingGlass/api/talk/temperingGlass`;
const handleMessage = (data) => {
// 进炉中
@@ -37,23 +38,36 @@
        widtha = rect.width;
        heighta = rect.height;
      }
  if (rect.angle === 0) {
          adjustedWidth = heighta * 0.12;
          adjustedHeight = widtha * 0.1;
          adjustedWidtha = heighta;
          adjustedHeighta = widtha;
          newX = 5087 - (rect.xCoordinate + heighta);
        } else {
          adjustedWidth = widtha * 0.12;
          adjustedHeight = heighta * 0.1;
          adjustedWidtha = widtha;
          adjustedHeighta = heighta;
          newX = 5087 - (rect.xCoordinate + widtha);
        }
      if (rect.angle === 0) {
    adjustedWidth = widtha * 0.12;
    adjustedHeight = heighta * 0.1;
    adjustedWidtha = widtha;
    adjustedHeighta = heighta;
    newX = 5087 - (rect.yCoordinate + widtha);
    } else {
    adjustedWidth = heighta * 0.12;
    adjustedHeight = widtha * 0.1;
    adjustedWidtha = heighta;
    adjustedHeighta = widtha;
    newX = 5087 - (rect.yCoordinate + heighta);
  }
  // if (rect.angle === 0) {
  //         adjustedWidth = heighta * 0.12;
  //         adjustedHeight = widtha * 0.1;
  //         adjustedWidtha = heighta;
  //         adjustedHeighta = widtha;
  //         newX = 5087 - (rect.xCoordinate + heighta);
  //       } else {
  //         adjustedWidth = widtha * 0.12;
  //         adjustedHeight = heighta * 0.1;
  //         adjustedWidtha = widtha;
  //         adjustedHeighta = heighta;
  //         newX = 5087 - (rect.xCoordinate + widtha);
  //       }
        return {  
        ...rect, 
        xcoordinate: newX * 0.12,
        ycoordinate: rect.yCoordinate * 0.1,
        ycoordinate: rect.xCoordinate * 0.1,
        width: adjustedWidth,  
        height: adjustedHeight,  
        widtha: adjustedWidtha, 
@@ -76,22 +90,35 @@
        heighta = rect.height;
      }
      if (rect.angle === 0) {  
          adjustedWidth = heighta * 0.12;
          adjustedHeight = widtha * 0.1;
          adjustedWidtha = heighta;
          adjustedHeighta = widtha;
          newX = 5087 - (rect.xCoordinate + heighta);
  } else {
          adjustedWidth = widtha * 0.12;
          adjustedHeight = heighta * 0.1;
          adjustedWidtha = widtha;
          adjustedHeighta = heighta;
          newX = 5087 - (rect.xCoordinate + widtha);
    adjustedWidth = widtha * 0.12;
    adjustedHeight = heighta * 0.1;
    adjustedWidtha = widtha;
    adjustedHeighta = heighta;
    newX = 5087 - (rect.yCoordinate + widtha);
    } else {
    adjustedWidth = heighta * 0.12;
    adjustedHeight = widtha * 0.1;
    adjustedWidtha = heighta;
    adjustedHeighta = widtha;
    newX = 5087 - (rect.yCoordinate + heighta);
  }  
  //     if (rect.angle === 0) {
  //         adjustedWidth = heighta * 0.12;
  //         adjustedHeight = widtha * 0.1;
  //         adjustedWidtha = heighta;
  //         adjustedHeighta = widtha;
  //         newX = 5087 - (rect.xCoordinate + heighta);
  // } else {
  //         adjustedWidth = widtha * 0.12;
  //         adjustedHeight = heighta * 0.1;
  //         adjustedWidtha = widtha;
  //         adjustedHeighta = heighta;
  //         newX = 5087 - (rect.xCoordinate + widtha);
  // }
        return {  
        ...rect, 
        xcoordinate: newX * 0.12,
        ycoordinate: rect.yCoordinate * 0.1,
        ycoordinate: rect.xCoordinate * 0.1,
        width: adjustedWidth,  
        height: adjustedHeight,  
        widtha: adjustedWidtha, 
@@ -179,8 +206,13 @@
      }
};
onMounted(() => {
  initializeWebSocket(socketUrl, handleMessage);
  socket = initializeWebSocket(socketUrl, handleMessage);
});
  onUnmounted(() => {
    if (socket) {
    closeWebSocket(socket);
    }
    });
function updateRectColors() {  
  adjustedRectsa.value.forEach(rect => {  
    if (rect.glassId === glassId) {