ソースを参照

1. 标段列表,金额概况页面
2. 标段列表,计量进度页面

MaiXinRong 5 年 前
コミット
e44136758c

+ 7 - 0
app/base/base_bills_service.js

@@ -422,6 +422,13 @@ class BaseBillsSerivce extends TreeService {
         return { update: await this.getDataById(ids) };
     }
 
+    // 统计方法
+    async addUp(condition) {
+        const sql = 'SELECT Sum(total_price) As total_price, Sum(deal_tp) As deal_tp' +
+            '  FROM ' + this.tableName + this.ctx.helper.whereSql(condition);
+        const result = await this.db.queryOne(sql);
+        return result;
+    }
 }
 
 module.exports = BaseBillsSerivce;

+ 1 - 1
app/const/audit.js

@@ -89,7 +89,7 @@ const stage = (function () {
         checked: 3, // 审批通过
         checkNo: 4, // 审批退回原报
         checkNoPre: 5, // 审批退回上一人
-        checkAgain: 6, // 重新审批
+        checkAgain: 6, // 重新审批 // 该状态仅可用于,终审退回时,修改原终审的审批状态,并同时新增一条新的终审审批中记录
     };
 
     // 流程状态提示

+ 7 - 12
app/controller/stage_controller.js

@@ -569,14 +569,7 @@ module.exports = app => {
                     }
                 }
                 renderData.dealPay = dealPay;
-                // if (dealPay && dealPay.length > 0) {
-                //     renderData.dealPay = dealPay;
-                // } else {
-                //     await ctx.service.pay.addDefaultPayData(this.ctx.tender.id);
-                //     await ctx.service.stagePay.addInitialStageData(ctx.stage);
-                //     renderData.dealPay = await ctx.service.stagePay.getStagePays(ctx.stage);
-                // }
-                renderData.calcBase = await ctx.service.stage.getStagePayCalcBase();
+                renderData.calcBase = await ctx.service.stage.getStagePayCalcBase(ctx.stage, ctx.tender.info);
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.stage.pay);
                 renderData.whiteList = this.ctx.app.config.multipart.whitelist;
 
