每日人数恢复按日期横向对比员工总数与增量
This commit is contained in:
1 parent
9f18e2eb85
commit
8379805328
2 files changed
+11
-1
No files matched your search
@@ -356,3 +356,5 @@ button.order-copy-button:focus-visible{outline:3px solid var(--gold);outline-off
|
|||||||
.customer-type-field{border:0;padding:0;margin:0;min-width:0}.customer-type-field legend{padding:0;margin-bottom:7px;color:var(--muted);font-size:12px}.customer-type-options{display:flex;flex-wrap:wrap;gap:8px}.customer-type-options>label{display:flex;align-items:center;gap:8px;min-height:44px;padding:9px 12px;margin:0;border:1px solid var(--border);border-radius:7px;background:var(--white);cursor:pointer}.customer-type-options input[type=radio]{width:17px;height:17px;min-height:0;margin:0;padding:0;flex:none;accent-color:var(--green)}.customer-type-options>label:has(input:checked){border-color:var(--green);background:var(--soft);color:var(--green)}.customer-type-options>label:focus-within{outline:2px solid var(--green);outline-offset:2px}.customer-type-options span{font-size:13px}
|
.customer-type-field{border:0;padding:0;margin:0;min-width:0}.customer-type-field legend{padding:0;margin-bottom:7px;color:var(--muted);font-size:12px}.customer-type-options{display:flex;flex-wrap:wrap;gap:8px}.customer-type-options>label{display:flex;align-items:center;gap:8px;min-height:44px;padding:9px 12px;margin:0;border:1px solid var(--border);border-radius:7px;background:var(--white);cursor:pointer}.customer-type-options input[type=radio]{width:17px;height:17px;min-height:0;margin:0;padding:0;flex:none;accent-color:var(--green)}.customer-type-options>label:has(input:checked){border-color:var(--green);background:var(--soft);color:var(--green)}.customer-type-options>label:focus-within{outline:2px solid var(--green);outline-offset:2px}.customer-type-options span{font-size:13px}
|
||||||
|
|
||||||
.private-ops-summary{min-width:980px}.private-ops-summary th.number{text-align:right}.private-ops-summary tbody th{background:var(--white);color:var(--ink);font-size:13px;font-weight:650;vertical-align:middle}.private-ops-summary td{vertical-align:middle;padding:11px 12px;font-variant-numeric:tabular-nums}.private-ops-summary td .small{margin-top:4px;font-size:11px}.private-ops-summary td:last-child{white-space:nowrap}.private-ops-summary tbody tr:hover td,.private-ops-summary tbody tr:hover th{background:#f5f7f2}.private-ops-summary th:first-child{position:sticky;left:0;z-index:1;min-width:90px;border-right:1px solid var(--border)}.private-ops-summary-wrap:focus-visible{outline:2px solid var(--green);outline-offset:2px}
|
.private-ops-summary{min-width:980px}.private-ops-summary th.number{text-align:right}.private-ops-summary tbody th{background:var(--white);color:var(--ink);font-size:13px;font-weight:650;vertical-align:middle}.private-ops-summary td{vertical-align:middle;padding:11px 12px;font-variant-numeric:tabular-nums}.private-ops-summary td .small{margin-top:4px;font-size:11px}.private-ops-summary td:last-child{white-space:nowrap}.private-ops-summary tbody tr:hover td,.private-ops-summary tbody tr:hover th{background:#f5f7f2}.private-ops-summary th:first-child{position:sticky;left:0;z-index:1;min-width:90px;border-right:1px solid var(--border)}.private-ops-summary-wrap:focus-visible{outline:2px solid var(--green);outline-offset:2px}
|
||||||
|
|
||||||
|
.private-people-history{min-width:520px}.private-people-history th[colspan]{text-align:center;border-left:1px solid var(--border)}.private-people-history th.number{text-align:right}.private-people-history tbody th{color:var(--ink);font-size:13px;font-weight:500;background:var(--white);vertical-align:middle}.private-people-history td{vertical-align:middle;font-variant-numeric:tabular-nums}.private-people-history td:nth-child(2n){border-left:1px solid var(--border)}.private-people-history .link-button{font-weight:600;padding:6px 0}.private-people-history .small{margin-top:4px;font-size:11px}.private-people-history th:first-child[rowspan],.private-people-history tbody th{position:sticky;left:0;z-index:1}.private-people-history tbody tr:hover td,.private-people-history tbody tr:hover th{background:#f5f7f2}
|
||||||
@@ -20,9 +20,17 @@ async function loadPrivateOperations(){
|
|||||||
const active=()=>privateOpsCurrent()&&request===privateOpsRequest&&user===state.user.id&&target===$('#private-ops-result');
|
const active=()=>privateOpsCurrent()&&request===privateOpsRequest&&user===state.user.id&&target===$('#private-ops-result');
|
||||||
try{const data=await api('/api/private-operations?'+new URLSearchParams(query));if(!active())return;
|
try{const data=await api('/api/private-operations?'+new URLSearchParams(query));if(!active())return;
|
||||||
if(!Array.isArray(data.summaries)||!Array.isArray(data.rows)||data.from!==query.from||data.date!==query.date)throw new Error('运营资料未完整返回,请重新查询');
|
if(!Array.isArray(data.summaries)||!Array.isArray(data.rows)||data.from!==query.from||data.date!==query.date)throw new Error('运营资料未完整返回,请重新查询');
|
||||||
target.innerHTML=`<section class="panel"><div class="panel-title"><h2>员工运营汇总</h2><span class="small muted">${e(data.from)} ~ ${e(data.date)}</span></div><div class="table-wrap private-ops-summary-wrap" tabindex="0" role="region" aria-label="员工运营汇总表"><table class="private-ops-summary"><thead><tr><th scope="col">员工</th><th scope="col" class="number">最近总人数</th><th scope="col" class="number">新增人数</th><th scope="col" class="number">成交订单</th><th scope="col" class="number">新客订单</th><th scope="col" class="number">老客订单</th><th scope="col" class="number">未标记订单</th><th scope="col" class="number">新客转化参考</th><th scope="col" class="number">退款订单</th><th scope="col">操作</th></tr></thead><tbody>${data.summaries.map(row=>`<tr><th scope="row">${e(row.label)}${row.enabled===false?'<div class="small muted">已停用</div>':''}</th><td class="number">${privateOpsNumber(row.total)}${row.totalDate?'<div class="small muted">'+e(row.totalDate)+'</div>':''}</td><td class="number"><strong>${privateOpsNumber(row.newPeople)}</strong><div class="small muted">${row.recordedDays}/${data.days} 天可算增量</div></td><td class="number"><strong>${row.orders}</strong></td><td class="number">${row.newOrders}</td><td class="number">${row.returningOrders}</td><td class="number">${row.unknownOrders}</td><td class="number">${privateOpsRate(row)}</td><td class="number">${row.refundOrders}</td><td>${button('记人数','private-people-open','quiet',`data-member="${e(row.member)}" data-date="${e(data.date)}"`)}</td></tr>`).join('')||'<tr><td colspan="10" class="muted">没有符合筛选条件的员工。</td></tr>'}</tbody></table></div><p class="small muted private-ops-help">新增人数=当天总人数-上次记录的总人数。新客转化参考=新客订单数÷新增人数。按订单数统计,可能包含之前加的客户或同一客户多次下单;不是同批客户的准确转化率。人数缺记、分母不大于0或订单未标记时不显示比率;区间比率按合计计算。</p></section><section class="panel"><h2>每日明细</h2><div class="table-wrap"><table class="private-ops-table"><thead><tr><th>日期/员工</th><th>总人数</th><th>新增人数</th><th>成交订单</th><th>新客/老客/未标记</th><th>转化参考</th><th>退款订单</th><th>操作</th></tr></thead><tbody>${data.rows.map(row=>`<tr><td>${e(row.date)}<div>${e(teamMemberName(row.member))}</div></td><td>${privateOpsNumber(row.total)}</td><td>${row.netChange===null?'—':(row.netChange>0?'+':'')+row.netChange}${row.previousDate?'<div class="small muted">对比 '+e(row.previousDate)+'</div>':''}</td><td>${row.orders}</td><td>${row.newOrders} / ${row.returningOrders} / ${row.unknownOrders}</td><td>${privateOpsRate(row)}</td><td>${row.refundOrders}</td><td>${button('记录/修改','private-people-open','quiet',`data-member="${e(row.member)}" data-date="${e(row.date)}"`)}</td></tr>`).join('')||'<tr><td colspan="8" class="muted">这个区间还没有人数或成交记录,可以先记录人数。</td></tr>'}</tbody></table></div><p class="small muted">新客户指首次在店里成交;老客户指复购。取消单不计成交,锁价交付后计入;退款按实际退款日另列,不抹去原日成交。直接回收和寄存不计成交。</p></section>`;
|
target.innerHTML=`<section class="panel"><div class="panel-title"><h2>员工运营汇总</h2><span class="small muted">${e(data.from)} ~ ${e(data.date)}</span></div><div class="table-wrap private-ops-summary-wrap" tabindex="0" role="region" aria-label="员工运营汇总表"><table class="private-ops-summary"><thead><tr><th scope="col">员工</th><th scope="col" class="number">最近总人数</th><th scope="col" class="number">新增人数</th><th scope="col" class="number">成交订单</th><th scope="col" class="number">新客订单</th><th scope="col" class="number">老客订单</th><th scope="col" class="number">未标记订单</th><th scope="col" class="number">新客转化参考</th><th scope="col" class="number">退款订单</th><th scope="col">操作</th></tr></thead><tbody>${data.summaries.map(row=>`<tr><th scope="row">${e(row.label)}${row.enabled===false?'<div class="small muted">已停用</div>':''}</th><td class="number">${privateOpsNumber(row.total)}${row.totalDate?'<div class="small muted">'+e(row.totalDate)+'</div>':''}</td><td class="number"><strong>${privateOpsNumber(row.newPeople)}</strong><div class="small muted">${row.recordedDays}/${data.days} 天可算增量</div></td><td class="number"><strong>${row.orders}</strong></td><td class="number">${row.newOrders}</td><td class="number">${row.returningOrders}</td><td class="number">${row.unknownOrders}</td><td class="number">${privateOpsRate(row)}</td><td class="number">${row.refundOrders}</td><td>${button('记人数','private-people-open','quiet',`data-member="${e(row.member)}" data-date="${e(data.date)}"`)}</td></tr>`).join('')||'<tr><td colspan="10" class="muted">没有符合筛选条件的员工。</td></tr>'}</tbody></table></div><p class="small muted private-ops-help">新增人数=当天总人数-上次记录的总人数。新客转化参考=新客订单数÷新增人数。按订单数统计,可能包含之前加的客户或同一客户多次下单;不是同批客户的准确转化率。人数缺记、分母不大于0或订单未标记时不显示比率;区间比率按合计计算。</p></section>${privatePeopleHistoryHTML(data)}`;
|
||||||
}catch(err){if(active())target.innerHTML=`<div class="error">${e(err.message)} ${button('重新读取','private-ops-retry')}</div>`;}
|
}catch(err){if(active())target.innerHTML=`<div class="error">${e(err.message)} ${button('重新读取','private-ops-retry')}</div>`;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function privatePeopleHistoryHTML(data){
|
||||||
|
const records=data.rows.filter(row=>row.total!==null&&row.total!==undefined),recordedMembers=new Set(records.map(row=>row.member)),members=data.members.filter(row=>recordedMembers.has(row.member));
|
||||||
|
const dates=[...new Set(records.map(row=>row.date))].sort(),lookup=new Map(records.map(row=>[row.date+'|'+row.member,row]));
|
||||||
|
const contents=dates.length?`<div class="table-wrap" tabindex="0" role="region" aria-label="每日人数记录"><table class="private-people-history"><thead><tr><th rowspan="2" scope="col">日期</th>${members.map(m=>`<th colspan="2" scope="colgroup">${e(m.label)}</th>`).join('')}</tr><tr>${members.map(()=>'<th scope="col" class="number">当日总人数</th><th scope="col" class="number">较上次新增</th>').join('')}</tr></thead><tbody>${dates.map(date=>`<tr><th scope="row">${e(date)}</th>${members.map(member=>{const row=lookup.get(date+'|'+member.member);return `<td class="number">${row?`<button type="button" class="link-button" data-action="private-people-open" data-date="${e(date)}" data-member="${e(member.member)}" aria-label="修改${e(member.label)} ${e(date)}人数">${privateOpsNumber(row.total)} 人</button>`:'<span class="muted">未记录</span>'}</td><td class="number">${row?row.netChange===null?'<span class="muted">首次记录</span>':`${row.netChange<0?'减少 '+Math.abs(row.netChange):'新增 '+row.netChange} 人${row.previousDate?`<div class="small muted">对比 ${e(row.previousDate)}</div>`:''}`:'—'}</td>`}).join('')}</tr>`).join('')}</tbody></table></div>`:'<p class="muted">所选日期暂无人数记录。</p>';
|
||||||
|
return `<section class="panel" id="private-people-history-panel"><div class="panel-title"><h2>每日人数记录</h2>${button('记录人数','private-people-open','quiet')}</div><p class="small muted">${e(data.from)} ~ ${e(data.date)} · 已记录 ${dates.length} 天。点击人数可修改对应员工当天的记录。</p>${contents}<p class="small muted">新增人数与上一次有记录的总人数比较,漏记日期自动跳过;没有人数记录的日期不显示,0人也作为有效记录。</p></section>`;
|
||||||
|
}
|
||||||
|
|
||||||
async function openPrivatePeople(member='',date=''){
|
async function openPrivatePeople(member='',date=''){
|
||||||
if(!privatePeopleCurrent())return;let dialog=$('#private-people-dialog');
|
if(!privatePeopleCurrent())return;let dialog=$('#private-people-dialog');
|
||||||
if(!dialog){dialog=document.createElement('dialog');dialog.id='private-people-dialog';dialog.setAttribute('aria-labelledby','private-people-title');dialog.addEventListener('close',()=>{++privatePeopleRequest;privatePeopleEntry=null;});document.body.append(dialog);}
|
if(!dialog){dialog=document.createElement('dialog');dialog.id='private-people-dialog';dialog.setAttribute('aria-labelledby','private-people-title');dialog.addEventListener('close',()=>{++privatePeopleRequest;privatePeopleEntry=null;});document.body.append(dialog);}
|
||||||
|
|||||||
Reference in new issue
Block a user