|
@@ -12,15 +12,65 @@
|
|
|
@delete="deleteFurniture"
|
|
|
/>
|
|
|
</template>
|
|
|
+
|
|
|
+ <template #subregion> </template>
|
|
|
</RadarView>
|
|
|
+
|
|
|
+ <div v-if="!disabled && showPanel" class="options">
|
|
|
+ <div class="close" @click="showPanel = false">×</div>
|
|
|
+ <div class="header">
|
|
|
+ <a-radio-group v-model:value="modeRadio" button-style="solid" size="small">
|
|
|
+ <a-radio-button :value="1">家具</a-radio-button>
|
|
|
+ <!-- <a-radio-button :value="2">子区域</a-radio-button> -->
|
|
|
+ <!-- <a-radio-button :value="3">信息面板</a-radio-button> -->
|
|
|
+ </a-radio-group>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-if="modeRadio === 1" class="furniture">
|
|
|
+ <a-radio-group v-model:value="sideRadio" size="small">
|
|
|
+ <a-radio-button :value="1">客厅</a-radio-button>
|
|
|
+ <a-radio-button :value="2">餐厅</a-radio-button>
|
|
|
+ <a-radio-button :value="3">卧室</a-radio-button>
|
|
|
+ <a-radio-button :value="4">卫生间</a-radio-button>
|
|
|
+ </a-radio-group>
|
|
|
+
|
|
|
+ <furniture-list v-if="sideRadio === 1" :icons="livingroomIcons" @add="add"></furniture-list>
|
|
|
+ <furniture-list v-if="sideRadio === 2" :icons="diningroomIcons" @add="add"></furniture-list>
|
|
|
+ <furniture-list v-if="sideRadio === 3" :icons="bedroomIocns" @add="add"></furniture-list>
|
|
|
+ <furniture-list v-if="sideRadio === 4" :icons="bathroomIocns" @add="add"></furniture-list>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-if="modeRadio === 2" class="subregion">
|
|
|
+ <div class="subregion-header">
|
|
|
+ <div class="title">区域列表</div>
|
|
|
+ <a-button size="small">新建区域</a-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="subregion-list">
|
|
|
+ <div class="list-item">区域1 包含床</div>
|
|
|
+ <div class="list-item">区域2</div>
|
|
|
+ <div class="list-item">区域3</div>
|
|
|
+ <div class="list-item">区域4</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-if="modeRadio === 3" class="infoPanel"> 信息展示 </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <a-button v-else type="link" @click="showPanel = true">开始配置</a-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { defineOptions, ref, watch } from 'vue'
|
|
|
+import { ref, watch } from 'vue'
|
|
|
import type { FurnitureItem } from '@/types/radar'
|
|
|
import RadarView from '../RadarView/index.vue'
|
|
|
import EditableFurniture from '../EditableFurniture/index.vue'
|
|
|
+import type { FurnitureIconType } from '@/types/furniture'
|
|
|
+import { message } from 'ant-design-vue'
|
|
|
+import { nanoid } from 'nanoid'
|
|
|
+import type { FurnitureType } from '@/api/room/types'
|
|
|
+import { furnitureIconNameMap, furnitureIconSizeMap } from '@/const/furniture'
|
|
|
|
|
|
defineOptions({ name: 'RadarEditor' })
|
|
|
|
|
@@ -45,16 +95,14 @@ watch(
|
|
|
{ deep: true }
|
|
|
)
|
|
|
|
|
|
-function updateFurniture(updated: FurnitureItem) {
|
|
|
- const list = localFurniture.value.map((i) => (i.nanoid === updated.nanoid ? updated : i))
|
|
|
- localFurniture.value = list
|
|
|
- emit('update:furnitureItems', list)
|
|
|
+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) {
|
|
|
- const list = localFurniture.value.filter((i) => i.nanoid !== nanoid)
|
|
|
- localFurniture.value = list
|
|
|
- emit('update:furnitureItems', list)
|
|
|
+ localFurniture.value = localFurniture.value.filter((i) => i.nanoid !== nanoid)
|
|
|
+ emit('update:furnitureItems', localFurniture.value)
|
|
|
}
|
|
|
|
|
|
function addFurniture(item: FurnitureItem) {
|
|
@@ -63,6 +111,65 @@ function addFurniture(item: FurnitureItem) {
|
|
|
}
|
|
|
|
|
|
defineExpose({ addFurniture })
|
|
|
+
|
|
|
+const modeRadio = ref<1 | 2 | 3>(1)
|
|
|
+const sideRadio = ref<1 | 2 | 3 | 4>(1)
|
|
|
+
|
|
|
+// 客厅图标
|
|
|
+const livingroomIcons = [
|
|
|
+ 'living_sofa',
|
|
|
+ 'living_sofa_single',
|
|
|
+ 'living_tea_table',
|
|
|
+ 'living_bookcase',
|
|
|
+ 'living_tv_stand',
|
|
|
+]
|
|
|
+
|
|
|
+// 餐厅图标
|
|
|
+const diningroomIcons = [
|
|
|
+ 'dining_table',
|
|
|
+ 'dining_table_rect',
|
|
|
+ 'dining_fridge',
|
|
|
+ 'dining_chair',
|
|
|
+ 'bath_door',
|
|
|
+]
|
|
|
+
|
|
|
+// 卧室图标
|
|
|
+const bedroomIocns = [
|
|
|
+ 'bed',
|
|
|
+ 'bed_table',
|
|
|
+ 'bed_dressing_chair',
|
|
|
+ 'bed_dressing_mirror',
|
|
|
+ 'bed_cabinet',
|
|
|
+]
|
|
|
+
|
|
|
+// 卫生间图标
|
|
|
+const bathroomIocns = ['bath_basin', 'bath_shower', 'bath_toilet', 'bath_floor']
|
|
|
+
|
|
|
+// 添加家具
|
|
|
+const add = (icon: FurnitureIconType) => {
|
|
|
+ // emit('add', icon)
|
|
|
+ console.log('add', icon)
|
|
|
+ const originWidth = furnitureIconSizeMap[icon].width || 30
|
|
|
+ const originHeight = furnitureIconSizeMap[icon].height || 30
|
|
|
+
|
|
|
+ const newItem: FurnitureItem = {
|
|
|
+ name: furnitureIconNameMap[icon],
|
|
|
+ type: icon as FurnitureType,
|
|
|
+ width: originWidth,
|
|
|
+ length: originHeight,
|
|
|
+ top: 0,
|
|
|
+ left: 0,
|
|
|
+ rotate: 0,
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ nanoid: nanoid(),
|
|
|
+ }
|
|
|
+
|
|
|
+ addFurniture(newItem)
|
|
|
+ message.success('已添加家具')
|
|
|
+}
|
|
|
+
|
|
|
+const showPanel = ref(true)
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="less">
|
|
@@ -74,4 +181,82 @@ defineExpose({ addFurniture })
|
|
|
opacity: 0.85;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.radarEditor {
|
|
|
+ position: relative;
|
|
|
+ display: flex;
|
|
|
+ gap: 8px;
|
|
|
+
|
|
|
+ .radar-view {
|
|
|
+ flex-shrink: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .options {
|
|
|
+ width: 220px;
|
|
|
+ background-color: #fefefe;
|
|
|
+ border-radius: 10px;
|
|
|
+ padding: 12px;
|
|
|
+ position: relative;
|
|
|
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
|
+
|
|
|
+ .close {
|
|
|
+ position: absolute;
|
|
|
+ top: 8px;
|
|
|
+ right: 12px;
|
|
|
+ font-size: 22px;
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 1;
|
|
|
+ color: #999;
|
|
|
+ cursor: pointer;
|
|
|
+ transition: color 0.2s;
|
|
|
+ }
|
|
|
+
|
|
|
+ .header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .furniture {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .subregion {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 12px;
|
|
|
+
|
|
|
+ &-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+
|
|
|
+ .title {
|
|
|
+ font-weight: 600;
|
|
|
+ color: #666;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &-list {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 8px;
|
|
|
+ gap: 8px;
|
|
|
+
|
|
|
+ .list-item {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 8px 12px;
|
|
|
+ border-radius: 8px;
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|