From 42b78d1411f2a4cf5ce3a5b63e52d8eabc38baae Mon Sep 17 00:00:00 2001 From: owen Date: Fri, 24 Nov 2023 20:54:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9F=8E=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=BB=9F=E8=AE=A1=E6=97=B6=E9=97=B4=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E9=80=89=E6=8B=A9=E6=98=A8=E5=A4=A9=E6=97=B6,=20?= =?UTF-8?q?=E4=BC=9A=E5=BC=BA=E5=88=B6=E6=9F=A5=E8=AF=A2=E4=B8=A4=E5=A4=A9?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit c3cad3f3ee4f23e5caabea83d08d42eaf955cc1d) --- src/components/ShortcutDateRangePicker/index.vue | 5 ----- src/utils/formatTime.ts | 5 ++++- src/views/mall/statistics/trade/index.vue | 9 +++++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/ShortcutDateRangePicker/index.vue b/src/components/ShortcutDateRangePicker/index.vue index 9f268a3f..117c079a 100644 --- a/src/components/ShortcutDateRangePicker/index.vue +++ b/src/components/ShortcutDateRangePicker/index.vue @@ -74,11 +74,6 @@ const emits = defineEmits<{ }>() /** 触发时间范围选中事件 */ const emitDateRangePicker = async () => { - // 开始与截止在同一天的, 折线图出不来, 需要延长一天 - if (DateUtil.isSameDay(times.value[0], times.value[1])) { - // 前天 - times.value[0] = DateUtil.formatDate(dayjs(times.value[0]).subtract(1, 'd')) - } emits('change', times.value) } diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index 655bd522..d71372ea 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -382,5 +382,8 @@ export function getDateRange( beginDate: dayjs.ConfigType, endDate: dayjs.ConfigType ): [string, string] { - return [dayjs(beginDate).startOf('d').toString(), dayjs(endDate).endOf('d').toString()] + return [ + dayjs(beginDate).startOf('d').format('YYYY-MM-DD HH:mm:ss'), + dayjs(endDate).endOf('d').format('YYYY-MM-DD HH:mm:ss') + ] } diff --git a/src/views/mall/statistics/trade/index.vue b/src/views/mall/statistics/trade/index.vue index e89f0cc3..86deaa87 100644 --- a/src/views/mall/statistics/trade/index.vue +++ b/src/views/mall/statistics/trade/index.vue @@ -219,6 +219,8 @@ import { TradeSummaryRespVO, TradeTrendSummaryRespVO } from '@/api/mall/statisti import { calculateRelativeRate, fenToYuan } from '@/utils' import download from '@/utils/download' import { CardTitle } from '@/components/Card' +import * as DateUtil from '@/utils/formatTime' +import dayjs from 'dayjs' /** 交易统计 */ defineOptions({ name: 'TradeStatistics' }) @@ -289,6 +291,13 @@ const lineChartOptions = reactive({ /** 处理交易状况查询 */ const getTradeTrendData = async () => { trendLoading.value = true + // 1. 处理时间: 开始与截止在同一天的, 折线图出不来, 需要延长一天 + const times = shortcutDateRangePicker.value.times + if (DateUtil.isSameDay(times[0], times[1])) { + // 前天 + times[0] = DateUtil.formatDate(dayjs(times[0]).subtract(1, 'd')) + } + // 查询数据 await Promise.all([getTradeTrendSummary(), getTradeStatisticsList()]) trendLoading.value = false }