68
68
</el-form >
69
69
</ComponentContainerProperty >
70
70
<!-- 优惠券选择 -->
71
- <CouponSelect ref =" couponSelectDialog" v-model:multiple-selection =" couponList" />
71
+ <CouponSelect
72
+ ref =" couponSelectDialog"
73
+ v-model:multiple-selection =" couponList"
74
+ :take-type =" CouponTemplateTakeTypeEnum.USER.type"
75
+ @change =" handleCouponSelect"
76
+ />
72
77
</template >
73
78
74
79
<script setup lang="ts">
75
80
import { CouponCardProperty } from ' ./config'
76
81
import { useVModel } from ' @vueuse/core'
77
82
import * as CouponTemplateApi from ' @/api/mall/promotion/coupon/couponTemplate'
78
83
import { floatToFixed2 } from ' @/utils'
79
- import { PromotionDiscountTypeEnum } from ' @/utils/constants'
84
+ import { CouponTemplateTakeTypeEnum , PromotionDiscountTypeEnum } from ' @/utils/constants'
80
85
import CouponSelect from ' @/views/mall/promotion/coupon/components/CouponSelect.vue'
81
86
82
87
// 优惠券卡片属性面板
@@ -93,10 +98,20 @@ const couponSelectDialog = ref()
93
98
const handleAddCoupon = () => {
94
99
couponSelectDialog .value .open ()
95
100
}
101
+ const handleCouponSelect = () => {
102
+ formData .value .couponIds = couponList .value .map ((coupon ) => coupon .id )
103
+ }
104
+
96
105
watch (
97
- () => couponList .value ,
98
- () => {
99
- formData .value .couponIds = couponList .value .map ((coupon ) => coupon .id )
106
+ () => formData .value .couponIds ,
107
+ async () => {
108
+ if (formData .value .couponIds ?.length > 0 ) {
109
+ couponList .value = await CouponTemplateApi .getCouponTemplateList (formData .value .couponIds )
110
+ }
111
+ },
112
+ {
113
+ immediate: true ,
114
+ deep: true
100
115
}
101
116
)
102
117
</script >
0 commit comments