瀏覽代碼

编辑器-导航:分组中新增全景图的功能

任一存 3 年之前
父節點
當前提交
0c5e9d50c8

+ 22 - 9
packages/code/src/components/materialSelectorForEditor.vue

@@ -220,6 +220,10 @@ export default {
       type: String,
       default: 'image',
     },
+    isMultiSelection: {
+      type: Boolean,
+      default: false,
+    }
   },
   components:{
   },
@@ -255,7 +259,6 @@ export default {
       })
     },
     tableHeadersForAudio() {
-      console.log(this.$MAPTABLEHEADER);
       return this.$MAPTABLEHEADER['audio'].filter(item => {
         return ['ossPath', 'name', 'fileSize'].includes(item.key)
       })
@@ -284,14 +287,26 @@ export default {
 
   methods: {
     selectItem(item, e) {
-      if (item.isUse == '1') {
-        e.target.checked = false
-        this.$alert({content:'选中素材不能超过600kb'})
+      if (false) {
+        // 对于图片,大于600kb的,压缩?
       } else {
-        if (e.target.checked) {
-          this.select = [item]
+        if (this.isMultiSelection) {
+          if (e.target.checked) {
+            this.select.push(item)
+          } else {
+            const toDeleteIdx = this.select.findIndex((eachSelect) => {
+              return eachSelect.id === item.id
+            })
+            if (toDeleteIdx >= 0) {
+              this.select.splice(toDeleteIdx, 1)
+            }
+          }
         } else {
-          this.select = []
+          if (e.target.checked) {
+            this.select = [item]
+          } else {
+            this.select = []
+          }
         }
       }
     },
@@ -307,7 +322,6 @@ export default {
         },
         (data) => {
           const newData = data.data.list.map((i) => {
-            i.isUse = i.fileSize > 600 ? '1' : '0'
             i.fileSize = changeByteUnit(Number(i.fileSize));
             i.createTime = i.createTime.substring(0, i.createTime.length - 3)
             i.updateTime = i.updateTime.substring(0, i.updateTime.length - 3)
@@ -338,7 +352,6 @@ export default {
         },
         (data) => {
           const newData = data.data.list.map((i) => {
-            i.isUse = i.fileSize > 600 ? '1' : '0'
             i.fileSize = changeByteUnit(Number(i.fileSize));
             i.createTime = i.createTime.substring(0, i.createTime.length - 3)
             i.updateTime = i.updateTime.substring(0, i.updateTime.length - 3)

+ 84 - 5
packages/code/src/components/sceneGroupInEditor.vue

@@ -16,18 +16,31 @@
         <i v-show="level === 1"
           class="iconfont icon-editor_list_add icon-add"
           v-tooltip="'新增二级分组'"
-          @click="onRequestForAddGroup"
+          @click.stop="onRequestForAddGroup"
         >
         </i>
         <i
           class="iconfont icon-editor_list_image icon-image"
-          v-tooltip="'新增全景图或三维场景'"
+          v-tooltip="'新增全景图或三维场景'" 
+          @click.stop="onRequestForAddScene"
+          v-show="
+            level === 2 ||
+            (
+              level === 1 &&
+              (
+                groupNode.children.length === 0 ||
+                (
+                  groupNode.children.length === 1 && groupNode.children[0].name === '默认二级分组'
+                )
+              )
+            )
+          "
         >
         </i>
         <i
           class="iconfont icon-editor_list_edit icon-edit"
           v-tooltip="'重命名'"
-          @click="onClickForRename"
+          @click.stop="onClickForRename"
         >
         </i>
         <i
@@ -95,16 +108,30 @@
         />
       </template>
     </div>
+
+    <div class="dialog" style="z-index: 2000" v-if="isShowSelectionWindow">
+      <MaterialSelectorForEditor
+        title="选择素材"
+        @cancle="isShowSelectionWindow = false"
+        @submit="onSubmitFromMaterialSelector"
+        :selectableType="['pano']"
+        :initialMaterialType="'pano'"
+        :isMultiSelection="true"
+      />
+    </div>
   </div>
 </template>
 
 <script>
 import SceneInGroupInEditor from "@/components/sceneInGroupInEditor.vue";
+import MaterialSelectorForEditor from "@/components/materialSelectorForEditor.vue";
+import { mapGetters } from "vuex";
 
 export default {
   name: 'SceneGroup',
   components: {
     SceneInGroupInEditor,
+    MaterialSelectorForEditor,
   },
   props: {
     groupNode: {
@@ -122,9 +149,13 @@ export default {
       isRenaming: false,
       newName: '',
       isConfirmingDeletion: false,
+      isShowSelectionWindow: false,
     }
   },
   computed: {
+    ...mapGetters({
+      info: "info",
+    }),
     topBarPaddingLeft() {
       return 12 + (this.level - 1) * 12 + 'px' 
     },
@@ -158,7 +189,9 @@ export default {
     onRequestForAddGroup() {
       this.$emit('addGroup', this.groupNode.id)
     },
-
+    onRequestForAddScene() {
+      this.isShowSelectionWindow = true
+    },
     onClickForRename() {
       this.isRenaming = true
       this.newName = this.groupNode.name
@@ -196,7 +229,53 @@ export default {
     },
     onInnerGroupConfirmDelete(...params) {
       this.$emit('deleteGroup', ...params)
-    }
+    },
+    onSubmitFromMaterialSelector(selected) {
+      let newScenes = null
+      // if (this.type == "scene") {
+      //   newScenes = selected.map((item) => {
+      //     return {
+      //       icon: item.thumb,
+      //       sceneCode: item.num,
+      //       sceneTitle: item.sceneName,
+      //       type: "4dkk",
+      //       category:this.groupNode.id,
+      //       id:'s_'+this.$randomWord(true,8,8)
+      //     };
+      //   });
+      // } else {
+      newScenes = selected.map((item) => {
+        return {
+          icon: item.icon,
+          sceneCode: item.sceneCode,
+          sceneTitle: item.name,
+          category: this.level === 1 ? this.groupNode.children[0].id : this.groupNode.id,
+          type: "pano",
+          id: 's_' + this.$randomWord(true, 8, 8)
+        }
+      })
+      // }
+
+      let allSuccess = true
+      newScenes.forEach((item, i) => {
+        let temp = this.info.scenes.find(sub => {
+          return sub.sceneCode == item.sceneCode
+        })
+        if (temp) {
+          setTimeout(() => {
+            this.$msg.message(`${item.type == '4dkk' ? '场景' : '全景图'}${item.sceneTitle}已存在,不可重复添加`)
+          }, i * 100)
+          allSuccess = false
+          return
+        }
+        this.info.scenes.push(item)
+      })
+
+      this.isShowSelectionWindow = false
+      if (allSuccess) {
+        this.$msg.success("操作成功")
+      }
+    },
   },
   mounted() {
     this.$bus.on('scene-group-expanded', this.onOtherSceneGroupExpanded)