fix: 简化优惠金额逻辑,前后端都用0作为默认值
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-03-27 15:33:59 +00:00
parent 228e71d580
commit f93aa242c9

View File

@@ -177,7 +177,7 @@ export default {
// 金额相关 // 金额相关
discountRate: 100, // 折扣率保留逻辑默认100%不打折) discountRate: 100, // 折扣率保留逻辑默认100%不打折)
discountMoney: '', // 优惠金额空字符串这样parseFloat后为NaN discountMoney: 0, // 优惠金额
totalAmount: 0, // 原价 totalAmount: 0, // 原价
discountAmount: 0, // 优惠金额(计算结果) discountAmount: 0, // 优惠金额(计算结果)
actualAmount: 0, // 实付金额 actualAmount: 0, // 实付金额
@@ -279,8 +279,7 @@ export default {
}, 0) }, 0)
// 2. 优惠金额直接使用用户输入的值 // 2. 优惠金额直接使用用户输入的值
const discountMoneyVal = parseFloat(this.discountMoney) this.discountAmount = parseFloat(this.discountMoney) || 0
this.discountAmount = isNaN(discountMoneyVal) ? 0 : discountMoneyVal
// 3. 计算实付金额 = 原价 - 优惠金额 // 3. 计算实付金额 = 原价 - 优惠金额
this.actualAmount = this.totalAmount - this.discountAmount this.actualAmount = this.totalAmount - this.discountAmount
@@ -299,7 +298,7 @@ export default {
price: item.price price: item.price
})), })),
discountRate: 100, // 保留折扣率逻辑默认100% discountRate: 100, // 保留折扣率逻辑默认100%
discountMoney: this.discountMoney ? parseFloat(this.discountMoney) : 0, discountMoney: parseFloat(this.discountMoney) || 0,
remark: this.remark, remark: this.remark,
paymentMethod: this.paymentMethod paymentMethod: this.paymentMethod
} }