瀏覽代碼

台账修订,显示截止本期相关

MaiXinRong 2 月之前
父節點
當前提交
3469e3d3a6
共有 4 個文件被更改,包括 80 次插入6 次删除
  1. 11 1
      app/controller/revise_controller.js
  2. 13 1
      app/public/js/revise.js
  3. 54 2
      app/public/js/revise_history.js
  4. 2 2
      app/service/ledger_revise.js

+ 11 - 1
app/controller/revise_controller.js

@@ -419,13 +419,22 @@ module.exports = app => {
                         }
                     }
                 }
+                const stage = await ctx.service.stage.getFlowLatestStage(ctx.revise.tid, true);
+                const curBills = stage ? await ctx.service.stageBills.getLastestStageData2(ctx.tender.id, stage.id) : [];
+                const preBills = stage && stage.order > 0 ? await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, stage.order - 1) : [];
+                const curPos = stage ? await ctx.service.stagePos.getLastestStageData2(ctx.tender.id, stage.id) : [];
+                const prePos = stage && stage.order > 0 ? await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, stage.order - 1) : [];
                 // 结算状态
                 const settleStatusBills = ctx.revise.readySettle ? await ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: ctx.revise.readySettle.id }}): [];
                 this.ctx.helper.assignRelaData(reviseBills, [
+                    { data: curBills, fields: ['contract_qty'], prefix: '', relaId: 'lid' },
+                    { data: preBills, fields: ['contract_qty'], prefix: 'pre_', relaId: 'lid' },
                     { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
                 ]);
                 const settleStatusPos = ctx.revise.readySettle ? await ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: ctx.revise.readySettle.id }}) : [];
                 this.ctx.helper.assignRelaData(revisePos, [
+                    { data: curPos, fields: ['contract_qty'], prefix: '', relaId: 'lid' },
+                    { data: prePos, fields: ['contract_qty'], prefix: 'pre_', relaId: 'lid' },
                     { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
                 ]);
                 const ledgerTags = await this.ctx.service.ledgerTag.getDatas(ctx.tender.id);
@@ -962,7 +971,8 @@ module.exports = app => {
                     return revisePosData;
                 case 'stageBills':
                 case 'stagePos':
-                    if (!ctx.lastStage) ctx.lastStage = await this._getLastStage(ctx);
+                    if (!ctx.lastStage) ctx.lastStage = await ctx.service.stage.getFlowLatestStage(ctx.revise.tid, true);
+                    if (!ctx.lastStage) return [];
                     await this.ctx.service.stage.doCheckStage(ctx.lastStage);
                     if (filter === 'stageBills') {
                         return await this._loadLastStageBillsData(ctx);

+ 13 - 1
app/public/js/revise.js

@@ -61,6 +61,8 @@ $(document).ready(() => {
     sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(billsSpreadSetting);
 
+    billsSpreadSetting.cols.push({title: '截止本期合同计量|数量', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
+        {title: '|完成率(%)', colSpan: '1', rowSpan: '|1', field: 'end_percent', hAlign: 2, width: 80, readOnly: true, type: 'Number'});
     billsSpreadSetting.headColWidth = [50];
     billsSpreadSetting.rowHeader = [
         {
@@ -99,6 +101,8 @@ $(document).ready(() => {
     SpreadJsObj.initSheet(billsSheet, billsSpreadSetting);
     const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
     const posSheet = posSpread.getActiveSheet();
+    posSpreadSetting.cols.push({title: '截止本期合同计量|数量', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
+        {title: '|完成率(%)', colSpan: '1', rowSpan: '|1', field: 'end_percent', hAlign: 2, width: 80, readOnly: true, type: 'Number'});
     sjsSettingObj.setGridSelectStyle(posSpreadSetting);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(posSpreadSetting);
     SpreadJsObj.initSheet(posSheet, posSpreadSetting);
@@ -168,10 +172,18 @@ $(document).ready(() => {
     };
     treeSetting.calcFun = function (node) {
         node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
+        node.end_contract_qty = ZhCalc.add(node.contract_qty, node.pre_contract_qty);
+        node.end_percent = node.quantity ? ZhCalc.mul(ZhCalc.div(node.contract_qty, node.quantity, 4), 100, 2) : 0;
     };
     const billsTree = createNewPathTree('revise', treeSetting);
     // 初始化 计量单元
-    const pos = new PosData({ id: 'id', ledgerId: 'lid' });
+    const pos = new PosData({
+        id: 'id', ledgerId: 'lid',
+        calcFun: function(node) {
+            node.end_contract_qty = ZhCalc.add(node.contract_qty, node.pre_contract_qty);
+            node.end_percent = node.quantity ? ZhCalc.mul(ZhCalc.div(node.contract_qty, node.quantity, 4), 100, 2) : 0;
+        }
+    });
 
     const billsTag = $.billsTag({
         relaTree: billsTree,

+ 54 - 2
app/public/js/revise_history.js

@@ -15,12 +15,17 @@ $(document).ready(() => {
     // 初始化spread
     const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
     const billsSheet = billsSpread.getActiveSheet();
+
+    billsSpreadSetting.cols.push({title: '截止本期合同计量|数量', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
+        {title: '|完成率(%)', colSpan: '1', rowSpan: '|1', field: 'end_percent', hAlign: 2, width: 80, readOnly: true, type: 'Number'});
     sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(billsSpreadSetting);
     sjsSettingObj.setNodeTypeCol(billsSpreadSetting.cols, [{field: 'node_type'}]);
     SpreadJsObj.initSheet(billsSheet, billsSpreadSetting);
     const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
     const posSheet = posSpread.getActiveSheet();
+    posSpreadSetting.cols.push({title: '截止本期合同计量|数量', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
+        {title: '|完成率(%)', colSpan: '1', rowSpan: '|1', field: 'end_percent', hAlign: 2, width: 80, readOnly: true, type: 'Number'});
     sjsSettingObj.setGridSelectStyle(posSpreadSetting);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(posSpreadSetting);
     SpreadJsObj.initSheet(posSheet, posSpreadSetting);
@@ -62,10 +67,18 @@ $(document).ready(() => {
     }
     treeSetting.calcFun = function (node) {
         node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
+        node.end_contract_qty = ZhCalc.add(node.contract_qty, node.pre_contract_qty);
+        node.end_percent = node.quantity ? ZhCalc.mul(ZhCalc.div(node.contract_qty, node.quantity, 4), 100, 2) : 0;
     };
     const billsTree = createNewPathTree('revise', treeSetting);
     // 初始化 部位明细
-    const pos = new PosData({ id: 'id', ledgerId: 'lid' });
+    const pos = new PosData({
+        id: 'id', ledgerId: 'lid',
+        calcFun: function(node) {
+            node.end_contract_qty = ZhCalc.add(node.contract_qty, node.pre_contract_qty);
+            node.end_percent = node.quantity ? ZhCalc.mul(ZhCalc.div(node.contract_qty, node.quantity, 4), 100, 2) : 0;
+        }
+    });
 
     const billsTreeSpreadObj = {
         /**
@@ -157,8 +170,47 @@ $(document).ready(() => {
             SpreadJsObj.resetFieldReadOnly(posSheet);
         },
     };
+    const assignRelaData = function(main, rela, mainKey = 'id', clear = false) {
+        const index = {},
+            indexPre = 'id_';
+        const loadFields = function(datas, fields, prefix, relaId) {
+            for (const d of datas) {
+                const key = indexPre + d[relaId];
+                const m = index[key];
+                if (m) {
+                    for (const f of fields) {
+                        if (d[f] !== undefined) {
+                            m[prefix + f] = d[f];
+                        }
+                    }
+                }
+            }
+        };
+        for (const m of main) {
+            index[indexPre + m[mainKey]] = m;
+            for (const r of rela) {
+                if (r.defaultData) _.assignIn(m, r.defaultData);
+            }
+            if (clear) {
+                rela.forEach(r => {
+                    r.fields.forEach(f => {
+                        delete m[r.prefix + f];
+                    });
+                })
+            }
+        }
+        for (const r of rela) {
+            loadFields(r.data, r.fields, r.prefix, r.relaId);
+        }
+    }
     // 加载清单&计量单元数据
-    postData('load', {filter:'reviseBills;revisePos;att'}, function (result) {
+    postData('load', {filter:'reviseBills;revisePos;att;stageBills;stagePos'}, function (result) {
+        assignRelaData(result.reviseBills, [
+            { data: result.stageBills, fields: ['contract_qty', 'pre_contract_qty'], prefix: '', relaId: 'lid' },
+        ]);
+        assignRelaData(result.revisePos, [
+            { data: result.stagePos, fields: ['contract_qty', 'pre_contract_qty'], prefix: '', relaId: 'lid' },
+        ]);
         billsTree.loadDatas(result.reviseBills);
         treeCalc.calculateAll(billsTree);
         SpreadJsObj.loadSheetData(billsSheet, SpreadJsObj.DataType.Tree, billsTree);

+ 2 - 2
app/service/ledger_revise.js

@@ -132,11 +132,11 @@ module.exports = app => {
             const sql = 'Insert Into ' + this.ctx.service.revisePos.tableName +
                 '  (id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, ex_qty1, crid, ccid, in_time, porder, position,' +
-                '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty, ex_qty1,' +
+                '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
                 '     ex_memo1, ex_memo2, ex_memo3)' +
                 '  Select id, tid, lid, name, drawing_code, quantity, add_stage, add_stage_order, add_times, add_user,' +
                 '     sgfh_qty, sjcl_qty, qtcl_qty, ex_qty1, crid, ccid, in_time, porder, position,' +
-                '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty, ex_qty1' +
+                '     sgfh_expr, sjcl_expr, qtcl_expr, real_qty,' +
                 '     ex_memo1, ex_memo2, ex_memo3' +
                 '  From ' + this.ctx.service.pos.tableName +
                 '  Where `tid` = ?';