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