Browse Source

1. 树结构基础问题
2. 项目管理、资料归集、动态投资,展开收起
3. 项目管理、资料归集、动态投资,滚动条
4. 变更调用调整

MaiXinRong 1 year ago
parent
commit
4759d870be

+ 11 - 7
app/base/base_tree_service.js

@@ -526,14 +526,14 @@ class TreeService extends Service {
      * @return {Promise<*>}
      * @private
      */
-    async _deleteNodeData(mid, deleteNode) {
+    async _deletePosterity(mid, node) {
         this.initSqlBuilder();
         this.sqlBuilder.setAndWhere(this.setting.mid, {
             value: mid,
             operate: '=',
         });
         this.sqlBuilder.setAndWhere(this.setting.fullPath, {
-            value: this.db.escape(deleteNode[this.setting.fullPath] + '%'),
+            value: this.db.escape(node[this.setting.fullPath] + '-%'),
             operate: 'Like',
         });
         const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'delete');
@@ -555,13 +555,15 @@ class TreeService extends Service {
         if (!select) throw '删除节点数据错误';
         const parent = await this.getDataByKid(mid, select[this.setting.pid]);
         // 获取将要被删除的数据
-        const deleteData = await this.getDataByFullPath(mid, select[this.setting.fullPath] + '%');
+        const deleteData = await this.getDataByFullPath(mid, select[this.setting.fullPath] + '-%');
+        deleteData.unshift(select);
         if (deleteData.length === 0) throw '删除节点数据错误';
 
         this.transaction = await this.db.beginTransaction();
         try {
             // 删除
-            const operate = await this._deleteNodeData(mid, select);
+            await this.transaction.delete(this.tableName, { id: select.id });
+            const operate = await this._deletePosterity(mid, select);
             // 选中节点--父节点 只有一个子节点时,应升级isLeaf
             if (parent) {
                 const count = await this.db.count(this.tableName, this.getCondition({mid: mid, pid: select[this.setting.pid]}));
@@ -601,14 +603,16 @@ class TreeService extends Service {
         const childCount = parent ? await this.count(this.getCondition({mid: mid, pid: parent[this.setting.kid]})) : -1;
         let deleteData = [];
         for (const s of selects) {
-            deleteData = deleteData.concat(await this.getDataByFullPath(mid, s[this.setting.fullPath] + '%'));
+            deleteData = deleteData.concat(await this.getDataByFullPath(mid, s[this.setting.fullPath] + '-%'));
+            deleteData.push(s);
         }
 
         this.transaction = await this.db.beginTransaction();
         try {
             // 删除
+            await this.transaction.delete(this.tableName, { id: selects.map(x => { return x.id }) });
             for (const s of selects) {
-                const operate = await this._deleteNodeData(mid, s);
+                const operate = await this._deletePosterity(mid, s);
             }
             // 选中节点--父节点 只有一个子节点时,应升级isLeaf
             if (parent && childCount === count) {
@@ -982,7 +986,7 @@ class TreeService extends Service {
         let updateData = await this.getNextsData(mid, pre[this.setting.pid], pre[this.setting.order] - 1);
         // 选中节点及子节点
         for (const p of newPath) {
-            updateData = updateData.concat(await this.getDataByFullPath(mid, p + '%'));
+            updateData = updateData.concat(await this.getDataByFullPath(mid, p + '-%'));
         }
         // 选中节点--原前兄弟节点&全部后兄弟节点
         return { update: updateData };

+ 2 - 1
app/controller/stage_controller.js

@@ -558,7 +558,8 @@ module.exports = app => {
                 const bills = data.bills ? data.bills : await ctx.service.ledger.getDataById(data.pos.lid);
                 const pos = data.pos;
                 const projectFunInfo = await this.ctx.service.project.getFunRela(ctx.session.sessionProject.id);
-                const changes = await ctx.service.change.getValidChanges(ctx.tender, ctx.stage, data, projectFunInfo.minusNoValue && ctx.tender.info.fun_rela.stage_change.minusNoValue);
+                // const changes = await ctx.service.change.getValidChanges(ctx.tender, ctx.stage, data, projectFunInfo.minusNoValue && ctx.tender.info.fun_rela.stage_change.minusNoValue);
+                const changes = await ctx.service.change.getValidChanges(ctx.tender, ctx.stage, data, true);
                 const useChanges = ctx.stage.readOnly
                     ? await ctx.service.stageChange.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder, bills.id, pos ? pos.id : -1)
                     : await ctx.service.stageChange.getLastestStageData(ctx.tender.id, ctx.stage.id, bills.id, pos ? pos.id : -1);

+ 20 - 1
app/public/js/budget_list.js

@@ -32,7 +32,7 @@ $(document).ready(() => {
                 html.push('<td width="20%" class="in-' + node.tree_level + '">');
                 if (node.is_folder) {
                     if (node.children.length > 0) {
-                        html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
+                        html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" id="'+ node.id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
                     } else {
                         html.push('<i class="fa fa-folder-o"></i> ', node.name);
                     }
@@ -95,6 +95,25 @@ $(document).ready(() => {
         };
 
         Utils.reloadTable();
+
+        $('body').on('click', '.fold-switch', function() {
+            const id = this.getAttribute('id');
+            const node = budgetTree.getItems(id);
+            budgetTree.setExpanded(node, !node.expanded);
+            const posterity = budgetTree.getPosterity(node);
+            if (node.expanded) {
+                $(this).html(`<i class="fa fa-minus-square-o"></i>`);
+            } else {
+                $(this).html(`<i class="fa fa-plus-square-o"></i>`);
+            }
+            for (const p of posterity) {
+                if (p.visible) {
+                    $(`tr[tree_id=${p.id}]`).show();
+                } else {
+                    $(`tr[tree_id=${p.id}]`).hide();
+                }
+            }
+        });
         return { budgetTree, TableObj, ...Utils };
     })({
         treeSetting: { id: 'id', pid: 'tree_pid', level: 'tree_level', order: 'tree_order', rootId: '-1' },

+ 19 - 1
app/public/js/file_list.js

@@ -31,7 +31,7 @@ $(document).ready(() => {
                 html.push('<td width="20%" class="in-' + node.tree_level + '">');
                 if (node.is_folder) {
                     if (node.children.length > 0) {
-                        html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
+                        html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" id="'+ node.id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
                     } else {
                         html.push('<i class="fa fa-folder-o"></i> ', node.name);
                     }
@@ -83,6 +83,24 @@ $(document).ready(() => {
         };
 
         Utils.reloadTable();
+        $('body').on('click', '.fold-switch', function() {
+            const id = this.getAttribute('id');
+            const node = projectTree.getItems(id);
+            projectTree.setExpanded(node, !node.expanded);
+            const posterity = projectTree.getPosterity(node);
+            if (node.expanded) {
+                $(this).html(`<i class="fa fa-minus-square-o"></i>`);
+            } else {
+                $(this).html(`<i class="fa fa-plus-square-o"></i>`);
+            }
+            for (const p of posterity) {
+                if (p.visible) {
+                    $(`tr[tree_id=${p.id}]`).show();
+                } else {
+                    $(`tr[tree_id=${p.id}]`).hide();
+                }
+            }
+        });
         return { projectTree, TableObj, ...Utils };
     })({
         treeSetting: { id: 'id', pid: 'tree_pid', level: 'tree_level', order: 'tree_order', rootId: '-1' },

+ 19 - 1
app/public/js/sub_project.js

@@ -20,7 +20,7 @@ $(document).ready(function() {
                 html.push('<td width="20%" class="in-' + node.tree_level + '">');
                 if (node.is_folder) {
                     if (node.children.length > 0) {
-                        html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
+                        html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" id="'+ node.id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
                     } else {
                         html.push('<i class="fa fa-folder-o"></i> ', node.name);
                     }
@@ -183,6 +183,24 @@ $(document).ready(function() {
             $('#sm-management').attr('tree_id', treeId);
             $('#set-management').modal('show');
         });
+        $('body').on('click', '.fold-switch', function() {
+            const id = this.getAttribute('id');
+            const node = ProjectTree.getItems(id);
+            ProjectTree.setExpanded(node, !node.expanded);
+            const posterity = ProjectTree.getPosterity(node);
+            if (node.expanded) {
+                $(this).html(`<i class="fa fa-minus-square-o"></i>`);
+            } else {
+                $(this).html(`<i class="fa fa-plus-square-o"></i>`);
+            }
+            for (const p of posterity) {
+                if (p.visible) {
+                    $(`tr[tree_id=${p.id}]`).show();
+                } else {
+                    $(`tr[tree_id=${p.id}]`).hide();
+                }
+            }
+        });
         return { ProjectTree, TableObj, ...Utils };
     })({
         treeSetting: { id: 'id', pid: 'tree_pid', level: 'tree_level', order: 'tree_order', rootId: '-1' },

+ 1 - 1
app/service/ledger_revise.js

@@ -162,7 +162,7 @@ module.exports = app => {
                     status: audit.status.uncheck,
                 });
             }
-            if (auditors) await transaction.insert(this.ctx.service.reviseAudit.tableName, newAuditors);
+            if (newAuditors.length > 0) await transaction.insert(this.ctx.service.reviseAudit.tableName, newAuditors);
         }
 
         /**

+ 1 - 0
app/view/budget/list.ejs

@@ -23,6 +23,7 @@
     </div>
 </div>
 <script>
+    autoFlashHeight();
     const budgetList = JSON.parse(unescape('<%- escape(JSON.stringify(budgetList)) %>'));
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
 </script>

+ 1 - 0
app/view/file/index.ejs

@@ -23,6 +23,7 @@
     </div>
 </div>
 <script>
+    autoFlashHeight();
     const projectList = JSON.parse(unescape('<%- escape(JSON.stringify(projectList)) %>'));
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
 </script>

+ 1 - 0
app/view/sub_proj/index.ejs

@@ -29,6 +29,7 @@
     </div>
 </div>
 <script>
+    autoFlashHeight();
     const projectList = JSON.parse(unescape('<%- escape(JSON.stringify(projectList)) %>'));
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
 </script>