diff --git a/src/api/mall/promotion/bargain/bargainActivity.ts b/src/api/mall/promotion/bargain/bargainActivity.ts new file mode 100644 index 00000000..a23477d9 --- /dev/null +++ b/src/api/mall/promotion/bargain/bargainActivity.ts @@ -0,0 +1,62 @@ +import request from '@/config/axios' +import { Sku, Spu } from '@/api/mall/product/spu' + +export interface BargainActivityVO { + id?: number + name?: string + startTime?: Date + endTime?: Date + status?: number + spuId?: number + userSize?: number // 达到该人数,才能砍到低价 + bargainCount?: number // 最大帮砍次数 + totalLimitCount?: number // 最大购买次数 + stock?: number // 活动总库存 + randomMinPrice?: number // 用户每次砍价的最小金额,单位:分 + randomMaxPrice?: number // 用户每次砍价的最大金额,单位:分 + successCount?: number // 砍价成功数量 + products?: BargainProductVO[] +} + +// 砍价活动所需属性 +export interface BargainProductVO { + spuId: number + skuId: number + bargainFirstPrice: number // 砍价起始价格,单位分 + bargainPrice: number // 砍价底价 + stock: number // 活动库存 +} + +// 扩展 Sku 配置 +export type SkuExtension = Sku & { + productConfig: BargainProductVO +} + +export interface SpuExtension extends Spu { + skus: SkuExtension[] // 重写类型 +} + +// 查询砍价活动列表 +export const getBargainActivityPage = async (params: any) => { + return await request.get({ url: '/promotion/bargain-activity/page', params }) +} + +// 查询砍价活动详情 +export const getBargainActivity = async (id: number) => { + return await request.get({ url: '/promotion/bargain-activity/get?id=' + id }) +} + +// 新增砍价活动 +export const createBargainActivity = async (data: BargainActivityVO) => { + return await request.post({ url: '/promotion/bargain-activity/create', data }) +} + +// 修改砍价活动 +export const updateBargainActivity = async (data: BargainActivityVO) => { + return await request.put({ url: '/promotion/bargain-activity/update', data }) +} + +// 删除砍价活动 +export const deleteBargainActivity = async (id: number) => { + return await request.delete({ url: '/promotion/bargain-activity/delete?id=' + id }) +} diff --git a/src/api/mall/promotion/combination/combinationActivity.ts b/src/api/mall/promotion/combination/combinationActivity.ts index 1e211c86..f89264e4 100644 --- a/src/api/mall/promotion/combination/combinationActivity.ts +++ b/src/api/mall/promotion/combination/combinationActivity.ts @@ -10,8 +10,8 @@ export interface CombinationActivityVO { startTime?: Date endTime?: Date userSize?: number - totalNum?: number - successNum?: number + totalCount?: number + successCount?: number orderUserCount?: number virtualGroup?: number status?: number @@ -23,7 +23,7 @@ export interface CombinationActivityVO { export interface CombinationProductVO { spuId: number skuId: number - activePrice: number // 拼团价格 + combinationPrice: number // 拼团价格 } // 扩展 Sku 配置 diff --git a/src/api/mall/promotion/coupon.ts b/src/api/mall/promotion/coupon/coupon.ts similarity index 100% rename from src/api/mall/promotion/coupon.ts rename to src/api/mall/promotion/coupon/coupon.ts diff --git a/src/api/mall/promotion/couponTemplate.ts b/src/api/mall/promotion/coupon/couponTemplate.ts similarity index 100% rename from src/api/mall/promotion/couponTemplate.ts rename to src/api/mall/promotion/coupon/couponTemplate.ts diff --git a/src/api/mall/promotion/seckill/seckillConfig.ts b/src/api/mall/promotion/seckill/seckillConfig.ts index eee82115..23ad15ca 100644 --- a/src/api/mall/promotion/seckill/seckillConfig.ts +++ b/src/api/mall/promotion/seckill/seckillConfig.ts @@ -20,7 +20,7 @@ export const getSeckillConfig = async (id: number) => { } // 获得所有开启状态的秒杀时段精简列表 -export const getListAllSimple = async () => { +export const getSimpleSeckillConfigList = async () => { return await request.get({ url: '/promotion/seckill-config/list-all-simple' }) } diff --git a/src/hooks/web/useCrudSchemas.ts b/src/hooks/web/useCrudSchemas.ts index 984e57c5..4cfe1eaf 100644 --- a/src/hooks/web/useCrudSchemas.ts +++ b/src/hooks/web/useCrudSchemas.ts @@ -9,6 +9,7 @@ import { TableColumn } from '@/types/table' import { DescriptionsSchema } from '@/types/descriptions' import { ComponentOptions, ComponentProps } from '@/types/components' import { DictTag } from '@/components/DictTag' +import { cloneDeep } from 'lodash-es' export type CrudSchema = Omit & { isSearch?: boolean // 是否在查询显示 @@ -306,3 +307,12 @@ const filterOptions = (options: Recordable, labelField?: string) => { return v }) } + +// 将 tableColumns 指定 fields 放到最前面 +export const sortTableColumns = (tableColumns: TableColumn[], field: string) => { + const fieldIndex = tableColumns.findIndex((item) => item.field === field) + const fieldColumn = cloneDeep(tableColumns[fieldIndex]) + tableColumns.splice(fieldIndex, 1) + // 添加到开头 + tableColumns.unshift(fieldColumn) +} diff --git a/src/views/bpm/group/index.vue b/src/views/bpm/group/index.vue index ee8c2e65..957ffc89 100644 --- a/src/views/bpm/group/index.vue +++ b/src/views/bpm/group/index.vue @@ -30,7 +30,7 @@ diff --git a/src/views/mall/promotion/bargain/activity/BargainActivityForm.vue b/src/views/mall/promotion/bargain/activity/BargainActivityForm.vue new file mode 100644 index 00000000..5384d6a1 --- /dev/null +++ b/src/views/mall/promotion/bargain/activity/BargainActivityForm.vue @@ -0,0 +1,219 @@ + + diff --git a/src/views/mall/promotion/bargain/activity/bargainActivity.data.ts b/src/views/mall/promotion/bargain/activity/bargainActivity.data.ts new file mode 100644 index 00000000..209fb468 --- /dev/null +++ b/src/views/mall/promotion/bargain/activity/bargainActivity.data.ts @@ -0,0 +1,165 @@ +import type { CrudSchema } from '@/hooks/web/useCrudSchemas' +import { dateFormatter2 } from '@/utils/formatTime' + +// 表单校验 +export const rules = reactive({ + name: [required], + startTime: [required], + endTime: [required], + userSize: [required], + bargainCount: [required], + singleLimitCount: [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: '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: 'userSize', + isSearch: false, + form: { + component: 'InputNumber', + labelMessage: '参与人数不能少于两人', + value: 2 + } + }, + { + label: '最大帮砍次数', + field: 'bargainCount', + isSearch: false, + form: { + component: 'InputNumber', + labelMessage: '参与人数不能少于两人', + value: 2 + } + }, + { + label: '总限购数量', + field: 'totalLimitCount', + isSearch: false, + form: { + component: 'InputNumber', + labelMessage: '用户最大能发起砍价的次数', + value: 0 + } + }, + { + label: '砍价的最小金额', + field: 'randomMinPrice', + isSearch: false, + isTable: false, + form: { + component: 'InputNumber', + componentProps: { + min: 0, + precision: 2, + step: 0.1 + }, + labelMessage: '用户每次砍价的最小金额', + value: 0 + } + }, + { + label: '砍价的最大金额', + field: 'randomMaxPrice', + isSearch: false, + isTable: false, + form: { + component: 'InputNumber', + componentProps: { + min: 0, + precision: 2, + step: 0.1 + }, + labelMessage: '用户每次砍价的最大金额', + value: 0 + } + }, + { + label: '砍价成功数量', + field: 'successCount', + isSearch: false, + isForm: false + }, + { + label: '活动状态', + field: 'status', + dictType: DICT_TYPE.COMMON_STATUS, + dictClass: 'number', + isSearch: true, + 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/bargain/activity/index.vue b/src/views/mall/promotion/bargain/activity/index.vue new file mode 100644 index 00000000..abcbcc6b --- /dev/null +++ b/src/views/mall/promotion/bargain/activity/index.vue @@ -0,0 +1,107 @@ + + diff --git a/src/views/mall/promotion/combination/CombinationActivityForm.vue b/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue similarity index 91% rename from src/views/mall/promotion/combination/CombinationActivityForm.vue rename to src/views/mall/promotion/combination/activity/CombinationActivityForm.vue index 265eb98e..3c802ede 100644 --- a/src/views/mall/promotion/combination/CombinationActivityForm.vue +++ b/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue @@ -19,7 +19,7 @@