jinx il y a 8 mois
Parent
commit
ae12b117e8

+ 37 - 39
packages/qjkankan-editor/src/components/dragTree/index.vue

@@ -59,8 +59,8 @@
               </div>
             </div>
             <div class="image-info" v-else>
-              <div class="cover-image">
-                <img ref="drag-image" :src="data.icon + ossImagePreviewUrlSuffix()" alt="" />
+              <div class="cover-image" ref="drag-image">
+                <img :id="`drag_image_${data.id}`" :src="data.icon + ossImagePreviewUrlSuffix()" alt="" />
               </div>
 
               <div class="image-name">
@@ -212,42 +212,18 @@ export default {
           this.$nextTick(() => {
             if (this.currentRootId || this.currentSecondId) {
               if (this.currentRootId && this.currentSecondId) {
-                this.$store.commit("scene/setCurrentScenesList", this.info.navigationTrees[this.rootTabIndex].children[this.secondTabIndex].children);
+                if (this.info.navigationTrees[this.rootTabIndex].children[this.secondTabIndex]) {
+                  this.$store.commit("scene/setCurrentScenesList", this.info.navigationTrees[this.rootTabIndex].children[this.secondTabIndex].children);
+                }
               } else if (this.currentRootId && !this.currentSecondId) {
-                this.$store.commit("scene/setCurrentScenesList", this.info.navigationTrees[this.rootTabIndex].children);
+                if (this.info.navigationTrees[this.rootTabIndex].children[0].type == "group") {
+                  this.$store.commit("navigation/setData", { currentSecondId: this.info.navigationTrees[this.rootTabIndex].children[0].id });
+                  this.$store.commit("scene/setCurrentScenesList", this.info.navigationTrees[this.rootTabIndex].children[this.secondTabIndex].children);
+                } else {
+                  this.$store.commit("scene/setCurrentScenesList", this.info.navigationTrees[this.rootTabIndex].children);
+                }
               }
             }
-
-            // let activeScene = null;
-            // let currentScene = this.currentScene;
-
-            // this.info.navigationTrees.forEach((item, index) => {
-            //   activeScene = item.children.find((pano) => pano.id == currentScene.id);
-
-            //   if (activeScene) {
-            //     this.$store.commit("scene/setCurrentScenesList", item.children);
-            //     this.$store.commit("navigation/setData", { currentSecondId: null, currentRootId: item.id });
-            //     // throw new Error("LoopTerminated");
-            //   }
-            //   item = item.children.forEach((s_item, s_index) => {
-            //     activeScene = s_item.children.find((pano) => pano.id == currentScene.id);
-
-            //     if (activeScene) {
-            //       this.$store.commit("scene/setCurrentScenesList", s_item.children);
-            //       this.$store.commit("navigation/setData", { currentSecondId: s_item.id, currentRootId: item.id });
-            //       // throw new Error("LoopTerminated");
-            //     }
-            //     s_item = s_item.children.forEach((t_item, t_index) => {
-            //       activeScene = t_item.children.find((pano) => pano.id == currentScene.id);
-
-            //       if (activeScene) {
-            //         this.$store.commit("scene/setCurrentScenesList", s_item.children);
-            //         this.$store.commit("navigation/setData", { currentSecondId: s_item.id, currentRootId: item.id });
-            //         // throw new Error("LoopTerminated");
-            //       }
-            //     });
-            //   });
-            // });
           });
         }
       },
