fix: 简化优惠金额逻辑,前后端都用0作为默认值
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -177,7 +177,7 @@ export default {
|
||||
|
||||
// 金额相关
|
||||
discountRate: 100, // 折扣率(保留逻辑,默认100%不打折)
|
||||
discountMoney: '', // 优惠金额(空字符串,这样parseFloat后为NaN)
|
||||
discountMoney: 0, // 优惠金额
|
||||
totalAmount: 0, // 原价
|
||||
discountAmount: 0, // 优惠金额(计算结果)
|
||||
actualAmount: 0, // 实付金额
|
||||
@@ -279,8 +279,7 @@ export default {
|
||||
}, 0)
|
||||
|
||||
// 2. 优惠金额直接使用用户输入的值
|
||||
const discountMoneyVal = parseFloat(this.discountMoney)
|
||||
this.discountAmount = isNaN(discountMoneyVal) ? 0 : discountMoneyVal
|
||||
this.discountAmount = parseFloat(this.discountMoney) || 0
|
||||
|
||||
// 3. 计算实付金额 = 原价 - 优惠金额
|
||||
this.actualAmount = this.totalAmount - this.discountAmount
|
||||
@@ -299,7 +298,7 @@ export default {
|
||||
price: item.price
|
||||
})),
|
||||
discountRate: 100, // 保留折扣率逻辑,默认100%
|
||||
discountMoney: this.discountMoney ? parseFloat(this.discountMoney) : 0,
|
||||
discountMoney: parseFloat(this.discountMoney) || 0,
|
||||
remark: this.remark,
|
||||
paymentMethod: this.paymentMethod
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user