feat: add by-day selector in performance filters
This commit is contained in:
+11
-2
@@ -156,6 +156,10 @@
|
|||||||
<option value="30">近 30 天</option>
|
<option value="30">近 30 天</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label>按天</label>
|
||||||
|
<select id="perfDay"><option value="all">全部日期</option></select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 模块1:核心指标概览 -->
|
<!-- 模块1:核心指标概览 -->
|
||||||
@@ -359,7 +363,8 @@
|
|||||||
fillSelect('perfChannel', [...new Set(perfData.map(d => d.channel))].sort());
|
fillSelect('perfChannel', [...new Set(perfData.map(d => d.channel))].sort());
|
||||||
fillSelect('perfProduct', [...new Set(perfData.map(d => d.product))].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());
|
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));
|
document.getElementById(id).addEventListener('change', drawPerf));
|
||||||
drawPerf();
|
drawPerf();
|
||||||
}
|
}
|
||||||
@@ -370,10 +375,14 @@
|
|||||||
const pr = document.getElementById('perfProduct').value;
|
const pr = document.getElementById('perfProduct').value;
|
||||||
const co = document.getElementById('perfCountry').value;
|
const co = document.getElementById('perfCountry').value;
|
||||||
const rg = document.getElementById('perfRange').value;
|
const rg = document.getElementById('perfRange').value;
|
||||||
|
const day = document.getElementById('perfDay').value;
|
||||||
if (ch !== 'all') d = d.filter(x => x.channel === ch);
|
if (ch !== 'all') d = d.filter(x => x.channel === ch);
|
||||||
if (pr !== 'all') d = d.filter(x => x.product === pr);
|
if (pr !== 'all') d = d.filter(x => x.product === pr);
|
||||||
if (co !== 'all') d = d.filter(x => x.location === co);
|
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 allDates = [...new Set(perfData.map(x => x.date))].sort();
|
||||||
const cut = allDates[Math.max(0, allDates.length - parseInt(rg))];
|
const cut = allDates[Math.max(0, allDates.length - parseInt(rg))];
|
||||||
d = d.filter(x => x.date >= cut);
|
d = d.filter(x => x.date >= cut);
|
||||||
|
|||||||
Reference in New Issue
Block a user