严智鑫
2024-06-14 6977fb42d5067f6c938ef3de559a6ad19b542a0b
UI-Project/src/views/PurchaseReturn/purchaseStorage.vue
@@ -3,7 +3,10 @@
import {reactive} from "vue";
import {useRouter} from "vue-router"
import { ref } from 'vue'
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { WebSocketHost ,host} from '@/utils/constants'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
const adjustedRects = ref([]);
const dialogFormVisible = ref(true)
const dialogFormVisiblea = ref(false)
@@ -22,55 +25,53 @@
  }
}
const gridOptions = reactive({
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe:true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true,height: 50},//鼠标移动或选择高亮
  id: 'OrderList',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollY:{ enabled: true },//开启虚拟滚动
  showOverflow:true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
    remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },
  data:  [
    {
    }
  ],
})
const socketUrl = `ws://${WebSocketHost}:${host}/api/temperingGlass/api/talk/temperingGlass`;
// 定义消息处理函数,更新 receivedData 变量
const handleMessage = (data) => {
  // 更新 tableData 的数据
  adjustedRects.value =  data.overGlass[0].map(rect => ({
        ...rect, // 复制原始对象的其他属性
        xcoordinate: rect.xCoordinate * 0.5, // 将x值除以3
        ycoordinate: rect.ycoordinate * 0.5,
        width: rect.width * 0.4,
        height: rect.height * 0.4,
        widtha: rect.width,
        heighta: rect.height,
      }));
      console.log(data.intoGlass[0]);
};
onMounted(() => {
  // fetchFlowCardId();
  // fetchTableData(); // 获取数据
  initializeWebSocket(socketUrl, handleMessage);
});
onBeforeUnmount(() => {
  console.log("关闭了")
  closeWebSocket();
});
</script>
<template>
  <div style="margin-top: 10px;">
<div>
    <el-card style="margin-left: 10px;margin-top: 10px;margin-right: 10px;" v-loading="loading">
      <div style="display: flex;margin-top: 20px;">
      <div style="margin-left: 400px;font-size: 20px;">工程号:P20240305001 </div>
      <div style="margin-left: 150px;font-size: 20px;">版图编号:1</div>
    </div>
    <div>
            <div id="boxa" style="width: 700px;height: 220px;margin-left: 260px;">
              <div style="margin-top: 85px;"> NG202405060798A01-1</div>
            <div> 500×1500</div>
          </div>
    </div>
    <el-scrollbar height="630px">
    <div  style="position: relative;width: 1400px;">
      <div
      v-for="(rect, index) in adjustedRects"
      :key="index"
      class="rect"
      :style="{ position: 'absolute',  top: `${rect.ycoordinate}px`, left: `${rect.xcoordinate}px`,
       width: `${rect.width}px`, height: `${rect.height}px`,
       backgroundColor: rect.state === 4 ? '#d1edc4' : '#f8e3c5' }">
     <div  class="centered-text">
    <div >{{ rect.flowcardId }}</div>
    <div style="margin-top: 50px;margin-left: -50px;">{{ rect.widtha }}*{{ rect.heighta }}</div>
  </div>
  </div>
   </div>
   </el-scrollbar>
    </el-card>
    </div>
  </div>
@@ -87,4 +88,15 @@
  margin-top: 70px;
  margin-bottom: 50px;
}
.rect {
  border: 1px solid black; /* 设置矩形的边框 */
  background-color: lightblue; /* 设置矩形的背景色 */
}
.centered-text {
  /* 设置文字居中样式 */
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%; /* 确保div占据整个矩形的高度 */
}
</style>