From c6a779310dfcfd5c343b79e5ac13b703ddd03eb6 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Mon, 20 Oct 2025 19:25:41 +0800 Subject: [PATCH 1/8] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=88=86=E8=B4=A6=E8=AE=A1=E7=AE=97=E6=A8=A1=E5=9D=97=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 显示被隐藏的分账计算模块(移除 display: 'none') - 调整 platformSharePercent 状态变量定义顺序 - 优化 Slider 组件: - 设置标记文字颜色为深灰色 (#666),避免看不清 - 添加 tooltip 提示框,拖动时显示当前百分比 - 设置 tooltip 背景为深色,文字为白色,确保清晰可见 - 移除重复的 90% 标记,只保留 0%、50%、100% 🤖 Generated with Claude Code Co-Authored-By: Claude --- zlt-web/react-web-next/src/pages/Welcome.tsx | 94 +++++++++++++++++--- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/zlt-web/react-web-next/src/pages/Welcome.tsx b/zlt-web/react-web-next/src/pages/Welcome.tsx index cca4503b..b0711164 100644 --- a/zlt-web/react-web-next/src/pages/Welcome.tsx +++ b/zlt-web/react-web-next/src/pages/Welcome.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useRef, useState } from 'react'; -import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid } from 'antd'; +import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid, Slider, InputNumber } from 'antd'; import { ReloadOutlined } from '@ant-design/icons'; import { Line, Pie } from '@ant-design/plots'; import TenantScopeFilter from '@/components/TenantScopeFilter'; @@ -22,7 +22,7 @@ const computeRangeByType = (type: RangeType, anchor?: Moment): [Moment, Moment] const STATUS_OPTIONS: { value: number; label: string; color?: string }[] = [ { value: 0, label: '待支付' }, { value: 1, label: '排队中', color: 'gold' }, - { value: 2, label: '已取号', color: 'red' }, + { value: 2, label: '已取消', color: 'red' }, { value: 3, label: '设备执行完成', color: 'green' }, { value: 4, label: '正在服务', color: 'blue' }, { value: 5, label: '素材上传', color: 'geekblue' }, @@ -36,8 +36,9 @@ const Welcome: React.FC = () => { // 租户与时间 const [tenantId, setTenantId] = useState(); const [includeChildren, setIncludeChildren] = useState(true); - const [rangeType, setRangeType] = useState('date'); - const [range, setRange] = useState<[Moment, Moment]>(makeDefaultToday()); + // 默认统计时间:年 + const [rangeType, setRangeType] = useState('year'); + const [range, setRange] = useState<[Moment, Moment]>(computeRangeByType('year', moment())); // 加载与数据 const [loading, setLoading] = useState(false); @@ -74,7 +75,8 @@ const Welcome: React.FC = () => { const handleRangeChange = (vals: any) => { if (!Array.isArray(vals) || vals.length !== 2 || !vals[0] || !vals[1]) { - setRange(makeDefaultToday()); + // 按当前类型回退默认范围 + setRange(computeRangeByType(rangeType, moment())); return; } let s = vals[0] as Moment; @@ -221,9 +223,15 @@ const Welcome: React.FC = () => { animation: false, }; + // 平台分账比例(默认 90%),用于分账计算展示框 + const [platformSharePercent, setPlatformSharePercent] = useState(90); + const totalAmountYuan = Number(((orderStats?.totalAmount ?? 0) as number) / 100); const refundAmountYuan = Number(((orderStats?.refundAmount ?? 0) as number) / 100); const netIncomeYuan = Number((totalAmountYuan - refundAmountYuan).toFixed(2)); + // 分账金额(基于净收入) + const platformAmountYuan = Number(((netIncomeYuan * platformSharePercent) / 100).toFixed(2)); + const scenicAmountYuan = Number((netIncomeYuan - platformAmountYuan).toFixed(2)); // 首次加载/筛选变化 useEffect(() => { @@ -247,11 +255,12 @@ const Welcome: React.FC = () => { { 总订单概览 - 总订单数 + 支付总订单数 @@ -294,7 +303,7 @@ const Welcome: React.FC = () => { - 净订单数 + 支付净订单数 @@ -324,6 +333,71 @@ const Welcome: React.FC = () => { + + + + + + + {/* 分账计算(基于净收入) */} + + + + + + 分账计算 + + + 平台分账比例 +
+ setPlatformSharePercent(Number(v))} + marks={{ + 0: { style: { color: '#666' }, label: '0%' }, + 50: { style: { color: '#666' }, label: '50%' }, + 100: { style: { color: '#666' }, label: '100%' } + }} + tooltip={{ + formatter: (value) => `${value}%`, + overlayStyle: { + backgroundColor: 'rgba(0, 0, 0, 0.75)', + color: '#fff' + }, + overlayInnerStyle: { + backgroundColor: 'rgba(0, 0, 0, 0.75)', + color: '#fff' + } + }} + /> + setPlatformSharePercent(Number(v || 0))} formatter={(v) => `${v}%`} parser={(v: any) => Number(String(v || '').replace('%', ''))} /> +
+
+ +
+ + + + + 平台分账金额(元) + + + + + + + + 景区分账金额(元) + + + + + + 基于净收入计算(净收入 = 订单总金额 - 退款总金额)
From a0ef9e233418eca96d511f18fafcdbe5c65e46d6 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Mon, 20 Oct 2025 19:26:47 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96Slider=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E6=97=B6tooltip=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=8F=AF=E8=A7=81=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 设置 Slider tooltip 背景为深色 rgba(0, 0, 0, 0.75) - 设置 tooltip 文字颜色为白色,确保在任何背景下都清晰可见 - 添加全局样式规则,覆盖Antd默认样式 🤖 Generated with Claude Code Co-Authored-By: Claude --- zlt-web/react-web-next/src/global.less | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zlt-web/react-web-next/src/global.less b/zlt-web/react-web-next/src/global.less index dd165ee3..3ebcb248 100644 --- a/zlt-web/react-web-next/src/global.less +++ b/zlt-web/react-web-next/src/global.less @@ -72,3 +72,14 @@ html, body, #root { height: 100%; } h1, .ant-typography h1 { font-size: 22px; } h2, .ant-typography h2 { font-size: 18px; } } + +/* Slider tooltip 提示框文字颜色优化 */ +.ant-slider-tooltip-inner { + background-color: rgba(0, 0, 0, 0.75) !important; + color: #fff !important; +} + +.ant-slider .ant-tooltip-inner { + background-color: rgba(0, 0, 0, 0.75) !important; + color: #fff !important; +} From 84ddcac0acc73e7555ada361c75ce14851a939f9 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Mon, 20 Oct 2025 19:27:59 +0800 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4Slider=E4=B8=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=9A=84=E5=B1=9E=E6=80=A7=EF=BC=8C=E4=BE=9D?= =?UTF-8?q?=E9=9D=A0=E5=85=A8=E5=B1=80=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?tooltip=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除不支持的 overlayStyle 和 overlayInnerStyle 属性 - 保留 formatter 用于显示百分比格式 - 由全局样式中的 .ant-slider-tooltip-inner 设置深色背景和白色文字 🤖 Generated with Claude Code Co-Authored-By: Claude --- zlt-web/react-web-next/src/pages/Welcome.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/zlt-web/react-web-next/src/pages/Welcome.tsx b/zlt-web/react-web-next/src/pages/Welcome.tsx index b0711164..e45838f1 100644 --- a/zlt-web/react-web-next/src/pages/Welcome.tsx +++ b/zlt-web/react-web-next/src/pages/Welcome.tsx @@ -362,17 +362,7 @@ const Welcome: React.FC = () => { 50: { style: { color: '#666' }, label: '50%' }, 100: { style: { color: '#666' }, label: '100%' } }} - tooltip={{ - formatter: (value) => `${value}%`, - overlayStyle: { - backgroundColor: 'rgba(0, 0, 0, 0.75)', - color: '#fff' - }, - overlayInnerStyle: { - backgroundColor: 'rgba(0, 0, 0, 0.75)', - color: '#fff' - } - }} + tooltip={{ formatter: (value) => `${value}%` }} /> setPlatformSharePercent(Number(v || 0))} formatter={(v) => `${v}%`} parser={(v: any) => Number(String(v || '').replace('%', ''))} /> From cf12bc56cd6d830cd22989cef337cf0842d1bd30 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Tue, 21 Oct 2025 12:37:44 +0800 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=A6=96?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/settings.local.json | 7 +++++-- zlt-web/react-web-next/package.json | 2 +- .../src/components/TenantScopeFilter/index.tsx | 5 +++-- .../src/components/ui/TenantSelector/index.tsx | 5 +++-- zlt-web/react-web-next/src/pages/Welcome.tsx | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index d531f92a..cd5c11f7 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -19,9 +19,12 @@ "Bash(npm run start:*)", "Bash(npm start)", "Bash(npm run build:*)", - "Bash(dir:*)" + "Bash(dir:*)", + "Bash(git add:*)", + "Bash(git commit -m \"$(cat <<''EOF''\nfix: 修复首页分账计算模块显示问题\n\n- 显示被隐藏的分账计算模块(移除 display: ''none'')\n- 调整 platformSharePercent 状态变量定义顺序\n- 优化 Slider 组件:\n - 设置标记文字颜色为深灰色 (#666),避免看不清\n - 添加 tooltip 提示框,拖动时显示当前百分比\n - 设置 tooltip 背景为深色,文字为白色,确保清晰可见\n- 移除重复的 90% 标记,只保留 0%、50%、100%\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude \nEOF\n)\")", + "Bash(git commit:*)" ], "deny": [], "ask": [] } -} \ No newline at end of file +} diff --git a/zlt-web/react-web-next/package.json b/zlt-web/react-web-next/package.json index 8bf28fe0..b4070cc2 100644 --- a/zlt-web/react-web-next/package.json +++ b/zlt-web/react-web-next/package.json @@ -12,7 +12,7 @@ "build:pre": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=pre API_PREFIX=http://119.45.169.13:9900 umi build", "build:prod": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=prod umi build", "build:test:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=test APP_BASE=/mgnt API_PREFIX=https://local.goflytec.com:9999 umi build", - "build:pre:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=pre APP_BASE=/mgnt API_PREFIX=https://local.goflytec.com:9900 umi build", + "build:pre:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=pre APP_BASE=/mgnt API_PREFIX=https://local.goflytec.com umi build", "build:prod:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=prod APP_BASE=/mgnt umi build", "lint": "eslint --ext .ts,.tsx src", "tsc": "tsc --noEmit" diff --git a/zlt-web/react-web-next/src/components/TenantScopeFilter/index.tsx b/zlt-web/react-web-next/src/components/TenantScopeFilter/index.tsx index 67a16afb..ca0b8afa 100644 --- a/zlt-web/react-web-next/src/components/TenantScopeFilter/index.tsx +++ b/zlt-web/react-web-next/src/components/TenantScopeFilter/index.tsx @@ -90,9 +90,10 @@ const TenantScopeFilter: React.FC = ({ onChanged, useSwitchTenant = false showSearch loading={loading} treeNodeFilterProp="title" - dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} + // 为避免被父容器(如卡片、图表)裁剪,提升弹层层级并挂载到 body + dropdownStyle={{ maxHeight: 400, overflow: 'auto', zIndex: 9999 as any }} dropdownMatchSelectWidth - getPopupContainer={(trigger) => (trigger?.parentElement as HTMLElement) || document.body} + getPopupContainer={() => document.body} placeholder="选择租户(含子租户)" value={tenantId} onChange={(val) => setTenantId(val)} diff --git a/zlt-web/react-web-next/src/components/ui/TenantSelector/index.tsx b/zlt-web/react-web-next/src/components/ui/TenantSelector/index.tsx index a67cc067..e0eb2a00 100644 --- a/zlt-web/react-web-next/src/components/ui/TenantSelector/index.tsx +++ b/zlt-web/react-web-next/src/components/ui/TenantSelector/index.tsx @@ -100,7 +100,9 @@ const TenantSelector: React.FC = ({ showSearch treeNodeFilterProp='title' loading={loading} - dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} + // 为避免被父容器(如卡片、图表)裁剪,提升弹层层级并挂载到 body + dropdownStyle={{ maxHeight: 400, overflow: 'auto', zIndex: 9999 as any }} + getPopupContainer={() => document.body} placeholder='选择租户(含子租户)' treeData={toTreeData(tree)} allowClear @@ -116,4 +118,3 @@ const TenantSelector: React.FC = ({ }; export default TenantSelector; - diff --git a/zlt-web/react-web-next/src/pages/Welcome.tsx b/zlt-web/react-web-next/src/pages/Welcome.tsx index e45838f1..afc58956 100644 --- a/zlt-web/react-web-next/src/pages/Welcome.tsx +++ b/zlt-web/react-web-next/src/pages/Welcome.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid, Slider, InputNumber } from 'antd'; import { ReloadOutlined } from '@ant-design/icons'; import { Line, Pie } from '@ant-design/plots'; @@ -333,7 +333,7 @@ const Welcome: React.FC = () => {
- + From 57ce4301fab208df90b81b25f0c8e18ebfcffb57 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Tue, 21 Oct 2025 16:48:35 +0800 Subject: [PATCH 5/8] =?UTF-8?q?feat:=20=E9=87=8D=E6=96=B0=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=A6=96=E9=A1=B5=E5=B8=83=E5=B1=80=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将景区订单数量统计移至分账计算栏右侧 - 左侧显示分账统计,右侧显示景区订单数量条形图 - 订单趋势折线图单独占据一整列,充分利用空间 - 优化折线图尺寸和响应式布局 - 增加年视图显示标签数量,避免数据密集问题 - 调整图表坐标系以适应新布局 🤖 Generated with Claude Code Co-Authored-By: Claude --- zlt-web/react-web-next/src/pages/Welcome.tsx | 564 +++++++++++++++++-- 1 file changed, 528 insertions(+), 36 deletions(-) diff --git a/zlt-web/react-web-next/src/pages/Welcome.tsx b/zlt-web/react-web-next/src/pages/Welcome.tsx index afc58956..90197d8c 100644 --- a/zlt-web/react-web-next/src/pages/Welcome.tsx +++ b/zlt-web/react-web-next/src/pages/Welcome.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useRef, useState } from 'react'; -import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid, Slider, InputNumber } from 'antd'; +import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid, Slider, InputNumber, Tooltip } from 'antd'; import { ReloadOutlined } from '@ant-design/icons'; -import { Line, Pie } from '@ant-design/plots'; +import { Line, Pie, Column } from '@ant-design/plots'; import TenantScopeFilter from '@/components/TenantScopeFilter'; import { dashboardApi } from '@/services/dashboard'; import { ordersApi } from '@/services/orders'; @@ -56,6 +56,12 @@ const Welcome: React.FC = () => { const [aggLoading, setAggLoading] = useState(false); const [orderLineSeries, setOrderLineSeries] = useState<{ date: string; value: number; type: string }[]>([]); + // 景区订单数量条形图数据 + const [scenicOrderData, setScenicOrderData] = useState<{ tourismName: string; orderCount: number }[]>([]); + + // 折线图Tooltip状态 + const [tooltipData, setTooltipData] = useState<{ x: number; y: number; content: string; lineX: number } | null>(null); + const getTimeParams = () => { const [start, end] = range || makeDefaultToday(); return { startTime: start.format('YYYY-MM-DD HH:mm:ss'), endTime: end.format('YYYY-MM-DD HH:mm:ss') }; @@ -116,6 +122,7 @@ const Welcome: React.FC = () => { } try { await loadAggregations(); } catch {} + try { await loadScenicOrderData(); } catch {} } catch (e) { message.error('加载统计失败'); } finally { @@ -132,13 +139,27 @@ const Welcome: React.FC = () => { setAggLoading(true); try { const { startTime, endTime } = getTimeParams(); - const unit: 'hour' | 'day' | 'month' = (rangeType === 'date') ? 'hour' : (rangeType === 'year' ? 'month' : 'day'); + // 根据rangeType确定显示粒度,但年维度也按天显示 + let unit: 'hour' | 'day' | 'month'; + let fmtLabel: (m: moment.Moment) => string; + let apiStatType: string; + + if (rangeType === 'date') { + unit = 'hour'; + fmtLabel = (m: moment.Moment) => m.format('HH:00'); + apiStatType = 'hour'; + } else { + // 月、年、周都按天显示 + unit = 'day'; + fmtLabel = (m: moment.Moment) => m.format('YYYY-MM-DD'); + apiStatType = 'day'; + } + const start = (range?.[0] || moment()).clone().startOf(unit as any); const end = (range?.[1] || moment()).clone().endOf(unit as any); // 生成所有时间点标签 const labels: string[] = []; - const fmtLabel = (m: moment.Moment) => (unit === 'hour' ? m.format('HH:00') : unit === 'day' ? m.format('YYYY-MM-DD') : m.format('YYYY-MM')); { const cursor = start.clone(); while (cursor.isSameOrBefore(end)) { @@ -147,32 +168,42 @@ const Welcome: React.FC = () => { } } - const seriesRes: any = await ordersApi.getOrderSeries({ tenantId, includeChildren, startTime, endTime, statType: rangeType, includeTestQrcodes: false }); + const seriesRes: any = await ordersApi.getOrderSeries({ tenantId, includeChildren, startTime, endTime, statType: apiStatType, includeTestQrcodes: false }); const seriesData: any[] = seriesRes?.data || []; - // 构建数据映射 - const dataMap: Record> = { - '订单创建': {}, - '完成': {}, - '退款': {} + const typeAlias: Record = { + '订单创建': '订单创建', + '订单完成': '订单完成', + '完成': '订单完成', + '退款': '退款', + '退款完成': '退款', }; + const targetTypes = ['订单创建', '订单完成', '退款']; + + // 构建数据映射 + const dataMap: Record> = {}; + targetTypes.forEach((key) => { dataMap[key] = {}; }); // 将后端数据填充到映射 seriesData.forEach((item: any) => { const date = item.date || ''; - const type = item.type || ''; + const rawType = item.type || ''; + const type = typeAlias[rawType] || rawType || '订单创建'; const value = Number(item.value || 0); - if (dataMap[type]) { - dataMap[type][date] = value; - } + if (!dataMap[type]) dataMap[type] = {}; + dataMap[type][date] = value; }); // 填充所有时间点,缺失的补 0 const lineSeries: { date: string; value: number; type: string }[] = []; labels.forEach((label) => { - lineSeries.push({ date: label, type: '订单创建', value: dataMap['订单创建'][label] || 0 }); - lineSeries.push({ date: label, type: '完成', value: dataMap['完成'][label] || 0 }); - lineSeries.push({ date: label, type: '退款', value: dataMap['退款'][label] || 0 }); + targetTypes.forEach((type) => { + lineSeries.push({ + date: label, + type, + value: dataMap[type]?.[label] || 0, + }); + }); }); setOrderLineSeries(lineSeries); @@ -183,28 +214,101 @@ const Welcome: React.FC = () => { } }; - // 折线图配置(按 type 分组,不同颜色显示) - const getColorByType = (type: string) => { - const colorMapping: Record = { - '订单创建': '#1890ff', - '完成': '#52c41a', - '退款': '#ff4d4f' - }; - return colorMapping[type] || '#1890ff'; + const loadScenicOrderData = async () => { + if (!tenantId) return; + try { + const { startTime, endTime } = getTimeParams(); + const scenicStats: any = await dashboardApi.getScenicOrderStats({ + tenantId, + includeChildren, + startTime, + endTime, + includeTestQrcodes: false + }); + const data = scenicStats?.data || scenicStats || []; + const formattedData = Array.isArray(data) ? data.map((item: any) => ({ + tourismName: item.tourismName || item.name || '未知景区', + orderCount: Number(item.orderCount || item.count || 0) + })).sort((a, b) => b.orderCount - a.orderCount) : []; + setScenicOrderData(formattedData); + } catch (error) { + console.error('加载景区订单数据失败:', error); + setScenicOrderData([]); + } }; const screens = Grid.useBreakpoint(); const isMobile = !screens.md; // 小于 md 视为移动端 - const orderLineConfig: any = { + + + // 折线图配置 - 最基础的配置确保颜色正确 + const orderLineConfig = { data: orderLineSeries, xField: 'date', yField: 'value', seriesField: 'type', smooth: true, + height: 350, + + // 直接指定颜色映射 + color: ({ + '订单创建': '#1677FF', + '订单完成': '#52C41A', + '退款': '#FF4D4F' + }), + + // 确保折点也使用对应颜色 + point: { + size: 5, + }, + + lineStyle: { + lineWidth: 3, + }, + + legend: { + position: 'top', + }, + }; + + // 景区订单数量条形图配置 + const scenicOrderConfig: any = { + data: scenicOrderData, + xField: 'tourismName', + yField: 'orderCount', autoFit: true, - height: isMobile ? 180 : 220, - legend: { position: 'top' }, - color: (datum: any) => getColorByType(datum.type), + height: isMobile ? 240 : 400, + padding: isMobile ? [24, 16, 40, 60] : [32, 24, 48, 80], + color: '#1668DC', + columnStyle: { + radius: [4, 4, 0, 0], + }, + label: { + position: 'top', + style: { + fill: '#666', + fontSize: 12, + }, + formatter: (text: any, item: any) => `${item.orderCount}`, + }, + xAxis: { + label: { + autoRotate: true, + rotate: isMobile ? 45 : 0, + style: { + fontSize: isMobile ? 10 : 12, + }, + }, + tickCount: isMobile ? 5 : undefined, + }, + yAxis: { + minTickInterval: 1, + nice: true, + label: { + formatter: (val: string) => `${Number(val)}`, + }, + }, + interactions: [{ type: 'active-region' }], }; // 饼图配置 @@ -339,9 +443,9 @@ const Welcome: React.FC = () => { - {/* 分账计算(基于净收入) */} + {/* 分账计算 + 景区订单数量统计 */} - + @@ -391,15 +495,403 @@ const Welcome: React.FC = () => { + + + + + + + + {/* 订单趋势 - 单独一列 */} + + + +
setTooltipData(null)} + > + + {/* 绘制坐标轴 */} + + + + {/* 图例 */} + + + 订单创建 + + + 订单完成 + + + 退款 + + + {/* 获取所有日期和最大值 */} + {(() => { + 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); + + // Y轴刻度和标签 + const ySteps = 5; + const yStepValue = Math.ceil(maxValue / ySteps); + + return ( + <> + {/* Y轴刻度和标签 */} + {Array.from({ length: ySteps + 1 }, (_, i) => { + const value = i * yStepValue; + const chartBottom = rangeType === 'year' ? 520 : 430; + const chartTop = 40; + const chartHeight = chartBottom - chartTop; + const y = chartBottom - (value / maxValue) * chartHeight; + return ( + + + + {value} + + + + ); + })} + + {/* X轴标签 - 智能处理重叠问题 */} + {(() => { + // 根据日期数量和时间范围计算显示策略 + let maxLabels = 12; + if (rangeType === 'year') { + maxLabels = 20; // 年视图时可以显示更多标签,因为有更宽的空间 + } else if (rangeType === 'month') { + maxLabels = 15; + } else if (rangeType === 'week') { + maxLabels = 10; + } + + const labelInterval = Math.ceil(allDates.length / maxLabels); + + return allDates.map((date, index) => { + // 判断是否显示此标签 + const shouldShow = index === 0 || + index === allDates.length - 1 || + index % labelInterval === 0; + + if (!shouldShow) return null; + + const x = 60 + index * xStep; + + // 智能格式化日期显示 + let displayText = date; + if (date.length > 10) { + displayText = date.substring(0, 10); + } + + // 根据不同时间范围简化显示 + if (date.includes('-')) { + 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 chartBottom = rangeType === 'year' ? 520 : 430; + return ( + + + {displayText} + + + + ); + }); + })()} + + {/* 垂直交互区域 - 只为有数据的日期创建 */} + {(() => { + // 获取有数据的日期集合 + const datesWithData = [...new Set(orderLineSeries.map(item => item.date))]; + + return datesWithData.map((date, dateIndex) => { + const actualDateIndex = allDates.indexOf(date); + const x = 60 + actualDateIndex * xStep; + + const chartBottom = rangeType === 'year' ? 520 : 430; + const chartTop = 40; + const chartHeight = chartBottom - chartTop; + return ( + { + const svgRect = e.currentTarget.closest('svg').getBoundingClientRect(); + const svgWidth = rangeType === 'year' ? 1200 : 1100; + const svgHeight = rangeType === 'year' ? 600 : 500; + const tooltipX = (e.clientX - svgRect.left) * (svgWidth / svgRect.width); + const tooltipY = (e.clientY - svgRect.top) * (svgHeight / svgRect.height); + + // 获取这个日期的所有数据 + const allDataForDate = orderLineSeries.filter(item => item.date === date); + + if (allDataForDate.length > 0) { + const contentLines = allDataForDate.map(item => { + const colorMap = { + '订单创建': '#1677FF', + '订单完成': '#52C41A', + '退款': '#FF4D4F' + }; + const color = colorMap[item.type] || '#666'; + return `● ${item.type}: ${item.value}`; + }).join('
'); + + // 格式化tooltip中的日期显示 + let tooltipDate = date; + if (rangeType === 'month' && date.includes('-')) { + const parts = date.split('-'); + if (parts.length >= 3) { + tooltipDate = `${parts[0]}年${parts[1]}月${parts[2]}日`; + } + } else if (date.length > 15) { + tooltipDate = date.substring(0, 15) + '...'; + } + + setTooltipData({ + x: tooltipX, + y: tooltipY - 40, + lineX: x, // 传递SVG坐标系的X位置 + content: `
${tooltipDate}
${contentLines}` + }); + } + }} + /> + ); + }); + })()} + + {/* 绘制折线和折点 */} + {['订单创建', '订单完成', '退款'].map((type, typeIndex) => { + const colorMap = ['#1677FF', '#52C41A', '#FF4D4F']; + const color = colorMap[typeIndex]; + const typeData = orderLineSeries.filter(item => item.type === type); + + if (typeData.length === 0) return null; + + // 为所有日期填充数据,缺失的日期用前一个有效数据填充 + const filledData: { date: string; value: number; original: boolean }[] = []; + let lastValidValue = 0; + + allDates.forEach((date) => { + const dataForDate = typeData.find(item => item.date === date); + + if (dataForDate) { + // 有真实数据 + lastValidValue = dataForDate.value; + filledData.push({ + date, + value: dataForDate.value, + original: true + }); + } else { + // 无数据,使用上一个有效值 + filledData.push({ + date, + value: lastValidValue, + original: false + }); + } + }); + + // 生成平滑曲线路径 - 使用贝塞尔曲线 + const pathData = (() => { + if (filledData.length === 0) return ''; + + const chartBottom = rangeType === 'year' ? 520 : 430; + const chartTop = 40; + const chartHeight = chartBottom - chartTop; + const points = filledData.map((item, index) => { + const x = 60 + index * xStep; + const y = chartBottom - (item.value / maxValue) * chartHeight; + return { x, y }; + }); + + let path = `M ${points[0].x} ${points[0].y}`; + + if (points.length === 1) { + return path; + } + + // 使用二次贝塞尔曲线连接各点 + for (let i = 1; i < points.length; i++) { + const prev = points[i - 1]; + const curr = points[i]; + + // 计算控制点,创建平滑曲线 + const cpx = (prev.x + curr.x) / 2; + const cpy = (prev.y + curr.y) / 2; + + if (i === 1) { + // 第一段曲线 + const cp1x = prev.x + (curr.x - prev.x) * 0.3; + const cp1y = prev.y; + path += ` C ${cp1x} ${cp1y}, ${cpx} ${cpy}, ${curr.x} ${curr.y}`; + } else { + // 后续曲线段 + const next = points[i + 1]; + if (next) { + const cp2x = curr.x - (next.x - prev.x) * 0.15; + const cp2y = curr.y; + path += ` S ${cp2x} ${cp2y}, ${curr.x} ${curr.y}`; + } else { + // 最后一个点 + const cp2x = curr.x - (curr.x - prev.x) * 0.3; + const cp2y = curr.y; + path += ` S ${cp2x} ${cp2y}, ${curr.x} ${curr.y}`; + } + } + } + + return path; + })(); + + return ( + + {/* 折线 - 平滑曲线,始终连续 */} + {filledData.filter(item => item.original).length > 0 && ( + + )} + + {/* 折点 - 只在有真实数据且值大于0的位置显示 */} + {typeData.map((item, index) => { + 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 chartHeight = chartBottom - chartTop; + const y = chartBottom - (item.value / maxValue) * chartHeight; + return ( + + ); + })} + + ); + })} + + ); + })()} + + {/* 垂直指示线 */} + {tooltipData && ( + + )} + + + {/* 自定义Tooltip */} + {tooltipData && ( +
+ )} +
+ + {/* 订单状态分布 + 订单列表 */} - + - -
- -
+ 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 6/8] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=99=AF=E5=8C=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=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 && ( {
{ + {/* 景区订单数量统计:单行展示 */} + + + + + + + + {/* 订单状态分布 + 订单列表 */} From 97b8ac126385c1c3417228ac6352bbb9c59a0129 Mon Sep 17 00:00:00 2001 From: duzhichao <1098974448@qq.com> Date: Wed, 22 Oct 2025 14:00:51 +0800 Subject: [PATCH 7/8] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=99=AF=E5=8C=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=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 --- .../central/order/mapper/DashboardMapper.java | 31 +++++ .../order/model/vo/ChartStatistics.java | 3 + .../service/impl/DashboardServiceImpl.java | 4 + zlt-web/react-web-next/src/pages/Welcome.tsx | 127 +++++++++++------- 4 files changed, 118 insertions(+), 47 deletions(-) diff --git a/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java b/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java index bccb674d..480dd5dc 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java +++ b/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java @@ -580,6 +580,37 @@ public interface DashboardMapper { }) List getQrcodeOrderCount(@Param("p") Map params); + @Select({ + "" + }) + List getTourismOrderCount(@Param("p") Map params); + @Select({ "