wangfei
2024-08-15 65062cbdae525bd0b7e5639a5a149d942e3d1b03
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,onUnmounted } from 'vue';
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { WebSocketHost ,host} from '@/utils/constants'
import { ElMessage, ElMessageBox } from 'element-plus'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
@@ -22,13 +22,12 @@
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) => {
// 进炉中
  if(data.intoGlass!=null){
    adjustedRects1.value =  data.intoGlass[0].map(rect => {  
      console.log( adjustedRects1.value);
      const scaleFactor =  794.67/5087;
        let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta,widtha,heighta;;
        let newX = rect.yCoordinate; 
      if (rect.width < rect.height) {
@@ -39,34 +38,21 @@
        heighta = rect.height;
      }
      if (rect.angle === 0) {  
    adjustedWidth = heighta * 0.12;
    adjustedWidth = widtha * scaleFactor;
    adjustedHeight = heighta * 0.1;
    // adjustedWidtha = widtha;
    // adjustedHeighta = heighta;
    newX = 5087 - (rect.yCoordinate + widtha);
    } else {
    adjustedWidth = heighta * scaleFactor;
    adjustedHeight = widtha * 0.1;  
    // adjustedWidtha = widtha;  
    // adjustedHeighta = heighta;  
    newX = 5087 - (rect.yCoordinate + heighta);
    } else {
    adjustedWidth = widtha * 0.12;
    adjustedHeight = heighta * 0.1;
    // adjustedWidtha = widtha;
    // adjustedHeighta = heighta;
    newX = 5087 - (rect.yCoordinate + widtha);
  }
  // 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);
  //       }
    newX = 5087 - (rect.yCoordinate + heighta);
  }
        return {  
        ...rect, 
        xcoordinate: newX * 0.12,
        xcoordinate: newX * scaleFactor,
        ycoordinate: rect.xCoordinate * 0.1,
        width: adjustedWidth,  
        height: adjustedHeight,  
@@ -79,7 +65,7 @@
      }
  if(data.intoGlass2!=null){
    adjustedRects2.value =  data.intoGlass2[0].map(rect => {  
      console.log( adjustedRects2.value);
      const scaleFactor =  794.67/5087;
      let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta,widtha,heighta;;
      let newX = rect.yCoordinate; 
      if (rect.width < rect.height) {
@@ -90,34 +76,21 @@
        heighta = rect.height;
      }
      if (rect.angle === 0) {  
    adjustedWidth = heighta * 0.12;
    adjustedHeight = widtha * 0.1;
    // adjustedWidtha = widtha;
    // adjustedHeighta = heighta;
    newX = 5087 - (rect.yCoordinate + heighta);
    } else {
    adjustedWidth = widtha * 0.12;
    adjustedWidth = widtha * scaleFactor;
    adjustedHeight = heighta * 0.1;
    // adjustedWidtha = widtha;  
    // adjustedHeighta = heighta;  
    newX = 5087 - (rect.yCoordinate + widtha); 
  }
  //     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);
  // }
    } else {
    adjustedWidth = heighta * scaleFactor;
    adjustedHeight = widtha * 0.1;
    // adjustedWidtha = widtha;
    // adjustedHeighta = heighta;
    newX = 5087 - (rect.yCoordinate + heighta);
  }
        return {  
        ...rect, 
        xcoordinate: newX * 0.12,
        xcoordinate: newX * scaleFactor,
        ycoordinate: rect.xCoordinate * 0.1,
        width: adjustedWidth,  
        height: adjustedHeight,  
@@ -131,6 +104,7 @@
  // 进炉前
  if(data.waitingGlass!=null){
    adjustedRectsa.value = data.waitingGlass[0].map(rect => {  
      const scaleFactor =  1621.78/5190;
  let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta,widtha,heighta;; 
  let newX = rect.yCoordinate; 
      if (rect.width < rect.height) {
@@ -141,13 +115,13 @@
        heighta = rect.height;
      }
  if (rect.angle === 0) {  
    adjustedWidth = widtha * 0.24;
    adjustedWidth = widtha * scaleFactor;
    adjustedHeight = heighta * 0.16;
    // adjustedWidtha = widtha;  
    // adjustedHeighta = heighta;  
    newX = 5190 - (rect.yCoordinate + widtha); 
    } else {  
    adjustedWidth = heighta * 0.24;
    adjustedWidth = heighta * scaleFactor;
    adjustedHeight = widtha * 0.16;  
    // adjustedWidtha = widtha;  
    // adjustedHeighta = heighta;  
@@ -155,7 +129,7 @@
  }  
  return {  
    ...rect, 
    x: newX * 0.24,
    x: newX * scaleFactor,
    y: rect.xCoordinate * 0.16,  
    width: adjustedWidth,  
    height: adjustedHeight,  
@@ -169,7 +143,8 @@
    // 已出炉
  if(data.outGlass!=null){
    adjustedRectsb.value = data.outGlass[0].map(rect => {  
  let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta,widtha,heighta;;
      const scaleFactor =  1621.78/5190;
      let adjustedWidth, adjustedHeight, adjustedWidtha, adjustedHeighta,widtha,heighta;;
  let newX = rect.yCoordinate; 
      if (rect.width < rect.height) {
        widtha = rect.height;
@@ -179,13 +154,13 @@
        heighta = rect.height;
      }
  if (rect.angle === 0) {  
    adjustedWidth = widtha * 0.24;
    adjustedWidth = widtha * scaleFactor;
    adjustedHeight = heighta * 0.16;  
    // adjustedWidtha = widtha;  
    // adjustedHeighta = heighta;  
    // newX = 5190 - (rect.yCoordinate + widtha); 
  } else {  
    adjustedWidth = heighta * 0.24;
    adjustedWidth = heighta * scaleFactor;
    adjustedHeight = widtha * 0.16;  
    // adjustedWidtha = heighta;  
    // adjustedHeighta = widtha;  
@@ -193,7 +168,7 @@
  }  
  return {  
        ...rect, // 复制原始对象的其他属性  
        x: newX * 0.24,
        x: newX * scaleFactor,
        y: rect.xCoordinate * 0.16,
        width: adjustedWidth,  
        height: adjustedHeight,  
@@ -206,24 +181,14 @@
      }
};
onMounted(() => {
  socket = initializeWebSocket(socketUrl, handleMessage);
  initializeWebSocket(socketUrl, handleMessage);
});
  onUnmounted(() => {
    if (socket) {
    closeWebSocket(socket);
    }
    });
function updateRectColors() {  
  adjustedRectsa.value.forEach(rect => {  
    if (rect.glassId === glassId) {  
      rect.state = 8;
      rect.state = 5;
    }
  });  
  adjustedRectsb.value.forEach(rect => {
    if (rect.glassId === glassId) {
      rect.state = 8;
    }
  });
}  
function getRectColora(state) {  
  switch (state) {  
@@ -233,7 +198,7 @@
      return '#95d475';
    case -1:  
      return '#CDAF95';  
    case 8:
    case 5:
      return '#911005';  
  }
}
@@ -243,7 +208,7 @@
      return '#eebe77';  
    case 4:  
      return '#CD6090';
    case 8:
    case 5:
      return '#911005';  
  }  
}
@@ -271,7 +236,7 @@
    glassId: currentGlassId.value,
    // temperingFeedSequence: currenttemperingFeedSequence.value,
    line: 4001,
    status: 8,
    status: 2,
    workingProcedure: '钢化',
    })
    if (response.code == 200) {
@@ -316,7 +281,7 @@
       left: `${rect.xcoordinate}px`,
        width: `${rect.width}px`, 
        height: `${rect.height}px`,
        backgroundColor: rect.state === 8 ? '#911005' : 'lightblue' }"
        backgroundColor: rect.state === 5 ? '#911005' : 'lightblue' }"
    >
     <div  class="centered-text">
    <div >{{ rect.glassId }}</div>  
@@ -344,7 +309,7 @@
       left: `${rect.xcoordinate}px`, 
       width: `${rect.width}px`, 
       height: `${rect.height}px`,
       backgroundColor: rect.state === 8 ? '#911005' : 'lightblue' }"
       backgroundColor: rect.state === 5 ? '#911005' : 'lightblue' }"
       >
     <div  class="centered-text">
    <div >{{ rect.glassId }}</div>