Преглед изворни кода

中间计量,项目节明细,部位明细

MaiXinRong пре 6 година
родитељ
комит
c0921eaa7f
3 измењених фајлова са 60 додато и 2 уклоњено
  1. 3 0
      app/controller/stage_controller.js
  2. 23 1
      app/public/js/stage_detail.js
  3. 34 1
      app/public/js/stage_im.js

+ 3 - 0
app/controller/stage_controller.js

@@ -279,11 +279,14 @@ module.exports = app => {
                 } else if (data.loadType === 'all') {
                     const result = {};
                     result.ledger = await ctx.service.ledger.getDataByTenderId(ctx.tender.id, -1);
+                    result.pos = await ctx.service.pos.getPosData({tid: ctx.tender.id});
                     if (ctx.stage.readOnly) {
                         result.curStage = await ctx.service.stageBills.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
+                        result.curPosStage = await ctx.service.stagePos.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
                         result.stageDetail = await ctx.service.stageDetail.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder);
                     } else {
                         result.curStage = await ctx.service.stageBills.getLastestStageData(ctx.tender.id, ctx.stage.id);
+                        result.curPosStage = await ctx.service.stagePos.getLastestStageData(ctx.tender.id, ctx.stage.id);
                         result.stageDetail = await ctx.service.stageDetail.getLastestStageData(ctx.tender.id, ctx.stage.id);
                     }
                     ctx.body = { err: 0, msg: '', data: result };

+ 23 - 1
app/public/js/stage_detail.js

@@ -38,6 +38,23 @@ $(document).ready(() => {
         }
     }
 
+    function loadPosData() {
+        const data = getSelectDetailData();
+        const rowIndex = parseInt($('#leaf-xmj-list').attr('rowIndex'));
+        const leafXmj = data.leafXmjs[rowIndex];
+        const html = [];
+        if (leafXmj) {
+            for (const p of leafXmj.pos) {
+                html.push('<tr>');
+                html.push('<td>', p.name, '</td>');
+                html.push('<td>', p.quantity, '</td>');
+                html.push('<td>', p.jl, '</td>');
+                html.push('</tr>');
+            }
+        }
+        $('#pos-list').html(html.join(''));
+    }
+
     function loadLeafXmjsData() {
         const data = getSelectDetailData();
         const html = [];
@@ -49,6 +66,8 @@ $(document).ready(() => {
             html.push('</tr>');
         }
         $('#leaf-xmj-list').html(html.join(''));
+        $('#leaf-xmj-list').attr('rowIndex', 0);
+        loadPosData();
     }
 
     function reBuildImData() {
@@ -96,10 +115,13 @@ $(document).ready(() => {
             reLoadDetailData();
             loadLeafXmjsData();
         });
+        $('tr', '#leaf-xmj-list').click(function () {
+            loadPosData();
+        });
     }
 
     postData(window.location.pathname + '/load', { loadType: 'all' }, function (data) {
-        stageIm.loadData(data.ledger, data.curStage, data.stageDetail);
+        stageIm.loadData(data.ledger, data.curStage, data.pos, data.curPosStage, data.stageDetail);
         reBuildImData();
     });
 

+ 34 - 1
app/public/js/stage_im.js

@@ -40,6 +40,18 @@ const stageIm = (function () {
         }
     };
     const gsTree = createNewPathTree('stage', gsTreeSetting);
+    const gsPosSetting = {
+        id: 'id', ledgerId: 'lid',
+        updateFields: ['contract_qty', 'qc_qty', 'postil'],
+    };
+    gsPosSetting.calcFun = function (pos) {
+        pos.pre_gather_qty = _.add(pos.pre_contract_qty, pos.pre_qc_qty);
+        pos.gather_qty = _.add(pos.contract_qty, pos.qc_qty);
+        pos.end_contract_qty = _.add(pos.pre_contract_qty, pos.contract_qty);
+        pos.end_qc_qty = _.add(pos.pre_qc_qty, pos.qc_qty);
+        pos.end_gather_qty = _.add(pos.pre_gather_qty, pos.gather_qty);
+    };
+    const gsPos = new StagePosData(gsPosSetting);
 
     function init (s, i) {
         stage = s;
@@ -54,13 +66,17 @@ const stageIm = (function () {
 
     }
 
-    function loadData (ledger, curStage, stageDetail) {
+    function loadData (ledger, curStage, pos, curPosStage, stageDetail) {
         gsTree.loadDatas(ledger);
 
         gsTree.loadCurStageData(curStage);
         // 根据设置 计算 台账树结构
         treeCalc.calculateAll(gsTree);
 
+        gsPos.loadDatas(pos);
+        gsPos.loadCurStageData(curPosStage);
+        gsPos.calculateAll();
+
         initCheck();
         details = stageDetail;
     }
@@ -152,6 +168,22 @@ const stageIm = (function () {
         }
     }
 
+    function generatePosData(node, lx) {
+        if (!lx.pos) {
+            lx.pos = [];
+        }
+        const posRange = gsPos.getLedgerPos(node.id);
+        for (const p of posRange) {
+            if (!p.gather_qty || checkZero(p.gather_qty)) { continue; }
+            let lp = _.find(lx.pos, {name: p.name});
+            if (!lp) {
+                lp = {name: p.name, qty: p.quantity};
+                lx.pos.push(lp);
+            }
+            lp.jl = _.round(_.add(lp.jl, p.gather_qty), 6);
+        }
+    }
+
     /**
      * 生成所属项目节数据(取最底层项目节)
      * @param node - 生成数据基于的台账节点
@@ -172,6 +204,7 @@ const stageIm = (function () {
             im.leafXmjs.push(lx);
         }
         lx.jl = _.round(_.add(lx.jl, node[jlField]), 6);
+        generatePosData(node, lx);
     }
 
     /**