2024-08-22 16:39:52 +08:00
|
|
|
|
<template>
|
|
|
|
|
<!-- 满减送活动规则组件 -->
|
|
|
|
|
<el-row>
|
|
|
|
|
<template v-if="formData.rules">
|
2024-08-23 16:22:46 +08:00
|
|
|
|
<el-col v-for="(rule, index) in formData.rules" :key="index" :span="24">
|
|
|
|
|
<span class="font-bold">活动层级{{ index + 1 }}</span>
|
|
|
|
|
<el-button v-if="index !== 0" link type="danger" @click="deleteRule(index)">
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
2024-08-22 16:39:52 +08:00
|
|
|
|
<el-form ref="formRef" :model="rule">
|
|
|
|
|
<el-form-item label="优惠门槛:" label-width="100px" prop="limit">
|
|
|
|
|
满
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="rule.limit"
|
|
|
|
|
:min="0"
|
|
|
|
|
class="w-150px! p-x-20px!"
|
|
|
|
|
placeholder=""
|
|
|
|
|
type="number"
|
|
|
|
|
/>
|
2024-08-23 18:28:37 +08:00
|
|
|
|
<!-- TODO @puhui999:走字典数据? -->
|
2024-08-22 16:39:52 +08:00
|
|
|
|
{{ PromotionConditionTypeEnum.PRICE.type === formData.conditionType ? '元' : '件' }}
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="优惠内容:" label-width="100px">
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
订单金额优惠
|
|
|
|
|
<el-form-item>
|
|
|
|
|
减
|
2024-08-26 16:30:35 +08:00
|
|
|
|
<el-input-number
|
2024-08-22 16:39:52 +08:00
|
|
|
|
v-model="rule.discountPrice"
|
2024-08-26 16:30:35 +08:00
|
|
|
|
:min="0"
|
|
|
|
|
:precision="2"
|
|
|
|
|
:step="0.1"
|
2024-08-22 16:39:52 +08:00
|
|
|
|
class="w-150px! p-x-20px!"
|
2024-08-26 16:30:35 +08:00
|
|
|
|
controls-position="right"
|
2024-08-22 16:39:52 +08:00
|
|
|
|
/>
|
|
|
|
|
元
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<span>包邮:</span>
|
|
|
|
|
<el-switch
|
|
|
|
|
v-model="rule.freeDelivery"
|
|
|
|
|
active-text="是"
|
|
|
|
|
inactive-text="否"
|
|
|
|
|
inline-prompt
|
|
|
|
|
/>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<span>送积分:</span>
|
2024-09-02 16:53:55 +08:00
|
|
|
|
<el-form-item>
|
2024-08-22 16:39:52 +08:00
|
|
|
|
送
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="rule.point"
|
|
|
|
|
class="w-150px! p-x-20px!"
|
|
|
|
|
placeholder=""
|
|
|
|
|
type="number"
|
|
|
|
|
/>
|
|
|
|
|
积分
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
2024-09-02 16:53:55 +08:00
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-tag type="warning"> 当赠送积分为 0 时,表示不赠送积分</el-tag>
|
|
|
|
|
</el-col>
|
2024-08-22 16:39:52 +08:00
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<span>送优惠券:</span>
|
2024-09-02 16:53:55 +08:00
|
|
|
|
<RewardRuleCouponSelect ref="rewardRuleCouponSelectRef" v-model="rule!" />
|
2024-08-22 16:39:52 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
2024-08-23 16:22:46 +08:00
|
|
|
|
</el-col>
|
2024-08-22 16:39:52 +08:00
|
|
|
|
</template>
|
2024-08-23 16:22:46 +08:00
|
|
|
|
<el-col :span="24" class="mt-10px">
|
2024-08-22 16:39:52 +08:00
|
|
|
|
<el-button type="primary" @click="addRule">添加优惠规则</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-08-26 16:30:35 +08:00
|
|
|
|
import RewardRuleCouponSelect from './RewardRuleCouponSelect.vue'
|
2024-08-22 16:39:52 +08:00
|
|
|
|
import { RewardActivityVO } from '@/api/mall/promotion/reward/rewardActivity'
|
|
|
|
|
import { PromotionConditionTypeEnum } from '@/utils/constants'
|
|
|
|
|
import { useVModel } from '@vueuse/core'
|
2024-08-23 16:57:36 +08:00
|
|
|
|
import { isEmpty } from '@/utils/is'
|
2024-08-22 16:39:52 +08:00
|
|
|
|
|
2024-08-26 16:30:35 +08:00
|
|
|
|
defineOptions({ name: 'RewardRule' })
|
|
|
|
|
|
2024-08-22 16:39:52 +08:00
|
|
|
|
const props = defineProps<{
|
|
|
|
|
modelValue: RewardActivityVO
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const emits = defineEmits<{
|
|
|
|
|
(e: 'update:modelValue', v: any): void
|
|
|
|
|
(e: 'deleteRule', v: number): void
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const formData = useVModel(props, 'modelValue', emits) // 活动数据
|
2024-08-26 16:30:35 +08:00
|
|
|
|
const rewardRuleCouponSelectRef = ref<InstanceType<typeof RewardRuleCouponSelect>[]>() // 活动规则优惠券 Ref
|
2024-08-22 16:39:52 +08:00
|
|
|
|
|
|
|
|
|
/** 删除优惠规则 */
|
|
|
|
|
const deleteRule = (ruleIndex: number) => {
|
|
|
|
|
formData.value.rules.splice(ruleIndex, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 添加优惠规则 */
|
|
|
|
|
const addRule = () => {
|
|
|
|
|
formData.value.rules.push({
|
|
|
|
|
limit: 0,
|
|
|
|
|
discountPrice: 0,
|
|
|
|
|
freeDelivery: false,
|
2024-09-02 16:53:55 +08:00
|
|
|
|
point: 0
|
2024-08-22 16:39:52 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2024-08-22 18:19:54 +08:00
|
|
|
|
|
2024-08-23 16:57:36 +08:00
|
|
|
|
/** 设置规则优惠券-提交时 */
|
|
|
|
|
const setRuleCoupon = () => {
|
2024-08-26 16:30:35 +08:00
|
|
|
|
if (isEmpty(rewardRuleCouponSelectRef.value)) {
|
2024-08-23 16:57:36 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-26 16:30:35 +08:00
|
|
|
|
rewardRuleCouponSelectRef.value?.forEach((item) => item.setGiveCouponList())
|
2024-08-23 16:57:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({ setRuleCoupon })
|
2024-08-22 16:39:52 +08:00
|
|
|
|
</script>
|