|
@@ -23,7 +23,9 @@ const keyFields = {
|
|
|
// 以下字段仅可通过树结构操作改变,不可直接通过update方式从接口提交,发现时过滤
|
|
|
const readOnlyFields = ['id', 'tender_id', 'ledger_id', 'ledger_pid', 'order', 'level', 'full_path', 'is_leaf'];
|
|
|
const calcFields = ['quantity', 'unit_price', 'total_price', 'deal_qty', 'deal_tp'];
|
|
|
+const upFields = ['unit_price'];
|
|
|
const qtyFields = ['quantity', 'deal_qty', 'dgn_qty1', 'dgn_qty2'];
|
|
|
+const tpFields = ['total_price', 'deal_tp'];
|
|
|
const zeroRange = 0.0000000001;
|
|
|
const rootId = -1;
|
|
|
const keyPre = 'tender_node_maxId:';
|
|
@@ -1597,27 +1599,31 @@ module.exports = app => {
|
|
|
if (this._checkCalcField(row)) {
|
|
|
let calcData = JSON.parse(JSON.stringify(row));
|
|
|
const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, row.unit ? row.unit : updateNode.unit);
|
|
|
+ // 数量保留小数位数
|
|
|
this.ctx.helper.checkFieldPrecision(calcData, qtyFields, precision.value);
|
|
|
+ // 单位保留小数位数
|
|
|
+ this.ctx.helper.checkFieldPrecision(calcData, upFields, this.ctx.tender.info.decimal.up);
|
|
|
+ // 计算
|
|
|
if (row.quantity !== undefined) {
|
|
|
if (row.unit_price !== undefined) {
|
|
|
- calcData.total_price = this.ctx.helper.times(row.quantity, row.unit_price);
|
|
|
+ calcData.total_price = this.ctx.helper.times(calcData.quantity, calcData.unit_price);
|
|
|
} else {
|
|
|
- calcData.total_price = this.ctx.helper.times(row.quantity, updateNode.unit_price);
|
|
|
+ calcData.total_price = this.ctx.helper.times(calcData.quantity, updateNode.unit_price);
|
|
|
}
|
|
|
} else if (row.unit_price !== undefined) {
|
|
|
- calcData.total_price = this.ctx.helper.times(updateNode.quantity, row.unit_price);
|
|
|
+ calcData.total_price = this.ctx.helper.times(updateNode.quantity, calcData.unit_price);
|
|
|
}
|
|
|
if (row.total_price !== undefined) {
|
|
|
calcData.quantity = null;
|
|
|
}
|
|
|
if (row.deal_qty !== undefined) {
|
|
|
if (row.unit_price !== undefined) {
|
|
|
- calcData.deal_tp = this.ctx.helper.times(row.deal_qty, row.unit_price);
|
|
|
+ calcData.deal_tp = this.ctx.helper.times(calcData.deal_qty, calcData.unit_price);
|
|
|
} else {
|
|
|
- calcData.deal_tp = this.ctx.helper.times(row.deal_qty, updateNode.unit_price);
|
|
|
+ calcData.deal_tp = this.ctx.helper.times(calcData.deal_qty, updateNode.unit_price);
|
|
|
}
|
|
|
} else if (row.unit_price !== undefined) {
|
|
|
- calcData.deal_tp = this.ctx.helper.times(updateNode.deal_qty, row.unit_price);
|
|
|
+ calcData.deal_tp = this.ctx.helper.times(updateNode.deal_qty, calcData.unit_price);
|
|
|
}
|
|
|
if (row.deal_tp !== undefined) {
|
|
|
calcData.deal_qty = null;
|