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 @@