| | |
| | | import request from "@/utils/request" |
| | | import {host, WebSocketHost} from '@/utils/constants' |
| | | import {useI18n} from 'vue-i18n' |
| | | |
| | | const {t} = useI18n() |
| | | let language = ref(localStorage.getItem('lang') || 'zh') |
| | | const blind = ref(false) |
| | |
| | | const currentGlassRect = computed(() => { |
| | | return adjustedRects.value.find(rect => rect.glass_id === currentGlassId.value); |
| | | }); |
| | | |
| | | function showDialog(glassId: number) { |
| | | currentGlassId.value = glassId; |
| | | blind.value = true; |
| | |
| | | rect.glass_id === glassId ? {...rect, isActive: true} : rect |
| | | ); |
| | | } |
| | | |
| | | const handleDialogClose = () => { |
| | | adjustedRects.value = adjustedRects.value.map(rect => ({ |
| | | ...rect, |
| | |
| | | } else { |
| | | } |
| | | }; |
| | | |
| | | const handleCurrentChange = (val: number) => { |
| | | currentPage.value = val; |
| | | // window.localStorage.setItem('pagenumber', currentPage.value). |
| | |
| | | glass_state: rect.glass_state |
| | | })); |
| | | }; |
| | | |
| | | function getRectColor(state: number): string { |
| | | switch (state) { |
| | | case 0: |
| | |
| | | return '#f3d19e'; |
| | | } |
| | | } |
| | | |
| | | // 更新矩形状态 |
| | | function updateRectStatus(glassId: string, status: number) { |
| | | adjustedRects.value.forEach(rect => { |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | const connectWebSocket = () => { |
| | | if (!webSocket) { |
| | | const socketUrl = `ws://${WebSocketHost}:${host}/api/cacheGlass/api/talk/cacheGlass`; |
| | |
| | | if (data.currentCutTerritory && data.currentCutTerritory.length > 0) { |
| | | const newRects = data.currentCutTerritory[0].map(rect => { |
| | | const existingRect = adjustedRects.value.find(r => r.glass_id === rect.glass_id); |
| | | |
| | | if (existingRect) { |
| | | return { |
| | | ...existingRect, |
| | |
| | | connectWebSocket(); |
| | | } |
| | | }); |
| | | |
| | | onUnmounted(() => { |
| | | if (webSocket) { |
| | | webSocket.close(); |
| | | } |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .rect { |
| | | border: 1px solid black; /* 设置矩形的边框 */ |
| | | /* background-color: lightblue; 设置矩形的背景色 */ |
| | | } |
| | | |
| | | .centered-text { |
| | | /* 设置文字居中样式 */ |
| | | /* display: flex; */ |
| | |
| | | height: 100%; /* 确保div占据整个矩形的高度 */ |
| | | font-size: small; |
| | | } |
| | | |
| | | #rect { |
| | | position: relative; /* 确保箭头可以相对于矩形定位 */ |
| | | /* 其他样式 */ |
| | | } |
| | | |
| | | #arrow { |
| | | position: absolute; |
| | | top: 70%; /* 箭头位于矩形中间 */ |
| | |
| | | border-right: 20px solid #911005; /* 右边框,形成箭头 */ |
| | | /* 根据需要调整边框大小和颜色 */ |
| | | } |
| | | |
| | | #line { |
| | | position: absolute; |
| | | top: 70%; /* 直线位于矩形中间 */ |
| | |
| | | width: 240px; /* 直线的长度,根据需要调整 */ |
| | | background-color: #911005; /* 直线的颜色 */ |
| | | } |
| | | |
| | | </style> |