【新增】MALL: 满减送活动赠送优惠券(100%)

pull/525/head
puhui999 2024-08-23 16:57:36 +08:00
parent a08684089d
commit f996d00e92
2 changed files with 25 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<template>
<Dialog v-model="dialogVisible" :title="dialogTitle" width="60%">
<Dialog v-model="dialogVisible" :title="dialogTitle" width="65%">
<el-form
ref="formRef"
v-loading="formLoading"
@ -31,7 +31,7 @@
</el-radio-group>
</el-form-item>
<el-form-item label="优惠设置">
<RewardRule v-model="formData" />
<RewardRule ref="rewardRuleRef" v-model="formData" />
</el-form-item>
<el-form-item label="活动范围" prop="productScope">
<el-radio-group v-model="formData.productScope">
@ -97,7 +97,8 @@ const formRules = reactive({
productSpuIds: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
productCategoryIds: [{ required: true, message: '商品分类不能为空', trigger: 'blur' }]
})
const formRef = ref([]) // Ref
const formRef = ref() // Ref
const rewardRuleRef = ref<InstanceType<typeof RewardRule>>() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
@ -126,14 +127,14 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
const submitForm = async () => {
//
if (!formRef) return
// TODO puhui999:
// const valid = await formRef.value.validate()
// if (!valid) return
// TODO puhui999:
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
//
rewardRuleRef.value?.setRuleCoupon()
const data = formData.value
//
setProductScopeValues(data)

View File

@ -69,7 +69,11 @@
inactive-text="否"
inline-prompt
/>
<RewardRuleCouponShowcase v-if="rule.giveCoupon" v-model="rule!" />
<RewardRuleCouponShowcase
v-if="rule.giveCoupon"
ref="rewardRuleCouponShowcaseRef"
v-model="rule!"
/>
</el-col>
</el-form-item>
</el-form>
@ -86,6 +90,7 @@ import RewardRuleCouponShowcase from './RewardRuleCouponShowcase.vue'
import { RewardActivityVO } from '@/api/mall/promotion/reward/rewardActivity'
import { PromotionConditionTypeEnum } from '@/utils/constants'
import { useVModel } from '@vueuse/core'
import { isEmpty } from '@/utils/is'
defineOptions({ name: 'RewardRule' })
@ -99,6 +104,7 @@ const emits = defineEmits<{
}>()
const formData = useVModel(props, 'modelValue', emits) //
const rewardRuleCouponShowcaseRef = ref<InstanceType<typeof RewardRuleCouponShowcase>[]>() // Ref
/** 删除优惠规则 */
const deleteRule = (ruleIndex: number) => {
@ -119,7 +125,16 @@ const addRule = () => {
})
}
// TODO puhui999:
/** 设置规则优惠券-提交时 */
const setRuleCoupon = () => {
if (isEmpty(rewardRuleCouponShowcaseRef.value)) {
return
}
rewardRuleCouponShowcaseRef.value?.forEach((item) => item.setGiveCouponList())
}
defineExpose({ setRuleCoupon })
</script>
<style lang="scss" scoped></style>