소스 검색

调整报表管理信息,保留最后一次用户修改痕迹

Tony Kang 10 달 전
부모
커밋
1a4d38bed9
2개의 변경된 파일10개의 추가작업 그리고 8개의 파일을 삭제
  1. 5 4
      app/controller/report_controller.js
  2. 5 4
      app/service/rpt_tree_node_cust.js

+ 5 - 4
app/controller/report_controller.js

@@ -77,11 +77,11 @@ module.exports = app => {
                 if (custFolders2.length > 0) {
                     rst.push(custFolders2[0]);
                 } else {
-                    await ctx.service.rptTreeNodeCust.createCustNodeByTenderId(tender_id, custFolders1[0].rpt_tpl_items);
+                    await ctx.service.rptTreeNodeCust.createCustNodeByTenderId(acc_id, tender_id, custFolders1[0].rpt_tpl_items);
                     rst.push(custFolders1[0]); // 直接拿原先的用了
                 }
-                // 考虑不同的用户会有同一个标段,需要不断地删除用户的自定义设置
-                await ctx.service.rptTreeNodeCust.removeCustFolder(custFolders1[0].id);
+                // 现在会记录最后一个修改用户的id,所以不能直接删除,需要先判断
+                if (custFolders1[0].id !== custFolders2[0].id) await ctx.service.rptTreeNodeCust.removeCustFolder(custFolders1[0].id);
             } else if (custFolders2.length > 0) {
                 rst.push(custFolders2[0]);
             }
@@ -1617,8 +1617,9 @@ module.exports = app => {
         async updateCustNode(ctx) {
             const params = JSON.parse(ctx.request.body.params);
             // console.log(params);
+            const custId = this.ctx.session.sessionUser.accountId;
             const newNodeItems = JSON.stringify(params.nodeItems);
-            const rst = await ctx.service.rptTreeNodeCust.updateCustNodeByTenderId(params.tender_id, newNodeItems);
+            const rst = await ctx.service.rptTreeNodeCust.updateCustNodeByTenderId(custId, params.tender_id, newNodeItems);
             // console.log(rst);
             ctx.body = { data: rst };
             // ctx.body = { data: { msg: 'test the network' } };

+ 5 - 4
app/service/rpt_tree_node_cust.js

@@ -87,12 +87,12 @@ module.exports = app => {
             }
         }
 
-        async createCustNodeByTenderId(tender_id, newRptItems) {
+        async createCustNodeByTenderId(cust_acc_id, tender_id, newRptItems) {
             let rst = null;
             this.transaction = await this.db.beginTransaction();
             try {
                 const data = {
-                    cust_acc_id: -1,
+                    cust_acc_id,
                     tender_id,
                     rpt_tpl_items: newRptItems,
                 };
@@ -109,7 +109,7 @@ module.exports = app => {
             }
         }
 
-        async updateCustNodeByTenderId(tender_id, newNodeItems) {
+        async updateCustNodeByTenderId(cust_acc_id, tender_id, newNodeItems) {
             let rst = null;
             try {
                 const custNode = await this.getCustFolderByTenderId(tender_id);
@@ -118,10 +118,11 @@ module.exports = app => {
                 if (custNode.length > 0) {
                     this.transaction = await this.db.beginTransaction();
                     custNode[0].rpt_tpl_items = newNodeItems;
+                    custNode[0].cust_acc_id = cust_acc_id;
                     rst = await this.transaction.update(this.tableName, custNode[0]);
                     this.transaction.commit();
                 } else {
-                    rst = await this.createCustNodeByTenderId(tender_id, newNodeItems);
+                    rst = await this.createCustNodeByTenderId(cust_acc_id, tender_id, newNodeItems);
                 }
             } catch (ex) {
                 console.log(ex);