3.2客户明细:T-1收入表头改为实际日期(动态)
This commit is contained in:
+17
-16
@@ -112,13 +112,7 @@
|
||||
<label>客户分类 <select id="deCat"><option value="">全部</option></select></label>
|
||||
<input type="text" id="deAcc" placeholder="筛选客户">
|
||||
</div>
|
||||
<div class="scroll"><table id="tCustDetail"><thead><tr>
|
||||
<th class="txt de-sort" data-k="cat" data-ty="str">客户分类<span class="arw"></span></th>
|
||||
<th class="txt de-sort" data-k="acc" data-ty="str">客户<span class="arw"></span></th>
|
||||
<th class="de-sort" data-k="base" data-ty="num">base收入<span class="arw"></span></th>
|
||||
<th class="de-sort" data-k="t1" data-ty="num">T-1收入<span class="arw"></span></th>
|
||||
<th class="de-sort" data-k="dod" data-ty="num">DoD(与T-2差)<span class="arw"></span></th>
|
||||
</tr></thead><tbody></tbody></table></div>
|
||||
<div class="scroll"><table id="tCustDetail"><thead></thead><tbody></tbody></table></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -412,6 +406,15 @@ function renderCustDetail(){
|
||||
} else {
|
||||
rows.sort(function(a,b){ return a.cat<b.cat?-1:a.cat>b.cat?1:(b.t1-a.t1); });
|
||||
}
|
||||
// 动态表头:用实际日期替代 T-1
|
||||
var thead=document.querySelector('#tCustDetail thead');
|
||||
thead.innerHTML='<tr>'
|
||||
+'<th class="txt de-sort" data-k="cat" data-ty="str">客户分类<span class="arw"></span></th>'
|
||||
+'<th class="txt de-sort" data-k="acc" data-ty="str">客户<span class="arw"></span></th>'
|
||||
+'<th class="de-sort" data-k="base" data-ty="num">base收入<span class="arw"></span></th>'
|
||||
+'<th class="de-sort" data-k="t1" data-ty="num">'+(t1||'—')+'收入<span class="arw"></span></th>'
|
||||
+'<th class="de-sort" data-k="dod" data-ty="num">DoD('+(t1||'—')+'−'+(t2||'—')+')<span class="arw"></span></th>'
|
||||
+'</tr>';
|
||||
var body=rows.map(function(r){
|
||||
var dc=r.dod==null?'':(r.dod>=0?'pos':'neg');
|
||||
return '<tr><td class="txt">'+r.cat+'</td><td class="txt">'+r.acc+'</td><td>'+n2(r.base)+'</td>'
|
||||
@@ -419,6 +422,12 @@ function renderCustDetail(){
|
||||
}).join('');
|
||||
document.querySelector('#tCustDetail tbody').innerHTML=body;
|
||||
document.querySelectorAll('#tCustDetail th.de-sort').forEach(function(th){
|
||||
th.style.cursor='pointer';
|
||||
th.onclick=function(){
|
||||
var k=th.getAttribute('data-k'), ty=th.getAttribute('data-ty');
|
||||
if(DE_SORT.k===k){ DE_SORT.dir=(DE_SORT.dir==='asc'?'desc':'asc'); } else { DE_SORT.k=k; DE_SORT.ty=ty; DE_SORT.dir='desc'; }
|
||||
renderCustDetail();
|
||||
};
|
||||
th.classList.remove('asc','desc');
|
||||
if(th.getAttribute('data-k')===DE_SORT.k) th.classList.add(DE_SORT.dir);
|
||||
});
|
||||
@@ -426,15 +435,7 @@ function renderCustDetail(){
|
||||
|
||||
// 3.1/3.2 表头排序绑定
|
||||
function bindCustSort(){
|
||||
// 3.1 的表头排序绑定在 renderCustDaily 内部动态处理(表头是动态生成的)
|
||||
document.querySelectorAll('#tCustDetail th.de-sort').forEach(function(th){
|
||||
th.style.cursor='pointer';
|
||||
th.onclick=function(){
|
||||
var k=th.getAttribute('data-k'), ty=th.getAttribute('data-ty');
|
||||
if(DE_SORT.k===k){ DE_SORT.dir=(DE_SORT.dir==='asc'?'desc':'asc'); } else { DE_SORT.k=k; DE_SORT.ty=ty; DE_SORT.dir='desc'; }
|
||||
renderCustDetail();
|
||||
};
|
||||
});
|
||||
// 3.1/3.2 表头排序绑定均在各自 render 内部动态处理(表头动态生成)
|
||||
// 3.2 筛选: 填充客户分类下拉 + 绑定
|
||||
var sel=document.getElementById('deCat');
|
||||
if(sel && D && D.cust_idsp){
|
||||
|
||||
Reference in New Issue
Block a user