ソースを参照

变更方案及申请小数位计算及保留位数值

laiguoran 3 年 前
コミット
ff3729b1df

+ 4 - 4
app/controller/change_controller.js

@@ -2620,10 +2620,10 @@ module.exports = app => {
                     auditConst: audit.changeApply,
                     fileList,
                     whiteList,
-                    tpUnit: ctx.change.applyDecimal ? ctx.change.applyDecimal.tp : ctx.tender.info.decimal.tp,
-                    upUnit: ctx.change.applyDecimal ? ctx.change.applyDecimal.up : ctx.tender.info.decimal.up,
+                    tpUnit: ctx.change.decimal ? ctx.change.decimal.tp : ctx.tender.info.decimal.tp,
+                    upUnit: ctx.change.decimal ? ctx.change.decimal.up : ctx.tender.info.decimal.up,
                     changeUnits: changeConst.units,
-                    precision: ctx.tender.info.precision,
+                    precision: ctx.change.decimal ? ctx.change.decimal.precision : ctx.tender.info.precision,
                     returnUrl: this.app._.includes(ctx.request.headers.referer, '/tender/' + ctx.tender.id + '/change/apply') && !this.app._.includes(ctx.request.headers.referer, '/tender/' + ctx.tender.id + '/change/apply/' + ctx.change.id + '/information') ? ctx.request.headers.referer : null,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.change.apply_information),
                     preUrl: '/tender/' + ctx.tender.id + '/change/apply/' + ctx.change.id + '/information',
@@ -3244,7 +3244,7 @@ module.exports = app => {
                     tpUnit: ctx.change.decimal ? ctx.change.decimal.tp : ctx.tender.info.decimal.tp,
                     upUnit: ctx.change.decimal ? ctx.change.decimal.up : ctx.tender.info.decimal.up,
                     changeUnits: changeConst.units,
-                    precision: ctx.tender.info.precision,
+                    precision: ctx.change.decimal ? ctx.change.decimal.precision : ctx.tender.info.precision,
                     returnUrl: this.app._.includes(ctx.request.headers.referer, '/tender/' + ctx.tender.id + '/change/plan') && !this.app._.includes(ctx.request.headers.referer, '/tender/' + ctx.tender.id + '/change/plan/' + ctx.change.id + '/information') ? ctx.request.headers.referer : null,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.change.plan_information),
                     preUrl: '/tender/' + ctx.tender.id + '/change/plan/' + ctx.change.id + '/information',

+ 1 - 1
app/middleware/change_apply_check.js

