|
@@ -46,6 +46,17 @@ const TreeExprCalc = (function(){
|
|
|
calcRela.exprCacheFields = calcRela.exprCacheKey.map(x => { return getCalcField(x); });
|
|
|
}
|
|
|
calcRela.errorMsg = setting.errorMsg || true;
|
|
|
+ calcRela.precision = setting.precision;
|
|
|
+ };
|
|
|
+ const findPrecision = function(list, unit) {
|
|
|
+ if (!unit) return list.other;
|
|
|
+
|
|
|
+ for (const p in list) {
|
|
|
+ if (list[p].unit && list[p].unit === unit) {
|
|
|
+ return list[p];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list.other;
|
|
|
};
|
|
|
const checkExprValid = function(expr, invalidOrders = []) {
|
|
|
if (!expr) return [true, ''];
|
|
@@ -188,7 +199,8 @@ const TreeExprCalc = (function(){
|
|
|
const addCache = function(expr) {
|
|
|
const cache = { id: expr.id };
|
|
|
if (expr.calcField === 'qty') {
|
|
|
- cache[calcRela.calcField.qty] = ZhCalc.round(expr.value, calcRela.decimal.qty);
|
|
|
+ const precision = findPrecision(calcRela.precision, expr.unit);
|
|
|
+ cache[calcRela.calcField.qty] = ZhCalc.round(expr.value, precision.value);
|
|
|
cache[calcRela.calcField.tp] = ZhCalc.mul(cache[calcRela.calcField.qty], expr.unit_price, calcRela.decimal.tp);
|
|
|
} else if (expr.calcField === 'tp') {
|
|
|
cache[calcRela.calcField.qty] = 0;
|