|
@@ -686,12 +686,12 @@ const handleChangeSupplier = (val) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const formatNumber = (value) => {
|
|
|
+const formatNumber = (value, num = 10000) => {
|
|
|
if (value === null || value === undefined || value === "") {
|
|
|
return "";
|
|
|
}
|
|
|
// 将输入值保留四位小数
|
|
|
- const formattedValue = Math.round(Number(value) * 10000) / 10000;
|
|
|
+ const formattedValue = Math.round(Number(value) * num) / num;
|
|
|
return formattedValue;
|
|
|
};
|
|
|
|
|
@@ -700,31 +700,36 @@ const handleChangeAmount = () => {
|
|
|
let productAmount = 0;
|
|
|
for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
const e = formData.data.purchaseDetailList[i];
|
|
|
- e.amount = formatNumber(parseFloat(e.count * e.price));
|
|
|
+ e.amount = formatNumber(parseFloat(e.count * e.price), 100);
|
|
|
productAmount += Number(e.amount);
|
|
|
}
|
|
|
- formData.data.productAmount = formatNumber(productAmount);
|
|
|
+ formData.data.productAmount = formatNumber(productAmount, 100);
|
|
|
// 其他收费
|
|
|
let otherAmount = 0;
|
|
|
for (let i = 0; i < formData.data.otherFeeList.length; i++) {
|
|
|
const e = formData.data.otherFeeList[i];
|
|
|
otherAmount += Number(e.price);
|
|
|
}
|
|
|
- formData.data.otherAmount = formatNumber(otherAmount);
|
|
|
+ formData.data.otherAmount = formatNumber(otherAmount, 100);
|
|
|
formData.data.amount = formatNumber(
|
|
|
parseFloat(
|
|
|
Number(formData.data.productAmount) + Number(formData.data.otherAmount)
|
|
|
- )
|
|
|
+ ),
|
|
|
+ 100
|
|
|
);
|
|
|
};
|
|
|
|
|
|
const handleChangeMoney = (val, index, key) => {
|
|
|
- formData.data.purchaseDetailList[index][key] = formatNumber(val);
|
|
|
+ let num = 100;
|
|
|
+ if (key === "count") {
|
|
|
+ num = 10000;
|
|
|
+ }
|
|
|
+ formData.data.purchaseDetailList[index][key] = formatNumber(val, num);
|
|
|
handleChangeAmount();
|
|
|
};
|
|
|
|
|
|
const handleChangeOtherMoney = (val, index, key) => {
|
|
|
- formData.data.otherFeeList[index][key] = formatNumber(val);
|
|
|
+ formData.data.otherFeeList[index][key] = formatNumber(val, 100);
|
|
|
handleChangeAmount();
|
|
|
};
|
|
|
|