浏览代码

Merge branch 'requirement_365' into debug

cldu 1 月之前
父节点
当前提交
85a4809f6f
共有 1 个文件被更改,包括 26 次插入8 次删除
  1. 26 8
      src/views/ppt_manage/newVersion/components/editor/InsertPageDialog.vue

+ 26 - 8
src/views/ppt_manage/newVersion/components/editor/InsertPageDialog.vue

@@ -120,22 +120,40 @@ export default {
     },
     searchTitle(newVal){
       if(!newVal) return
-      let data = null
-      this.privateList.forEach((item)=>{
-        item.children.forEach(i=>{
-          if(i.PptId===newVal){
-            data = i
-          }
-        })
-      })
+      let data = this.findPptById(this.privateList || [],newVal) || {};
       this.$refs.privateTree.setCurrentKey('ppt'+newVal)
       const node = this.$refs.privateTree.getCurrentNode()
+      if(!node) return;
       !this.privateExpandKeys.includes(node.catalogId)&&this.privateExpandKeys.push(node.catalogId)
       this.choosedItem = data
       this.searchOptions=[]
     }
   },
   methods: {
+    findPptById(data, newVal){
+      let result = null;
+      function traverse(node) {
+          if (!node || result) return;
+
+          if (node.PptId == newVal) {
+            result = node;
+            return;
+          }
+
+          if (Array.isArray(node.children)) {
+            for (const child of node.children) {
+              traverse(child);
+              if (result) break;
+            }
+          }
+      }
+
+      for (const item of data) {
+        traverse(item);
+        if (result) break;
+      }
+      return result;
+    },
     cancelHandle(){this.$emit('cancel')},
     saveHandle(){
       if(this.value.length===0){