RewardRule.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <!-- 满减送活动规则组件 -->
  3. <el-row>
  4. <template v-if="formData.rules">
  5. <div v-for="(rule, index) in formData.rules" :key="index">
  6. <el-col :span="24">
  7. <span class="font-bold">活动层级{{ index + 1 }}</span>
  8. <el-button v-if="index !== 0" link type="danger" @click="deleteRule(index)">
  9. 删除
  10. </el-button>
  11. </el-col>
  12. <el-form ref="formRef" :model="rule">
  13. <el-form-item label="优惠门槛:" label-width="100px" prop="limit">
  14. <el-input
  15. v-model="rule.limit"
  16. :min="0"
  17. class="w-150px! p-x-20px!"
  18. placeholder=""
  19. type="number"
  20. />
  21. {{ PromotionConditionTypeEnum.PRICE.type === formData.conditionType ? '元' : '件' }}
  22. </el-form-item>
  23. <el-form-item label="优惠内容:" label-width="100px">
  24. <el-col :span="24">
  25. 订单金额优惠
  26. <el-form-item>
  27. <el-input
  28. v-model="rule.discountPrice"
  29. class="w-150px! p-x-20px!"
  30. placeholder=""
  31. type="number"
  32. />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="24">
  36. <span>包邮:</span>
  37. <el-switch
  38. v-model="rule.freeDelivery"
  39. active-text="是"
  40. inactive-text="否"
  41. inline-prompt
  42. />
  43. </el-col>
  44. <el-col :span="24">
  45. <span>送积分:</span>
  46. <el-switch
  47. v-model="rule.givePoint"
  48. active-text="是"
  49. inactive-text="否"
  50. inline-prompt
  51. />
  52. <el-form-item v-if="rule.givePoint">
  53. <el-input
  54. v-model="rule.point"
  55. class="w-150px! p-x-20px!"
  56. placeholder=""
  57. type="number"
  58. />
  59. 积分
  60. </el-form-item>
  61. </el-col>
  62. <!-- 优惠券待处理 也可以参考优惠劵的SpuShowcase-->
  63. <!-- TODO 待实现!-->
  64. <el-col :span="24">
  65. <span>送优惠券:</span>
  66. <el-switch
  67. v-model="rule.giveCoupon"
  68. active-text="是"
  69. inactive-text="否"
  70. inline-prompt
  71. />
  72. <RewardRuleCouponShowcase v-if="rule.giveCoupon" />
  73. </el-col>
  74. </el-form-item>
  75. </el-form>
  76. </div>
  77. </template>
  78. <el-col :span="24">
  79. <el-button type="primary" @click="addRule">添加优惠规则</el-button>
  80. </el-col>
  81. </el-row>
  82. </template>
  83. <script lang="ts" setup>
  84. import RewardRuleCouponShowcase from './RewardRuleCouponShowcase.vue'
  85. import { RewardActivityVO } from '@/api/mall/promotion/reward/rewardActivity'
  86. import { PromotionConditionTypeEnum } from '@/utils/constants'
  87. import { useVModel } from '@vueuse/core'
  88. defineOptions({ name: 'RewardRule' })
  89. const props = defineProps<{
  90. modelValue: RewardActivityVO
  91. }>()
  92. const emits = defineEmits<{
  93. (e: 'update:modelValue', v: any): void
  94. (e: 'deleteRule', v: number): void
  95. }>()
  96. const formData = useVModel(props, 'modelValue', emits) // 活动数据
  97. /** 删除优惠规则 */
  98. const deleteRule = (ruleIndex: number) => {
  99. formData.value.rules.splice(ruleIndex, 1)
  100. }
  101. /** 添加优惠规则 */
  102. const addRule = () => {
  103. formData.value.rules.push({
  104. limit: 0,
  105. discountPrice: 0,
  106. freeDelivery: false,
  107. givePoint: false,
  108. point: 0,
  109. giveCoupon: false,
  110. couponIds: [],
  111. couponCounts: []
  112. })
  113. }
  114. // TODO puhui999: 规则校验完善
  115. </script>
  116. <style lang="scss" scoped></style>