@@ -313,7 +289,9 @@ export default {
       if (node.data.type == "group") {
         ev.dataTransfer.setDragImage(this.$refs["drag-group"], -10, -18);
       } else {
-        ev.dataTransfer.setDragImage(this.$refs["drag-image"], -10, -18);
+        // ev.dataTransfer.setDragImage(this.$refs["drag-image"], -10, -18);
+        let dom = document.getElementById(`drag_image_${node.data.id}`);
+        ev.dataTransfer.setDragImage(dom, -10, -18);
       }
     },
     handleDragEnter(draggingNode, dropNode, ev) {
@@ -384,9 +362,17 @@ export default {
                 return false;
               }
             } else {
+              if (draggingNode.level == 1 && draggingNode.data.children.length && draggingNode.data.children[0].type == "group") {
+                //禁止含有二级目录的一级目录,拖拽到其他一级目录
+                return false;
+              }
               return type == "prev" || type == "next";
             }
           } else if (dropNode.level == 1) {
+            //禁止含有二级目录的一级目录,拖拽到其他一级目录
+            if (draggingNode.level == 1 && draggingNode.data.children.length && draggingNode.data.children[0].type == "group") {
+              return false;
+            }
             return type == "prev" || type == "next" || type == "inner";
           }
         }
@@ -710,7 +696,7 @@ export default {
               item.children = list;
             }
 
