feat: new layout phase F, Ficha da máquina and Números as on the canvas

Roadmap Novo Layout, phase F step 2 (canvas U2, N1): the machines list as
compact rows with their status line; the machine sheet in the shared
dialog with a fixed head and the tabs Situação, Lançamentos and Dados da
máquina (launch rule unchanged); Números as one scrolling page with the
four headline cards, Metros por dia, Produção, Vendas and Consulta
groups. The people list and roles matrix are untouched. Built by Bobina.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-16 11:52:39 -03:00
parent 392a21082e
commit a34d8e1888
4 changed files with 284 additions and 159 deletions

View File

@@ -218,27 +218,35 @@ async function loadStats(){
if(editLimits){editLimits.hidden=!may('manage');editLimits.onclick=()=>stageLimitsDialog();}
statsData=data;statsPeriod();
$('stats-note').textContent='Pedidos pagos de '+dayLabel(data.start)+' a '+dayLabel(data.end)+', sem testes e cancelados';
const hk=(label,value,unit,note)=>{const k=node('div',undefined,'hk');const b=node('b',value);if(unit)b.append(node('small',unit));
k.append(node('span',label),b,...(note?[node('em',note)]:[]));return k;};
const mk=(label,value,unit)=>{const k=node('div',undefined,'mk');const b=node('b',value);if(unit)b.append(node('small',unit));k.append(node('span',label),b);return k;};
const pct=n=>data.orders?Math.round(100*n/data.orders)+'%':'';
const [reais,centavos]=money(data.cents).split(',');
const share=v=>v==null?'—':String(v).replace('.',',')+'%';
const rw=data.rework;
// The ticket is the cash received over the cash orders only: an Interno or
// faturado order records the table price, not money received (front 7a.3).
const cashOrders=Math.max(0,Number(data.orders)-(data.price_table||[]).reduce((sum,row)=>sum+(row.orders||0),0));
const hero=node('div',undefined,'hero');
hero.append(hk('Metros vendidos',metres(data.metres).replace(' m',''),'m',plural(data.orders,'pedido pago','pedidos pagos')),
hk('Recebido, com frete',reais,','+centavos,cashOrders?'ticket médio de '+money(Math.round(data.cents/cashOrders)):''),
hk('Do pagamento ao Finalizado',duration(data.lead.median_hours),'',data.lead.orders?'mediana de '+plural(data.lead.orders,'pedido','pedidos')+', sem o tempo em Aguardando contato':'nenhum finalizado no período'));
const rw=data.rework, share=v=>v==null?'—':String(v).replace('.',',')+'%';
const minis=node('div',undefined,'minis');
minis.append(mk('Pedidos pagos',String(data.orders)),
mk('Ticket médio',cashOrders?money(Math.round(data.cents/cashOrders)):'—'),
mk('Com correção',String(data.corrected),pct(data.corrected)),
mk('Artes tratadas',String(data.treated.orders),pct(data.treated.orders)),
mk('Retrabalho da casa',share(rw.house.percent),'meta '+share(rw.house.goal_percent)),
mk('Aguardando contato',String(board.orders.filter(waitingContact).length),'agora'));
$('stats-kpis').replaceChildren(hero,minis);
const card=(label,value,note,unit)=>{
const k=node('div',undefined,'kpi'),b=node('b',value);
if(unit)b.append(node('small',unit));
k.append(node('span',label),b,...(note?[node('small',note)]:[]));return k;
};
const cards=node('div',undefined,'stats-cards');
cards.append(
card('Metros vendidos',metres(data.metres).replace(' m',''),plural(data.orders,'pedido pago','pedidos pagos'),'m'),
card('Recebido, com frete',money(data.cents),cashOrders?'ticket médio de '+money(Math.round(data.cents/cashOrders)):''),
card('Do pagamento ao Finalizado',duration(data.lead.median_hours),data.lead.orders?'mediana de '+plural(data.lead.orders,'pedido','pedidos')+', sem o tempo em Aguardando contato':'nenhum finalizado no período'),
card('Retrabalho da casa',share(rw.house.percent),'meta '+share(rw.house.goal_percent)));
// The old small figures stay under the four cards: the two already shown in
// the cards' notes (paid orders and ticket) are not repeated.
const mini=(label,value,note)=>{
const k=node('div',undefined,'kpi-mini');
k.append(node('span',label),node('b',value),...(note?[node('small',note)]:[]));return k;
};
const extra=node('div',undefined,'stats-extra');
extra.append(
mini('Com correção',String(data.corrected),pct(data.corrected)),
mini('Artes tratadas',String(data.treated.orders),pct(data.treated.orders)),
mini('Aguardando contato',String(board.orders.filter(waitingContact).length),'agora'));
$('stats-kpis').replaceChildren(cards,extra);
statsChart($('stats-chart'),data.daily);
// Por máquina: what each printed, how fast, and what it has now.
const cap=board.printing_cap||2;
@@ -270,10 +278,9 @@ async function loadStats(){
$('stats-unpaid').replaceChildren(...unpaidRows.map(([label,value])=>{const tr=node('tr');
tr.append(node('td',label),node('td',value,'r'));return tr;}));
// Who prepared the finals of the period's orders, for the designer's productivity.
const most=Math.max(1,...data.treated.by.map(t=>t.orders));
$('stats-treated').replaceChildren(...(data.treated.by.length?data.treated.by.map(t=>{
const row=node('div',undefined,'byrow'),track=node('span',undefined,'track'),fill=node('i');fill.style.width=(100*t.orders/most)+'%';track.append(fill);
row.append(node('span',t.who),track,node('b',String(t.orders)));return row;}):[node('p','Nenhuma arte tratada no período.','empty')]));
const tr=node('tr');tr.append(node('td',t.who),node('td',String(t.orders),'r'));return tr;}):
[emptyRow('Nenhuma arte tratada no período.',2)]));
// Rework (D-02 to D-04): authorized metres redone over the film printed, against the goal.
const scale=Math.max(rw.goal_percent*2,...rw.causes.map(r=>r.percent||0))*1.15||1;
const meter=(value,goal)=>{const m=node('span',undefined,'meter'),track=node('span',undefined,'track'),fill=node('span',undefined,'fill'+(goal!=null&&value>goal?' warn':''));
@@ -319,23 +326,7 @@ async function loadStats(){
node('td',String(s.samples),'r'));
if(!s.samples)tr.classList.add('off');
return tr;}));
// Coupons of the period (front 8.3): the page's sections live in the HTML,
// so this panel is built here once and kept beside "Pedidos sem pagamento".
let couponPanel=$('stats-coupons-panel');
if(!couponPanel){
couponPanel=node('section',undefined,'panel clip');couponPanel.id='stats-coupons-panel';
const head=node('div',undefined,'phead');head.append(node('h2','Cupons'));
const table=node('table',undefined,'table');
const thead=node('thead'),headRow=node('tr');
for(const [label,cls] of [['Cupom',''],['Pedidos','r'],['Metros','r'],['Desconto','r'],['Recebido','r']])
headRow.append(node('th',label,cls));
thead.append(headRow);
const tbody=node('tbody');tbody.id='stats-coupons';
table.append(thead,tbody);
couponPanel.append(head,node('p','Cupons usados pelos pedidos pagos do período.','phint'),table);
const anchor=$('stats-unpaid')?.closest('section');
if(anchor)anchor.after(couponPanel);else $('tab-stats').append(couponPanel);
}
// Coupons of the period (front 8.3): the panel lives in the Consulta group.
const couponRows=data.coupons||[];
$('stats-coupons').replaceChildren(...(couponRows.length?couponRows.map(coupon=>{
const tr=node('tr');