diff --git a/src/api/mall/promotion/coupon/couponTemplate.ts b/src/api/mall/promotion/coupon/couponTemplate.ts
index daac1334..bf294441 100755
--- a/src/api/mall/promotion/coupon/couponTemplate.ts
+++ b/src/api/mall/promotion/coupon/couponTemplate.ts
@@ -9,7 +9,7 @@ export interface CouponTemplateVO {
takeType: number
usePrice: number
productScope: number
- productSpuIds: string
+ productSpuIds: number[]
validityType: number
validStartTime: Date
validEndTime: Date
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index cd346a5c..03c1f999 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -220,6 +220,10 @@ export const PromotionProductScopeEnum = {
SPU: {
scope: 2,
name: '指定商品参与'
+ },
+ CATEGORY: {
+ scope: 3,
+ name: '指定品类参与'
}
}
diff --git a/src/views/mall/product/category/components/ProductCategorySelect.vue b/src/views/mall/product/category/components/ProductCategorySelect.vue
new file mode 100644
index 00000000..b8011290
--- /dev/null
+++ b/src/views/mall/product/category/components/ProductCategorySelect.vue
@@ -0,0 +1,47 @@
+
+
+
+
diff --git a/src/views/mall/promotion/coupon/template/CouponTemplateForm.vue b/src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
index 69132fbb..e511dd0c 100644
--- a/src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
+++ b/src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
@@ -172,6 +172,12 @@
+
+
+
确 定
@@ -190,6 +196,7 @@ import {
PromotionProductScopeEnum
} from '@/utils/constants'
import SpuTableSelect from '@/views/mall/product/spu/components/SpuTableSelect.vue'
+import ProductCategorySelect from '@/views/mall/product/category/components/ProductCategorySelect.vue'
defineOptions({ name: 'CouponTemplateForm' })
@@ -218,7 +225,8 @@ const formData = ref({
fixedStartTerm: undefined,
fixedEndTerm: undefined,
productScope: PromotionProductScopeEnum.ALL.scope,
- productSpuIds: []
+ productSpuIds: [],
+ productCategoryIds: []
})
const formRules = reactive({
name: [{ required: true, message: '优惠券名称不能为空', trigger: 'blur' }],
@@ -235,7 +243,8 @@ const formRules = reactive({
fixedStartTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
fixedEndTerm: [{ required: true, message: '开始领取天数不能为空', trigger: 'blur' }],
productScope: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }],
- productSpuIds: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }]
+ productSpuIds: [{ required: true, message: '商品范围不能为空', trigger: 'blur' }],
+ productCategoryIds: [{ required: true, message: '分类范围不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
const productSpus = ref([]) // 商品列表
@@ -302,6 +311,12 @@ const submitForm = async () => {
? formData.value.validTimes[1]
: undefined
} as CouponTemplateApi.CouponTemplateVO
+
+ if (formData.value.productCategoryIds?.length > 0) {
+ // 改个名字?加个字段?
+ data.productSpuIds = formData.value.productCategoryIds
+ }
+
if (formType.value === 'create') {
await CouponTemplateApi.createCouponTemplate(data)
message.success(t('common.createSuccess'))
@@ -337,7 +352,8 @@ const resetForm = () => {
fixedStartTerm: undefined,
fixedEndTerm: undefined,
productScope: PromotionProductScopeEnum.ALL.scope,
- productSpuIds: []
+ productSpuIds: [],
+ productCategoryIds: []
}
formRef.value?.resetFields()
productSpus.value = []
@@ -350,6 +366,10 @@ const getProductScope = async () => {
// 获得商品列表
productSpus.value = await ProductSpuApi.getSpuDetailList(formData.value.productSpuIds)
break
+ case PromotionProductScopeEnum.CATEGORY.scope:
+ formData.value.productCategoryIds = formData.value.productSpuIds
+ formData.value.productSpuIds = []
+ break
default:
break
}