<script setup>
|
import {Search} from "@element-plus/icons-vue";
|
import {reactive} from "vue";
|
import {useRouter} from "vue-router"
|
|
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)
|
|
const getTableRow = (row,type) =>{
|
switch (type) {
|
case 'edit' :{
|
//alert('我接收到子组件传送的编辑信息')
|
router.push({path: '/main/returns/createReturns', query: { ReturnID: 'TH24010101' }})
|
break
|
}
|
case 'delete':{
|
alert('我接收到子组件传送的删除信息')
|
break
|
}
|
}
|
}
|
|
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">
|
<el-scrollbar height="600px">
|
<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>
|
|
</template>
|
|
<style scoped>
|
#boxa{
|
border: 1px solid rgb(119, 116, 116);
|
background-color: #529b2e;
|
text-align: center;
|
display: inline-block;
|
margin-left: 20px;
|
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>
|