fix: harden week-two ordering, artwork and operations
This commit is contained in:
@@ -4,7 +4,23 @@
|
||||
scope and run top to bottom, exactly as the original did. */
|
||||
// ── carrinho
|
||||
let itemAtual=null;
|
||||
function invalidaItemAtual(){
|
||||
if(!itemAtual) return;
|
||||
itemAtual=null;
|
||||
$('atual').style.display='none';
|
||||
$('carrLin').innerHTML='';
|
||||
pintaPedido();
|
||||
}
|
||||
function itemPodeEnviar(item){
|
||||
return item.qualityStatus==='ok' || item.qualityStatus==='unverified' ||
|
||||
(item.qualityStatus==='warning' && item.qualityAcknowledged===true);
|
||||
}
|
||||
function cartPodeEnviar(){
|
||||
const items=[...pedido,...(itemAtual?[itemAtual]:[])];
|
||||
return items.length>0 && items.every(itemPodeEnviar);
|
||||
}
|
||||
function limpaPaineis(){
|
||||
invalidaItemAtual();
|
||||
['qual','prev'].forEach(id=>$(id).classList.remove('on'));
|
||||
if(!pedido.length){ $('carr').classList.remove('on'); }
|
||||
}
|
||||
@@ -37,6 +53,7 @@ function pintaPedido(){
|
||||
$('bPagar').textContent = (pedido.length + (itemAtual?1:0))>1
|
||||
? 'Pagar os '+(pedido.length+(itemAtual?1:0))+' itens de uma vez'
|
||||
: 'Ir para o pagamento';
|
||||
$('bPagar').disabled = !cartPodeEnviar() || !entrega.cotado || !clienteOk();
|
||||
if(pedido.length || itemAtual) $('carr').classList.add('on');
|
||||
if($('cartLink')) $('cartLink').textContent='Carrinho ('+n+')';
|
||||
window.dispatchEvent(new Event('dtf-cart-changed'));
|
||||
@@ -62,8 +79,36 @@ function carrinho(){
|
||||
'<div class="l" style="color:var(--laranja2)"><span>Revisão e reencaixe</span><b>grátis</b></div>';
|
||||
$('carrLin').innerHTML=l;
|
||||
$('atual').style.display='';
|
||||
const sources=(ehFolha()?folhas:artes).map(x=>ehFolha()
|
||||
? {kind:'sheet',width_cm:x.med?.larg||larguraFilme(),length_cm:+(x.m*100).toFixed(4),
|
||||
copies:x.rep||1,rotation_degrees:0,mirrored:false,
|
||||
measurement:x.med?'file':'customer'}
|
||||
: {kind:'artwork',width_cm:x.cm,length_cm:+(x.cm*propDe(x)).toFixed(4),
|
||||
copies:x.q,rotation_degrees:x.giro||0,mirrored:!!x.esp,
|
||||
measurement:x.src?'file':'customer'});
|
||||
let layout;
|
||||
if(ehFolha()){
|
||||
let y=0;
|
||||
const placements=[];
|
||||
sources.forEach((source,source_index)=>{
|
||||
for(let copy_index=0;copy_index<source.copies;copy_index++){
|
||||
placements.push({source_index,copy_index,x_cm:0,y_cm:+y.toFixed(4),
|
||||
width_cm:source.width_cm,length_cm:source.length_cm,
|
||||
rotation_degrees:0,mirrored:false});
|
||||
y+=source.length_cm;
|
||||
}
|
||||
});
|
||||
layout={height_cm:+y.toFixed(4),placements};
|
||||
}else{
|
||||
if(!montagemLayout) return;
|
||||
layout=montagemLayout;
|
||||
}
|
||||
itemAtual={modo, tit:MODOS[modo].tit, nota, metros, cob, unit, total:tot,
|
||||
localFiles:(ehFolha()?folhas:artes).map(x=>x.f),
|
||||
production:{version:2,film_width_cm:larguraFilme(),sources,...layout},
|
||||
qualityStatus:$('ciente').classList.contains('recusa')?'rejected':
|
||||
$('ciente').classList.contains('on')?'warning':nota===0?'unverified':'ok',
|
||||
qualityAcknowledged:false,
|
||||
desc:fmtM(cob)+' m · '+rs(unit)+'/m · nota '+nota};
|
||||
pintaPedido();
|
||||
previa();
|
||||
@@ -74,4 +119,3 @@ function carrinho(){
|
||||
}
|
||||
}
|
||||
function qm(t,c){ const m=$('qmsg'); m.style.display='block'; m.style.color=c||'var(--verde)'; m.innerHTML=t; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user