Forráskód Böngészése

显示隐藏直接销毁模型

bill 3 éve
szülő
commit
3f89afec32

+ 1 - 1
src/api/constant.ts

@@ -42,7 +42,7 @@ export const DELETE_TAGGING_STYLE = '/fusion/edit/hotIcon/delete'
 // 测量线
 export const MESASURE_LIST = `/fusion/fusionMeter/allList`
 export const INSERT_MESASURE = `/fusion/fusionMeter/add`
-export const UPDATE_MESASURE = `/fusion/fusionMeter/updateMeterTitle`
+export const UPDATE_MESASURE = `/fusion/fusionMeter/updateMeter`
 export const DELETE_MESASURE = `/fusion/fusionMeter/delete`
 
 // 导览

+ 2 - 3
src/components/list/index.vue

@@ -9,7 +9,7 @@
     <ul class="content" v-if="showContent">
       <li 
         v-for="(item, i) in data" 
-        :key="key ? item[key] : i" 
+        :key="rawKey ? item.raw[rawKey] : i" 
         :class="{select: item.select}"
         @click.stop="$emit('changeSelect', item)"
       >
@@ -23,14 +23,13 @@
 
 <script lang="ts" setup>
 type Item = Record<string, any> & {select?: boolean}
-type ListProps = { title?: string, key?: string, data: Array<Item>, showContent?: boolean}
+type ListProps = { title?: string, rawKey?: string, data: Array<Item>, showContent?: boolean}
 
 withDefaults(
   defineProps<ListProps>(),
   { showContent: true }
 )
 
-
 defineEmits<{ (e: 'changeSelect', item: Item): void }>()
 </script>
 

+ 1 - 1
src/layout/model-list/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <List :title="title" key="id" :data="modelList" :showContent="showContent">
+  <List :title="title" rawKey="id" :data="modelList" :showContent="showContent">
     <template #action>
       <slot name="action" />
     </template>

+ 9 - 1
src/sdk/association.ts

