diff --git a/pages/storage/order-settlement/index.js b/pages/storage/order-settlement/index.js index 9bd09bf..945acf0 100644 --- a/pages/storage/order-settlement/index.js +++ b/pages/storage/order-settlement/index.js @@ -135,24 +135,29 @@ Scene({ if(e.target.id == 'netWeight'){ if(!util.isEmpty(this.data.form.deductPercent) && Number(this.data.form.deductPercent) > 0){ var deductWeight = math.divide(math.times(this.data.form.netWeight, this.data.form.deductPercent), 100) + this.data.form.deductWeight = deductWeight this.setData({ ['form.settleWeight']: math.minus(this.data.form.netWeight, deductWeight) }) } else { + this.data.form.deductWeight = 0 this.setData({ ['form.settleWeight']: e.detail }) } } else if(e.target.id == 'deductPercent'){ if(!util.isEmpty(this.data.form.netWeight) && Number(this.data.form.netWeight) > 0){ if(Number(this.data.form.deductPercent) < 100){ var deductWeight = math.divide(math.times(this.data.form.netWeight, this.data.form.deductPercent), 100) + this.data.form.deductWeight = deductWeight this.setData({ ['form.settleWeight']: math.minus(this.data.form.netWeight, deductWeight) }) } else { + this.data.form.deductWeight = 0 this.setData({ ['form.settleWeight']: '' }) } } } else if(e.target.id == 'settleWeight'){ if(!util.isEmpty(this.data.form.netWeight) && Number(this.data.form.netWeight) > 0){ if(Number(this.data.form.netWeight) > Number(this.data.form.settleWeight)){ - this.data.form.deductWeight = math.minus(this.data.form.netWeight, this.data.form.settleWeight) - this.setData({ ['form.deductPercent']: math.times(math.divide(this.data.form.deductWeight, this.data.form.netWeight), 100).toFixed(2) }) + var deductWeight = math.minus(this.data.form.netWeight, this.data.form.settleWeight) + this.data.form.deductWeight = deductWeight + this.setData({ ['form.deductPercent']: math.times(math.divide(deductWeight, this.data.form.netWeight), 100).toFixed(2) }) } else { this.data.form.deductWeight = 0 this.setData({ ['form.deductPercent']: '' }) @@ -230,6 +235,9 @@ Scene({ if(this.data.form.netWeight && Number(this.data.form.netWeight) > 0){ params.netWeight = math.times(this.data.form.netWeight, 1000) } + if(this.data.form.deductPercent && Number(this.data.form.deductPercent) > 0){ + params.deductPercent = this.data.form.deductPercent + } if(this.data.form.deductWeight && Number(this.data.form.deductWeight) > 0){ params.deductWeight = math.times(this.data.form.deductWeight, 1000) }