wu
2024-07-24 c11bf3b956e09dd4d917074f1076d3ef48747492
UI-Project/src/views/PurchaseReturn/purchaseReturn.vue
@@ -5,6 +5,7 @@
import request from "@/utils/request"
import { ref, onMounted, onBeforeUnmount } from 'vue';  
import { WebSocketHost ,host} from '@/utils/constants'
import { ElMessage, ElMessageBox } from 'element-plus'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
  import { useI18n } from 'vue-i18n'
  const { t } = useI18n()
@@ -19,6 +20,8 @@
const adjustedRects2 = ref([]);
const adjustedRectsa = ref([]);
const adjustedRectsb = ref([]);
const currentGlassId = ref(null);
const currenttemperingFeedSequence = ref(null);
const socketUrl = `ws://${WebSocketHost}:${host}/api/temperingGlass/api/talk/temperingGlass`;
const handleMessage = (data) => {
// 进炉中
@@ -140,19 +143,64 @@
onMounted(() => {
  initializeWebSocket(socketUrl, handleMessage);
});
function getRectColor(state) {
function updateRectColors() {
  adjustedRectsa.value.forEach(rect => {
    if (rect.glassId === glassId) {
      rect.state = 5;
    }
  });
}
function getRectColora(state) {
  switch (state) {  
    case 0:  
      return '#f8e3c5';
      return '#d1edc4';
    case 1:  
      return '#d1edc4';
      return '#E6E6FA';
    case -1:  
      return '#dedfe0';  
    case 5:
      return '#911005';
  }
}
function getRectColorb(state) {
  switch (state) {
    case 3:
      return '#f8e3c5';
    case 4:
      return '#F0F8FF';
    case 5:
      return '#911005';
  }  
}
function showDialog(row) {
}
function showDialog(rect) {
  currentGlassId.value = rect.glassId;
  currenttemperingFeedSequence.value = rect.temperingFeedSequence;
  blind.value = true;  
}  
// 破损
const handleDamage = async () => {
  try  {
  const response = await request.post('/temperingGlass/temperingGlassInfo/updateTemperingState', {
    glassId: currentGlassId.value,
    // temperingFeedSequence: currenttemperingFeedSequence.value,
    line: 4001,
    status: 2,
    workingProcedure: '钢化',
    })
    if (response.code == 200) {
      ElMessage.success(response.message);
      blind.value = false;
      updateRectColors();
    } else {
      // 请求失败,显示错误消息
      ElMessage.error(response.message);
    }
}
catch (error) {
    // 处理错误
    console.error(error);
  }
}
onBeforeUnmount(() => {
  console.log("关闭了")
  closeWebSocket();
@@ -173,8 +221,14 @@
      <div  
      v-for="(rect, index) in adjustedRects"
      :key="index"  
      @click="showDialog(rect)"
      class="rect"
      :style="{ position: 'absolute',  top: `${rect.ycoordinate}px`, left: `${rect.xcoordinate}px`, width: `${rect.width}px`, height: `${rect.height}px`  }"
      :style="{ position: 'absolute',
       top: `${rect.ycoordinate}px`,
       left: `${rect.xcoordinate}px`,
        width: `${rect.width}px`,
        height: `${rect.height}px`,
        backgroundColor: rect.state === 5 ? '#911005' : 'lightblue' }"
    >
     <div  class="centered-text">
    <div >{{ rect.glassId }}</div>  
@@ -194,9 +248,15 @@
      <div  
      v-for="(rect, index) in adjustedRects2"
      :key="index"  
      @click="showDialog(rect)"
      class="rect"
      :style="{ position: 'absolute',  top: `${rect.ycoordinate}px`, left: `${rect.xcoordinate}px`, width: `${rect.width}px`, height: `${rect.height}px`  }"
    >
      :style="{ position: 'absolute',
       top: `${rect.ycoordinate}px`,
       left: `${rect.xcoordinate}px`,
       width: `${rect.width}px`,
       height: `${rect.height}px`,
       backgroundColor: rect.state === 5 ? '#911005' : 'lightblue' }"
       >
     <div  class="centered-text">
    <div >{{ rect.glassId }}</div>  
    <div >{{ rect.flowCardId }}</div>  
@@ -214,17 +274,16 @@
  <el-card style="flex: 1;margin-left: 10px;margin-top: 10px;margin-right: 10px;height: 600px;" v-loading="loading">
    <div v-if="adjustedRectsa.length > 0">
      <div style="text-align: center;">炉号:{{ adjustedRects[0].engineerId }}-{{ adjustedRects[0].temperingLayoutId }}</div>  
      <!-- <div style="text-align: center;">流程卡: {{ adjustedRectsa[0].flowCardId }}</div>   -->
      <el-scrollbar height="550px" style="background-color: #e9e9eb;">
    <div  style="position: relative;max-width: 1400px;">  
      <div  
      v-for="(rect, index) in adjustedRectsa"  
      :key="index"  
      @click="showDialog"
      @click="showDialog(rect)"
      class="rect"  
      :style="{ position: 'absolute',  top: `${rect.y}px`, left: `${rect.x}px`,
       width: `${rect.width}px`, height: `${rect.height}px`,
      backgroundColor: getRectColor(rect.state) }">
      backgroundColor: getRectColora(rect.state) }">
    <div  class="centered-text">
    <div>{{ rect.glassId }}</div>  
    <div >{{ rect.flowCardId }}</div>  
@@ -246,10 +305,12 @@
      <div  
      v-for="(rect, index) in adjustedRectsb"  
      :key="index"  
      @click="showDialog(rect)"
      class="rect"  
      :style="{ position: 'absolute',  top: `${rect.y}px`, left: `${rect.x}px`,
       width: `${rect.width}px`, height: `${rect.height}px`,
       backgroundColor: rect.state === 4 ? '#911005' : '#f8e3c5' }">
      backgroundColor: getRectColorb(rect.state) }">
       <!-- backgroundColor: rect.state === 4 ? '#911005' : '#f8e3c5' }"> -->
     <div  class="centered-text">
    <div >{{ rect.glassId }}</div>  
    <div >{{ rect.flowCardId }}</div>  
@@ -263,7 +324,7 @@
</div>
<el-dialog v-model="blind" top="30vh" width="15%" style="text-align: center;">
        <el-button type="warning" plain :icon="Delete" @click="handleDamage(currentGlassId)"  style="width: 140px;margin-left: 10px;">
        <el-button type="warning" plain :icon="Delete" @click="handleDamage"  style="width: 140px;margin-left: 10px;">
          {{ $t('order.dilapidation') }}
        </el-button>
  </el-dialog> 
@@ -348,6 +409,6 @@
  justify-content: center;  
  align-items: center; 
  height: 100%; /* 确保div占据整个矩形的高度 */  
  font-size: small;
  /* font-size: small; */
</style>