浏览代码

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

laiguoran 2 年之前
父节点
当前提交
31aa0c9d7e
共有 2 个文件被更改,包括 18 次插入8 次删除
  1. 18 6
      app/public/js/file_detail.js
  2. 0 2
      app/view/file/file.ejs

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

@@ -19,15 +19,19 @@ $(document).ready(function() {
             const cache = getLocalCache(this.expandKey);
             this.expandCache = cache ? _.uniq(cache.split(',')) : [];
             this.curFilingKey = 'cur-filing-' + window.location.pathname.split('/')[2];
+            $('#filing').height($(".sjs-height-0").height()-$('.d-flex',".sjs-height-0").height());
         }
         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 +343,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);
+                        }
                     }
                 }
             });
@@ -410,6 +421,7 @@ $(document).ready(function() {
                 filingObj.expandFiling(node, false);
             },
             beforeDrop: function(key, nodes, target, moveType, isCopy) {
+                if (!canFiling) return false;
                 if (!target) return false;
                 if (nodes[0].level < 1) {
                     toastr.error('顶层节点请勿移动');

+ 0 - 2
app/view/file/file.ejs

@@ -27,8 +27,6 @@
                         <% if (canFiling) { %>
                         <div class="p-2"><a href="javascript: void(0);" id="add-slibing">添加同级</a></div>
                         <div class="p-2"><a href="javascript: void(0);" id="add-child">添加子级</a></div>
-                        <% } else { %>
-                        <div class="p-2 ml-2">分类目录</div>
                         <% } %>
                     </div>
                     <ul id="filing" class="ztree" style="overflow: auto"></ul>