Browse Source

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

laiguoran 5 years ago
parent
commit
035faa108e
3 changed files with 29 additions and 27 deletions
  1. 8 8
      app/service/stage_bonus.js
  2. 14 12
      app/service/stage_jgcl.js
  3. 7 7
      app/service/stage_other.js

+ 8 - 8
app/service/stage_bonus.js

@@ -24,7 +24,7 @@ module.exports = app => {
 
         async getStageData(sid) {
             const data = await this.getAllDataByCondition({where: { sid: sid }});
-            if (this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
+            if (this.ctx.stage && this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
                 for (const d of data) {
                     const his = d.shistory ? JSON.parse(d.shistory) : [];
                     const h = this.ctx.helper._.find(his, {
@@ -98,13 +98,13 @@ module.exports = app => {
                 if (!od) continue;
 
                 const nd = {id: od.id};
-                if (d.name) nd.name = d.name;
-                if (d.tp) nd.tp = this.ctx.helper.round(d.tp, this.ctx.tender.info.decimal.tp);
-                if (d.code) nd.code = d.code;
-                if (d.proof) nd.proof = d.proof;
-                if (d.real_time) nd.real_time = new Date(d.real_time);
-                if (d.memo) nd.memo = d.memo;
-                if (d.order) nd.order = d.order;
+                if (d.name !== undefined) nd.name = d.name;
+                if (d.tp !== undefined) nd.tp = this.ctx.helper.round(d.tp, this.ctx.tender.info.decimal.tp);
+                if (d.code !== undefined) nd.code = d.code;
+                if (d.proof !== undefined) nd.proof = d.proof;
+                if (d.real_time !== undefined) nd.real_time = new Date(d.real_time);
+                if (d.memo !== undefined) nd.memo = d.memo;
+                if (d.order !== undefined) nd.order = d.order;
                 uDatas.push(nd);
                 console.log(nd);
             }

+ 14 - 12
app/service/stage_jgcl.js

@@ -24,7 +24,7 @@ module.exports = app => {
 
         async getStageData(sid) {
             const data = await this.getAllDataByCondition({where: { sid: sid }});
-            if (this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
+            if (this.ctx.stage && this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
                 for (const d of data) {
                     const his = d.shistory ? JSON.parse(d.shistory) : [];
                     const h = this.ctx.helper._.find(his, {
@@ -125,27 +125,29 @@ module.exports = app => {
                 const nd = {id: od.id};
                 if (d.name) nd.name = d.name;
                 if (od.pre_used === null || od.pre_used === undefined || od.pre_used === 0) {
-                    if (d.unit) nd.unit = d.unit;
-                    nd.unit_price = d.unit_price ? this.ctx.helper.round(d.unit_price, info.decimal.up) : od.unit_price;
+                    if (d.unit !== undefined) nd.unit = d.unit;
+                    nd.unit_price = d.unit_price !== undefined ? this.ctx.helper.round(d.unit_price, info.decimal.up) : od.unit_price;
+                } else {
+                    nd.unit_price = od.unit_price;
                 }
                 const precision = this.ctx.helper.findPrecision(info.precision, d.unit_price);
-                if (d.arrive_qty) {
+                if (d.arrive_qty !== undefined) {
                     nd.arrive_qty = this.ctx.helper.round(d.arrive_qty, precision.value);
                     nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, nd.arrive_qty, info.decimal.tp);
-                } else if (d.unit_price) {
+                } else if (d.unit_price !== undefined) {
                     nd.arrive_tp = this.ctx.helper.mul(nd.unit_price, od.arrive_qty, info.decimal.tp);
                 }
-                if (d.deduct_qty) {
+                if (d.deduct_qty !== undefined) {
                     nd.deduct_qty = this.ctx.helper.round(d.deduct_qty, precision.value);
                     nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, nd.deduct_qty, info.decimal.tp);
-                } else if (d.unit_price) {
+                } else if (d.unit_price !== undefined) {
                     nd.deduct_tp = this.ctx.helper.mul(nd.unit_price, od.deduct_qty, info.decimal.tp);
                 }
-                if (d.source) nd.source = d.source;
-                if (d.bills_code) nd.bills_code = d.bills_code;
-                if (d.check_code) nd.check_code = d.check_code;
-                if (d.memo) nd.memo = d.memo;
-                if (d.order) nd.order = d.order;
+                if (d.source !== undefined) nd.source = d.source;
+                if (d.bills_code !== undefined) nd.bills_code = d.bills_code;
+                if (d.check_code !== undefined) nd.check_code = d.check_code;
+                if (d.memo !== undefined) nd.memo = d.memo;
+                if (d.order !== undefined) nd.order = d.order;
                 uDatas.push(nd);
             }
             if (uDatas.length > 0) {

+ 7 - 7
app/service/stage_other.js

@@ -24,7 +24,7 @@ module.exports = app => {
 
         async getStageData(sid) {
             const data = await this.getAllDataByCondition({where: { sid: sid }});
-            if (this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
+            if (this.ctx.stage && this.ctx.stage.readOnly && this.ctx.stage.status !== auditConst.status.checked) {
                 for (const d of data) {
                     const his = d.shistory ? JSON.parse(d.shistory) : [];
                     const h = this.ctx.helper._.find(his, {
@@ -99,18 +99,18 @@ module.exports = app => {
                 if (!od) continue;
 
                 const nd = {id: od.id};
-                if (d.name) {
+                if (d.name !== undefined) {
                     if (od.pre_used) throw '往期已使用,不可修改名称';
                     nd.name = d.name;
                 }
-                if (d.order) nd.order = d.order;
-                if (d.total_price) {
+                if (d.order !== undefined) nd.order = d.order;
+                if (d.total_price !== undefined) {
                     if (od.pre_used) throw '往期已使用,不可修改金额';
                     nd.total_price = this.ctx.helper.round(d.total_price, this.ctx.tender.info.decimal.tp);
                 }
-                if (d.tp) nd.tp = this.ctx.helper.round(d.tp, this.ctx.tender.info.decimal.tp);
-                if (d.real_time) nd.real_time = new Date(d.real_time);
-                if (d.memo) nd.memo = d.memo;
+                if (d.tp !== undefined) nd.tp = this.ctx.helper.round(d.tp, this.ctx.tender.info.decimal.tp);
+                if (d.real_time !== undefined) nd.real_time = new Date(d.real_time);
+                if (d.memo !== undefined) nd.memo = d.memo;
                 uDatas.push(nd);
             }
             if (uDatas.length > 0) {