|
@@ -49,6 +49,7 @@ import { message } from 'ant-design-vue'
|
|
import { nanoid } from 'nanoid'
|
|
import { nanoid } from 'nanoid'
|
|
import { useRoomStore } from '@/stores/room'
|
|
import { useRoomStore } from '@/stores/room'
|
|
import type { LocalSubRegionItem } from '@/api/room/types'
|
|
import type { LocalSubRegionItem } from '@/api/room/types'
|
|
|
|
+import { convert_region_r2c, rotateRect } from '@/utils/coordTransform'
|
|
|
|
|
|
defineOptions({ name: 'EditableSubregion' })
|
|
defineOptions({ name: 'EditableSubregion' })
|
|
const roomStore = useRoomStore()
|
|
const roomStore = useRoomStore()
|
|
@@ -292,6 +293,43 @@ const startResize = (block: LocalSubRegionItem, e: MouseEvent) => {
|
|
// ✅ 回显数据(地理→像素)
|
|
// ✅ 回显数据(地理→像素)
|
|
const echoSubRegions = () => {
|
|
const echoSubRegions = () => {
|
|
roomStore.localSubRegions = roomStore.localSubRegions.map((item, index) => {
|
|
roomStore.localSubRegions = roomStore.localSubRegions.map((item, index) => {
|
|
|
|
+ const itemRegion = convert_region_r2c(
|
|
|
|
+ {
|
|
|
|
+ x_cm_start: Number(item.startXx),
|
|
|
|
+ x_cm_stop: Number(item.stopXx),
|
|
|
|
+ y_cm_start: Number(item.startYy),
|
|
|
|
+ y_cm_stop: Number(item.stopYy),
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ x_radar: 250,
|
|
|
|
+ y_radar: 250,
|
|
|
|
+ }
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ const routeRegion = rotateRect(itemRegion, { x: 250, y: 250 }, props.angle)
|
|
|
|
+
|
|
|
|
+ console.log(item, itemRegion, routeRegion, '🚀🚀🚀🚀🚀🚀🚀')
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ ...item,
|
|
|
|
+ nanoid: item.nanoid || nanoid(),
|
|
|
|
+ isDraging: false,
|
|
|
|
+ isResizing: false,
|
|
|
|
+ isActive: false,
|
|
|
|
+ isTracking: Boolean(item.trackPresence),
|
|
|
|
+ isFalling: Boolean(item.excludeFalling),
|
|
|
|
+ isBed: index === 0 && props.hasBed,
|
|
|
|
+ pixelX: routeRegion.left,
|
|
|
|
+ pixelY: routeRegion.top,
|
|
|
|
+ pixelWidth: routeRegion.width,
|
|
|
|
+ pixelHeight: routeRegion.height,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+echoSubRegions()
|
|
|
|
+
|
|
|
|
+const renderSubRegions = () => {
|
|
|
|
+ roomStore.localSubRegions = roomStore.localSubRegions.map((item, index) => {
|
|
const centerX = (Number(item.startXx) + Number(item.stopXx)) / 2
|
|
const centerX = (Number(item.startXx) + Number(item.stopXx)) / 2
|
|
const centerY = (Number(item.startYy) + Number(item.stopYy)) / 2
|
|
const centerY = (Number(item.startYy) + Number(item.stopYy)) / 2
|
|
const w = Math.abs(Number(item.stopXx) - Number(item.startXx))
|
|
const w = Math.abs(Number(item.stopXx) - Number(item.startXx))
|
|
@@ -314,7 +352,6 @@ const echoSubRegions = () => {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-echoSubRegions()
|
|
|
|
|
|
|
|
// ✅ 监听手动调整,重新回显像素位置
|
|
// ✅ 监听手动调整,重新回显像素位置
|
|
const geoCoordinatesSignature = computed(() => {
|
|
const geoCoordinatesSignature = computed(() => {
|
|
@@ -325,7 +362,7 @@ const geoCoordinatesSignature = computed(() => {
|
|
|
|
|
|
watch(geoCoordinatesSignature, () => {
|
|
watch(geoCoordinatesSignature, () => {
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
- echoSubRegions()
|
|
|
|
|
|
+ renderSubRegions()
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
|