From 2e96b1c9840b7adfbc8110eb3a36bd2b406dc392 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 2 Jul 2023 19:22:57 +0800 Subject: [PATCH 1/8] feat: mall CombinationActivity --- .../combination/combinationactivity.ts | 48 +++++ src/utils/formatTime.ts | 7 + .../activity/CombinationActivityForm.vue | 74 ++++++++ .../activity/combinationActivity.data.ts | 168 ++++++++++++++++++ .../promotion/combination/activity/index.vue | 88 +++++++++ 5 files changed, 385 insertions(+) create mode 100644 src/api/mall/promotion/combination/combinationactivity.ts create mode 100644 src/views/mall/promotion/combination/activity/CombinationActivityForm.vue create mode 100644 src/views/mall/promotion/combination/activity/combinationActivity.data.ts create mode 100644 src/views/mall/promotion/combination/activity/index.vue diff --git a/src/api/mall/promotion/combination/combinationactivity.ts b/src/api/mall/promotion/combination/combinationactivity.ts new file mode 100644 index 00000000..bc946773 --- /dev/null +++ b/src/api/mall/promotion/combination/combinationactivity.ts @@ -0,0 +1,48 @@ +import request from '@/config/axios' + +export interface CombinationActivityVO { + id: number + name: string + spuId: number + totalLimitCount: number + singleLimitCount: number + startTime: Date + endTime: Date + userSize: number + totalNum: number + successNum: number + orderUserCount: number + virtualGroup: number + status: number + limitDuration: number +} + +// 查询拼团活动列表 +export const getCombinationActivityPage = async (params) => { + return await request.get({ url: '/promotion/combination-activity/page', params }) +} + +// 查询拼团活动详情 +export const getCombinationActivity = async (id: number) => { + return await request.get({ url: '/promotion/combination-activity/get?id=' + id }) +} + +// 新增拼团活动 +export const createCombinationActivity = async (data: CombinationActivityVO) => { + return await request.post({ url: '/promotion/combination-activity/create', data }) +} + +// 修改拼团活动 +export const updateCombinationActivity = async (data: CombinationActivityVO) => { + return await request.put({ url: '/promotion/combination-activity/update', data }) +} + +// 删除拼团活动 +export const deleteCombinationActivity = async (id: number) => { + return await request.delete({ url: '/promotion/combination-activity/delete?id=' + id }) +} + +// 导出拼团活动 Excel +export const exportCombinationActivity = async (params) => { + return await request.download({ url: '/promotion/combination-activity/export-excel', params }) +} diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index c9d80618..003f7c1c 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -23,6 +23,13 @@ export function formatDate(date: Date, format?: string): string { return dayjs(date).format(format) } +/** + * 获取当前的日期+时间 + */ +export function getNowDateTime() { + return dayjs().format('YYYY-MM-DD HH:mm:ss') +} + /** * 获取当前日期是第几周 * @param dateTime 当前传入的日期值 diff --git a/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue b/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue new file mode 100644 index 00000000..f0c22be5 --- /dev/null +++ b/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue @@ -0,0 +1,74 @@ + + diff --git a/src/views/mall/promotion/combination/activity/combinationActivity.data.ts b/src/views/mall/promotion/combination/activity/combinationActivity.data.ts new file mode 100644 index 00000000..1c423520 --- /dev/null +++ b/src/views/mall/promotion/combination/activity/combinationActivity.data.ts @@ -0,0 +1,168 @@ +import type { CrudSchema } from '@/hooks/web/useCrudSchemas' +import { dateFormatter, getNowDateTime } from '@/utils/formatTime' + +// 表单校验 +export const rules = reactive({ + name: [required], + totalLimitCount: [required], + singleLimitCount: [required], + startTime: [required], + endTime: [required], + userSize: [required], + totalNum: [required], + successNum: [required], + orderUserCount: [required], + virtualGroup: [required], + status: [required], + limitDuration: [required] +}) + +// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/ +const crudSchemas = reactive([ + { + label: '拼团名称', + field: 'name', + isSearch: true, + isTable: false, + form: { + colProps: { + span: 24 + } + } + }, + { + label: '活动时间', + field: 'activityTime', + formatter: dateFormatter, + search: { + show: true, + component: 'DatePicker', + componentProps: { + valueFormat: 'YYYY-MM-DD HH:mm:ss', + type: 'datetimerange' + } + }, + form: { + component: 'DatePicker', + componentProps: { + valueFormat: 'YYYY-MM-DD HH:mm:ss', + type: 'datetimerange' + }, + value: [getNowDateTime(), getNowDateTime()], + colProps: { + span: 24 + } + } + }, + { + label: '参与人数', + field: 'orderUserCount', + isSearch: false, + form: { + component: 'InputNumber', + labelMessage: '参与人数不能少于两人', + value: 2 + } + }, + { + label: '限制时长', + field: 'limitDuration', + isSearch: false, + isTable: false, + form: { + component: 'InputNumber', + labelMessage: '限制时长(小时)', + componentProps: { + placeholder: '请输入限制时长(小时)' + } + } + }, + { + label: '总限购数量', + field: 'totalLimitCount', + isSearch: false, + isTable: false, + form: { + component: 'InputNumber', + value: 0 + } + }, + { + label: '单次限购数量', + field: 'singleLimitCount', + isSearch: false, + isTable: false, + form: { + component: 'InputNumber', + value: 0 + } + }, + { + label: '购买人数', + field: 'userSize', + isSearch: false, + isForm: false + }, + { + label: '开团组数', + field: 'totalNum', + isSearch: false, + isForm: false + }, + { + label: '成团组数', + field: 'successNum', + isSearch: false, + isForm: false + }, + { + label: '虚拟成团', + field: 'virtualGroup', + isSearch: false, + isTable: false, + form: { + component: 'InputNumber', + value: 0 + } + }, + { + label: '活动状态', + field: 'status', + dictType: DICT_TYPE.COMMON_STATUS, + dictClass: 'number', + isSearch: true, + isForm: false + }, + { + label: '创建时间', + field: 'createTime', + formatter: dateFormatter, + isSearch: false, + isTable: false, + search: { + component: 'DatePicker', + componentProps: { + valueFormat: 'YYYY-MM-DD HH:mm:ss', + type: 'daterange', + defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] + } + }, + isForm: false + }, + { + label: '拼团商品', + field: 'spuId', + isSearch: false, + form: { + colProps: { + span: 24 + } + } + }, + { + label: '操作', + field: 'action', + isForm: false + } +]) +export const { allSchemas } = useCrudSchemas(crudSchemas) diff --git a/src/views/mall/promotion/combination/activity/index.vue b/src/views/mall/promotion/combination/activity/index.vue new file mode 100644 index 00000000..09cc1a7f --- /dev/null +++ b/src/views/mall/promotion/combination/activity/index.vue @@ -0,0 +1,88 @@ + + From b98149f1a75058edc9e85914772a1ae4cacf479d Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 3 Jul 2023 12:07:19 +0800 Subject: [PATCH 2/8] fix: mall SeckillActivity --- src/api/mall/product/spu.ts | 5 ++++ .../promotion/components/SpuAndSkuList.vue | 9 +++---- .../seckill/activity/SeckillActivityForm.vue | 26 ++++++++----------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/api/mall/product/spu.ts b/src/api/mall/product/spu.ts index d7ccfc5c..0ea324b8 100644 --- a/src/api/mall/product/spu.ts +++ b/src/api/mall/product/spu.ts @@ -86,6 +86,11 @@ export const getSpu = (id: number) => { return request.get({ url: `/product/spu/get-detail?id=${id}` }) } +// 获得商品 Spu 详情列表 +export const getSpuDetailList = (ids: number[]) => { + return request.get({ url: `/product/spu/list?spuIds=${ids}` }) +} + // 删除商品 Spu export const deleteSpu = (id: number) => { return request.delete({ url: `/product/spu/delete?id=${id}` }) diff --git a/src/views/mall/promotion/components/SpuAndSkuList.vue b/src/views/mall/promotion/components/SpuAndSkuList.vue index e239a39a..f1b6843c 100644 --- a/src/views/mall/promotion/components/SpuAndSkuList.vue +++ b/src/views/mall/promotion/components/SpuAndSkuList.vue @@ -47,17 +47,14 @@ diff --git a/src/views/mall/promotion/components/SpuAndSkuList.vue b/src/views/mall/promotion/components/SpuAndSkuList.vue index 20ade584..8efb7f83 100644 --- a/src/views/mall/promotion/components/SpuAndSkuList.vue +++ b/src/views/mall/promotion/components/SpuAndSkuList.vue @@ -1,5 +1,5 @@