|
@@ -1,23 +1,15 @@
|
|
<template>
|
|
<template>
|
|
<div class="radarEditor" :class="{ disabled: props.disabled }">
|
|
<div class="radarEditor" :class="{ disabled: props.disabled }">
|
|
- <DetectionAreaView
|
|
|
|
- :coordinates="coordinates"
|
|
|
|
- :direction="angle"
|
|
|
|
- :furniture-items="localFurniture"
|
|
|
|
- :canvas-size="500"
|
|
|
|
- mode="edit"
|
|
|
|
- >
|
|
|
|
|
|
+ <DetectionAreaView :coordinates="coordinates" :direction="angle" mode="edit">
|
|
<template #furnitures>
|
|
<template #furnitures>
|
|
<EditableFurniture
|
|
<EditableFurniture
|
|
- v-for="item in localFurniture"
|
|
|
|
|
|
+ v-for="item in roomStore.localFurnitureItems"
|
|
:key="item.nanoid"
|
|
:key="item.nanoid"
|
|
:item="item"
|
|
:item="item"
|
|
:angle="angle"
|
|
:angle="angle"
|
|
:coordinates="coordinates"
|
|
:coordinates="coordinates"
|
|
:canvas-size="400"
|
|
:canvas-size="400"
|
|
:disabled="disabled"
|
|
:disabled="disabled"
|
|
- @update="updateFurniture"
|
|
|
|
- @delete="deleteFurniture"
|
|
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -48,7 +40,7 @@
|
|
<a-radio-button :value="1">配置面板</a-radio-button>
|
|
<a-radio-button :value="1">配置面板</a-radio-button>
|
|
<a-radio-button :value="2">信息面板</a-radio-button>
|
|
<a-radio-button :value="2">信息面板</a-radio-button>
|
|
</a-radio-group>
|
|
</a-radio-group>
|
|
- <a-button type="link" size="small" @click="syncCoordinates">同步坐标</a-button>
|
|
|
|
|
|
+ <!-- <a-button type="link" size="small" @click="syncCoordinates">同步坐标</a-button> -->
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div v-if="modeRadio === 1" class="config">
|
|
<div v-if="modeRadio === 1" class="config">
|
|
@@ -113,11 +105,14 @@
|
|
<div class="panel">
|
|
<div class="panel">
|
|
<div class="panel-hd">
|
|
<div class="panel-hd">
|
|
<div
|
|
<div
|
|
- >家具列表 <span v-if="localFurniture.length">({{ localFurniture.length }})</span></div
|
|
|
|
|
|
+ >家具列表
|
|
|
|
+ <span v-if="roomStore.localFurnitureItems.length"
|
|
|
|
+ >({{ roomStore.localFurnitureItems.length }})</span
|
|
|
|
+ ></div
|
|
>
|
|
>
|
|
<a-space>
|
|
<a-space>
|
|
<a-popconfirm
|
|
<a-popconfirm
|
|
- v-if="localFurniture.length"
|
|
|
|
|
|
+ v-if="roomStore.localFurnitureItems.length"
|
|
title="确定清空家具吗?"
|
|
title="确定清空家具吗?"
|
|
@confirm="clearFurniture"
|
|
@confirm="clearFurniture"
|
|
>
|
|
>
|
|
@@ -127,8 +122,12 @@
|
|
</a-space>
|
|
</a-space>
|
|
</div>
|
|
</div>
|
|
<div class="panel-ct">
|
|
<div class="panel-ct">
|
|
- <template v-if="localFurniture.length">
|
|
|
|
- <div v-for="(furniture, index) in localFurniture" :key="index" class="list-item">
|
|
|
|
|
|
+ <template v-if="roomStore.localFurnitureItems.length">
|
|
|
|
+ <div
|
|
|
|
+ v-for="(furniture, index) in roomStore.localFurnitureItems"
|
|
|
|
+ :key="index"
|
|
|
|
+ class="list-item"
|
|
|
|
+ >
|
|
<a-collapse v-model:activeKey="furnitureActiveKey" ghost>
|
|
<a-collapse v-model:activeKey="furnitureActiveKey" ghost>
|
|
<a-collapse-panel :key="index + 1" :header="`${furniture.name} 属性`">
|
|
<a-collapse-panel :key="index + 1" :header="`${furniture.name} 属性`">
|
|
<div class="mapConfig">
|
|
<div class="mapConfig">
|
|
@@ -249,11 +248,13 @@
|
|
<div class="panel-hd">
|
|
<div class="panel-hd">
|
|
<div
|
|
<div
|
|
>区域列表
|
|
>区域列表
|
|
- <span v-if="localSubRegions.length">({{ localSubRegions.length }})</span></div
|
|
|
|
|
|
+ <span v-if="roomStore.localSubRegions.length"
|
|
|
|
+ >({{ roomStore.localSubRegions.length }})</span
|
|
|
|
+ ></div
|
|
>
|
|
>
|
|
<a-space>
|
|
<a-space>
|
|
<a-popconfirm
|
|
<a-popconfirm
|
|
- v-if="localSubRegions.length"
|
|
|
|
|
|
+ v-if="roomStore.localSubRegions.length"
|
|
title="确定清空子区域吗?"
|
|
title="确定清空子区域吗?"
|
|
@confirm="clearSubregions"
|
|
@confirm="clearSubregions"
|
|
>
|
|
>
|
|
@@ -264,7 +265,11 @@
|
|
</div>
|
|
</div>
|
|
<div class="panel-ct">
|
|
<div class="panel-ct">
|
|
<template v-if="localSubRegions.length">
|
|
<template v-if="localSubRegions.length">
|
|
- <div v-for="(region, index) in localSubRegions" :key="index" class="list-item">
|
|
|
|
|
|
+ <div
|
|
|
|
+ v-for="(region, index) in roomStore.localSubRegions"
|
|
|
|
+ :key="index"
|
|
|
|
+ class="list-item"
|
|
|
|
+ >
|
|
<a-collapse v-model:activeKey="regionActiveKey" ghost>
|
|
<a-collapse v-model:activeKey="regionActiveKey" ghost>
|
|
<a-collapse-panel :key="index + 1" :header="`子区域 ${index + 1} 属性`">
|
|
<a-collapse-panel :key="index + 1" :header="`子区域 ${index + 1} 属性`">
|
|
<div class="mapConfig">
|
|
<div class="mapConfig">
|
|
@@ -371,7 +376,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { ref, watch, computed, onUnmounted, reactive } from 'vue'
|
|
|
|
|
|
+import { ref, computed, onUnmounted, reactive } from 'vue'
|
|
// import type { FurnitureItem } from '@/types/radar'
|
|
// import type { FurnitureItem } from '@/types/radar'
|
|
import DetectionAreaView from '../DetectionAreaView/index.vue'
|
|
import DetectionAreaView from '../DetectionAreaView/index.vue'
|
|
import EditableFurniture from '../EditableFurniture/index.vue'
|
|
import EditableFurniture from '../EditableFurniture/index.vue'
|
|
@@ -382,8 +387,8 @@ import { nanoid } from 'nanoid'
|
|
import { furnitureIconNameMap, furnitureIconSizeMap } from '@/const/furniture'
|
|
import { furnitureIconNameMap, furnitureIconSizeMap } from '@/const/furniture'
|
|
import type {
|
|
import type {
|
|
FurnitureItem,
|
|
FurnitureItem,
|
|
- LocalFurnitureItem,
|
|
|
|
- LocalSubRegionItem,
|
|
|
|
|
|
+ // LocalFurnitureItem,
|
|
|
|
+ // LocalSubRegionItem,
|
|
SubRegions,
|
|
SubRegions,
|
|
} from '@/api/room/types'
|
|
} from '@/api/room/types'
|
|
import {
|
|
import {
|
|
@@ -393,14 +398,15 @@ import {
|
|
ArrowDownOutlined,
|
|
ArrowDownOutlined,
|
|
ArrowRightOutlined,
|
|
ArrowRightOutlined,
|
|
} from '@ant-design/icons-vue'
|
|
} from '@ant-design/icons-vue'
|
|
|
|
+import { useRoomStore } from '@/stores/room'
|
|
|
|
|
|
defineOptions({ name: 'RadarEditor' })
|
|
defineOptions({ name: 'RadarEditor' })
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
coordinates: [number, number, number, number]
|
|
coordinates: [number, number, number, number]
|
|
angle: number
|
|
angle: number
|
|
- furnitureItems?: LocalFurnitureItem[]
|
|
|
|
- subRegions?: LocalSubRegionItem[]
|
|
|
|
|
|
+ // furnitureItems?: LocalFurnitureItem[]
|
|
|
|
+ // subRegions?: LocalSubRegionItem[]
|
|
disabled?: boolean
|
|
disabled?: boolean
|
|
}
|
|
}
|
|
const props = defineProps<Props>()
|
|
const props = defineProps<Props>()
|
|
@@ -409,8 +415,9 @@ const emit = defineEmits<{
|
|
(e: 'update:subRegions', regions: SubRegions[]): void
|
|
(e: 'update:subRegions', regions: SubRegions[]): void
|
|
}>()
|
|
}>()
|
|
|
|
|
|
-const localFurniture = ref<FurnitureItem[]>(props.furnitureItems ?? [])
|
|
|
|
-const localSubRegions = ref<SubRegions[]>(props.subRegions ?? [])
|
|
|
|
|
|
+const roomStore = useRoomStore()
|
|
|
|
+const localFurniture = ref<FurnitureItem[]>(roomStore.localFurnitureItems ?? [])
|
|
|
|
+const localSubRegions = ref<SubRegions[]>(roomStore.localSubRegions ?? [])
|
|
|
|
|
|
console.log('props', props)
|
|
console.log('props', props)
|
|
|
|
|
|
@@ -438,42 +445,8 @@ const nudge = (direction: 'left' | 'right' | 'up' | 'down') => {
|
|
// emit('update', { ...localItem })
|
|
// emit('update', { ...localItem })
|
|
}
|
|
}
|
|
|
|
|
|
-watch(
|
|
|
|
- () => props.furnitureItems,
|
|
|
|
- (newVal) => {
|
|
|
|
- if (newVal) localFurniture.value = [...newVal]
|
|
|
|
- },
|
|
|
|
- { deep: true }
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-watch(
|
|
|
|
- () => props.subRegions,
|
|
|
|
- (newVal) => {
|
|
|
|
- if (newVal) localSubRegions.value = [...newVal]
|
|
|
|
- },
|
|
|
|
- { deep: true }
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-// 监听本地子区域变化,通知父组件
|
|
|
|
-watch(
|
|
|
|
- localSubRegions,
|
|
|
|
- (newRegions) => {
|
|
|
|
- // emit('update:subRegions', newRegions)
|
|
|
|
- console.log('子区域变化', newRegions)
|
|
|
|
- // 缓存起来
|
|
|
|
- localStorage.setItem('subRegions', JSON.stringify(newRegions))
|
|
|
|
- },
|
|
|
|
- { deep: true }
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-function updateFurniture(item: FurnitureItem) {
|
|
|
|
- localFurniture.value = localFurniture.value.map((i) => (i.nanoid === item.nanoid ? item : i))
|
|
|
|
- emit('update:furnitureItems', localFurniture.value)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
function deleteFurniture(nanoid: string) {
|
|
function deleteFurniture(nanoid: string) {
|
|
- localFurniture.value = localFurniture.value.filter((i) => i.nanoid !== nanoid)
|
|
|
|
- emit('update:furnitureItems', localFurniture.value)
|
|
|
|
|
|
+ roomStore.localFurnitureItems = roomStore.localFurnitureItems.filter((i) => i.nanoid !== nanoid)
|
|
}
|
|
}
|
|
|
|
|
|
function addFurniture(item: FurnitureItem) {
|
|
function addFurniture(item: FurnitureItem) {
|
|
@@ -596,16 +569,16 @@ const modeRadioChange = () => {
|
|
furnitureActiveKey.value = []
|
|
furnitureActiveKey.value = []
|
|
}
|
|
}
|
|
|
|
|
|
-const syncCoordinates = () => {
|
|
|
|
- console.log('同步坐标', localFurniture.value, localSubRegions.value)
|
|
|
|
-}
|
|
|
|
|
|
+// const syncCoordinates = () => {
|
|
|
|
+// console.log('同步坐标', localFurniture.value, localSubRegions.value)
|
|
|
|
+// }
|
|
|
|
|
|
const clearSubregions = () => {
|
|
const clearSubregions = () => {
|
|
localSubRegions.value = []
|
|
localSubRegions.value = []
|
|
}
|
|
}
|
|
|
|
|
|
const clearFurniture = () => {
|
|
const clearFurniture = () => {
|
|
- localFurniture.value = []
|
|
|
|
|
|
+ roomStore.localFurnitureItems = []
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|