فهرست منبع

feat: 新增家具添加已删除时的子区域联动交互;

liujia 8 ساعت پیش
والد
کامیت
bae6c5e164
2فایلهای تغییر یافته به همراه42 افزوده شده و 14 حذف شده
  1. 2 2
      src/components/DetectionAreaView/index.vue
  2. 40 12
      src/components/RadarEditor/index.vue

+ 2 - 2
src/components/DetectionAreaView/index.vue

@@ -528,12 +528,12 @@ const drawAreaBorder = () => {
   const canvasRect = convert_region_r2c(radarRect, radarPosition)
 
   // 绘制蓝色边框
-  ctx.strokeStyle = '#1677ff'
+  ctx.strokeStyle = 'rgb(51, 136, 255)'
   ctx.lineWidth = 1
   ctx.strokeRect(canvasRect.left, canvasRect.top, canvasRect.width, canvasRect.height)
 
   // 添加半透明蓝色填充
-  ctx.fillStyle = 'rgba(52, 152, 219, 0.3)'
+  ctx.fillStyle = 'rgba(51, 136, 255, 0.2)'
   ctx.fillRect(canvasRect.left, canvasRect.top, canvasRect.width, canvasRect.height)
 }
 

+ 40 - 12
src/components/RadarEditor/index.vue

@@ -103,7 +103,7 @@
               >
                 <a-button size="small" type="link">清空</a-button>
               </a-popconfirm>
-              <a-button size="small" type="link" @click="modeRadio = 1">添加</a-button>
+              <!-- <a-button size="small" type="link" @click="modeRadio = 1">添加</a-button> -->
             </a-space>
           </div>
           <div class="panel-ct">
@@ -373,7 +373,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, computed, onUnmounted, reactive } from 'vue'
+import { ref, computed, onUnmounted, reactive, h } from 'vue'
 import DetectionAreaView from '../DetectionAreaView/index.vue'
 import EditableFurniture from '../EditableFurniture/index.vue'
 import EditableSubregion from '../EditableSubregion/index.vue'
@@ -427,17 +427,16 @@ const inputStyle = computed(() => ({ width: '70px' }))
 // }
 
 function deleteFurniture(nanoid: string) {
+  const hasBed = roomStore.localFurnitureItems.some((i) => i.nanoid === nanoid && i.type === 'bed')
+  if (hasBed && roomStore.localSubRegions.length) {
+    roomStore.localSubRegions = roomStore.localSubRegions.map((region) => ({
+      ...region,
+      isBed: false,
+    }))
+  }
   roomStore.localFurnitureItems = roomStore.localFurnitureItems.filter((i) => i.nanoid !== nanoid)
 }
 
-// function addFurniture(item: FurnitureItem) {
-//   // localFurniture.value.push(item)
-//   roomStore.localFurnitureItems.push(item)
-//   // emit('update:furnitureItems', [...roomStore.localFurnitureItems])
-// }
-
-// defineExpose({ addFurniture })
-
 const modeRadio = ref<1 | 2 | 3>(1)
 const sideRadio = ref<1 | 2 | 3 | 4>(1)
 const editableSubregionRef = ref<InstanceType<typeof EditableSubregion>>()
@@ -488,8 +487,6 @@ const add = (icon: FurnitureIconType) => {
     type: icon,
     width: originWidth,
     length: originHeight,
-    // top: 0,
-    // left: 0,
     rotate: 0,
     x: 0,
     y: 0,
@@ -497,6 +494,37 @@ const add = (icon: FurnitureIconType) => {
   }
 
   roomStore.localFurnitureItems.push(newItem)
+  if (icon === 'bed') {
+    if (roomStore.localSubRegions.length) {
+      roomStore.localSubRegions[0].isBed = true
+    } else {
+      roomStore.localSubRegions.push({
+        nanoid: nanoid(),
+        startXx: 0,
+        stopXx: 0,
+        startYy: 0,
+        stopYy: 0,
+        startZz: 0,
+        stopZz: 0,
+        isLowSnr: 0,
+        isDoor: 0,
+        presenceEnterDuration: 0,
+        presenceExitDuration: 0,
+        trackPresence: 0,
+        excludeFalling: 0,
+        isDraging: false,
+        isResizing: false,
+        isActive: false,
+        isTracking: false,
+        isFalling: false,
+        pixelX: 0,
+        pixelY: 0,
+        pixelWidth: 0,
+        pixelHeight: 0,
+        isBed: true,
+      })
+    }
+  }
   // message.success('已添加家具')
 }