fix: 【MALL 商城】商城-满减送管理功能中,已添加的优惠券删除后保存不成功

This commit is contained in:
YunaiV
2025-07-14 12:24:19 +08:00
parent 2e495f1312
commit a61fe176ce

View File

@ -107,16 +107,15 @@ const initGiveCouponList = async () => {
/** 设置赠送的优惠券 */
const setGiveCouponList = () => {
if (isEmpty(rewardRule.value) || isEmpty(list.value)) {
if (isEmpty(rewardRule.value)) {
return
}
// 核心:清空 rewardRule.value.giveCouponTemplateCounts解决删除不生效的问题
rewardRule.value.giveCouponTemplateCounts = {}
// 设置优惠券和其数量的对应
list.value.forEach((rule) => {
if (!rewardRule.value.giveCouponTemplateCounts) {
rewardRule.value.giveCouponTemplateCounts = {}
}
rewardRule.value.giveCouponTemplateCounts[rule.id] = rule.giveCount!
rewardRule.value.giveCouponTemplateCounts![rule.id] = rule.giveCount!
})
}
defineExpose({ setGiveCouponList })