@@ -63,13 +63,17 @@ const sceneModelMap = new WeakMap<FuseModel, SceneModel>()
 export const getSceneModel = (model?: FuseModel | null) => model && sceneModelMap.get(toRaw(model))
 
 const associationModels = (sdk: SDK) => {
-  const getModels = () => fuseModels.value
+  const getModels = () => {
+    return fuseModels.value.filter(model => getFuseModelShowVariable(model).value)
+  }
   shallowWatchArray(getModels, (models, oldModels) => {
     const { added, deleted } = diffArrayChange(models, oldModels)
     for (const item of added) {
+      console.log('added', item)
       if (getSceneModel(item)) {
         continue;
       }
+      console.log('added load', item)
 
       const itemRaw = toRaw(item)
       const sceneModel = sdk.addModel({
@@ -131,6 +135,9 @@ const associationModels = (sdk: SDK) => {
     }
     for (const item of deleted) {
       getSceneModel(item)?.destroy()
+      setTimeout(() => {
+        sceneModelMap.delete(toRaw(item))
+      })
     }
   })
   
@@ -237,6 +244,7 @@ const associationMessaures = (sdk: SDK) => {
     for (const item of deleted) {
       const sceneMeasure = getSceneMeasure(item)
       sceneMeasure && sceneMeasure.destroy!()
+      sceneMeasureMap.delete(toRaw(item))
     }
   })
 

+ 3 - 3
src/store/measure.ts

@@ -24,9 +24,9 @@ export type Measure<T extends MeasureType = MeasureType> = SMeasure<T> & { selec
 export type Measures = Measure[]
 
 export const MeasureTypeMeta = {
-  [MeasureType.area]: { icon: 'v-l', desc: '自由', unitDesc: '长度', unit: 'm' },
-  [MeasureType.free]: { icon: 'f-l', desc: '垂直', unitDesc: '长度', unit: 'm' },
-  [MeasureType.vertical]: { icon: 'h-r', desc: '面积', unitDesc: '面积', unit: 'm²' }
+  [MeasureType.area]: { icon: 'h-r', desc: '面积', unitDesc: '面积', unit: 'm²' },
+  [MeasureType.free]: { icon: 'v-l', desc: '自由', unitDesc: '长度', unit: 'm' },
+  [MeasureType.vertical]: { icon: 'f-l', desc: '垂直', unitDesc: '长度', unit: 'm' }
 }
 
 export const measures = ref<Measures>([])

+ 4 - 1
src/views/measure/show.vue

@@ -18,10 +18,13 @@
 
 <script setup lang="ts">
 import MeasureSign from '@/views/measure/sign.vue'
+import { ref } from 'vue'
 import { measures, initialMeasures } from '@/store'
-import { custom } from '@/env'
+import { custom, showMeasuresStack } from '@/env'
+import { useViewStack } from '@/hook'
 
 initialMeasures() 
+useViewStack(() => showMeasuresStack.push(ref(true)))
 </script>
 
 

+ 14 - 2
src/views/merge/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <RightPano v-if="custom.currentModel && active">
+  <RightPano v-if="custom.currentModel && active" class="merge-layout">
     <ui-group>
       <template #header>
         <Actions class="edit-header" :items="actionItems" v-model:current="currentItem" />
@@ -116,4 +116,16 @@ useViewStack(() => togetherCallback([
 ]))
 useViewStack(autoSaveFuseModels)
 
-</script>
+</script>
+
+<style lang="scss">
+.merge-layout {
+  .ui-input .text.suffix input {
+    padding-left: 5px;
+    padding-right: 15px;
+  }
+  .ui-input .text.suffix .retouch {
+    right: 5px;
+  }
+}
+</style>

+ 6 - 4
src/views/proportion/index.vue

@@ -17,7 +17,7 @@
 <script lang="ts" setup>
 import { Message } from 'bill/index'
 import { useViewStack } from '@/hook'
-import { router } from '@/router'
+import { router, RoutesName } from '@/router'
 import { ref, computed, watch, nextTick } from 'vue'
 import { getSceneModel } from '@/sdk'
 import { autoSaveFuseModels, getFuseModel, leave } from '@/store'
@@ -25,9 +25,11 @@ import { autoSaveFuseModels, getFuseModel, leave } from '@/store'
 import type { ScaleSet } from '@/sdk'
 
 const model = computed(() => {
-  const modelId = router.currentRoute.value.params.id as string
-  if (modelId) {
-    return getFuseModel(modelId)
+  if (router.currentRoute.value.name === RoutesName.proportion) {
+    const modelId = router.currentRoute.value.params.id as string
+    if (modelId) {
+      return getFuseModel(modelId)
+    }
   }
 })
 

+ 3 - 3
src/views/summary/index.vue

@@ -14,9 +14,9 @@
         {{tab.text}}
       </span>
     </div>
-    <Taggings v-show="current === TabKey.tagging" />
-    <Guides  v-show="current === TabKey.guide"/>
-    <Measures  v-show="current === TabKey.measure"/>
+    <Taggings v-if="current === TabKey.tagging" />
+    <Guides  v-if="current === TabKey.guide"/>
+    <Measures  v-if="current === TabKey.measure"/>
   </RightFillPano>
 </template>
 

+ 1 - 0
src/views/tagging-position/index.vue

@@ -81,6 +81,7 @@ watchEffect((onCleanup) => {
           ...position,
           taggingId: tagging.value!.id
         })
+        console.log(storePosition)
         taggingPositions.value.push(storePosition)
       }
     }

+ 2 - 1
src/views/tagging-position/sign.vue

@@ -7,7 +7,6 @@
     </div>
     <div class="actions" @click.stop>
       <ui-icon 
-        :class="{disabled: disabledFly}"
         type="del" 
         ctrl  
         @click.stop="$emit('delete')"
@@ -26,6 +25,7 @@
 import { computed } from 'vue';
 import { 
   getFuseModel,
+  fuseModels,
   getFuseModelShowVariable
 } from '@/store'
 
@@ -34,6 +34,7 @@ import type { TaggingPosition } from '@/store'
 const props = defineProps<{ position: TaggingPosition, title: string }>()
 const disabledFly = computed(() => {
   const model = getFuseModel(props.position.modelId)
+  console.log(fuseModels.value, props.position.modelId, model, getFuseModelShowVariable(model!).value)
   return !model || !getFuseModelShowVariable(model).value
 })