瀏覽代碼

资料归集,移动节点,多层父项名称刷新问题

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

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

@@ -23,11 +23,14 @@ $(document).ready(function() {
         calcTotalFileCount() {
             this.dragTree.recursiveFun(this.dragTree.children, x => {
                 if (x.children && x.children.length > 0) {
-                    x.total_file_count = x.children.map(y => {
-                        return y.total_file_count;
-                    }).reduce((pre, value) => {
-                        return pre + value
+                    x.total_file_count = x.children.reduce((pre, c) => {
+                        return pre + c.total_file_count
                     }, 0);
+                    // x.total_file_count = x.children.map(y => {
+                    //     return y.total_file_count;
+                    // }).reduce((pre, value) => {
+                    //     return pre + value
+                    // }, 0);
                 } else {
                     x.total_file_count = x.file_count;
                 }
@@ -339,11 +342,18 @@ $(document).ready(function() {
             postData('filing/move', { id: node.id, tree_pid, tree_order }, function(result) {
                 const refresh = self.dragTree.loadPostData(result);
                 self.calcTotalFileCount();
+                const updated = [];
                 for (const u of refresh.update) {
                     const node = self.filingTree.getNodeByParam('id', u.id);
                     if (node) {
-                        node.name = node.source_node.name + (node.source_node.total_file_count > 0 ? `(${node.source_node.total_file_count})` : '');
-                        filingObj.filingTree.updateNode(node);
+                        const path = node.getPath();
+                        for (const p of path) {
+                            if (updated.indexOf(p.id) >= 0) continue;
+
+                            p.name = p.source_node.name + (p.source_node.total_file_count > 0 ? `(${p.source_node.total_file_count})` : '');
+                            filingObj.filingTree.updateNode(p);
+                            updated.push(p.id);
+                        }
                     }
                 }
             });