-            if (item.children.length == 1 && item.type == "group" && !item.children[0].children.length) {
+            if (item.children.length == 1 && item.type == "group" && !item.children[0].children.length && item.children[0].type != "pano") {
               //新增二级目录的时候,如果新增完只有一个二级目录,且二级目录为空,创建多一个目录,且第一个为默认二级目录
               let list = [];
               let defaultDir = {
@@ -756,8 +742,19 @@ export default {
               list = list.concat(groupList);
               item.children = list;
               console.error(item.children);
-              break;
             }
+
+            // if (groupList.length == 1 && !groupList[0].children.length) {
+            //   //当只有一个二级目录,二级目录没有场景
+
+            //   item.children = [];
+            // }
+            if (groupList.length == 1 && !panoList.length && groupList[0].children.length) {
+              //当只有一个二级目录,二级目录有场景
+              item.children = groupList[0].children;
+            }
+
+            break;
         }
 
         // if (item.id == this.currentRootId) {
@@ -967,7 +964,7 @@ export default {
 
       > i {
         margin-left: 12px;
-
+        cursor: pointer;
         &.iconfont {
           &:hover {
             color: #0076f6;
@@ -1016,6 +1013,7 @@ export default {
   height: auto;
   // padding: 10px 0;
   border-radius: 4px;
+  cursor: default;
 }
 .el-tree-node__content {
   // padding-left: 30px !important;

+ 8 - 8
packages/qjkankan-editor/src/framework/EditorHead.vue

@@ -74,13 +74,13 @@ export default {
       // console.error("canLoad", data);
       this.canLoad = data;
       // if (data) {
-        // this.getInfo().then((res) => {
-        //   // getInfo里调用了后端接口,底层用了jquery的网络请求方法,为啥会导致promise嵌套没有展平,res拿到的不是promise 对象的resolve值而是promise对象本身????
-        //   res.then(() => {
-        //     // alert(1);
-        //     this.$store.commit("TakeInfoSnapShotAtSave");
-        //   });
-        // });
+      // this.getInfo().then((res) => {
+      //   // getInfo里调用了后端接口,底层用了jquery的网络请求方法,为啥会导致promise嵌套没有展平,res拿到的不是promise 对象的resolve值而是promise对象本身????
+      //   res.then(() => {
+      //     // alert(1);
+      //     this.$store.commit("TakeInfoSnapShotAtSave");
+      //   });
+      // });
       // }
     });
   },
@@ -142,7 +142,7 @@ export default {
             });
           });
         }
-
+        console.error(this.currentSecondId);
         // if (data.firstScene) {
         //   firstScene = data.scenes.find((item) => item.sceneCode == data.firstScene.sceneCode);
         // }

+ 29 - 7
packages/qjkankan-editor/src/framework/play/pano/components/new-list.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="bar-list" v-if="info" :class="{ disable: isEditing }">
+    <!-- {{secondGroups}} -->
     <div class="top-con" v-show="currentScenesList.length">
       <div v-if="currentScenesList.length" class="scene-list swiper-container" ref="scene-swiper" :style="`width:${scenesListW > 1150 ? '100%' : scenesListW + 'px'}`">
         <!-- <div class="scene-list swiper-container" ref="scene-swiper"> -->
@@ -43,13 +44,14 @@
         </div>
       </div>
       <div class="second-group-box">
-        <div v-if="info.navigationTrees[rootTabIndex]?.children[0]?.type == 'group' && showSecondTab" class="second-group-list swiper-container" ref="second-group-swiper">
+        <!-- <div v-if="info.navigationTrees[rootTabIndex]?.children[0]?.type == 'group' && showSecondTab" class="second-group-list swiper-container" ref="second-group-swiper"> -->
+        <div v-if="secondGroups.length > 1" class="second-group-list swiper-container" ref="second-group-swiper">
           <div class="swiper-wrapper second-group-wrapper">
             <div
               class="swiper-slide second-group-slide"
               @click="tabSecond(item, index)"
               v-if="item.children.length"
-              v-for="(item, index) in info.navigationTrees[rootTabIndex].children"
+              v-for="(item, index) in secondGroups"
               :class="{ active: currentSecondId == item.id, disabled: isLockV4Scene, loopspan: fixTitle(item.name).length > spanlength && currentSecondId == item.id }"
             >
               <div class="second-group-content">
@@ -126,13 +128,22 @@ export default {
 
   watch: {
     currentScenesList(val) {
+   
+      if (!val.length && this.info.navigationTrees[this.rootTabIndex]?.children.length > 1 && this.info.navigationTrees[this.rootTabIndex]?.children[0].type == "group") {
+        let index = this.info.navigationTrees[this.rootTabIndex]?.children.findIndex((item) => item.children.length);
+        let id = this.info.navigationTrees[this.rootTabIndex]?.children[index]?.id;
+        this.$store.commit("navigation/setData", { currentSecondId: id });
+        this.tabSecond(this.info.navigationTrees[this.rootTabIndex]?.children[index]);
+      }
+   
+
+
       this.$nextTick(() => {
         this.initSceneSwiper();
         if (this.info.navigationTrees.length > 1) {
           this.initRootGroupSwiper();
         }
-
-        if (this.info.navigationTrees[this.currentRootId]?.children[this.currentSecondId]?.type == "group") {
+        if (this.info.navigationTrees[this.rootTabIndex]?.children[this.secondTabIndex]?.type == "group" && this.secondGroups.length > 1) {
           this.initSecondGroupSwiper();
         }
       });
@@ -185,11 +196,18 @@ export default {
       return this.info.navigationTrees.findIndex((item) => item.id == this.currentRootId);
     },
     secondTabIndex() {
+      console.error(
+        "secondTabIndex",
+        this.info.navigationTrees[this.rootTabIndex].children.findIndex((item) => item.id == this.currentSecondId)
+      );
       return this.info.navigationTrees[this.rootTabIndex].children.findIndex((item) => item.id == this.currentSecondId);
     },
     showSecondTab() {
       return this.info.navigationTrees[this.rootTabIndex].children.some((item) => item.id != this.currentSecondId);
     },
+    secondGroups() {
+      return this.info.navigationTrees[this.rootTabIndex].children.filter((item) => item.children.length);
+    },
   },
   methods: {
     fixTitle(name) {
@@ -249,9 +267,9 @@ export default {
       }
       this.$nextTick(() => {
         this.initSceneSwiper();
-        if (this.info.navigationTrees.length > 1) {
-          this.initRootGroupSwiper();
-        }
+
+        this.initRootGroupSwiper();
+
         if (this.info.navigationTrees[this.currentRootId]?.children[this.currentSecondId]?.type == "group") {
           this.initSecondGroupSwiper();
         }
@@ -297,6 +315,7 @@ export default {
         this.SecondGroupSwiper.destroy();
         this.SecondGroupSwiper = null;
       }
+      console.error("initSecondGroupSwiper");
       this.SecondGroupSwiper = new Swiper(".second-group-list", this.swiperOptions);
       this.$nextTick(() => {
         if (this.secondTabIndex >= 0) {
@@ -312,6 +331,9 @@ export default {
     },
 
     initRootGroupSwiper() {
+      if (this.info.navigationTrees.length <= 1) {
+        return;
+      }
       if (this.rootGroupSwiper) {
         this.rootGroupSwiper.destroy();
         this.rootGroupSwiper = null;

+ 15 - 6
packages/qjkankan-view/src/components/UIGather/list.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="bar-list" v-if="metadata?.navigationTrees?.length" :class="{ barshow: isShowScenesList }">
-    <div class="top-con" v-show="currentScenesList.length">
-      <div v-if="currentScenesList.length" class="scene-list swiper-container" ref="scene-swiper" :style="`width:${scenesListW > 1150 ? '100%' : scenesListW + 'px'}`">
+    <div class="top-con" v-show="currentScenesList.length > 1">
+      <div v-if="currentScenesList.length > 1" class="scene-list swiper-container" ref="scene-swiper" :style="`width:${scenesListW > 1150 ? '100%' : scenesListW + 'px'}`">
         <!-- <div class="scene-list swiper-container" ref="scene-swiper"> -->
         <div class="swiper-wrapper scene-wrapper">
           <!-- <div
@@ -43,7 +43,8 @@
         </div>
       </div>
       <div class="second-group-box" v-if="metadata?.navigationTrees[rootTabIndex]">
-        <div v-if="metadata?.navigationTrees[rootTabIndex]?.children[0]?.type == 'group' && showSecondTab" class="second-group-list swiper-container" ref="second-group-swiper">
+        <!-- <div v-if="metadata?.navigationTrees[rootTabIndex]?.children[0]?.type == 'group' && showSecondTab" class="second-group-list swiper-container" ref="second-group-swiper"> -->
+        <div v-if="secondGroups.length > 1" class="second-group-list swiper-container" ref="second-group-swiper">
           <div class="swiper-wrapper second-group-wrapper">
             <template v-for="(item, index) in metadata?.navigationTrees[rootTabIndex]?.children">
               <div
@@ -155,6 +156,9 @@ const secondTabIndex = computed(() => {
 const showSecondTab = computed(() => {
   return metadata.value && metadata.value?.navigationTrees ? metadata.value?.navigationTrees[rootTabIndex.value].children.some((item) => item.id != currentSecondId.value) : false;
 });
+const secondGroups = computed(() => {
+  return metadata.value?.navigationTrees[rootTabIndex.value].children.filter((item) => item.children.length);
+});
 
 const scenesListW = computed(() => currentScenesList.value.length * (swidth.value["swScenes"] + 10));
 
@@ -214,10 +218,10 @@ watch(
 );
 
 watch(
-  () => rootTabIndex.value,
+  () => currentRootId.value,
   (val) => {
     nextTick(() => {
-      if (metadata.value.navigationTrees[rootTabIndex.value]?.children[secondTabIndex.value]?.type == "group") {
+      if (secondGroups.value.length > 1) {
         initSecondGroupSwiper();
       }
     });
@@ -295,6 +299,9 @@ const changeSceneList = () => {
   });
 };
 const initSceneSwiper = () => {
+  if (currentScenesList.value.length <= 1) {
+    return;
+  }
   if (SceneSwiper.value) {
     SceneSwiper.value.destroy();
     SceneSwiper.value = null;
@@ -339,7 +346,9 @@ const initRootGroupSwiper = () => {
   // nextTick(() => {
   //   rootGroupSwiper.value = new Swiper(".root-group-list", swiperOptions);
   // });
-
+  if (metadata.value.navigationTrees.length <= 1) {
+    return;
+  }
   if (!rootGroupSwiper.value) {
     rootGroupSwiper.value = new Swiper(".root-group-list", swiperOptions);
     if (rootTabIndex.value >= 0) {