diff --git a/src/api/mall/promotion/bargain/bargainActivity.ts b/src/api/mall/promotion/bargain/bargainActivity.ts index d16f422c..9ad219ac 100644 --- a/src/api/mall/promotion/bargain/bargainActivity.ts +++ b/src/api/mall/promotion/bargain/bargainActivity.ts @@ -24,7 +24,7 @@ export interface BargainProductVO { spuId: number skuId: number bargainFirstPrice: number // 砍价起始价格,单位分 - bargainPrice: number // 砍价底价 + bargainMinPrice: number // 砍价底价 stock: number // 活动库存 } diff --git a/src/api/mall/promotion/combination/combinationRecord.ts b/src/api/mall/promotion/combination/combinationRecord.ts index bf8c3668..90e8937e 100644 --- a/src/api/mall/promotion/combination/combinationRecord.ts +++ b/src/api/mall/promotion/combination/combinationRecord.ts @@ -22,6 +22,11 @@ export const getCombinationRecordPage = async (params) => { return await request.get({ url: '/promotion/combination-record/page', params }) } +// 查询一个拼团的完整拼团记录 +export const getCombinationRecordPageByHeadId = async (params) => { + return await request.get({ url: '/promotion/combination-record/page-by-headId', params }) +} + // 获得拼团记录的概要信息 export const getCombinationRecordSummary = async () => { return await request.get({ url: '/promotion/combination-record/get-summary' }) diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index b30151eb..53ccda11 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -1,5 +1,56 @@ import dayjs from 'dayjs' +/** + * 日期快捷选项适用于 el-date-picker + */ +export const defaultShortcuts = [ + { + text: '今天', + value: () => { + return new Date() + } + }, + { + text: '昨天', + value: () => { + const date = new Date() + date.setTime(date.getTime() - 3600 * 1000 * 24) + return [date, date] + } + }, + { + text: '最近七天', + value: () => { + const date = new Date() + date.setTime(date.getTime() - 3600 * 1000 * 24 * 7) + return [date, new Date()] + } + }, + { + text: '最近 30 天', + value: () => { + const date = new Date() + date.setTime(date.getTime() - 3600 * 1000 * 24 * 30) + return [date, new Date()] + } + }, + { + text: '本月', + value: () => { + const date = new Date() + date.setDate(1) // 设置为当前月的第一天 + return [date, new Date()] + } + }, + { + text: '今年', + value: () => { + const date = new Date() + return [new Date(`${date.getFullYear()}-01-01`), date] + } + } +] + /** * 时间日期转换 * @param date 当前时间,new Date() 格式 diff --git a/src/utils/formatter.ts b/src/utils/formatter.ts index 7c6e39ff..8777f322 100644 --- a/src/utils/formatter.ts +++ b/src/utils/formatter.ts @@ -1,12 +1,7 @@ -import { fenToYuan } from '@/utils' -import { TableColumnCtx } from 'element-plus' +import { floatToFixed2 } from '@/utils' // 格式化金额【分转元】 -export const fenToYuanFormat = ( - row: any, - column: TableColumnCtx, - cellValue: any, - index: number -) => { - return `¥${fenToYuan(cellValue)}` +// @ts-ignore +export const fenToYuanFormat = (_, __, cellValue: any, ___) => { + return `¥${floatToFixed2(cellValue)}` } diff --git a/src/utils/index.ts b/src/utils/index.ts index c63f899a..6c9a5df2 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -224,13 +224,12 @@ export const convertToInteger = (num: number | string | undefined): number => { * 元转分 */ export const yuanToFen = (amount: string | number): number => { - return Math.round(Number(amount) * 100) + return convertToInteger(amount) } /** * 分转元 */ export const fenToYuan = (price: string | number): number => { - price = Number(price) - return (price / 100.0).toFixed(2) + return formatToFraction(price) } diff --git a/src/views/mall/promotion/bargain/activity/BargainActivityForm.vue b/src/views/mall/promotion/bargain/activity/BargainActivityForm.vue index a649f1ba..d8d1463c 100644 --- a/src/views/mall/promotion/bargain/activity/BargainActivityForm.vue +++ b/src/views/mall/promotion/bargain/activity/BargainActivityForm.vue @@ -61,6 +61,7 @@ import { SpuAndSkuList, SpuProperty, SpuSelect } from '@/views/mall/promotion/co import { getPropertyList, RuleConfig } from '@/views/mall/product/spu/components' import * as ProductSpuApi from '@/api/mall/product/spu' import { convertToInteger, formatToFraction } from '@/utils' +import { cloneDeep } from 'lodash-es' defineOptions({ name: 'PromotionBargainActivityForm' }) @@ -204,8 +205,7 @@ const submitForm = async () => { // 提交请求 formLoading.value = true try { - // TODO @puhui999: 这样要深克隆 - const data = formRef.value.formModel as BargainActivityApi.BargainActivityVO + const data = cloneDeep(formRef.value.formModel) as BargainActivityApi.BargainActivityVO const products = spuAndSkuListRef.value.getSkuConfigs('productConfig') products.forEach((item: BargainProductVO) => { // 砍价价格元转分 diff --git a/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue b/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue index c50b698e..5b6e582b 100644 --- a/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue +++ b/src/views/mall/promotion/combination/activity/CombinationActivityForm.vue @@ -167,8 +167,7 @@ const submitForm = async () => { products.forEach((item: CombinationActivityApi.CombinationProductVO) => { item.combinationPrice = convertToInteger(item.combinationPrice) }) - // TODO @puhui999: 这样要深克隆 - const data = formRef.value.formModel as CombinationActivityApi.CombinationActivityVO + const data = cloneDeep(formRef.value.formModel) as CombinationActivityApi.CombinationActivityVO data.products = products // 真正提交 if (formType.value === 'create') { diff --git a/src/views/mall/promotion/combination/record/CombinationRecordListDialog.vue b/src/views/mall/promotion/combination/record/CombinationRecordListDialog.vue new file mode 100644 index 00000000..1d58c76d --- /dev/null +++ b/src/views/mall/promotion/combination/record/CombinationRecordListDialog.vue @@ -0,0 +1,119 @@ + + + diff --git a/src/views/mall/promotion/combination/record/index.vue b/src/views/mall/promotion/combination/record/index.vue index e55286af..740af96b 100644 --- a/src/views/mall/promotion/combination/record/index.vue +++ b/src/views/mall/promotion/combination/record/index.vue @@ -78,7 +78,7 @@ - - + @@ -184,23 +192,27 @@ @pagination="getList" /> + + +