修复: 定价 结算 出货补单 计算中可能出现的数字精度问题

This commit is contained in:
admin 2024-07-26 10:49:28 +08:00
parent d5fed6e7ff
commit 082a7b58ff
5 changed files with 22 additions and 34 deletions

View File

@ -33,7 +33,7 @@
border="none"
:disabled="item.disabled || item.type === 'select'"
:disabledColor="
['补单时间', '站点磅秤', '供应商', '收货产品'].indexOf(item.name) >
['补单时间', '站点磅秤', '供应商', '收货产品', '车牌号'].indexOf(item.name) >
-1
? '#ffffff'
: '#f5f7fa'
@ -443,20 +443,19 @@ watch(
预估总价 结算单价*结算重量
实际收入实际结算金额-运费-杂费
*/
model1.order.netWeight = num_subtract((parseFloat(grossWeightNew) || 0), (parseFloat(tareNew) || 0))
model1.order.netWeight = num_subtract((parseFloat(grossWeightNew) || 0), (parseFloat(tareNew) || 0)).toFixed(2)
if (model1.order.buttonType === 0) {
if (model1.order.subtractNum) {
model1.order.netWeight = num_subtract(model1.order.netWeight, model1.order.subtractNum)
model1.order.netWeight = num_subtract(model1.order.netWeight, model1.order.subtractNum).toFixed(2)
}
} else if (model1.order.buttonType === 1) {
if (model1.order.subtractNum) {
model1.order.netWeight = num_multiply(model1.order.netWeight, ((100 - model1.order.subtractNum) / 100))
model1.order.netWeight = num_multiply(model1.order.netWeight, ((100 - model1.order.subtractNum) / 100)).toFixed(2)
}
}
model1.order.totalPrice = Math.floor(
(model1.order.price || 0) * (model1.order.netWeight || 0)
);
model1.order.totalPrice = num_multiply((model1.order.price || 0), (model1.order.netWeight || 0)).toFixed(2)
// =
model1.order.balanceTotalPrice = model1.order.totalPrice;
}

View File

@ -33,7 +33,7 @@
border="none"
:disabled="item.disabled || item.type === 'select'"
:disabledColor="
['补单时间', '过磅设备', '客户', '出货产品'].indexOf(item.name) > -1
['补单时间', '过磅设备', '客户', '出货产品','车牌号'].indexOf(item.name) > -1
? '#ffffff'
: '#f5f7fa'
"
@ -121,7 +121,7 @@
</template>
<script setup lang="ts">
import { DeviceApi, GoodsApi, PictureApi, ShipmentApi } from "@/services";
import { countDots, formatDate, isTwoDecimalPlaces } from "@/utils";
import { countDots, formatDate, isTwoDecimalPlaces, num_subtract } from "@/utils";
import { DeviceType, ImagesType, OrderType } from "@/utils/enum";
import _ from "underscore";
import ProductDialog from "@/components/Dialog/ProductDialog.vue";
@ -438,7 +438,7 @@ watch(
预估总价 结算单价*结算重量
实际收入实际结算金额-运费-杂费
*/
model1.order.netWeight = (grossWeightNew || 0) - (tareNew || 0);
model1.order.netWeight = num_subtract((grossWeightNew || 0), (tareNew || 0)).toFixed(2);
}
);

View File

