SPU: 完善优惠卷选择

(cherry picked from commit 18df708b49)
This commit is contained in:
puhui999 2023-10-20 11:48:59 +08:00 committed by shizhong
parent 801ea4c176
commit de53601fcb
5 changed files with 32 additions and 18 deletions

View File

@ -25,6 +25,11 @@ export interface Sku {
salesCount?: number // 商品销量
}
export interface GiveCouponTemplate {
id?: number
name?: string // 优惠券名称
}
export interface Spu {
id?: number
name?: string // 商品名称
@ -55,6 +60,7 @@ export interface Spu {
stock?: number // 商品库存
createTime?: Date // 商品创建时间
status?: number // 商品状态
giveCouponTemplate?: GiveCouponTemplate[]
}
// 获得 Spu 列表

View File

@ -150,14 +150,15 @@ import {
} from '@/views/mall/promotion/coupon/formatter'
import { dateFormatter } from '@/utils/formatTime'
import * as CouponTemplateApi from '@/api/mall/promotion/coupon/couponTemplate'
import type { GiveCouponTemplate } from '@/api/mall/product/spu'
defineOptions({ name: 'CouponSelect' })
defineProps<{
multipleSelection: { id: number; name: string }[]
multipleSelection: GiveCouponTemplate[]
}>()
const emit = defineEmits<{
(e: 'update:multipleSelection', v: { id: number; name: string }[])
(e: 'update:multipleSelection', v: GiveCouponTemplate[])
}>()
const dialogVisible = ref(false) //
const dialogTitle = ref('选择优惠卷') //
@ -212,6 +213,8 @@ const handleSelectionChange = (val: CouponTemplateApi.CouponTemplateVO[]) => {
val.map((item) => ({ id: item.id, name: item.name }))
)
}
const submitForm = async () => {}
const submitForm = () => {
dialogVisible.value = false
}
</script>
<style lang="scss" scoped></style>

View File

@ -82,16 +82,15 @@
{{ row.recommendGood ? '是' : '否' }}
</template>
<template #activityOrders>
<el-tag>默认</el-tag>
<el-tag class="ml-2" type="success">秒杀</el-tag>
<el-tag class="ml-2" type="info">砍价</el-tag>
<el-tag class="ml-2" type="warning">拼团</el-tag>
<el-tag v-for="coupon in couponTemplateList" :key="coupon.id as number" class="mr-[10px]">
{{ coupon.name }}
</el-tag>
</template>
</Descriptions>
<CouponSelect ref="couponSelectRef" />
<CouponSelect ref="couponSelectRef" v-model:multiple-selection="couponTemplateList" />
</template>
<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 { propTypes } from '@/utils/propTypes'
import { copyValueToTarget } from '@/utils'
@ -113,8 +112,8 @@ const props = defineProps({
activeName: propTypes.string.def(''),
isDetail: propTypes.bool.def(false) //
})
const couponSelectRef = ref() //
const couponTemplateList = ref<{ id: number; name: string }[]>([]) //
const couponSelectRef = ref() // Ref
const couponTemplateList = ref<GiveCouponTemplate[]>([]) //
const openCouponSelect = () => {
couponSelectRef.value?.open()
}
@ -129,7 +128,8 @@ const formData = ref<Spu>({
recommendBenefit: false, //
recommendBest: false, //
recommendNew: false, //
recommendGood: false //
recommendGood: false, //
giveCouponTemplate: [] //
})
//
const rules = reactive({
@ -163,6 +163,9 @@ watch(
return
}
copyValueToTarget(formData.value, data)
if (data.giveCouponTemplate) {
couponTemplateList.value = data.giveCouponTemplate
}
recommendOptions.forEach(({ value }) => {
if (formData.value[value] && !checkboxGroup.value.includes(value)) {
checkboxGroup.value.push(value)
@ -189,6 +192,7 @@ const validate = async () => {
throw new Error('商品其他设置未完善!!')
} else {
//
formData.value.giveCouponTemplate = couponTemplateList.value
Object.assign(props.propFormData, formData.value)
}
})

View File

@ -62,14 +62,14 @@ const otherSettingsRef = ref() // 其他设置Ref
// spu
const formData = ref<ProductSpuApi.Spu>({
name: '', //
categoryId: null, //
categoryId: undefined, //
keyword: '', //
unit: null, //
unit: undefined, //
picUrl: '', //
sliderPicUrls: [], //
introduction: '', //
deliveryTemplateId: null, //
brandId: null, //
deliveryTemplateId: undefined, //
brandId: undefined, //
specType: false, //
subCommissionType: false, //
skus: [
@ -94,7 +94,8 @@ const formData = ref<ProductSpuApi.Spu>({
recommendBenefit: false, //
recommendBest: false, //
recommendNew: false, //
recommendGood: false //
recommendGood: false, //
giveCouponTemplate: [] //
})
/** 获得详情 */

View File

@ -96,7 +96,7 @@ export const otherSettingsSchema = reactive<CrudSchema[]>([
},
{
label: '赠送的优惠劵',
field: 'giveCouponTemplateIds'
field: 'giveCouponTemplate'
},
{
label: '活动显示排序',