|
@@ -222,6 +222,7 @@
|
|
|
<script>
|
|
<script>
|
|
|
import { emailReg, phoneReg, numberReg } from 'ele-admin';
|
|
import { emailReg, phoneReg, numberReg } from 'ele-admin';
|
|
|
import { paymentTypeOp } from '@/enum/dict';
|
|
import { paymentTypeOp } from '@/enum/dict';
|
|
|
|
|
+ import { formatPrice } from '@/BIZComponents/setProduct.js';
|
|
|
export default {
|
|
export default {
|
|
|
props: {
|
|
props: {
|
|
|
delDetailIds: Array,
|
|
delDetailIds: Array,
|
|
@@ -351,11 +352,11 @@
|
|
|
];
|
|
];
|
|
|
},
|
|
},
|
|
|
allRatio() {
|
|
allRatio() {
|
|
|
- return this.form.datasource.reduce((acc, cur) => acc + Number(cur.ratio), 0).toFixed(2);
|
|
|
|
|
|
|
+ return formatPrice(this.form.datasource.reduce((acc, cur) => acc + Number(cur.ratio), 0));
|
|
|
},
|
|
},
|
|
|
allPrice() {
|
|
allPrice() {
|
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
// 使用分进行计算,避免浮点数精度问题
|
|
|
- return (this.form.datasource.reduce((acc, cur) => acc + Math.round(Number(cur.price) * 100), 0) / 100).toFixed(2);
|
|
|
|
|
|
|
+ return formatPrice(this.form.datasource.reduce((acc, cur) => acc + Math.round(Number(cur.price) * 100), 0) / 100);
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -404,7 +405,7 @@
|
|
|
}
|
|
}
|
|
|
let newval = (val / 100).toFixed(2);
|
|
let newval = (val / 100).toFixed(2);
|
|
|
// console.log('newval~~~', newval)
|
|
// console.log('newval~~~', newval)
|
|
|
- let price = (this.discountAmount * newval).toFixed(2);
|
|
|
|
|
|
|
+ let price = formatPrice(this.discountAmount * newval);
|
|
|
// console.log(newval, price, index, '88888');
|
|
// console.log(newval, price, index, '88888');
|
|
|
if (index != null) {
|
|
if (index != null) {
|
|
|
// console.log(newval, price, index, '999999');
|
|
// console.log(newval, price, index, '999999');
|
|
@@ -464,7 +465,7 @@
|
|
|
// 直接计算价格,避免使用async/await的forEach
|
|
// 直接计算价格,避免使用async/await的forEach
|
|
|
let val = Number(r.ratio);
|
|
let val = Number(r.ratio);
|
|
|
let newval = (val / 100).toFixed(2);
|
|
let newval = (val / 100).toFixed(2);
|
|
|
- let price = (this.discountAmount * newval).toFixed(2);
|
|
|
|
|
|
|
+ let price = formatPrice(this.discountAmount * newval);
|
|
|
newData[i] = {
|
|
newData[i] = {
|
|
|
...r,
|
|
...r,
|
|
|
price: price
|
|
price: price
|
|
@@ -496,7 +497,7 @@
|
|
|
const lastPrice = Math.round((discountAmount - otherPriceSum) * 100) / 100;
|
|
const lastPrice = Math.round((discountAmount - otherPriceSum) * 100) / 100;
|
|
|
newData[lastIndex] = {
|
|
newData[lastIndex] = {
|
|
|
...newData[lastIndex],
|
|
...newData[lastIndex],
|
|
|
- price: lastPrice.toFixed(2)
|
|
|
|
|
|
|
+ price: formatPrice(lastPrice)
|
|
|
};
|
|
};
|
|
|
console.log('adjusted last item price:', lastPrice);
|
|
console.log('adjusted last item price:', lastPrice);
|
|
|
}
|
|
}
|