@ -36,7 +36,7 @@
:value="(model1.order as any)[item.key]"
@change="(e:any) => {handleInput(e, item)}"
:disabled="item.disabled || item.type === 'select'"
:disabledColor="item.name === '收货产品' ? '#ffffff' : '#f5f7fa'"
:disabledColor="['收货产品','车牌号'].indexOf(item.name) > -1 ? '#ffffff' : '#f5f7fa'"
@clear="handleClear(item)"
@blur="(e:any) => {handleBlur(e, item)}"
>
@ -143,7 +143,7 @@ import { onLoad, onShow } from "@dcloudio/uni-app";
import { ImagesType, OrderType } from "@/utils/enum";
import ProductDialog from "@/components/Dialog/ProductDialog.vue";
import valid from "@/utils/validate";
import { countDots, isTwoDecimalPlaces } from "@/utils";
import { countDots, isTwoDecimalPlaces, num_subtract, num_multiply } from "@/utils";
import Photo from "@/components/Photo/index.vue";
import CarNoDialog from "@/components/Dialog/CarNoDialog.vue";
@ -548,21 +548,14 @@ watch(
if (model1.order.scaleStatus === 0) {
return;
}
model1.order.netWeight = parseFloat(
(
(parseFloat(grossWeightNew as any) || 0) -
(parseFloat(tareNew as any) || 0)
).toFixed(2)
);
model1.order.netWeight = <any>num_subtract((parseFloat(grossWeightNew as any) || 0), (parseFloat(tareNew as any) || 0)).toFixed(2)
if (model1.order.buttonType === 0) {
if (model1.order.subtractNum) {
model1.order.netWeight =
model1.order.netWeight - model1.order.subtractNum;
model1.order.netWeight = <any>num_subtract(<any>model1.order.netWeight, model1.order.subtractNum).toFixed(2)
}
} else if (model1.order.buttonType === 1) {
if (model1.order.subtractNum) {
model1.order.netWeight =
model1.order.netWeight * ((100 - model1.order.subtractNum) / 100);
model1.order.netWeight = <any>num_multiply(<any>model1.order.netWeight,((100 - model1.order.subtractNum) / 100)).toFixed(2)
}
}

View File

@ -111,6 +111,7 @@ import {
num_subtract,
countDots,
isTwoDecimalPlaces,
num_multiply
} from "@/utils";
import {
ImagesType,
@ -492,30 +493,25 @@ watch(
预估总价 结算单价*结算重量
实际收入实际结算金额-运费-杂费
*/
model1.order.settlementNet = num_subtract(
model1.order.settlementNet = <any>num_subtract(
settlementGrossNew || 0,
settlementTareNew || 0
);
).toFixed(2);
if (model1.order.buttonType === 0) {
if (model1.order.subtractNum) {
model1.order.settlementWeight =
model1.order.settlementNet - model1.order.subtractNum;
model1.order.settlementWeight = <any>num_subtract(<any>model1.order.settlementNet, model1.order.subtractNum).toFixed(2)
// model1.order.settlementNet - model1.order.subtractNum;
} else {
model1.order.settlementWeight = model1.order.settlementNet;
}
} else if (model1.order.buttonType === 1) {
if (model1.order.subtractNum) {
model1.order.settlementWeight =
model1.order.settlementNet * ((100 - model1.order.subtractNum) / 100);
model1.order.settlementWeight = <any>num_multiply(<any>model1.order.settlementNet, ((100 - model1.order.subtractNum) / 100)).toFixed(2)
} else {
model1.order.settlementWeight = model1.order.settlementNet;
}
}
model1.order.estimatePrice = parseInt(
(
(model1.order.unitPrice || 0) * (model1.order.settlementWeight || 0)
).toFixed(2)
);
model1.order.estimatePrice = <any>num_multiply((model1.order.unitPrice || 0),(model1.order.settlementWeight || 0)).toFixed(2)
// if (!model1.order.totalPrice) {
// model1.order.totalPrice = model1.order.estimatePrice;
// }

View File

@ -33,7 +33,7 @@
:customStyle="{}"
border="none"
:disabled="item.disabled || item.type === 'select'"
:disabledColor="item.name === '出货产品' ? '#ffffff' : '#f5f7fa'"
:disabledColor="['出货产品','车牌号'].indexOf(item.name) > -1 ? '#ffffff' : '#f5f7fa'"
@change="(e:any) => {handleInput(e, item)}"
@blur="(e:any) => {handleBlur(e, item)}"
@clear="handleClear(item)"