feat: add by-day selector in performance filters

This commit is contained in:
王源
2026-09-10 14:35:04 +08:00
parent 3678a9d65a
commit c4d7fdae5f
+11 -2
View File
@@ -156,6 +156,10 @@
<option value="30">近 30 天</option>
</select>
</div>
<div class="control-group">
<label>按天</label>
<select id="perfDay"><option value="all">全部日期</option></select>
</div>
</div>
<!-- 模块1:核心指标概览 -->
@@ -359,7 +363,8 @@
fillSelect('perfChannel', [...new Set(perfData.map(d => d.channel))].sort());
fillSelect('perfProduct', [...new Set(perfData.map(d => d.product))].sort());
fillSelect('perfCountry', [...new Set(perfData.map(d => d.location))].filter(x=>x&&x!=='0').sort());
['perfChannel','perfProduct','perfCountry','perfRange'].forEach(id =>
fillSelect('perfDay', [...new Set(perfData.map(d => d.date))].sort().reverse());
['perfChannel','perfProduct','perfCountry','perfRange','perfDay'].forEach(id =>
document.getElementById(id).addEventListener('change', drawPerf));
drawPerf();
}
@@ -370,10 +375,14 @@
const pr = document.getElementById('perfProduct').value;
const co = document.getElementById('perfCountry').value;
const rg = document.getElementById('perfRange').value;
const day = document.getElementById('perfDay').value;
if (ch !== 'all') d = d.filter(x => x.channel === ch);
if (pr !== 'all') d = d.filter(x => x.product === pr);
if (co !== 'all') d = d.filter(x => x.location === co);
if (rg !== 'all') {
// 选了具体某天则优先按天过滤(覆盖时间范围);否则用时间范围
if (day !== 'all') {
d = d.filter(x => x.date === day);
} else if (rg !== 'all') {
const allDates = [...new Set(perfData.map(x => x.date))].sort();
const cut = allDates[Math.max(0, allDates.length - parseInt(rg))];
d = d.filter(x => x.date >= cut);