Skip to content

Commit 75135e1

Browse files
author
puhui999
committed
商品 spu 脱离优惠卷模块
1 parent a7439ee commit 75135e1

File tree

8 files changed

+127
-86
lines changed

8 files changed

+127
-86
lines changed

src/api/mall/product/spu.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export interface Spu {
6161
createTime?: Date // 商品创建时间
6262
status?: number // 商品状态
6363
activityOrders: number[] // 活动排序
64-
giveCouponTemplates: GiveCouponTemplate[] // 优惠卷
6564
}
6665

6766
// 获得 Spu 列表

src/views/mall/product/spu/form/ActivityOrdersSort.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ const initSortable = () => {
5454
}
5555
onMounted(async () => {
5656
await nextTick()
57+
// 如果活动排序为空也就是新增的时候加入活动
58+
if (props.activityOrders && props.activityOrders.length === 0) {
59+
emit(
60+
'update:activityOrders',
61+
props.promotionTypes.map((item) => item.value as number)
62+
)
63+
}
5764
initSortable()
5865
})
5966
</script>

src/views/mall/product/spu/form/OtherSettingsForm.vue

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,12 @@
4242
</el-col>
4343
<el-col :span="24">
4444
<el-form-item label="活动优先级">
45-
<!-- TODO @puhui999:这个目前先写死;主要是,这个优惠类型不好用 promotion_type_enum;因为优惠劵、会员折扣都算。 -->
4645
<ActivityOrdersSort
4746
v-model:activity-orders="formData.activityOrders"
4847
:promotion-types="promotionTypes"
4948
/>
5049
</el-form-item>
5150
</el-col>
52-
<el-col :span="24">
53-
<el-form-item label="赠送优惠劵">
54-
<el-tag
55-
v-for="coupon in formData.giveCouponTemplates"
56-
:key="coupon.id as number"
57-
class="mr-[10px]"
58-
>
59-
{{ coupon.name }}
60-
</el-tag>
61-
<el-button @click="openCouponSelect">选择优惠券</el-button>
62-
</el-form-item>
63-
</el-col>
6451
</el-row>
6552
</el-form>
6653

@@ -91,26 +78,15 @@
9178
{{ promotionTypes.find((item) => item.value === activityType)?.label }}
9279
</el-tag>
9380
</template>
94-
<template #giveCouponTemplates="{ row }">
95-
<el-tag
96-
v-for="coupon in row.giveCouponTemplates"
97-
:key="coupon.id as number"
98-
class="mr-[10px]"
99-
>
100-
{{ coupon.name }}
101-
</el-tag>
102-
</template>
10381
</Descriptions>
104-
<CouponSelect ref="couponSelectRef" v-model:multiple-selection="formData.giveCouponTemplates" />
10582
</template>
10683
<script lang="ts" setup>
10784
import type { Spu } from '@/api/mall/product/spu'
10885
import { PropType } from 'vue'
10986
import { propTypes } from '@/utils/propTypes'
11087
import { copyValueToTarget } from '@/utils'
11188
import { otherSettingsSchema } from './spu.data'
112-
import { DICT_TYPE, DictDataType, getIntDictOptions } from '@/utils/dict'
113-
import CouponSelect from './CouponSelect.vue'
89+
import { DICT_TYPE, DictDataType } from '@/utils/dict'
11490
import ActivityOrdersSort from './ActivityOrdersSort.vue'
11591
11692
defineOptions({ name: 'OtherSettingsForm' })
@@ -128,14 +104,66 @@ const props = defineProps({
128104
isDetail: propTypes.bool.def(false) // 是否作为详情组件
129105
})
130106
131-
// 优惠卷
132-
const couponSelectRef = ref() // 优惠卷模版选择 Ref
133-
const openCouponSelect = () => {
134-
couponSelectRef.value?.open()
135-
}
136-
107+
// TODO @puhui999:这个目前先写死;主要是,这个优惠类型不好用 promotion_type_enum;因为优惠劵、会员折扣都算
137108
// 活动优先级处理
138-
const promotionTypes = ref<DictDataType[]>(getIntDictOptions(DICT_TYPE.PROMOTION_TYPE_ENUM))
109+
const promotionTypes = ref<DictDataType[]>([
110+
{
111+
dictType: 'promotionTypes',
112+
label: '秒杀活动',
113+
value: 1,
114+
colorType: 'warning',
115+
cssClass: ''
116+
},
117+
{
118+
dictType: 'promotionTypes',
119+
label: '砍价活动',
120+
value: 2,
121+
colorType: 'warning',
122+
cssClass: ''
123+
},
124+
{
125+
dictType: 'promotionTypes',
126+
label: '拼团活动',
127+
value: 3,
128+
colorType: 'warning',
129+
cssClass: ''
130+
},
131+
{
132+
dictType: 'promotionTypes',
133+
label: '限时折扣',
134+
value: 4,
135+
colorType: 'warning',
136+
cssClass: ''
137+
},
138+
{
139+
dictType: 'promotionTypes',
140+
label: '满减送',
141+
value: 5,
142+
colorType: 'warning',
143+
cssClass: ''
144+
},
145+
{
146+
dictType: 'promotionTypes',
147+
label: '会员折扣',
148+
value: 6,
149+
colorType: 'warning',
150+
cssClass: ''
151+
},
152+
{
153+
dictType: 'promotionTypes',
154+
label: '优惠劵',
155+
value: 7,
156+
colorType: 'warning',
157+
cssClass: ''
158+
},
159+
{
160+
dictType: 'promotionTypes',
161+
label: '积分',
162+
value: 8,
163+
colorType: 'warning',
164+
cssClass: ''
165+
}
166+
])
139167
140168
const otherSettingsFormRef = ref() // 表单Ref
141169
// 表单数据
@@ -148,8 +176,7 @@ const formData = ref<Spu>({
148176
recommendBest: false, // 是否精品
149177
recommendNew: false, // 是否新品
150178
recommendGood: false, // 是否优品
151-
activityOrders: [], // 活动排序
152-
giveCouponTemplates: [] // 赠送的优惠券
179+
activityOrders: [] // 活动排序
153180
})
154181
// 表单规则
155182
const rules = reactive({

src/views/mall/product/spu/form/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ const formData = ref<ProductSpuApi.Spu>({
9595
recommendBest: false, // 是否精品
9696
recommendNew: false, // 是否新品
9797
recommendGood: false, // 是否优品
98-
activityOrders: [], // 活动排序
99-
giveCouponTemplates: [] // 赠送的优惠券
98+
activityOrders: [] // 活动排序
10099
})
101100
102101
/** 获得详情 */

src/views/mall/product/spu/form/spu.data.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ export const otherSettingsSchema = reactive<CrudSchema[]>([
9494
label: '是否优品推荐',
9595
field: 'recommendGood'
9696
},
97-
{
98-
label: '赠送的优惠劵',
99-
field: 'giveCouponTemplates'
100-
},
10197
{
10298
label: '活动显示排序',
10399
field: 'activityOrders'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import CouponSendForm from './CouponSendForm.vue'
2+
import CouponSelect from './CouponSelect.vue'
3+
4+
export { CouponSendForm, CouponSelect }

0 commit comments

Comments
 (0)