feat: 订单创建改用优惠金额字段,保留折扣率逻辑

This commit is contained in:
Agent
2026-03-27 13:44:23 +00:00
parent b1211962ce
commit b5f621c980

View File

@@ -72,14 +72,14 @@
<text class="section-title">优惠设置</text>
</view>
<view class="form-item">
<text class="label">折扣率</text>
<text class="label">优惠金额</text>
<input
class="discount-input"
type="digit"
v-model="discountRate"
v-model="discountMoney"
@change="calcAmount"
/>
<text class="unit">%</text>
<text class="unit"></text>
</view>
</view>
@@ -176,9 +176,10 @@ export default {
searchKeyword: '',
// 金额相关
discountRate: 100, // 折扣率
discountRate: 100, // 折扣率保留逻辑默认100%不打折)
discountMoney: 0, // 优惠金额
totalAmount: 0, // 原价
discountAmount: 0, // 优惠金额
discountAmount: 0, // 优惠金额(计算结果)
actualAmount: 0, // 实付金额
// 其他
@@ -277,8 +278,8 @@ export default {
return sum + (item.price * item.quantity)
}, 0)
// 2. 计算优惠金额 = 原价 × (100 - 折扣率) / 100
this.discountAmount = this.totalAmount * (100 - this.discountRate) / 100
// 2. 优惠金额直接使用用户输入的值
this.discountAmount = parseFloat(this.discountMoney) || 0
// 3. 计算实付金额 = 原价 - 优惠金额
this.actualAmount = this.totalAmount - this.discountAmount
@@ -296,7 +297,8 @@ export default {
quantity: item.quantity,
price: item.price
})),
discountRate: parseFloat(this.discountRate),
discountRate: 100, // 保留折扣率逻辑默认100%
discountMoney: parseFloat(this.discountMoney) || 0,
remark: this.remark,
paymentMethod: this.paymentMethod
}