瀏覽代碼

资料归集,显示至问题

MaiXinRong 2 年之前
父節點
當前提交
8f135dae59
共有 1 個文件被更改,包括 13 次插入6 次删除
  1. 13 6
      app/public/js/file_detail.js

+ 13 - 6
app/public/js/file_detail.js

@@ -316,13 +316,20 @@ $(document).ready(function() {
             })
         }
         expandByCustom(fun) {
-            this.expandCache = [];
+            const self = this;
+            const expandCache = [];
+            const expandChildren = function(children) {
+                for (const child of children) {
+                    if (!child.children || child.children.length === 0) continue;
+                    const expand = fun(child);
+                    if (expand) expandCache.push(child.id);
+                    self.filingTree.expandNode(child, expand, false, false);
+                    expandChildren(child.children);
+                }
+            };
             const nodes = this.filingTree.getNodes();
-            for (const node of nodes) {
-                const expand = fun(node);
-                if (expand) this.expandCache.push(node.id);
-                this.filingTree.expandNode(node, expand, false, false);
-            }
+            expandChildren(nodes);
+            this.expandCache = expandCache;
             setLocalCache(this.expandKey, this.expandCache.join(','));
         }
         moveFiling(node, tree_pid, tree_order) {