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