浏览代码

暂存计量,导入数据优化

MaiXinRong 10 月之前
父节点
当前提交
143cfa2d27
共有 3 个文件被更改,包括 15 次插入5 次删除
  1. 1 1
      app/public/js/stage.js
  2. 2 2
      app/public/js/stage_im.js
  3. 12 2
      app/service/stage_stash.js

+ 1 - 1
app/public/js/stage.js

@@ -2415,7 +2415,7 @@ $(document).ready(() => {
             exprCacheKey: ['bqhtje'],
             exprCacheKey: ['bqhtje'],
         });
         });
         // 加载中间计量
         // 加载中间计量
-        stageIm.init(tenderInfo, stage, imType, tenderInfo.decimal, stage.assist ? stage.assist.ass_ledger_id : '');
+        stageIm.init(tenderInfo, stage, imType, tenderInfo.decimal);
         stageIm.loadData(result.ledgerData, result.posData, result.detailData, result.stageChange, result.import_change, result.detailAtt);
         stageIm.loadData(result.ledgerData, result.posData, result.detailData, result.stageChange, result.import_change, result.detailAtt);
         if (stage.assist) {
         if (stage.assist) {
             stageIm.loadFilter(stage.assist.ass_ledger_id);
             stageIm.loadFilter(stage.assist.ass_ledger_id);

+ 2 - 2
app/public/js/stage_im.js

@@ -93,7 +93,7 @@ const stageIm = (function () {
     }
     }
 
 
     function loadFilter(filter) {
     function loadFilter(filter) {
-        gsTree.loadFilter(filter);
+        if (filter) gsTree.loadFilter(filter);
     }
     }
 
 
     function loadData4Rela(ledger, pos, stageDetail, stageChange, stageDetailAtt) {
     function loadData4Rela(ledger, pos, stageDetail, stageChange, stageDetailAtt) {
@@ -947,7 +947,7 @@ const stageIm = (function () {
     function recursiveBuildImData (nodes) {
     function recursiveBuildImData (nodes) {
         if (!nodes || nodes.length === 0) { return; }
         if (!nodes || nodes.length === 0) { return; }
         for (const node of nodes) {
         for (const node of nodes) {
-            if (node.filter !== undefined && node.filter) continue;
+            if (node.filter) continue;
 
 
             if (gsTree.isLeafXmj(node) || ((stage.im_type !== imType.bw.value && stage.im_type !== imType.bb.value) && stage.im_gather && node.check)) {
             if (gsTree.isLeafXmj(node) || ((stage.im_type !== imType.bw.value && stage.im_type !== imType.bb.value) && stage.im_gather && node.check)) {
                 if (stage.im_type === imType.tz.value) {
                 if (stage.im_type === imType.tz.value) {

+ 12 - 2
app/service/stage_stash.js

@@ -242,9 +242,19 @@ module.exports = app => {
                 { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
                 { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
             ]);
             ]);
 
 
+            const billsIndex = {};
+            for (const b of bills) {
+                billsIndex[b.id] = b;
+            }
+            for (const p of pos) {
+                if (!billsIndex[p.lid]) continue;
+                if (!billsIndex[p.lid].pos) billsIndex[p.lid].pos = [];
+                billsIndex[p.lid].pos.push(p);
+            }
+
             const said = this.ctx.session.sessionUser.accountId;
             const said = this.ctx.session.sessionUser.accountId;
             for (const d of data) {
             for (const d of data) {
-                const b = bills.find(x => { return x.id === d.lid });
+                const b = billsIndex[d.lid]; //bills.find(x => { return x.id === d.lid });
                 if (!b || b.settle_status === settleStatus.finish) continue;
                 if (!b || b.settle_status === settleStatus.finish) continue;
 
 
                 const nbs = {
                 const nbs = {
@@ -254,7 +264,7 @@ module.exports = app => {
                 };
                 };
                 if (d.pos) {
                 if (d.pos) {
                     for (const bp of d.pos) {
                     for (const bp of d.pos) {
-                        const p = pos.find(x => { return x.id === bp.pid});
+                        const p = b.pos.find(x => { return x.id === bp.pid});
                         if (!p || p.settle_status === settleStatus.finish) continue;
                         if (!p || p.settle_status === settleStatus.finish) continue;
 
 
                         const nps = { tid: stage.tid, sid: stage.id, said, lid: b.id, pid: p.id, times: 1, order: 0 };
                         const nps = { tid: stage.tid, sid: stage.id, said, lid: b.id, pid: p.id, times: 1, order: 0 };