商品 spu 脱离优惠卷模块

This commit is contained in:
puhui999
2023-10-24 16:57:20 +08:00
parent a7439ee08b
commit 75135e1e4f
8 changed files with 131 additions and 90 deletions

View File

@@ -54,6 +54,13 @@ const initSortable = () => {
}
onMounted(async () => {
await nextTick()
// 如果活动排序为空也就是新增的时候加入活动
if (props.activityOrders && props.activityOrders.length === 0) {
emit(
'update:activityOrders',
props.promotionTypes.map((item) => item.value as number)
)
}
initSortable()
})
</script>

View File

@@ -42,25 +42,12 @@
</el-col>
<el-col :span="24">
<el-form-item label="活动优先级">
<!-- TODO @puhui999这个目前先写死主要是这个优惠类型不好用 promotion_type_enum因为优惠劵会员折扣都算 -->
<ActivityOrdersSort
v-model:activity-orders="formData.activityOrders"
:promotion-types="promotionTypes"
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="赠送优惠劵">
<el-tag
v-for="coupon in formData.giveCouponTemplates"
:key="coupon.id as number"
class="mr-[10px]"
>
{{ coupon.name }}
</el-tag>
<el-button @click="openCouponSelect">选择优惠券</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
@@ -91,17 +78,7 @@
{{ promotionTypes.find((item) => item.value === activityType)?.label }}
</el-tag>
</template>
<template #giveCouponTemplates="{ row }">
<el-tag
v-for="coupon in row.giveCouponTemplates"
:key="coupon.id as number"
class="mr-[10px]"
>
{{ coupon.name }}
</el-tag>
</template>
</Descriptions>
<CouponSelect ref="couponSelectRef" v-model:multiple-selection="formData.giveCouponTemplates" />
</template>
<script lang="ts" setup>
import type { Spu } from '@/api/mall/product/spu'
@@ -109,8 +86,7 @@ import { PropType } from 'vue'
import { propTypes } from '@/utils/propTypes'
import { copyValueToTarget } from '@/utils'
import { otherSettingsSchema } from './spu.data'
import { DICT_TYPE, DictDataType, getIntDictOptions } from '@/utils/dict'
import CouponSelect from './CouponSelect.vue'
import { DICT_TYPE, DictDataType } from '@/utils/dict'
import ActivityOrdersSort from './ActivityOrdersSort.vue'
defineOptions({ name: 'OtherSettingsForm' })
@@ -128,14 +104,66 @@ const props = defineProps({
isDetail: propTypes.bool.def(false) // 是否作为详情组件
})
// 优惠卷
const couponSelectRef = ref() // 优惠卷模版选择 Ref
const openCouponSelect = () => {
couponSelectRef.value?.open()
}
// TODO @puhui999这个目前先写死主要是这个优惠类型不好用 promotion_type_enum因为优惠劵、会员折扣都算
// 活动优先级处理
const promotionTypes = ref<DictDataType[]>(getIntDictOptions(DICT_TYPE.PROMOTION_TYPE_ENUM))
const promotionTypes = ref<DictDataType[]>([
{
dictType: 'promotionTypes',
label: '秒杀活动',
value: 1,
colorType: 'warning',
cssClass: ''
},
{
dictType: 'promotionTypes',
label: '砍价活动',
value: 2,
colorType: 'warning',
cssClass: ''
},
{
dictType: 'promotionTypes',
label: '拼团活动',
value: 3,
colorType: 'warning',
cssClass: ''
},
{
dictType: 'promotionTypes',
label: '限时折扣',
value: 4,
colorType: 'warning',
cssClass: ''
},
{
dictType: 'promotionTypes',
label: '满减送',
value: 5,
colorType: 'warning',
cssClass: ''
},
{
dictType: 'promotionTypes',
label: '会员折扣',
value: 6,
colorType: 'warning',
cssClass: ''
},
{
dictType: 'promotionTypes',
label: '优惠劵',
value: 7,
colorType: 'warning',
cssClass: ''
},
{
dictType: 'promotionTypes',
label: '积分',
value: 8,
colorType: 'warning',
cssClass: ''
}
])
const otherSettingsFormRef = ref() // 表单Ref
// 表单数据
@@ -148,8 +176,7 @@ const formData = ref<Spu>({
recommendBest: false, // 是否精品
recommendNew: false, // 是否新品
recommendGood: false, // 是否优品
activityOrders: [], // 活动排序
giveCouponTemplates: [] // 赠送的优惠券
activityOrders: [] // 活动排序
})
// 表单规则
const rules = reactive({

View File

@@ -95,8 +95,7 @@ const formData = ref<ProductSpuApi.Spu>({
recommendBest: false, // 是否精品
recommendNew: false, // 是否新品
recommendGood: false, // 是否优品
activityOrders: [], // 活动排序
giveCouponTemplates: [] // 赠送的优惠券
activityOrders: [] // 活动排序
})
/** 获得详情 */

View File

@@ -94,10 +94,6 @@ export const otherSettingsSchema = reactive<CrudSchema[]>([
label: '是否优品推荐',
field: 'recommendGood'
},
{
label: '赠送的优惠劵',
field: 'giveCouponTemplates'
},
{
label: '活动显示排序',
field: 'activityOrders'

View File

@@ -0,0 +1,4 @@
import CouponSendForm from './CouponSendForm.vue'
import CouponSelect from './CouponSelect.vue'
export { CouponSendForm, CouponSelect }