|
@@ -23,11 +23,14 @@ $(document).ready(function() {
|
|
calcTotalFileCount() {
|
|
calcTotalFileCount() {
|
|
this.dragTree.recursiveFun(this.dragTree.children, x => {
|
|
this.dragTree.recursiveFun(this.dragTree.children, x => {
|
|
if (x.children && x.children.length > 0) {
|
|
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);
|
|
}, 0);
|
|
|
|
+ // x.total_file_count = x.children.map(y => {
|
|
|
|
+ // return y.total_file_count;
|
|
|
|
+ // }).reduce((pre, value) => {
|
|
|
|
+ // return pre + value
|
|
|
|
+ // }, 0);
|
|
} else {
|
|
} else {
|
|
x.total_file_count = x.file_count;
|
|
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) {
|
|
postData('filing/move', { id: node.id, tree_pid, tree_order }, function(result) {
|
|
const refresh = self.dragTree.loadPostData(result);
|
|
const refresh = self.dragTree.loadPostData(result);
|
|
self.calcTotalFileCount();
|
|
self.calcTotalFileCount();
|
|
|
|
+ const updated = [];
|
|
for (const u of refresh.update) {
|
|
for (const u of refresh.update) {
|
|
const node = self.filingTree.getNodeByParam('id', u.id);
|
|
const node = self.filingTree.getNodeByParam('id', u.id);
|
|
if (node) {
|
|
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);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|