diff --git a/index.html b/index.html
index 473b6af..d7bdd8d 100644
--- a/index.html
+++ b/index.html
@@ -104,18 +104,7 @@
3.1 客户分类日报
DoD=T-1−T-2,DoD%=T-1/T-2−1。波动原因可编辑(暂存本浏览器)。
-
+
3.2 客户明细 保留14天
@@ -358,6 +347,20 @@ function renderCustDaily(){
return (vavb?1:0)*dir;
});
}
+ // 动态表头:用实际日期替代 T-4~T-1
+ function dLbl(dt){ return dt? dt : '—'; }
+ var thead=document.querySelector('#tCustDaily thead');
+ thead.innerHTML=''
+ +'| 客户分类 | '
+ +'iDSP个数 | '
+ +'base daily revenue | '
+ +''+dLbl(t4)+' | '
+ +''+dLbl(t3)+' | '
+ +''+dLbl(t2)+' | '
+ +''+dLbl(t1)+' | '
+ +'DoD('+dLbl(t1)+'−'+dLbl(t2)+') | '
+ +'DoD% | '
+ +'波动原因 |
';
var body=rows.map(function(r){
var dc=r.dod==null?'':(r.dod>=0?'pos':'neg');
return '| '+r.cat+' | '+(r.idsp||'')+' | '+n2(r.base)+' | '
@@ -368,7 +371,14 @@ function renderCustDaily(){
+reasonCell('cust_daily', r.cat)+'
';
}).join('');
document.querySelector('#tCustDaily tbody').innerHTML=body;
+ // 表头动态生成后重新绑定排序点击 + 箭头
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');
if(th.getAttribute('data-k')===CD_SORT.k) th.classList.add(CD_SORT.dir);
});
@@ -416,14 +426,7 @@ function renderCustDetail(){
// 3.1/3.2 表头排序绑定
function bindCustSort(){
- 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();
- };
- });
+ // 3.1 的表头排序绑定在 renderCustDaily 内部动态处理(表头是动态生成的)
document.querySelectorAll('#tCustDetail th.de-sort').forEach(function(th){
th.style.cursor='pointer';
th.onclick=function(){