@@ -585,9 +578,11 @@ module.exports = app => {
                     (ctx.stage.status === auditConst.status.checkNoPre && ctx.session.sessionUser.accountId === ctx.stage.curAuditor.aid) ||
                     (ctx.stage.status === auditConst.status.checking && ctx.stage.curAuditor && ctx.stage.curAuditor.aid === ctx.session.sessionUser.accountId);
 
-                // 计算 本期金额
-                const payCalculator = new PayCalculator(this.ctx, this.ctx.tender.info.decimal);
-                await payCalculator.calculateAll(renderData.dealPay);
+                if (!stage.readOnly) {
+                    // 计算 本期金额
+                    const payCalculator = new PayCalculator(ctx, ctx.stage, ctx.tender.info);
+                    await payCalculator.calculateAll(renderData.dealPay);
+                }
                 await this.layout('stage/pay.ejs', renderData, 'stage/pay_modal.ejs');
             } catch (err) {
                 console.log(err);
@@ -615,7 +610,7 @@ module.exports = app => {
 
                 const data = JSON.parse(ctx.request.body.data);
                 const responseData = { err: 0, msg: '', data: {}, };
-                const payCalculator = new PayCalculator(this.ctx, this.ctx.tender.info.decimal);
+                const payCalculator = new PayCalculator(ctx, ctx.stage, ctx.tender.info);
                 switch (data.type) {
                     case 'add':
                         responseData.data = await ctx.service.pay.add();

+ 41 - 10
app/controller/tender_controller.js

@@ -31,16 +31,26 @@ module.exports = app => {
             ctx.showTitle = true;
         }
 
-        async _list(view, setting, modal = '', listStatus = '') {
+        async _list(view, modal = '') {
             try {
                 // 获取用户新建标段权利
                 const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
                 const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
 
-                const tenderList = await this.ctx.service.tender.getList(listStatus, userPermission);
+                const tenderList = await this.ctx.service.tender.getList('', userPermission);
                 for (const t of tenderList) {
-                    t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
-                    t.completeStage = await this.ctx.service.stage.getLastestCompleteStage(t.id);
+                    if (t.user_id === this.ctx.session.sessionUser.accountId && (
+                        t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck)) {
+                        const sum = await this.ctx.service.ledger.addUp({tender_id: t.id, is_leaf: true});
+                        t.total_price = sum.total_price;
+                        t.deal_tp = sum.deal_tp;
+                    }
+                    if (t.ledger_status === auditConst.ledger.status.checked) {
+                        t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
+                        if (t.lastStage) {
+                            await this.ctx.service.stage.checkStageGatherData(t.lastStage);
+                        }
+                    }
                 }
                 const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 const valuations = await this.ctx.service.valuation.getProjectValidValuation(this.ctx.session.sessionProject.id);
@@ -49,7 +59,6 @@ module.exports = app => {
                     tenderConst,
                     settingConst,
                     categoryData,
-                    tableColSetting: setting,
                     measureType: tenderConst.measureType,
                     jsFiles: this.app.jsFiles.common.concat(this.jsFiles),
                     auditConst,
@@ -58,6 +67,7 @@ module.exports = app => {
                 };
                 await this.layout(view, renderData, modal);
             } catch (err) {
+                console.log(err);
                 this.log(err);
                 this.ctx.redirect('/dashboard');
             }
@@ -71,7 +81,7 @@ module.exports = app => {
          */
         async listInfo(ctx) {
             this.jsFiles = this.app.jsFiles.tender.list;
-            await this._list('tender/index.ejs', tenderConst.infoTableCol, 'tender/modal.ejs');
+            await this._list('tender/index.ejs', 'tender/modal.ejs');
         }
 
         /**
@@ -82,7 +92,7 @@ module.exports = app => {
          */
         async listProgress(ctx) {
             this.jsFiles = this.app.jsFiles.tender.progress;
-            await this._list('tender/progress.ejs', tenderConst.progressTableCol, 'tender/modal.ejs');
+            await this._list('tender/progress.ejs', 'tender/modal.ejs');
         }
 
         /**
@@ -97,10 +107,31 @@ module.exports = app => {
             const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
             const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
             if (userPermission !== null && userPermission.tender !== undefined && userPermission.tender.indexOf('1') !== -1) {
-                this.jsFiles = this.app.jsFiles.tender.manage;
-                await this._list('tender/manage.ejs', tenderConst.manageTableCol, 'tender/manage_modal.ejs', 'manage');
+                // 获取用户新建标段权利
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
+
+                const tenderList = await this.ctx.service.tender.getList('manage', userPermission);
+                for (const t of tenderList) {
+                    t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
+                    t.completeStage = await this.ctx.service.stage.getLastestCompleteStage(t.id);
+                }
+                const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
+                const valuations = await this.ctx.service.valuation.getProjectValidValuation(this.ctx.session.sessionProject.id);
+                const renderData = {
+                    tenderList,
+                    tenderConst,
+                    settingConst,
+                    categoryData,
+                    measureType: tenderConst.measureType,
+                    jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.tender.manage),
+                    auditConst,
+                    userPermission,
+                    valuations,
+                };
+                await this.layout('tender/manage.ejs', renderData, 'tender/manage_modal.ejs');
             } else {
-                this.ctx.redirect('/dashboard');
+                this.ctx.redirect(ctx.request.header.referer);
             }
         }
 

+ 10 - 10
app/lib/pay_calc.js

@@ -14,10 +14,12 @@ const payType = PayConst.payType;
 const deadlineType = PayConst.deadlineType;
 
 class PayCalculate {
-    constructor (ctx, decimal) {
+    constructor (ctx, stage, tenderInfo) {
         this.ctx = ctx;
+        this.stage = stage;
         this.percentReg = /[0-9]+%/g;
-        this.decimal = decimal.pay ? decimal.payTp : decimal.tp;
+        this.tenderInfo = tenderInfo;
+        this.decimal = tenderInfo.decimal.pay ? tenderInfo.decimal.payTp : tenderInfo.decimal.tp;
     }
 
     /**
@@ -26,7 +28,7 @@ class PayCalculate {
      */
     async getCalcBase () {
         if (this.bases) { return; }
-        const bases = await this.ctx.service.stage.getStagePayCalcBase();
+        const bases = await this.ctx.service.stage.getStagePayCalcBase(this.stage, this.tenderInfo);
         this.bases = bases.sort(function (a, b) {
             return a.sort - b.sort;
             // if (a && b) {
@@ -91,10 +93,10 @@ class PayCalculate {
      */
     async calculateStartRangePrice (pays) {
         await this.getCalcBase();
-        const order = this.ctx.stage.curAuditor ? this.ctx.stage.curAuditor.order : 0;
+        const order = this.stage.curOrder;
         for (const p of pays) {
             // 非本期,本次添加的合同支付项,不允许计算,其中默认添加的合同支付项,归属于第一期原报
-            if (p.csorder === this.ctx.stage.order || (p.csorder === 0 || this.ctx.stage.order === 1)) {
+            if (p.csorder === this.stage.order || (p.csorder === 0 || this.stage.order === 1)) {
                 if (p.csaorder === order) {
                     if (!p.sprice && p.sexpr && p.sexpr !== '') {
                         p.sprice = this.ctx.helper.round(this.calculateExpr(p.sexpr), this.decimal);
@@ -113,7 +115,7 @@ class PayCalculate {
     async getAddCalcRela() {
         // todo 获取截止上期数据
         const pre = null;
-        const cur = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
+        const cur = await this.ctx.service.stageBills.getSumTotalPrice(this.stage);
         const add = {};
         if (pre) {
             add.contract_tp = this.ctx.helper.add(pre.contract_tp, cur.contract_tp);
@@ -137,7 +139,7 @@ class PayCalculate {
                 return true;
             }
         } else if (pay.dl_type === deadlineType.count.value) {
-            return this.ctx.stage.order >= pay.dl_count;
+            return this.stage.order >= pay.dl_count;
         } else {
             return false;
         }
@@ -153,9 +155,7 @@ class PayCalculate {
         const yfPay = pays.find(function (p) {
             return p.ptype === payType.yf;
         });
-        if (!yfPay) {
-            throw '合同支付数据错误';
-        }
+        if (!yfPay) return false;
         yfPay.tp = 0;
         for (const p of pays) {
             if (p.ptype === payType.normal || p.ptype === payType.wc) {

+ 32 - 14
app/public/js/tender_list.js

@@ -215,8 +215,20 @@ function initTenderTree () {
         }
         return tenderCategory;
     }
+    function calculateTender(tender) {
+        if (tender.lastStage) {
+            tender.gather_tp = ZhCalc.add(tender.lastStage.contract_tp, tender.lastStage.qc_tp);
+            tender.end_contract_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp);
+            tender.end_qc_tp = ZhCalc.add(tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp);
+            tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
+            tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
+            tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
+            tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
+        }
+    }
     tenderTree.splice(0, tenderTree.length);
     for (const t of tenders) {
+        calculateTender(t);
         t.valid = true;
         if (t.category && levelCategory.length > 0) {
             const parent = loadTenderCategory(t);
@@ -263,32 +275,37 @@ function recursiveGetTenderNodeHtml (node, arr) {
     html.push(node.lastStage ? auditConst.stage.statusString[node.lastStage.status] : auditConst.ledger.statusString[node.ledger_status]);
     html.push('</td>');
     // 0号台账合同
-    html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    html.push('<td class="text-right">');
+    html.push(node.total_price);
+    console.log(node);
     html.push('</td>');
     // 本期完成
-    html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    html.push('<td class="text-right">');
+    html.push(node.gather_tp);
     html.push('</td>');
     // 截止本期合同
-    html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    html.push('<td class="text-right">');
+    html.push(node.end_contract_tp);
     html.push('</td>');
     // 截止本期变更
-    html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    html.push('<td class="text-right">');
+    html.push(node.end_qc_tp);
     html.push('</td>');
     // 截止本期完成
-    html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    html.push('<td class="text-right">');
+    html.push(node.end_gather_tp);
     html.push('</td>');
     // 截止上期完成
-    html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    html.push('<td class="text-right">');
+    html.push(node.pre_gather_tp);
     html.push('</td>');
     // 本期应付
-    html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    html.push('<td class="text-right">');
+    html.push(node.yf_tp);
+    html.push('</td>');
+    // 截止本期应付
+    html.push('<td class="text-right">');
+    html.push(node.end_yf_tp);
     html.push('</td>');
     html.push('</tr>');
     if (node.children) {
@@ -315,6 +332,7 @@ function getTenderTreeHtml () {
         html.push('<th>', '截止本期完成', '</th>');
         html.push('<th>', '截止上期完成', '</th>');
         html.push('<th>', '本期应付', '</th>');
+        html.push('<th>', '截止本期应付', '</th>');
         html.push('</tr>', '</thead>');
         for (const t of tenderTree) {
             html.push(recursiveGetTenderNodeHtml(t, tenderTree));

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

@@ -259,7 +259,7 @@ function recursiveGetTenderNodeHtml (node, arr) {
     html.push('<td tid="' + node.id + '">');
     if (!node.cid) {
         html.push('<a href="#javascript: void(0)" name="edit" class="btn btn-outline-primary btn-sm">编辑</a>');
-        if (node.lastStage === null) {
+        if (node.lastStage === null || node.lastStage === undefined) {
             html.push('<a href="javascript: void(0)" name="del" class="btn btn-outline-danger btn-sm ml-1">删除</a>');
         } else {
             html.push('<button class="btn btn-outline-secondary btn-sm ml-1" data-toggle="tooltip" data-placement="top" title="请先删除所有期">删除</button>');

+ 36 - 8
app/public/js/tender_list_progress.js

@@ -215,8 +215,19 @@ function initTenderTree () {
         }
         return tenderCategory;
     }
+    function calculateTender(tender) {
+        if (tender.lastStage) {
+            tender.end_qc_tp = ZhCalc.add(tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp);
+            tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
+            tender.gather_tp = ZhCalc.add(tender.lastStage.contract_tp, tender.lastStage.qc_tp);
+            tender.sum_tp = ZhCalc.add(tender.total_price, tender.end_qc_tp);
+        } else {
+            tender.sum_tp = tender.total_price;
+        }
+    }
     tenderTree.splice(0, tenderTree.length);
     for (const t of tenders) {
+        calculateTender(t);
         t.valid = true;
         if (t.category && levelCategory.length > 0) {
             const parent = loadTenderCategory(t);
@@ -231,6 +242,22 @@ function initTenderTree () {
         }
     }
 }
+function getProgressHtml(total, pre, cur) {
+    if (total !== 0) {
+        let preP = ZhCalc.mul(ZhCalc.div(pre, total, 2), 100, 0);
+        let curP = ZhCalc.mul(ZhCalc.div(cur, total, 2), 100, 0);
+        let other = Math.max(ZhCalc.div(ZhCalc.div(total, pre), cur), 0);
+        let otherP = Math.max(100 - preP - curP, 0);
+        const html = '<div class="progress">' +
+            '<div class="progress-bar bg-success" style="width: ' + preP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成:¥' + pre + '">' + preP + '%</div>' +
+            '<div class="progress-bar bg-info" style="width: ' + curP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' + cur + '">' + curP + '%</div>' +
+            '<div class="progress-bar bg-gray" style="width: ' + otherP + '%;" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' + other + '">' + otherP + '%</div>' +
+            '</div>';
+        return html;
+    } else {
+        return '';
+    }
+}
 function recursiveGetTenderNodeHtml (node, arr) {
     const html = [];
     html.push('<tr>');
@@ -252,17 +279,18 @@ function recursiveGetTenderNodeHtml (node, arr) {
         html.push(node.lastStage ? '第' + node.lastStage.order + '期' : '台账');
     }
     html.push('</td>');
-    // 完成期数
-    // html.push('<td>');
-    // html.push(node.completeStage ? '第' + node.completeStage.order + '期' : '');
-    // html.push('</td>');
     // 累计合同计量
     html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    const sum = node.lastStage ? ZhCalc.add(node.total_price, node.lastStage.end_qc_tp) : node.total_price;
+    html.push(node.sum_tp ? node.sum_tp : '');
     html.push('</td>');
     // 截止本期累计完成/本期完成/未完成
     html.push('<td>');
-    //html.push(node[c.field] ? node[c.field] : '');
+    if (node.lastStage) {
+        html.push(getProgressHtml(node.sum_tp, node.pre_gather_tp, node.gather_tp));
+    } else {
+        html.push('');
+    }
     html.push('</td>');
     html.push('</tr>');
     if (node.children) {
@@ -279,8 +307,8 @@ function getTenderTreeHtml () {
         html.push('<table class="table table-hover table-bordered">');
         html.push('<thead>', '<tr>');
         html.push('<th>', '名称', '</th>');
-        html.push('<th>', '计量期数', '</th>');
-        html.push('<th>', '累计合同计量', '</th>');
+        html.push('<th width="120">', '计量期数', '</th>');
+        html.push('<th>', '总价 <i class="fa fa-question-circle text-primary"  data-placement="bottom" data-toggle="tooltip" data-original-title="0号台账+截止本期数量变更"></i>', '</th>');
         html.push('<th>', '截止本期累计完成/本期完成/未完成', '</th>');
         html.push('</tr>', '</thead>');
         for (const t of tenderTree) {

+ 5 - 1
app/service/ledger_audit.js

@@ -180,11 +180,15 @@ module.exports = app => {
             if (!audit) {
                 throw '审核人信息错误';
             }
+            const sum = await this.ctx.service.ledger.addUp({tender_id: tenderId, is_leaf: true});
 
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, {id: audit.id, status: auditConst.status.checking, begin_time: new Date()});
-                await transaction.update(this.ctx.service.tender.tableName, {id: tenderId, ledger_status: auditConst.status.checking});
+                await transaction.update(this.ctx.service.tender.tableName, {
+                    id: tenderId, ledger_status: auditConst.status.checking,
+                    total_price: sum.total_price, deal_tp: sum.deal_tp,
+                });
 
                 // 添加短信通知-需要审批提醒功能
                 const smsUser = await this.ctx.service.projectAccount.getDataById(audit.audit_id);

+ 4 - 0
app/service/revise_audit.js

@@ -284,6 +284,10 @@ module.exports = app => {
                         await transaction.update(this.ctx.service.ledgerRevise.tableName, {id: revise.id, status: checkType, end_time: time});
                         // 拷贝修订数据至台账
                         await this._replaceLedgerByRevise(transaction, revise);
+                        const sum = await this.ctx.service.reviseBills.addUp({tender_id: revise.tid, is_leaf: true});
+                        await transaction.update(this.ctx.service.tender.tableName, {
+                            id: revise.tid, total_price: sum.total_price, deal_tp: sum.deal_tp
+                        });
 
                         // 添加短信通知-审批通过提醒功能
                         const smsUser = await this.ctx.service.projectAccount.getDataById(revise.uid);

+ 21 - 4
app/service/stage.js

@@ -94,6 +94,22 @@ module.exports = app => {
             return await this.db.query(sql, sqlParam);
         }
 
+        async checkStageGatherData(stage) {
+            // 最新一期计量(未审批完成),当前操作人的期详细数据,应实时计算
+            if (stage.status !== auditConst.status.checked) {
+                const curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
+                const isActive = curAuditor ? curAuditor.id === this.ctx.session.sessionUser.accountId : stage.user_id === this.ctx.session.sessionUser.accountId;
+                stage.curTimes = stage.status === auditConst.status.checkNo ? stage.times - 1 : stage.times;
+                stage.curOrder = curAuditor ? curAuditor.order : 0;
+                if (isActive) {
+                    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);
+                }
+            }
+        }
+
         /**
          * 获取标段下的全部计量期,按倒序
          * @param tenderId
@@ -169,6 +185,7 @@ module.exports = app => {
                 newStage.im_gather_node = preStage.im_gather_node;
                 newStage.pre_contract_tp = this.ctx.helper.add(preStage.pre_contract_tp, preStage.contract_tp);
                 newStage.pre_qc_tp = this.ctx.helper.add(preStage.pre_qc_tp, preStage.qc_tp);
+                newStage.pre_yf_tp = this.ctx.helper.add(preStage.pre_yf_tp, preStage.yf_tp);
             }
             const transaction = await this.db.beginTransaction();
             try {
@@ -239,9 +256,9 @@ module.exports = app => {
          * 获取 当期的 计算基数
          * @returns {Promise<any>}
          */
-        async getStagePayCalcBase() {
+        async getStagePayCalcBase(stage, tenderInfo) {
             const calcBase = JSON.parse(JSON.stringify(payConst.calcBase));
-            const param = this.ctx.tender.info.deal_param;
+            const param = tenderInfo.deal_param;
             for (const cb of calcBase) {
                 switch (cb.code) {
                     case 'htj':
@@ -260,11 +277,11 @@ module.exports = app => {
                         cb.value = param.materialAdvance;
                         break;
                     case 'bqwc':
-                        const sum = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
+                        const sum = await this.ctx.service.stageBills.getSumTotalPrice(stage);
                         cb.value = this.ctx.helper.add(sum.contract_tp, sum.qc_tp);
                         break;
                     case 'ybbqwc':
-                        const sumGcl = await this.ctx.service.stageBills.getSumTotalPriceGcl(this.ctx.stage, '^1[0-9]{2}-');
+                        const sumGcl = await this.ctx.service.stageBills.getSumTotalPriceGcl(stage, '^1[0-9]{2}-');
                         cb.value = this.ctx.helper.add(sumGcl.contract_tp, sumGcl.qc_tp);
                         break;
                     default:

+ 3 - 1
app/service/stage_audit.js

@@ -233,7 +233,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, {id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time});
                 // 计算并合同支付最终数据
-                await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
+                const yfPay = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
                 // 无下一审核人表示,审核结束
                 if (nextAudit) {
                     // 复制一份下一审核人数据
@@ -245,6 +245,7 @@ module.exports = app => {
                         id: stageId, status: auditConst.status.checking,
                         contract_tp: tpData.contract_tp,
                         qc_tp: tpData.qc_tp,
+                        yf_tp: yfPay.tp,
                     });
 
                     // 添加短信通知-需要审批提醒功能
@@ -272,6 +273,7 @@ module.exports = app => {
                         id: stageId, status: checkData.checkType,
                         contract_tp: tpData.contract_tp,
                         qc_tp: tpData.qc_tp,
+                        yf_tp: yfPay.tp,
                     });
 
                     // 添加短信通知-审批通过提醒功能

+ 15 - 1
app/service/stage_pay.js

@@ -9,6 +9,7 @@
  */
 
 const timesLen = require('../const/audit').stage.timesLen;
+const payConst = require('../const/deal_pay');
 
 module.exports = app => {
     class StagePay extends app.BaseService {
@@ -210,7 +211,7 @@ module.exports = app => {
             }
             const stagePays = await this.getStagePays(stage);
             const PayCalculator = require('../lib/pay_calc');
-            const payCalculator = new PayCalculator(this.ctx, this.ctx.tender.info.decimal);
+            const payCalculator = new PayCalculator(this.ctx, stage, this.ctx.tender.info);
             await payCalculator.calculateAll(stagePays);
             const srUpdate = [], update = [];
             for (const sp of stagePays) {
@@ -231,6 +232,19 @@ module.exports = app => {
             if (srUpdate.length > 0) {
                 await transaction.updateRows(this.ctx.service.pay.tableName, srUpdate);
             }
+            const yf = this._.find(stagePays, {ptype: payConst.payType.yf});
+            return yf;
+        }
+
+        async getYfTotalPrice(stage) {
+            if (!stage) throw '计算数据错误';
+            const stagePays = await this.getStagePays(stage);
+            const PayCalculator = require('../lib/pay_calc');
+            const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(stage.tid);
+            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;
         }
 
         /**

+ 3 - 3
app/service/tender.js

@@ -84,7 +84,7 @@ module.exports = app => {
             let sqlParam = [];
             if (listStatus === 'manage') {
                 // 管理页面只取属于自己创建的标段
-                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, ' +
+                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`,' +
                     '    pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
                     '  FROM ?? As t ' +
                     '  Left Join ?? As pa ' +
@@ -93,7 +93,7 @@ module.exports = app => {
                 sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, session.sessionProject.id, session.sessionUser.accountId];
             } else if (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1) {
                 // 具有查看所有标段权限的用户查阅标段
-                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, ' +
+                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`,' +
                     '    pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
                     '  FROM ?? As t ' +
                     '  Left Join ?? As pa ' +
@@ -104,7 +104,7 @@ module.exports = app => {
                 // 根据用户权限查阅标段
                 // tender 163条数据,project_account 68条数据测试
                 // 查询两张表耗时0.003s,查询tender左连接project_account耗时0.002s
-                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, ' +
+                sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`,' +
                     '    pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
                     // '  FROM ?? As t, ?? As pa ' +
                     // '  WHERE t.`project_id` = ? AND t.`user_id` = pa.`id` AND (' +

+ 0 - 1
app/view/tender/index.ejs

@@ -9,7 +9,6 @@
     const tenders = JSON.parse('<%- JSON.stringify(tenderList) %>');
     const categoryType = JSON.parse('<%- JSON.stringify(settingConst.cType) %>');
     const category = JSON.parse('<%- JSON.stringify(categoryData) %>');
-    const TenderTableCol = JSON.parse('<%- JSON.stringify(tableColSetting) %>');
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
     const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');
 </script>

+ 0 - 1
app/view/tender/manage.ejs

@@ -9,6 +9,5 @@
     const tenders = JSON.parse('<%- JSON.stringify(tenderList) %>');
     const categoryType = JSON.parse('<%- JSON.stringify(settingConst.cType) %>');
     const category = JSON.parse('<%- JSON.stringify(categoryData) %>');
-    const TenderTableCol = JSON.parse('<%- JSON.stringify(tableColSetting) %>');
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
 </script>

+ 0 - 1
app/view/tender/progress.ejs

@@ -9,5 +9,4 @@
     const tenders = JSON.parse('<%- JSON.stringify(tenderList) %>');
     const categoryType = JSON.parse('<%- JSON.stringify(settingConst.cType) %>');
     const category = JSON.parse('<%- JSON.stringify(categoryData) %>');
-    const TenderTableCol = JSON.parse('<%- JSON.stringify(tableColSetting) %>');
 </script>

+ 12 - 2
config/web.js

@@ -56,8 +56,10 @@ const JsFiles = {
                 files: [
                     "/public/js/ztree/jquery.ztree.core.js",
                     "/public/js/ztree/jquery.ztree.exedit.js",
+                    "/public/js/decimal.min.js",
                 ],
                 mergeFiles: [
+                    "/public/js/zh_calc.js",
                     "/public/js/tender_list.js"
                 ],
                 mergeFile: 'tender_list',
@@ -66,8 +68,12 @@ const JsFiles = {
                 files: [
                     "/public/js/ztree/jquery.ztree.core.js",
                     "/public/js/ztree/jquery.ztree.exedit.js",
+                    "/public/js/decimal.min.js",
+                ],
+                mergeFiles: [
+                    "/public/js/zh_calc.js",
+                    "/public/js/tender_list_progress.js"
                 ],
-                mergeFiles: ["/public/js/tender_list_progress.js"],
                 mergeFile: 'tender_list_progress',
             },
             manage: {
@@ -75,8 +81,12 @@ const JsFiles = {
                     "/public/js/ztree/jquery.ztree.core.js",
                     "/public/js/ztree/jquery.ztree.exedit.js",
                     "/public/js/moment/moment.min.js",
+                    "/public/js/decimal.min.js",
+                ],
+                mergeFiles: [
+                    "/public/js/zh_calc.js",
+                    "/public/js/tender_list_manage.js",
                 ],
-                mergeFiles: ["/public/js/tender_list_manage.js"],
                 mergeFile: 'tender_list_manage',
             },
             info: {