@@ -35,7 +35,7 @@ module.exports = options => {
             change.auditors = yield this.service.changeApplyAudit.getAuditors(change.id, change.times);
             change.curAuditor = yield this.service.changeApplyAudit.getCurAuditor(change.id, change.times);
             // decimal小数位设置
-            change.decimal = change.decimal ? JSON.parse(change.decimal) : { tp: this.tender.info.decimal.tp, up: this.tender.info.decimal.up };
+            change.decimal = change.decimal ? JSON.parse(change.decimal) : { tp: this.tender.info.decimal.tp, up: this.tender.info.decimal.up, precision: this.tender.info.precision };
 
             if (!change) throw '变更令数据有误';
             // 权限相关

+ 1 - 1
app/middleware/change_plan_check.js

@@ -35,7 +35,7 @@ module.exports = options => {
             change.auditors = yield this.service.changePlanAudit.getAuditors(change.id, change.times);
             change.curAuditor = yield this.service.changePlanAudit.getCurAuditor(change.id, change.times);
             // decimal小数位设置
-            change.decimal = change.decimal ? JSON.parse(change.decimal) : { tp: this.tender.info.decimal.tp, up: this.tender.info.decimal.up };
+            change.decimal = change.decimal ? JSON.parse(change.decimal) : { tp: this.tender.info.decimal.tp, up: this.tender.info.decimal.up, precision: this.tender.info.precision };
 
             if (!change) throw '变更令数据有误';
             // 权限相关

+ 10 - 8
app/public/js/change_apply_information.js

@@ -227,10 +227,10 @@ $(document).ready(() => {
                 return ZhCalc.round(data.unit_price, unitPriceUnit);
             },
             oa_tp: function (data) {
-                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), data.oamount), totalPriceUnit);
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
             },
             ca_tp: function (data) {
-                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), data.camount), totalPriceUnit);
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
             },
             oamount: function (data) {
                 return ZhCalc.round(data.oamount, findDecimal(data.unit));
@@ -643,12 +643,14 @@ $(document).ready(() => {
         changeSpreadObj.makeSjsFooter();
 
         // 计算最新的变更总额和change的total_price是否一致,不一致则更新
-        let new_tp = 0;
-        for (const c of changeList) {
-            new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(c.camount, ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
-        }
-        if (change.total_price && change.total_price !== new_tp) {
-            postData(preUrl + '/list/save', { type:'update_tp', updateData: new_tp }, function (result) {});
+        if (change.status !== auditConst.status.checked) {
+            let new_tp = 0;
+            for (const c of changeList) {
+                new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.camount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
+            }
+            if (change.total_price && change.total_price !== new_tp) {
+                postData(preUrl + '/list/save', { type:'update_tp', updateData: new_tp }, function (result) {});
+            }
         }
     });
 });

+ 13 - 10
app/public/js/change_plan_information.js

@@ -233,10 +233,10 @@ $(document).ready(() => {
                 return ZhCalc.round(data.unit_price, unitPriceUnit);
             },
             oa_tp: function (data) {
-                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), data.oamount), totalPriceUnit);
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
             },
             ca_tp: function (data) {
-                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), data.camount), totalPriceUnit);
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
             },
             oamount: function (data) {
                 return ZhCalc.round(data.oamount, findDecimal(data.unit));
@@ -248,7 +248,7 @@ $(document).ready(() => {
                 return ZhCalc.round(data.samount, findDecimal(data.unit));
             },
             sa_tp: function (data) {
-                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), data.samount), totalPriceUnit);
+                return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.samount, findDecimal(data.unit))), totalPriceUnit);
             },
         },
         readOnly: {
@@ -268,7 +268,7 @@ $(document).ready(() => {
         setAuditValue: function () {
             for (const c of changeList) {
                 for (const audit of change.listAudits) {
-                    c['sa_tp_' + audit.aid] = ZhCalc.round(ZhCalc.mul(c['audit_amount_' + audit.aid], ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
+                    c['sa_tp_' + audit.aid] = ZhCalc.round(ZhCalc.mul(ZhCalc.round(c['audit_amount_' + audit.aid], findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
                 }
             }
         },
@@ -840,12 +840,15 @@ $(document).ready(() => {
         }
 
         // 计算最新的变更总额和change的total_price是否一致,不一致则更新
-        let new_tp = 0;
-        for (const c of changeList) {
-            new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(c.spamount, ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
-        }
-        if (change.total_price && change.total_price !== new_tp) {
-            postData(preUrl + '/list/save', { type:'update_tp', updateData: new_tp }, function (result) {});
+        if (change.status !== auditConst.status.checked) {
+            let new_tp = 0;
+            for (const c of changeList) {
+                new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
+            }
+            if (change.total_price && change.total_price !== new_tp) {
+                postData(preUrl + '/list/save', {type: 'update_tp', updateData: new_tp}, function (result) {
+                });
+            }
         }
     });
 

+ 1 - 0
app/public/js/material_list.js

@@ -217,6 +217,7 @@ $(document).ready(() => {
         gclGatherData = gclGatherModel.gatherGclData().filter(item => {
             return item.qc_qty || item.contract_qty
         });
+        console.log(gclGatherData);
         if (openMaterialChecklist) {
             // 取交集
             gclGatherData = _.filter(gclGatherData, function (item) {