소스 검색

Merge branch 'master' of http://192.168.0.115:3000/bill/fuse-code

xzw 3 년 전
부모
커밋
14b71bee07
6개의 변경된 파일41개의 추가작업 그리고 22개의 파일을 삭제
  1. 25 1
      src/layout/edit/fuse-edit.vue
  2. 4 9
      src/layout/edit/fuse-left-pano.vue
  3. 8 10
      src/layout/edit/scene-select.vue
  4. 2 2
      src/store/view.ts
  5. 1 0
      src/utils/meta.ts
  6. 1 0
      src/views/view/index.vue

+ 25 - 1
src/layout/edit/fuse-edit.vue

@@ -1,11 +1,18 @@
 <template>
   <template v-if="loaded" style="height: 100%">
     <Header></Header>
-    <router-view v-slot="{ Component }">
+    <router-view v-slot="{ Component }" v-if="fuseModels.length">
       <keep-alive>
         <component :is="Component" />
       </keep-alive>
     </router-view>
+    
+
+    <SelectModel v-else>
+      <ui-button type="primary" class="add-fuse-model">
+        <ui-icon type="add" />添加数据
+      </ui-button>
+    </SelectModel>
   </template>
 </template>
 
@@ -19,6 +26,7 @@ import {
   enterEdit, 
   isOld, 
   save, 
+  fuseModels,
   initialFuseModels,
   initialScenes,
   initialTaggingStyles, 
@@ -28,6 +36,7 @@ import {
 } from '@/store'
 
 import Header from './header/index.vue'
+import SelectModel from './scene-select.vue'
 
 const loaded = ref(false)
 const initialSys = async () => {
@@ -62,3 +71,18 @@ watch(currentMeta, (meta, _, onClean) => {
   }
 }, { flush: 'post', immediate: true })
 </script>
+
+<style lang="scss" scoped>
+.add-fuse-model {
+  position: absolute;
+  left: 50%;
+  transform: translateX(-50%);
+  width: 160px;
+  z-index: 3;
+  bottom: 10px;
+
+  .icon {
+    margin-right: 4px;
+  }
+}
+</style>

+ 4 - 9
src/layout/edit/fuse-left-pano.vue

@@ -5,18 +5,14 @@
       @delete-model="modelDelete"
       @click-model="modelChangeSelect"
     >
-      <template #action>
-        <ui-icon 
-          type="add" 
-          @click="insertMode = true" 
-          ctrl 
-          v-if="custom.modelsChangeStore" 
-        />
+      <template #action v-if="custom.modelsChangeStore">
+        <SelectModel>
+          <ui-icon ctrl type="add" />
+        </SelectModel>
       </template>
     </ModelList>
   </LeftPano>
 
-  <SelectModel @close="insertMode = false" v-if="insertMode" />
 </template>
 
 <script lang="ts" setup>
@@ -31,7 +27,6 @@ import { LeftPano } from '@/layout'
 
 import type { FuseModel } from '@/store'
 
-const insertMode = ref(false)
 const modelChangeSelect = (model: FuseModel) => {
   if (getFuseModelShowVariable(model).value) {
     if (custom.currentModel !== model) {

+ 8 - 10
src/layout/edit/scene-select.vue

@@ -2,9 +2,9 @@
   <Modal 
     width="800px"
     title="添加场景" 
-    :visible="true"
+    :visible="visible"
     @ok="okHandler"
-    @cancel="emit('close')"
+    @cancel="visible = false"
     okText="确定"
     cancelText="取消"
   >
@@ -26,6 +26,10 @@
       />
     </div>
   </Modal>
+
+  <div @click="visible = true">
+    <slot></slot>
+  </div>
 </template>
 
 <script lang="ts" setup>
@@ -41,13 +45,8 @@ type Key = Scene['modelId']
 
 const Search = Input.Search
 
-const emit = defineEmits<{
-  (e: 'close'): void
-  (e: 'select', ids: Key[]): void
-}>()
-
 const selectIds = computed(() => fuseModels.value.map(item => item.modelId))
-
+const visible = ref(false)
 const keyword = ref('')
 const filterScenes = computed(
   () => scenes.value.filter(item => item.name && item.modelId && item.name.includes(keyword.value))
@@ -91,8 +90,7 @@ const okHandler = createLoadPack(async () => {
     })
   })
   await save()
-
-  emit('close')
+  visible.value = false
 })
 </script>
 

+ 2 - 2
src/store/view.ts

@@ -34,14 +34,14 @@ export const createView = (view: Partial<View> = {}): View => {
     flyData: '',
     num: null,
     numType: null,
-    fusionId: fuseModels.value[0].fusionId,
+    fusionId: fuseModels.value.length ? fuseModels.value[0].fusionId : -1,
     sort: Math.min(...views.value.map(item => item.sort)) - 1,
     ...view,
   }
   if (typeof view.fusionId === 'number') {
     return {
       ...base,
-      ...view,
+      ...view, 
       fusionId: view.fusionId,
       num: null,
       numType: null

+ 1 - 0
src/utils/meta.ts

@@ -26,6 +26,7 @@ export const getUrlType = (url: string) => {
         return type as MetaType
       }
     }
+    return MetaType.other
   } else {
     return MetaType.other
   }

+ 1 - 0
src/views/view/index.vue

@@ -57,6 +57,7 @@ const getView = async () => {
       ...type
     }))
   } catch (e: Error) {
+    console.error(e)
     Message.error(e.message)
   }
 }