From ce63b005226c36f313c2d1d1a1c4d8291be1efca Mon Sep 17 00:00:00 2001 From: linbin <495561397@qq.com> Date: Fri, 26 Sep 2025 11:33:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E8=BF=B0:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=86=E6=9E=90=E6=A8=A1=E5=9D=97=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=BB=93=E6=9E=84=E5=92=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化商品分析、客户分析、订单分析三个页面的日期范围筛选功能,统一使用近1天、近7天、近30天选项 - 完善客户分析页面的自定义日期范围选择逻辑,增加日期范围选择事件监听器 - 优化客户分析页面的数据查询和导出功能,根据选择的日期范围类型处理不同的查询参数 - 移除客户分析页面中多余的默认日期设置代码 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- 商家端web/数据分析/商品分析.html | 3 +- 商家端web/数据分析/客户分析.html | 79 +++++++++++++++++++++----------- 商家端web/数据分析/订单分析.html | 3 +- 3 files changed, 54 insertions(+), 31 deletions(-) diff --git a/商家端web/数据分析/商品分析.html b/商家端web/数据分析/商品分析.html index ca57eb3..4f44785 100644 --- a/商家端web/数据分析/商品分析.html +++ b/商家端web/数据分析/商品分析.html @@ -226,8 +226,7 @@
+ + + + + +
+ - - + + @@ -482,13 +495,6 @@ chartData.push(0); } - // 设置默认日期范围(最近30天) - const today = new Date(); - const thirtyDaysAgo = new Date(); - thirtyDaysAgo.setDate(today.getDate() - 30); - - document.getElementById('startDate').valueAsDate = thirtyDaysAgo; - document.getElementById('endDate').valueAsDate = today; // 图表配置 const chartConfig = { @@ -624,22 +630,37 @@ options: chartConfig }); + // 日期范围选择 + document.getElementById('dateRange').addEventListener('change', function() { + const customDateRange = document.getElementById('customDateRange'); + if (this.value === 'custom') { + customDateRange.style.display = 'flex'; + } else { + customDateRange.style.display = 'none'; + } + }); + // 查询数据函数 function queryData() { - const startDate = document.getElementById('startDate').value; - const endDate = document.getElementById('endDate').value; + const dateRange = document.getElementById('dateRange').value; + let startDate, endDate; - if (!startDate || !endDate) { - showNotification('请选择时间范围', 'error'); - return; + if (dateRange === 'custom') { + startDate = document.getElementById('startDate').value; + endDate = document.getElementById('endDate').value; + + if (!startDate || !endDate) { + showNotification('请选择时间范围', 'error'); + return; + } + + if (new Date(startDate) > new Date(endDate)) { + showNotification('开始时间不能大于结束时间', 'error'); + return; + } } - if (new Date(startDate) > new Date(endDate)) { - showNotification('开始时间不能大于结束时间', 'error'); - return; - } - - console.log('查询参数:', { startDate, endDate }); + console.log('查询参数:', { dateRange, startDate, endDate }); updateStatsCards(); updateCharts(); @@ -649,12 +670,16 @@ // 导出数据函数 function exportData() { - const startDate = document.getElementById('startDate').value; - const endDate = document.getElementById('endDate').value; + const dateRange = document.getElementById('dateRange').value; - if (!startDate || !endDate) { - showNotification('请选择时间范围', 'error'); - return; + if (dateRange === 'custom') { + const startDate = document.getElementById('startDate').value; + const endDate = document.getElementById('endDate').value; + + if (!startDate || !endDate) { + showNotification('请选择时间范围', 'error'); + return; + } } console.log('导出数据'); diff --git a/商家端web/数据分析/订单分析.html b/商家端web/数据分析/订单分析.html index c3459b6..8a09453 100644 --- a/商家端web/数据分析/订单分析.html +++ b/商家端web/数据分析/订单分析.html @@ -210,8 +210,7 @@