Skip to content

Commit c3cad3f

Browse files
committed
商城:修复会员统计时间范围选择昨天时, 会强制查询两天的问题
1 parent 253401a commit c3cad3f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/components/ShortcutDateRangePicker/index.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ const emits = defineEmits<{
7474
}>()
7575
/** 触发时间范围选中事件 */
7676
const emitDateRangePicker = async () => {
77-
// 开始与截止在同一天的, 折线图出不来, 需要延长一天
78-
if (DateUtil.isSameDay(times.value[0], times.value[1])) {
79-
// 前天
80-
times.value[0] = DateUtil.formatDate(dayjs(times.value[0]).subtract(1, 'd'))
81-
}
8277
emits('change', times.value)
8378
}
8479

src/utils/formatTime.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,8 @@ export function getDateRange(
335335
beginDate: dayjs.ConfigType,
336336
endDate: dayjs.ConfigType
337337
): [string, string] {
338-
return [dayjs(beginDate).startOf('d').toString(), dayjs(endDate).endOf('d').toString()]
338+
return [
339+
dayjs(beginDate).startOf('d').format('YYYY-MM-DD HH:mm:ss'),
340+
dayjs(endDate).endOf('d').format('YYYY-MM-DD HH:mm:ss')
341+
]
339342
}

src/views/mall/statistics/trade/index.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ import { TradeSummaryRespVO, TradeTrendSummaryRespVO } from '@/api/mall/statisti
219219
import { calculateRelativeRate, fenToYuan } from '@/utils'
220220
import download from '@/utils/download'
221221
import { CardTitle } from '@/components/Card'
222+
import * as DateUtil from '@/utils/formatTime'
223+
import dayjs from 'dayjs'
222224
223225
/** 交易统计 */
224226
defineOptions({ name: 'TradeStatistics' })
@@ -289,6 +291,13 @@ const lineChartOptions = reactive<EChartsOption>({
289291
/** 处理交易状况查询 */
290292
const getTradeTrendData = async () => {
291293
trendLoading.value = true
294+
// 1. 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天
295+
const times = shortcutDateRangePicker.value.times
296+
if (DateUtil.isSameDay(times[0], times[1])) {
297+
// 前天
298+
times[0] = DateUtil.formatDate(dayjs(times[0]).subtract(1, 'd'))
299+
}
300+
// 查询数据
292301
await Promise.all([getTradeTrendSummary(), getTradeStatisticsList()])
293302
trendLoading.value = false
294303
}

0 commit comments

Comments
 (0)