From 37d15d17ef2924918a632418e2eef5bf54451ebe Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Tue, 21 Oct 2025 19:05:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=99=AF=E5=8C=BA=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/model/vo/DashboardStatisticsVO.java | 4 +- .../service/impl/DashboardServiceImpl.java | 4 +- zlt-web/react-web-next/src/pages/Welcome.tsx | 156 +++++++++++------- 3 files changed, 97 insertions(+), 67 deletions(-) diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java index a276238e..a5d7207c 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java @@ -14,6 +14,6 @@ public class DashboardStatisticsVO { @Schema(description = "图表统计") private ChartStatistics chartStats; - @Schema(description = "筛选选项") - private FilterOptions filterOptions; + /* @Schema(description = "筛选选项") + private FilterOptions filterOptions;*/ } \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java index 5d0be2fe..1df43bb5 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java +++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java @@ -47,7 +47,7 @@ public class DashboardServiceImpl implements IDashboardService { DashboardStatisticsVO emptyStats = new DashboardStatisticsVO(); emptyStats.setOrderStats(new OrderStatisticsVO()); emptyStats.setChartStats(new ChartStatistics()); - emptyStats.setFilterOptions(new FilterOptions()); + //emptyStats.setFilterOptions(new FilterOptions()); return emptyStats; } @@ -81,7 +81,7 @@ public class DashboardServiceImpl implements IDashboardService { // 2. 获取图表统计 statistics.setChartStats(getChartStatistics(params)); // 3. 获取筛选选项 - statistics.setFilterOptions(getFilterOptions(params)); + // statistics.setFilterOptions(getFilterOptions(params)); } catch (Exception e) { log.error("获取仪表盘统计数据失败", e); } diff --git a/zlt-web/react-web-next/src/pages/Welcome.tsx b/zlt-web/react-web-next/src/pages/Welcome.tsx index 90197d8c..f9cb7d22 100644 --- a/zlt-web/react-web-next/src/pages/Welcome.tsx +++ b/zlt-web/react-web-next/src/pages/Welcome.tsx @@ -147,7 +147,7 @@ const Welcome: React.FC = () => { if (rangeType === 'date') { unit = 'hour'; fmtLabel = (m: moment.Moment) => m.format('HH:00'); - apiStatType = 'hour'; + apiStatType = 'date'; } else { // 月、年、周都按天显示 unit = 'day'; @@ -194,9 +194,15 @@ const Welcome: React.FC = () => { dataMap[type][date] = value; }); + // 获取接口返回的实际数据范围 + const actualDates = [...new Set(seriesData.map((item: any) => item.date))].sort(); + + // 如果没有数据,使用生成的labels;否则使用实际数据范围 + const effectiveLabels = actualDates.length > 0 ? actualDates : labels; + // 填充所有时间点,缺失的补 0 const lineSeries: { date: string; value: number; type: string }[] = []; - labels.forEach((label) => { + effectiveLabels.forEach((label) => { targetTypes.forEach((type) => { lineSeries.push({ date: label, @@ -337,6 +343,11 @@ const Welcome: React.FC = () => { const platformAmountYuan = Number(((netIncomeYuan * platformSharePercent) / 100).toFixed(2)); const scenicAmountYuan = Number((netIncomeYuan - platformAmountYuan).toFixed(2)); + const axisLeft = 40; + const axisTop = 40; + const axisBottom = 370; + const axisRight = 1850; + // 首次加载/筛选变化 useEffect(() => { if (!tenantId) return; @@ -388,9 +399,9 @@ const Welcome: React.FC = () => { - {/* 概览卡片:左侧订单数统计 + 右侧金额统计 */} + {/* 概览卡片:总订单 / 金额 / 分账 */} - + 总订单概览 @@ -415,7 +426,7 @@ const Welcome: React.FC = () => { - + 金额统计 @@ -441,12 +452,8 @@ const Welcome: React.FC = () => { - - - {/* 分账计算 + 景区订单数量统计 */} - - - + + 分账计算 @@ -495,11 +502,6 @@ const Welcome: React.FC = () => { - - - - - {/* 订单趋势 - 单独一列 */} @@ -509,33 +511,33 @@ const Welcome: React.FC = () => {
setTooltipData(null)} > - + {/* 绘制坐标轴 */} {/* 图例 */} - + 订单创建 @@ -550,8 +552,8 @@ const Welcome: React.FC = () => { {(() => { const allDates = [...new Set(orderLineSeries.map(item => item.date))].sort(); const maxValue = Math.max(...orderLineSeries.map(item => item.value), 1); - const chartRight = rangeType === 'year' ? 1150 : 1050; - const xStep = (chartRight - 60) / Math.max(allDates.length - 1, 1); + const chartRight = axisRight; + const xStep = (chartRight - axisLeft) / Math.max(allDates.length - 1, 1); // Y轴刻度和标签 const ySteps = 5; @@ -562,24 +564,24 @@ const Welcome: React.FC = () => { {/* Y轴刻度和标签 */} {Array.from({ length: ySteps + 1 }, (_, i) => { const value = i * yStepValue; - const chartBottom = rangeType === 'year' ? 520 : 430; - const chartTop = 40; + const chartBottom = axisBottom; + const chartTop = axisTop; const chartHeight = chartBottom - chartTop; const y = chartBottom - (value / maxValue) * chartHeight; return ( {value} @@ -591,9 +593,9 @@ const Welcome: React.FC = () => { // 根据日期数量和时间范围计算显示策略 let maxLabels = 12; if (rangeType === 'year') { - maxLabels = 20; // 年视图时可以显示更多标签,因为有更宽的空间 + maxLabels = 24; // 年视图显示月份标记,每月1-2个标签 } else if (rangeType === 'month') { - maxLabels = 15; + maxLabels = Math.min(allDates.length, 31); } else if (rangeType === 'week') { maxLabels = 10; } @@ -602,13 +604,26 @@ const Welcome: React.FC = () => { return allDates.map((date, index) => { // 判断是否显示此标签 - const shouldShow = index === 0 || - index === allDates.length - 1 || - index % labelInterval === 0; + let shouldShow = index === 0 || index === allDates.length - 1; + + // 年视图特殊处理:优先显示每月1日或15日 + if (rangeType === 'year') { + if (date.includes('-')) { + const parts = date.split('-'); + if (parts.length >= 3) { + const day = parseInt(parts[2]); + // 显示每月1日,或者每月中间的某个日期 + shouldShow = shouldShow || day === 1 || day === 15; + } + } + } else { + // 其他视图按间隔显示 + shouldShow = shouldShow || index % labelInterval === 0; + } if (!shouldShow) return null; - const x = 60 + index * xStep; + const x = axisLeft + index * xStep; // 智能格式化日期显示 let displayText = date; @@ -621,16 +636,22 @@ const Welcome: React.FC = () => { const parts = date.split('-'); if (parts.length >= 3) { if (rangeType === 'year') { - displayText = `${parts[1]}-${parts[2]}`; // 月-日 - } else if (rangeType === 'month') { - displayText = `${parts[1]}-${parts[2]}`; // 月-日 - } else { - displayText = `${parts[1]}-${parts[2]}`; // 月-日 - } + const day = parseInt(parts[2]); + // 年视图:每月1日显示"月月",其他日期显示"月-日" + if (day === 1) { + displayText = `${parseInt(parts[1])}月`; + } else { + displayText = `${parts[1]}-${parts[2]}`; + } + } else if (rangeType === 'month') { + displayText = `${parts[1]}-${parts[2]}`; // 月-日 + } else { + displayText = `${parts[1]}-${parts[2]}`; // 月-日 + } } } - const chartBottom = rangeType === 'year' ? 520 : 430; + const chartBottom = axisBottom; return ( { return datesWithData.map((date, dateIndex) => { const actualDateIndex = allDates.indexOf(date); - const x = 60 + actualDateIndex * xStep; + const x = axisLeft + actualDateIndex * xStep; - const chartBottom = rangeType === 'year' ? 520 : 430; - const chartTop = 40; + const chartBottom = axisBottom; + const chartTop = axisTop; const chartHeight = chartBottom - chartTop; return ( { style={{ cursor: 'pointer' }} onMouseEnter={(e: any) => { const svgRect = e.currentTarget.closest('svg').getBoundingClientRect(); - const svgWidth = rangeType === 'year' ? 1200 : 1100; - const svgHeight = rangeType === 'year' ? 600 : 500; + const svgWidth = 1900; + const svgHeight = 450; const tooltipX = (e.clientX - svgRect.left) * (svgWidth / svgRect.width); const tooltipY = (e.clientY - svgRect.top) * (svgHeight / svgRect.height); @@ -683,7 +704,7 @@ const Welcome: React.FC = () => { if (allDataForDate.length > 0) { const contentLines = allDataForDate.map(item => { - const colorMap = { + const colorMap: Record = { '订单创建': '#1677FF', '订单完成': '#52C41A', '退款': '#FF4D4F' @@ -753,11 +774,11 @@ const Welcome: React.FC = () => { const pathData = (() => { if (filledData.length === 0) return ''; - const chartBottom = rangeType === 'year' ? 520 : 430; - const chartTop = 40; + const chartBottom = axisBottom; + const chartTop = axisTop; const chartHeight = chartBottom - chartTop; const points = filledData.map((item, index) => { - const x = 60 + index * xStep; + const x = axisLeft + index * xStep; const y = chartBottom - (item.value / maxValue) * chartHeight; return { x, y }; }); @@ -820,9 +841,9 @@ const Welcome: React.FC = () => { if (item.value <= 0) return null; const dateIndex = allDates.indexOf(item.date); - const x = 60 + dateIndex * xStep; - const chartBottom = rangeType === 'year' ? 520 : 430; - const chartTop = 40; + const x = axisLeft + dateIndex * xStep; + const chartBottom = axisBottom; + const chartTop = axisTop; const chartHeight = chartBottom - chartTop; const y = chartBottom - (item.value / maxValue) * chartHeight; return ( @@ -851,9 +872,9 @@ const Welcome: React.FC = () => { {tooltipData && ( {
{ + {/* 景区订单数量统计:单行展示 */} + + + + + + + + {/* 订单状态分布 + 订单列表 */}