浏览代码

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang 5 年之前
父节点
当前提交
86a785902b

+ 4 - 0
app/controller/stage_controller.js

@@ -723,6 +723,7 @@ module.exports = app => {
                         check_calc: false,
                         contract_tp: payCalculator.cur.contract_tp, qc_tp: payCalculator.cur.qc_tp,
                         yf_tp: payCalculator.yf.tp,
+                        sf_tp: payCalculator.sf.tp
                     }, {id: this.ctx.stage.id});
                 }
                 await this.layout('stage/pay.ejs', renderData, 'stage/pay_modal.ejs');
@@ -762,6 +763,7 @@ module.exports = app => {
                             check_calc: false,
                             contract_tp: payCalculator.cur.contract_tp, qc_tp: payCalculator.cur.qc_tp,
                             yf_tp: payCalculator.yf.tp,
+                            sf_tp: payCalculator.sf.tp
                         }, {id: this.ctx.stage.id});
 
                         break;
@@ -778,6 +780,7 @@ module.exports = app => {
                                 check_calc: false,
                                 contract_tp: payCalculator.cur.contract_tp, qc_tp: payCalculator.cur.qc_tp,
                                 yf_tp: payCalculator.yf.tp,
+                                sf_tp: payCalculator.sf.tp
                             }, {id: this.ctx.stage.id});
                         } else {
                             if (data.updateData instanceof Array) {
@@ -795,6 +798,7 @@ module.exports = app => {
                             check_calc: false,
                             contract_tp: payCalculator.cur.contract_tp, qc_tp: payCalculator.cur.qc_tp,
                             yf_tp: payCalculator.yf.tp,
+                            sf_tp: payCalculator.sf.tp
                         }, {id: this.ctx.stage.id});
                         break;
                 }

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

@@ -2251,8 +2251,8 @@ $(document).ready(() => {
                 check('xm', $('#xm'), data, updateData);
                 check('position', $('#position'), data, updateData);
                 check('jldy', $('#jldy'), data, updateData);
-                check('drawing_code', $('#drawing_code'), data, updateData);
-                check('calc-memo', $('#calc-memo'), data, updateData);
+                check('drawing_code', $('#drawing-code'), data, updateData);
+                check('calc_memo', $('#calc-memo'), data, updateData);
                 updateData.custom_define = updateData.custom_define.join(',');
                 // updateData.bw = $('#bw-name').val();
                 // updateData.peg = $('#peg').val();

+ 16 - 2
app/service/stage.js

@@ -176,7 +176,9 @@ module.exports = app => {
                     const tpData = await this.ctx.service.stageBills.getSumTotalPrice(stage);
                     stage.contract_tp = tpData.contract_tp;
                     stage.qc_tp = tpData.qc_tp;
-                    stage.yf_tp = await this.ctx.service.stagePay.getYfTotalPrice(stage);
+                    const tp = await this.ctx.service.stagePay.getSpecialTotalPrice(stage);
+                    stage.yf_tp = tp.yf;
+                    stage.sf_tp = tp.sf;
                 }
             }
         }
@@ -213,11 +215,23 @@ module.exports = app => {
                     const tpData = await this.ctx.service.stageBills.getSumTotalPrice(stage);
                     stage.contract_tp = tpData.contract_tp;
                     stage.qc_tp = tpData.qc_tp;
-                    stage.yf_tp = await this.ctx.service.stagePay.getYfTotalPrice(stage);
+                    const tp = await this.ctx.service.stagePay.getSpecialTotalPrice(stage);
+                    stage.yf_tp = tp.yf;
+                    stage.sf_tp = tp.sf;
                     stage.tp = this.ctx.helper.add(stage.contract_tp, stage.qc_tp);
                     stage.end_tp = this.ctx.helper.add(stage.pre_tp, stage.tp);
                 }
             }
+            for (const s of stages) {
+                if (s.yf_tp && s.sf_tp === 0) {
+                    const sf = await this.ctx.service.stagePay.getHistorySf(s);
+                    if (sf) {
+                        await this.ctx.service.stage.update({ sf_tp: sf.tp, pre_sf_tp: sf.pre_tp}, {id: s.id});
+                    }
+                    s. sf_tp = sf.tp;
+
+                }
+            }
             return stages;
         }
 

+ 9 - 4
app/service/stage_audit.js

@@ -218,7 +218,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, {id: audit.id, status: auditConst.status.checking, begin_time: new Date()});
                 // 计算原报最终数据
-                const yfPay = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
+                const [yfPay, sfPay] = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 // 复制一份下一审核人数据
                 await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, 1, transaction);
                 await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
@@ -231,6 +231,7 @@ module.exports = app => {
                     contract_tp: tpData.contract_tp,
                     qc_tp: tpData.qc_tp,
                     yf_tp: yfPay.tp,
+                    sf_tp: sfPay.tp,
                     cache_time_r: this.ctx.stage.cache_time_l,
                 });
 
