【新增】MALL: 满减送活动赠送优惠券(100%)
parent
a08684089d
commit
f996d00e92
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Dialog v-model="dialogVisible" :title="dialogTitle" width="60%">
|
<Dialog v-model="dialogVisible" :title="dialogTitle" width="65%">
|
||||||
<el-form
|
<el-form
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
v-loading="formLoading"
|
v-loading="formLoading"
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="优惠设置">
|
<el-form-item label="优惠设置">
|
||||||
<RewardRule v-model="formData" />
|
<RewardRule ref="rewardRuleRef" v-model="formData" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="活动范围" prop="productScope">
|
<el-form-item label="活动范围" prop="productScope">
|
||||||
<el-radio-group v-model="formData.productScope">
|
<el-radio-group v-model="formData.productScope">
|
||||||
|
@ -97,7 +97,8 @@ const formRules = reactive({
|
||||||
productSpuIds: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
|
productSpuIds: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
|
||||||
productCategoryIds: [{ 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) => {
|
const open = async (type: string, id?: number) => {
|
||||||
|
@ -126,14 +127,14 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
// 校验表单
|
// 校验表单
|
||||||
if (!formRef) return
|
if (!formRef) return
|
||||||
// TODO puhui999: 规则校验
|
const valid = await formRef.value.validate()
|
||||||
// const valid = await formRef.value.validate()
|
if (!valid) return
|
||||||
// if (!valid) return
|
|
||||||
// TODO puhui999: 处理下数据兼容接口
|
|
||||||
|
|
||||||
// 提交请求
|
// 提交请求
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
|
// 设置活动规则优惠券
|
||||||
|
rewardRuleRef.value?.setRuleCoupon()
|
||||||
const data = formData.value
|
const data = formData.value
|
||||||
// 设置商品范围
|
// 设置商品范围
|
||||||
setProductScopeValues(data)
|
setProductScopeValues(data)
|
||||||
|
|
|
@ -69,7 +69,11 @@
|
||||||
inactive-text="否"
|
inactive-text="否"
|
||||||
inline-prompt
|
inline-prompt
|
||||||
/>
|
/>
|
||||||
<RewardRuleCouponShowcase v-if="rule.giveCoupon" v-model="rule!" />
|
<RewardRuleCouponShowcase
|
||||||
|
v-if="rule.giveCoupon"
|
||||||
|
ref="rewardRuleCouponShowcaseRef"
|
||||||
|
v-model="rule!"
|
||||||
|
/>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
@ -86,6 +90,7 @@ import RewardRuleCouponShowcase from './RewardRuleCouponShowcase.vue'
|
||||||
import { RewardActivityVO } from '@/api/mall/promotion/reward/rewardActivity'
|
import { RewardActivityVO } from '@/api/mall/promotion/reward/rewardActivity'
|
||||||
import { PromotionConditionTypeEnum } from '@/utils/constants'
|
import { PromotionConditionTypeEnum } from '@/utils/constants'
|
||||||
import { useVModel } from '@vueuse/core'
|
import { useVModel } from '@vueuse/core'
|
||||||
|
import { isEmpty } from '@/utils/is'
|
||||||
|
|
||||||
defineOptions({ name: 'RewardRule' })
|
defineOptions({ name: 'RewardRule' })
|
||||||
|
|
||||||
|
@ -99,6 +104,7 @@ const emits = defineEmits<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const formData = useVModel(props, 'modelValue', emits) // 活动数据
|
const formData = useVModel(props, 'modelValue', emits) // 活动数据
|
||||||
|
const rewardRuleCouponShowcaseRef = ref<InstanceType<typeof RewardRuleCouponShowcase>[]>() // 活动规则优惠券 Ref
|
||||||
|
|
||||||
/** 删除优惠规则 */
|
/** 删除优惠规则 */
|
||||||
const deleteRule = (ruleIndex: number) => {
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|
Loading…
Reference in New Issue