Browse Source

资料归集,移动、删除层级时,父节点文件数统计问题

MaiXinRong 1 year ago
parent
commit
9e2ecf8d32
2 changed files with 14 additions and 7 deletions
  1. 13 6
      app/public/js/file_detail.js
  2. 1 1
      app/public/js/shares/drag_tree.js

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

@@ -25,16 +25,13 @@ $(document).ready(function() {
             this.dragTree.recursiveFun(this.dragTree.children, x => {
                 if (x.children && x.children.length > 0) {
                     x.total_file_count = x.children.reduce((pre, c) => {
+                        if (x.filing_type === 1) console.log('reduce', c.name, c.total_file_count);
                         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;
+                    x.total_file_count = x.file_count || 0;
                 }
+                if (x.filing_type === 1) console.log(x.name, x.total_file_count);
             });
         }
         _loadFilingSourceNode() {
@@ -169,10 +166,20 @@ $(document).ready(function() {
             });
         }
         delFiling(node, callback) {
+            const parent = node.getParentNode();
             const self = this;
             postData('filing/del', { id: node.id }, function(result) {
+                self.updateFilingFileCount(node, 0);
                 self.dragTree.loadPostData(result);
                 self.filingTree.removeNode(node);
+                self.calcTotalFileCount();
+                if (parent) {
+                    const path = parent.getPath();
+                    for (const p of path) {
+                        p.name = p.source_node.name + (p.source_node.total_file_count > 0 ? `(${p.source_node.total_file_count})` : '');
+                        filingObj.filingTree.updateNode(p);
+                    }
+                }
                 if (callback) callback();
             });
         }

+ 1 - 1
app/public/js/shares/drag_tree.js

@@ -398,7 +398,7 @@ const createDragTree = function (setting) {
                 array.splice(index, 1);
             };
             for (const data of datas) {
-                const node = this.getItems(data[this.setting.id]);
+                const node = this.getItems(data);
                 if (node) {
                     freeDatas.push(node);
                     node.deleteIndex = this.nodes.indexOf(node);