@@ -274,7 +275,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, {id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time});
                 // 计算并合同支付最终数据
-                const yfPay = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
+                const [yfPay, sfPay] = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 // 无下一审核人表示,审核结束
                 if (nextAudit) {
                     // 复制一份下一审核人数据
@@ -290,6 +291,7 @@ module.exports = app => {
                         contract_tp: tpData.contract_tp,
                         qc_tp: tpData.qc_tp,
                         yf_tp: yfPay.tp,
+                        sf_tp: sfPay.tp,
                         cache_time_r: this.ctx.stage.cache_time_l,
                     });
 
@@ -323,6 +325,7 @@ module.exports = app => {
                         contract_tp: tpData.contract_tp,
                         qc_tp: tpData.qc_tp,
                         yf_tp: yfPay.tp,
+                        sf_tp: sfPay.tp,
                         cache_time_r: this.ctx.stage.cache_time_l,
                     });
 
@@ -385,7 +388,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 计算并合同支付最终数据
-                const yfPay = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
+                const [yfPay, sfPay] = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 await transaction.update(this.tableName, {id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time});
                 // 同步 期信息
                 await transaction.update(this.ctx.service.stage.tableName, {
@@ -394,6 +397,7 @@ module.exports = app => {
                     qc_tp: tpData.qc_tp,
                     times: times + 1,
                     yf_tp: yfPay.tp,
+                    sf_tp: sfPay.tp,
                     cache_time_r: this.ctx.stage.cache_time_l,
                 });
                 // 拷贝新一次审核流程列表
@@ -461,7 +465,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 计算并合同支付最终数据
-                const yfPay = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
+                const [yfPay, sfPay] = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 // 同步 期信息
                 await transaction.update(this.ctx.service.stage.tableName, {
                     id: stageId,
@@ -469,6 +473,7 @@ module.exports = app => {
                     qc_tp: tpData.qc_tp,
                     times: times,
                     yf_tp: yfPay.tp,
+                    sf_tp: sfPay.tp,
                     cache_time_r: this.ctx.stage.cache_time_l,
                 });
                 await transaction.update(this.tableName, {id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time});

+ 12 - 3
app/service/stage_pay.js

@@ -244,10 +244,11 @@ module.exports = app => {
                 await transaction.updateRows(this.ctx.service.pay.tableName, srUpdate);
             }
             const yf = this._.find(stagePays, {ptype: payConst.payType.yf});
-            return yf;
+            const sf = this._.find(stagePays, {ptype: payConst.payType.sf});
+            return [yf, sf];
         }
 
-        async getYfTotalPrice(stage) {
+        async getSpecialTotalPrice(stage) {
             if (!stage) throw '计算数据错误';
             const stagePays = await this.getStagePays(stage);
             const PayCalculator = require('../lib/pay_calc');
@@ -255,7 +256,15 @@ module.exports = app => {
             const payCalculator = new PayCalculator(this.ctx, stage, tenderInfo);
             await payCalculator.calculateAll(stagePays);
             const yf = this._.find(stagePays, {ptype: payConst.payType.yf});
-            return yf ? yf.tp : 0;
+            const sf = this._.find(stagePays, {ptype: payConst.payType.sf});
+            return { yf: yf ? yf.tp : 0, sf: sf ? sf.tp : 0 };
+        }
+
+        async getHistorySf(stage) {
+            if (!stage) return 0;
+            const stagePays = await this.getStageLastestPays(stage.id);
+            const sf = this._.find(stagePays, {ptype: payConst.payType.sf});
+            return sf;
         }
 
         /**

+ 4 - 0
app/view/measure/stage.ejs

@@ -28,6 +28,8 @@
                         <th class="text-center">本期完成计量</th>
                         <th class="text-center">截止上期完成计量</th>
                         <th class="text-center">截止本期完成计量</th>
+                        <th class="text-center">本期应付</th>
+                        <th class="text-center">本期实付</th>
                         <th class="text-center">审批进度</th>
                         <th class="text-center">操作</th>
                     </tr>
@@ -48,6 +50,8 @@
                         <td class="text-right"><%- (s.tp ? s.tp : '')%></td>
                         <td class="text-right"><%- (s.pre_tp ? s.pre_tp : '')%></td>
                         <td class="text-right"><%- (s.end_tp ? s.end_tp : '')%></td>
+                        <td class="text-right"><%- (s.yf_tp ? s.yf_tp : '') %></td>
+                        <td class="text-right"><%- (s.sf_tp ? s.sf_tp : '') %></td>
                         <td class="<%- auditConst.auditProgressClass[s.status] %>">
                             <% if (s.curAuditor) { %>
                             <a href="#sp-list" data-toggle="modal" data-target="#sp-list" s-order="<%- s.order %>"><%- s.curAuditor.name %><%if (s.curAuditor.role !== '' && s.curAuditor.role !== null) { %>-<%- s.curAuditor.role %><% } %></a>