SPU: 完善优惠卷选择
This commit is contained in:
parent
3464bb9c74
commit
18df708b49
@ -25,6 +25,11 @@ export interface Sku {
|
|||||||
salesCount?: number // 商品销量
|
salesCount?: number // 商品销量
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GiveCouponTemplate {
|
||||||
|
id?: number
|
||||||
|
name?: string // 优惠券名称
|
||||||
|
}
|
||||||
|
|
||||||
export interface Spu {
|
export interface Spu {
|
||||||
id?: number
|
id?: number
|
||||||
name?: string // 商品名称
|
name?: string // 商品名称
|
||||||
@ -55,6 +60,7 @@ export interface Spu {
|
|||||||
stock?: number // 商品库存
|
stock?: number // 商品库存
|
||||||
createTime?: Date // 商品创建时间
|
createTime?: Date // 商品创建时间
|
||||||
status?: number // 商品状态
|
status?: number // 商品状态
|
||||||
|
giveCouponTemplate?: GiveCouponTemplate[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获得 Spu 列表
|
// 获得 Spu 列表
|
||||||
|
@ -150,14 +150,15 @@ import {
|
|||||||
} from '@/views/mall/promotion/coupon/formatter'
|
} from '@/views/mall/promotion/coupon/formatter'
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
|
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
|
||||||
|
import type { GiveCouponTemplate } from '@/api/mall/product/spu'
|
||||||
|
|
||||||
defineOptions({ name: 'CouponSelect' })
|
defineOptions({ name: 'CouponSelect' })
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
multipleSelection: { id: number; name: string }[]
|
multipleSelection: GiveCouponTemplate[]
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:multipleSelection', v: { id: number; name: string }[])
|
(e: 'update:multipleSelection', v: GiveCouponTemplate[])
|
||||||
}>()
|
}>()
|
||||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const dialogTitle = ref('选择优惠卷') // 弹窗的标题
|
const dialogTitle = ref('选择优惠卷') // 弹窗的标题
|
||||||
@ -212,6 +213,8 @@ const handleSelectionChange = (val: CouponTemplateApi.CouponTemplateVO[]) => {
|
|||||||
val.map((item) => ({ id: item.id, name: item.name }))
|
val.map((item) => ({ id: item.id, name: item.name }))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const submitForm = async () => {}
|
const submitForm = () => {
|
||||||
|
dialogVisible.value = false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
@ -82,16 +82,15 @@
|
|||||||
{{ row.recommendGood ? '是' : '否' }}
|
{{ row.recommendGood ? '是' : '否' }}
|
||||||
</template>
|
</template>
|
||||||
<template #activityOrders>
|
<template #activityOrders>
|
||||||
<el-tag>默认</el-tag>
|
<el-tag v-for="coupon in couponTemplateList" :key="coupon.id as number" class="mr-[10px]">
|
||||||
<el-tag class="ml-2" type="success">秒杀</el-tag>
|
{{ coupon.name }}
|
||||||
<el-tag class="ml-2" type="info">砍价</el-tag>
|
</el-tag>
|
||||||
<el-tag class="ml-2" type="warning">拼团</el-tag>
|
|
||||||
</template>
|
</template>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
<CouponSelect ref="couponSelectRef" />
|
<CouponSelect ref="couponSelectRef" v-model:multiple-selection="couponTemplateList" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Spu } from '@/api/mall/product/spu'
|
import type { GiveCouponTemplate, Spu } from '@/api/mall/product/spu'
|
||||||
import { PropType } from 'vue'
|
import { PropType } from 'vue'
|
||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { copyValueToTarget } from '@/utils'
|
import { copyValueToTarget } from '@/utils'
|
||||||
@ -113,8 +112,8 @@ const props = defineProps({
|
|||||||
activeName: propTypes.string.def(''),
|
activeName: propTypes.string.def(''),
|
||||||
isDetail: propTypes.bool.def(false) // 是否作为详情组件
|
isDetail: propTypes.bool.def(false) // 是否作为详情组件
|
||||||
})
|
})
|
||||||
const couponSelectRef = ref() // 优惠卷模版选择
|
const couponSelectRef = ref() // 优惠卷模版选择 Ref
|
||||||
const couponTemplateList = ref<{ id: number; name: string }[]>([]) // 选择的优惠卷
|
const couponTemplateList = ref<GiveCouponTemplate[]>([]) // 选择的优惠卷
|
||||||
const openCouponSelect = () => {
|
const openCouponSelect = () => {
|
||||||
couponSelectRef.value?.open()
|
couponSelectRef.value?.open()
|
||||||
}
|
}
|
||||||
@ -129,7 +128,8 @@ const formData = ref<Spu>({
|
|||||||
recommendBenefit: false, // 是否优惠
|
recommendBenefit: false, // 是否优惠
|
||||||
recommendBest: false, // 是否精品
|
recommendBest: false, // 是否精品
|
||||||
recommendNew: false, // 是否新品
|
recommendNew: false, // 是否新品
|
||||||
recommendGood: false // 是否优品
|
recommendGood: false, // 是否优品
|
||||||
|
giveCouponTemplate: [] // 赠送的优惠券
|
||||||
})
|
})
|
||||||
// 表单规则
|
// 表单规则
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
@ -163,6 +163,9 @@ watch(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
copyValueToTarget(formData.value, data)
|
copyValueToTarget(formData.value, data)
|
||||||
|
if (data.giveCouponTemplate) {
|
||||||
|
couponTemplateList.value = data.giveCouponTemplate
|
||||||
|
}
|
||||||
recommendOptions.forEach(({ value }) => {
|
recommendOptions.forEach(({ value }) => {
|
||||||
if (formData.value[value] && !checkboxGroup.value.includes(value)) {
|
if (formData.value[value] && !checkboxGroup.value.includes(value)) {
|
||||||
checkboxGroup.value.push(value)
|
checkboxGroup.value.push(value)
|
||||||
@ -189,6 +192,7 @@ const validate = async () => {
|
|||||||
throw new Error('商品其他设置未完善!!')
|
throw new Error('商品其他设置未完善!!')
|
||||||
} else {
|
} else {
|
||||||
// 校验通过更新数据
|
// 校验通过更新数据
|
||||||
|
formData.value.giveCouponTemplate = couponTemplateList.value
|
||||||
Object.assign(props.propFormData, formData.value)
|
Object.assign(props.propFormData, formData.value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -62,14 +62,14 @@ const otherSettingsRef = ref() // 其他设置Ref
|
|||||||
// spu 表单数据
|
// spu 表单数据
|
||||||
const formData = ref<ProductSpuApi.Spu>({
|
const formData = ref<ProductSpuApi.Spu>({
|
||||||
name: '', // 商品名称
|
name: '', // 商品名称
|
||||||
categoryId: null, // 商品分类
|
categoryId: undefined, // 商品分类
|
||||||
keyword: '', // 关键字
|
keyword: '', // 关键字
|
||||||
unit: null, // 单位
|
unit: undefined, // 单位
|
||||||
picUrl: '', // 商品封面图
|
picUrl: '', // 商品封面图
|
||||||
sliderPicUrls: [], // 商品轮播图
|
sliderPicUrls: [], // 商品轮播图
|
||||||
introduction: '', // 商品简介
|
introduction: '', // 商品简介
|
||||||
deliveryTemplateId: null, // 运费模版
|
deliveryTemplateId: undefined, // 运费模版
|
||||||
brandId: null, // 商品品牌
|
brandId: undefined, // 商品品牌
|
||||||
specType: false, // 商品规格
|
specType: false, // 商品规格
|
||||||
subCommissionType: false, // 分销类型
|
subCommissionType: false, // 分销类型
|
||||||
skus: [
|
skus: [
|
||||||
@ -94,7 +94,8 @@ const formData = ref<ProductSpuApi.Spu>({
|
|||||||
recommendBenefit: false, // 是否优惠
|
recommendBenefit: false, // 是否优惠
|
||||||
recommendBest: false, // 是否精品
|
recommendBest: false, // 是否精品
|
||||||
recommendNew: false, // 是否新品
|
recommendNew: false, // 是否新品
|
||||||
recommendGood: false // 是否优品
|
recommendGood: false, // 是否优品
|
||||||
|
giveCouponTemplate: [] // 赠送的优惠券
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 获得详情 */
|
/** 获得详情 */
|
||||||
|
@ -96,7 +96,7 @@ export const otherSettingsSchema = reactive<CrudSchema[]>([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '赠送的优惠劵',
|
label: '赠送的优惠劵',
|
||||||
field: 'giveCouponTemplateIds'
|
field: 'giveCouponTemplate'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '活动显示排序',
|
label: '活动显示排序',
|
||||||
|
Loading…
Reference in New Issue
Block a user