commit
e187c55408
@ -0,0 +1,60 @@
|
||||
import request from '@/config/axios'
|
||||
import { Sku, Spu } from '@/api/mall/product/spu'
|
||||
|
||||
export interface DiscountActivityVO {
|
||||
id?: number
|
||||
spuId?: number
|
||||
name?: string
|
||||
status?: number
|
||||
remark?: string
|
||||
startTime?: Date
|
||||
endTime?: Date
|
||||
products?: DiscountProductVO[]
|
||||
}
|
||||
// 限时折扣相关 属性
|
||||
export interface DiscountProductVO {
|
||||
spuId: number
|
||||
skuId: number
|
||||
discountType: number
|
||||
discountPercent: number
|
||||
discountPrice: number
|
||||
}
|
||||
|
||||
// 扩展 Sku 配置
|
||||
export type SkuExtension = Sku & {
|
||||
productConfig: DiscountProductVO
|
||||
}
|
||||
|
||||
export interface SpuExtension extends Spu {
|
||||
skus: SkuExtension[] // 重写类型
|
||||
}
|
||||
|
||||
// 查询限时折扣活动列表
|
||||
export const getDiscountActivityPage = async (params) => {
|
||||
return await request.get({ url: '/promotion/discount-activity/page', params })
|
||||
}
|
||||
|
||||
// 查询限时折扣活动详情
|
||||
export const getDiscountActivity = async (id: number) => {
|
||||
return await request.get({ url: '/promotion/discount-activity/get?id=' + id })
|
||||
}
|
||||
|
||||
// 新增限时折扣活动
|
||||
export const createDiscountActivity = async (data: DiscountActivityVO) => {
|
||||
return await request.post({ url: '/promotion/discount-activity/create', data })
|
||||
}
|
||||
|
||||
// 修改限时折扣活动
|
||||
export const updateDiscountActivity = async (data: DiscountActivityVO) => {
|
||||
return await request.put({ url: '/promotion/discount-activity/update', data })
|
||||
}
|
||||
|
||||
// 关闭限时折扣活动
|
||||
export const closeDiscountActivity = async (id: number) => {
|
||||
return await request.put({ url: '/promotion/discount-activity/close?id=' + id })
|
||||
}
|
||||
|
||||
// 删除限时折扣活动
|
||||
export const deleteDiscountActivity = async (id: number) => {
|
||||
return await request.delete({ url: '/promotion/discount-activity/delete?id=' + id })
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
|
||||
// 表单校验
|
||||
export const rules = reactive({
|
||||
spuId: [required],
|
||||
name: [required],
|
||||
startTime: [required],
|
||||
endTime: [required],
|
||||
discountType: [required]
|
||||
})
|
||||
|
||||
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
|
||||
const crudSchemas = reactive<CrudSchema[]>([
|
||||
{
|
||||
label: '活动名称',
|
||||
field: 'name',
|
||||
isSearch: true,
|
||||
form: {
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
table: {
|
||||
width: 120
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '活动开始时间',
|
||||
field: 'startTime',
|
||||
formatter: dateFormatter2,
|
||||
isSearch: true,
|
||||
search: {
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
type: 'daterange'
|
||||
}
|
||||
},
|
||||
form: {
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'date',
|
||||
valueFormat: 'x'
|
||||
}
|
||||
},
|
||||
table: {
|
||||
width: 120
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '活动结束时间',
|
||||
field: 'endTime',
|
||||
formatter: dateFormatter2,
|
||||
isSearch: true,
|
||||
search: {
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
type: 'daterange'
|
||||
}
|
||||
},
|
||||
form: {
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'date',
|
||||
valueFormat: 'x'
|
||||
}
|
||||
},
|
||||
table: {
|
||||
width: 120
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '优惠类型',
|
||||
field: 'discountType',
|
||||
dictType: DICT_TYPE.PROMOTION_DISCOUNT_TYPE,
|
||||
dictClass: 'number',
|
||||
isSearch: true,
|
||||
form: {
|
||||
component: 'Radio',
|
||||
value: 1
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '活动商品',
|
||||
field: 'spuId',
|
||||
isTable: true,
|
||||
isSearch: false,
|
||||
form: {
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
table: {
|
||||
width: 300
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
field: 'remark',
|
||||
isSearch: false,
|
||||
form: {
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
type: 'textarea',
|
||||
rows: 4
|
||||
},
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
table: {
|
||||
width: 300
|
||||
}
|
||||
}
|
||||
])
|
||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
||||
Loading…
Reference in New Issue