3.1客户分类日报:T-4~T-1表头改为实际日期(动态)
This commit is contained in:
+23
-20
@@ -104,18 +104,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>3.1 客户分类日报</h2>
|
<h2>3.1 客户分类日报</h2>
|
||||||
<div class="sub-note">DoD=T-1−T-2,DoD%=T-1/T-2−1。波动原因可编辑(暂存本浏览器)。</div>
|
<div class="sub-note">DoD=T-1−T-2,DoD%=T-1/T-2−1。波动原因可编辑(暂存本浏览器)。</div>
|
||||||
<div class="scroll"><table id="tCustDaily"><thead><tr>
|
<div class="scroll"><table id="tCustDaily"><thead></thead><tbody></tbody></table></div>
|
||||||
<th class="txt cd-sort" data-k="cat" data-ty="str">客户分类<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="idsp" data-ty="num">iDSP个数<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="base" data-ty="num">base daily revenue<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="t4" data-ty="num">T-4收入<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="t3" data-ty="num">T-3收入<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="t2" data-ty="num">T-2收入<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="t1" data-ty="num">T-1收入<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="dod" data-ty="num">DoD<span class="arw"></span></th>
|
|
||||||
<th class="cd-sort" data-k="dodp" data-ty="num">DoD%<span class="arw"></span></th>
|
|
||||||
<th class="txt">波动原因</th>
|
|
||||||
</tr></thead><tbody></tbody></table></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>3.2 客户明细 <span class="tag">保留14天</span></h2>
|
<h2>3.2 客户明细 <span class="tag">保留14天</span></h2>
|
||||||
@@ -358,6 +347,20 @@ function renderCustDaily(){
|
|||||||
return (va<vb?-1:va>vb?1:0)*dir;
|
return (va<vb?-1:va>vb?1:0)*dir;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 动态表头:用实际日期替代 T-4~T-1
|
||||||
|
function dLbl(dt){ return dt? dt : '—'; }
|
||||||
|
var thead=document.querySelector('#tCustDaily thead');
|
||||||
|
thead.innerHTML='<tr>'
|
||||||
|
+'<th class="txt cd-sort" data-k="cat" data-ty="str">客户分类<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="idsp" data-ty="num">iDSP个数<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="base" data-ty="num">base daily revenue<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="t4" data-ty="num">'+dLbl(t4)+'<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="t3" data-ty="num">'+dLbl(t3)+'<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="t2" data-ty="num">'+dLbl(t2)+'<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="t1" data-ty="num">'+dLbl(t1)+'<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="dod" data-ty="num">DoD('+dLbl(t1)+'−'+dLbl(t2)+')<span class="arw"></span></th>'
|
||||||
|
+'<th class="cd-sort" data-k="dodp" data-ty="num">DoD%<span class="arw"></span></th>'
|
||||||
|
+'<th class="txt">波动原因</th></tr>';
|
||||||
var body=rows.map(function(r){
|
var body=rows.map(function(r){
|
||||||
var dc=r.dod==null?'':(r.dod>=0?'pos':'neg');
|
var dc=r.dod==null?'':(r.dod>=0?'pos':'neg');
|
||||||
return '<tr><td class="txt">'+r.cat+'</td><td>'+(r.idsp||'')+'</td><td>'+n2(r.base)+'</td>'
|
return '<tr><td class="txt">'+r.cat+'</td><td>'+(r.idsp||'')+'</td><td>'+n2(r.base)+'</td>'
|
||||||
@@ -368,7 +371,14 @@ function renderCustDaily(){
|
|||||||
+reasonCell('cust_daily', r.cat)+'</tr>';
|
+reasonCell('cust_daily', r.cat)+'</tr>';
|
||||||
}).join('');
|
}).join('');
|
||||||
document.querySelector('#tCustDaily tbody').innerHTML=body;
|
document.querySelector('#tCustDaily tbody').innerHTML=body;
|
||||||
|
// 表头动态生成后重新绑定排序点击 + 箭头
|
||||||
document.querySelectorAll('#tCustDaily th.cd-sort').forEach(function(th){
|
document.querySelectorAll('#tCustDaily th.cd-sort').forEach(function(th){
|
||||||
|
th.style.cursor='pointer';
|
||||||
|
th.onclick=function(){
|
||||||
|
var k=th.getAttribute('data-k'), ty=th.getAttribute('data-ty');
|
||||||
|
if(CD_SORT.k===k){ CD_SORT.dir=(CD_SORT.dir==='asc'?'desc':'asc'); } else { CD_SORT.k=k; CD_SORT.ty=ty; CD_SORT.dir='desc'; }
|
||||||
|
renderCustDaily();
|
||||||
|
};
|
||||||
th.classList.remove('asc','desc');
|
th.classList.remove('asc','desc');
|
||||||
if(th.getAttribute('data-k')===CD_SORT.k) th.classList.add(CD_SORT.dir);
|
if(th.getAttribute('data-k')===CD_SORT.k) th.classList.add(CD_SORT.dir);
|
||||||
});
|
});
|
||||||
@@ -416,14 +426,7 @@ function renderCustDetail(){
|
|||||||
|
|
||||||
// 3.1/3.2 表头排序绑定
|
// 3.1/3.2 表头排序绑定
|
||||||
function bindCustSort(){
|
function bindCustSort(){
|
||||||
document.querySelectorAll('#tCustDaily th.cd-sort').forEach(function(th){
|
// 3.1 的表头排序绑定在 renderCustDaily 内部动态处理(表头是动态生成的)
|
||||||
th.style.cursor='pointer';
|
|
||||||
th.onclick=function(){
|
|
||||||
var k=th.getAttribute('data-k'), ty=th.getAttribute('data-ty');
|
|
||||||
if(CD_SORT.k===k){ CD_SORT.dir=(CD_SORT.dir==='asc'?'desc':'asc'); } else { CD_SORT.k=k; CD_SORT.ty=ty; CD_SORT.dir='desc'; }
|
|
||||||
renderCustDaily();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
document.querySelectorAll('#tCustDetail th.de-sort').forEach(function(th){
|
document.querySelectorAll('#tCustDetail th.de-sort').forEach(function(th){
|
||||||
th.style.cursor='pointer';
|
th.style.cursor='pointer';
|
||||||
th.onclick=function(){
|
th.onclick=function(){
|
||||||
|
|||||||
Reference in New Issue
Block a user