feat: Ajuste Fino priced per art, with the offer under each Prumo warning (Marcus 10/11, point 1)
The designer treatment becomes Ajuste Fino, priced per art with a batch band set in the Site tab (e.g. R$ 9,90, from 10 arts R$ 6,90). Under each art the Prumo warns about, the Site offers 'Quer que um designer resolva? Ajuste Fino'; the cart keeps 'Ajuste Fino em todas as artes'. The server counts the chosen arts, Tiny gets the line with that quantity, the card shows 'Ajuste Fino · N artes'. Old carts asking the treatment for the whole order keep working. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
stroke:item.strokeClass||null,strokeChoice:item.strokeChoice||null,
|
||||
sheets:(item.partes||[]).map(part=>part.production),
|
||||
files:(item.localFiles||[]).map(file=>({name:file.name,size:file.size,lastModified:file.lastModified}))
|
||||
})),treatment:!!$('fTratamento')?.checked,coupon:cupomCode()});
|
||||
})),treatment:ajusteSnapshot(),coupon:cupomCode()});
|
||||
}
|
||||
// The quote this browser is paying, forgotten. clearDraft also empties the
|
||||
// payment area; forgetDraft leaves on screen what is there (a confirmation).
|
||||
@@ -80,9 +80,11 @@
|
||||
// The art grade rules (front 8.5): the Site uses only the treatment rule,
|
||||
// forcing the checkbox when the cart's worst grade is below it.
|
||||
window.dtfGradeRules=session.grade_rules||{};
|
||||
// Treatment by the designer (front 5): only offered when TREATMENT_CENTS
|
||||
// is set; the server adds the same amount and the 24 h to the quote.
|
||||
// Ajuste Fino (front 1a): per art, with a band by the order's number of
|
||||
// arts. Only offered when TREATMENT_CENTS is set; the server adds the
|
||||
// same amount and the 24 h to the quote.
|
||||
TAXA_TRATAMENTO=(session.treatment_cents||0)/100;
|
||||
FAIXAS.tratamento=session.treatment_bands||[];
|
||||
const tratamentoBox=document.getElementById('tratamentoBox');
|
||||
if(tratamentoBox){
|
||||
tratamentoBox.hidden=!(TAXA_TRATAMENTO>0);
|
||||
@@ -116,6 +118,7 @@
|
||||
}
|
||||
window.dtfProducts=session.products;
|
||||
if(typeof folhas!=='undefined'&&folhas.length&&typeof pintaFolha==='function')pintaFolha();
|
||||
if(typeof artes!=='undefined'&&artes.length&&typeof pintaArtes==='function')pintaArtes();
|
||||
if(typeof itemAtual!=='undefined'&&itemAtual&&typeof carrinho==='function')carrinho();
|
||||
if(typeof pintaTipoEnvio==='function')pintaTipoEnvio();
|
||||
semPedidos=!Object.values(session.products).some(product=>product.enabled);
|
||||
@@ -174,8 +177,11 @@
|
||||
const prazo = approved.freight.days ? ' · até '+approved.freight.days+' dias úteis' : '';
|
||||
rows.push(linha(pickup ? 'Retirada em Franca' : (approved.freight.description || 'Frete')+prazo,
|
||||
approved.freight.total_cents ? rs(approved.freight.total_cents/100) : 'Grátis'));
|
||||
if(quote.treatment?.cents)
|
||||
rows.push(linha('Tratamento da arte pelo designer · +24 h', rs(quote.treatment.cents/100)));
|
||||
if(quote.treatment?.cents){
|
||||
const arts=Number(quote.treatment.arts)||0;
|
||||
rows.push(linha('Ajuste Fino'+(arts?' · '+arts+(arts===1?' arte':' artes'):'')+' · +24 h',
|
||||
rs(quote.treatment.cents/100)));
|
||||
}
|
||||
if(approved.coupon)
|
||||
rows.push(linha('Cupom '+approved.coupon.code, '− '+rs(approved.coupon.discount_cents/100)));
|
||||
rows.push(linha('Total', rs(approved.total_cents/100), 'tot'));
|
||||
@@ -435,7 +441,9 @@
|
||||
if (destination) content.destination = destination;
|
||||
// "Quero aprovar uma prova antes de imprimir": the order waits for the customer.
|
||||
if ($('fProva')?.checked) content.proof = true;
|
||||
if ($('fTratamento')?.checked) content.treatment = true;
|
||||
// Ajuste Fino: true for every art, or the [item, source] pairs chosen.
|
||||
const treatment=tratamentoParaItens(sheets);
|
||||
if (treatment) content.treatment = treatment;
|
||||
if (cartSnapshot()!==initialCart) throw new Error('O carrinho mudou durante o envio. Confira os itens e envie de novo.');
|
||||
// Browser timings for Números (item 0.12); they never affect the price.
|
||||
const T=window.dtfTimings, timings={};
|
||||
|
||||
@@ -1121,9 +1121,9 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
</div>
|
||||
|
||||
<div class="cxE" id="tratamentoBox" hidden>
|
||||
<h4>Tratamento da arte</h4>
|
||||
<h4>Ajuste Fino</h4>
|
||||
<label class="provaOp"><input type="checkbox" id="fTratamento">
|
||||
<span><b>Quero o tratamento pelo designer — <span id="tratamentoPreco"></span></b>
|
||||
<span><b>Ajuste Fino em todas as artes — <span id="tratamentoPreco"></span> por arte</b>
|
||||
O designer ajusta a arte para DTF, com fundo transparente e 300 DPI, e sobe o arquivo
|
||||
pelo card. O prazo do pedido aumenta em 24 h.</span></label>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
which defines api, may, money, when, say, node and button.
|
||||
A price is history: one that has started is never changed or deleted, so
|
||||
only a scheduled (future) price may be cancelled. */
|
||||
const SITE_UNIT_LABEL={metro:' /m',pedido:' por pedido'};
|
||||
const SITE_UNIT_LABEL={metro:' /m',pedido:' por pedido',arte:' por arte'};
|
||||
|
||||
// Reais with a comma, as the Site shows them: "19,90" is 1990 cents.
|
||||
function moneyInputCents(value){
|
||||
@@ -18,10 +18,11 @@ function moneyInputCents(value){
|
||||
// A price that already started is refused by the server (409).
|
||||
const cancelScheduledPrice=id=>api('/site/prices/'+id+'/cancel',{});
|
||||
|
||||
// "5" or "5,5": a band's start in metres, as the table reads it.
|
||||
// "5" or "5,5": a band's start, in metres or arts, as the table reads it.
|
||||
function bandMetres(value){return String(Number(value)).replace('.',',');}
|
||||
function bandsText(bands){
|
||||
return (bands||[]).map(band=>' · '+bandMetres(band.from_metres)+' m: '+money(band.unit_cents)).join('');
|
||||
function bandsText(bands,unit='metro'){
|
||||
return (bands||[]).map(band=>' · '+bandMetres(band.from_metres)+' '+
|
||||
(unit==='arte'?(Number(band.from_metres)===1?'arte':'artes'):'m')+': '+money(band.unit_cents)).join('');
|
||||
}
|
||||
|
||||
function siteProductRow(product){
|
||||
@@ -66,17 +67,18 @@ function sitePriceBlock(product){
|
||||
starts.setAttribute('aria-label','Quando o novo preço de '+product.title+' começa');
|
||||
startsLabel.append(starts);
|
||||
// Faixas progressivas (front 8.2): a nova tabela começa vazia; as faixas
|
||||
// viajam com este preço. O tratamento é um valor por pedido, sem faixas.
|
||||
// viajam com este preço. Ajuste Fino conta as faixas em artes, os produtos em metros.
|
||||
const bandUnit=product.unit==='arte'?'artes':'m';
|
||||
const bandRows=node('div',undefined,'siteBandRows');
|
||||
const addBand=node('button','Adicionar faixa','btn ghost');addBand.type='button';
|
||||
const paintAdd=()=>{addBand.disabled=bandRows.children.length>=5;};
|
||||
const bandRow=()=>{
|
||||
const row=node('div',undefined,'siteBandRow');
|
||||
const fromLabel=node('label');fromLabel.append(node('span','A partir de (m)'));
|
||||
const fromLabel=node('label');fromLabel.append(node('span','A partir de ('+bandUnit+')'));
|
||||
const from=node('input');from.type='text';from.inputMode='decimal';from.className='siteBandFrom';
|
||||
from.setAttribute('aria-label','Metragem da faixa de '+product.title);
|
||||
from.setAttribute('aria-label','Início da faixa em '+bandUnit+' de '+product.title);
|
||||
fromLabel.append(from);
|
||||
const priceLabel=node('label');priceLabel.append(node('span','R$ por metro'));
|
||||
const priceLabel=node('label');priceLabel.append(node('span','R$ por '+(product.unit==='arte'?'arte':'metro')));
|
||||
const bandPrice=node('input');bandPrice.type='text';bandPrice.inputMode='decimal';bandPrice.className='siteBandPrice';
|
||||
bandPrice.setAttribute('aria-label','Preço da faixa de '+product.title);
|
||||
priceLabel.append(bandPrice);
|
||||
@@ -93,7 +95,7 @@ function sitePriceBlock(product){
|
||||
const from=Number(row.querySelector('.siteBandFrom').value.replace(',','.'));
|
||||
const unit=moneyInputCents(row.querySelector('.siteBandPrice').value);
|
||||
if(!Number.isFinite(from)||from<=0||unit===null||unit<=0)
|
||||
throw new Error('Confira as faixas: metragem e preço maiores que zero.');
|
||||
throw new Error('Confira as faixas: início e preço maiores que zero.');
|
||||
return {from_metres:String(from),unit_cents:unit};
|
||||
});
|
||||
const save=button('Salvar',async()=>{
|
||||
@@ -103,18 +105,17 @@ function sitePriceBlock(product){
|
||||
if(whenDate&&Number.isNaN(whenDate.getTime()))throw new Error('Data inválida.');
|
||||
await api('/site/products/'+product.id+'/prices',
|
||||
{unit_cents:cents,starts_at:whenDate?whenDate.toISOString():null,
|
||||
bands:product.id==='tratamento'?[]:formBands()});
|
||||
bands:formBands()});
|
||||
say(whenDate?'Preço salvo para '+when(whenDate)+'.':'Preço salvo. Vale a partir de agora.');
|
||||
await loadSiteAdmin();
|
||||
},'btn pri');
|
||||
form.append(priceLabel,startsLabel,save);
|
||||
if(product.id!=='tratamento')form.append(bands);
|
||||
form.append(priceLabel,startsLabel,save,bands);
|
||||
|
||||
const scheduled=node('div',undefined,'siteScheduled');
|
||||
if(product.scheduled.length){
|
||||
for(const row of product.scheduled){
|
||||
const line=node('div',undefined,'siteScheduledRow');
|
||||
line.append(node('span',money(row.unit_cents)+SITE_UNIT_LABEL[product.unit]+bandsText(row.bands)+
|
||||
line.append(node('span',money(row.unit_cents)+SITE_UNIT_LABEL[product.unit]+bandsText(row.bands,product.unit)+
|
||||
' a partir de '+when(row.starts_at)));
|
||||
line.append(button('Cancelar',async()=>{
|
||||
await cancelScheduledPrice(row.id);
|
||||
@@ -132,7 +133,7 @@ function sitePriceBlock(product){
|
||||
const body=node('tbody');
|
||||
for(const row of product.history){
|
||||
const tr=node('tr');
|
||||
tr.append(node('td',money(row.unit_cents)+bandsText(row.bands),'nowrap'),node('td',when(row.starts_at),'nowrap'),
|
||||
tr.append(node('td',money(row.unit_cents)+bandsText(row.bands,product.unit),'nowrap'),node('td',when(row.starts_at),'nowrap'),
|
||||
node('td',row.created_by),node('td',when(row.created_at),'nowrap'));
|
||||
body.append(tr);
|
||||
}
|
||||
@@ -188,7 +189,7 @@ async function loadGradeRules(){
|
||||
ensureGradePanel();
|
||||
const data=await api('/site/grade-rules');
|
||||
const aviso=gradeRuleRow('Avisar o designer abaixo de',data.aviso);
|
||||
const tratamento=gradeRuleRow('Exigir o tratamento abaixo de',data.tratamento);
|
||||
const tratamento=gradeRuleRow('Exigir o Ajuste Fino abaixo de',data.tratamento);
|
||||
const save=button('Salvar',async()=>{
|
||||
const avisoValue=aviso.on.checked?Number(aviso.num.value):null;
|
||||
const tratamentoValue=tratamento.on.checked?Number(tratamento.num.value):null;
|
||||
@@ -196,14 +197,14 @@ async function loadGradeRules(){
|
||||
if(value!==null&&(!Number.isInteger(value)||value<1||value>100))
|
||||
throw new Error('A nota vai de 1 a 100.');
|
||||
if(avisoValue!==null&&tratamentoValue!==null&&tratamentoValue>avisoValue)
|
||||
throw new Error('A regra do tratamento precisa ser menor ou igual à do aviso.');
|
||||
throw new Error('A regra do Ajuste Fino precisa ser menor ou igual à do aviso.');
|
||||
await api('/site/grade-rules',{aviso:avisoValue,tratamento:tratamentoValue});
|
||||
say('Regras da nota da arte salvas.');
|
||||
await loadGradeRules();
|
||||
},'btn pri');
|
||||
const children=[aviso.row,tratamento.row];
|
||||
if(!data.treatment_offered)
|
||||
children.push(node('p','Ative e dê preço ao Tratamento pelo designer para esta regra valer.','siteGradeWarn'));
|
||||
children.push(node('p','Ative e dê preço ao Ajuste Fino para esta regra valer.','siteGradeWarn'));
|
||||
const foot=node('div',undefined,'siteGradeSave');foot.append(save);children.push(foot);
|
||||
$('site-grade-body').replaceChildren(...children);
|
||||
}
|
||||
|
||||
@@ -1053,7 +1053,11 @@ function cardFlags(order){
|
||||
if(redo.length)out.push(['bad','Retrabalho',redo.map(r=>'Retrabalho · '+REWORK_CAUSES[r.cause]+' · '+metres(r.metres)+(r.authorized?'':' · aguardando autorização')).join(' · ')]);
|
||||
if(live&&s.items.some(mirroredItem))out.push(['warn','Espelhada',MIRROR_NOTE]);
|
||||
if(waitingContact(order))out.push(['warn','Contato','Aguardando contato: '+order.contact_note+' · '+contactWho(order)]);
|
||||
if(order.snapshot.treatment)out.push(['warn','Tratamento pago','O designer trata a arte antes de imprimir; prazo +24 h']);
|
||||
if(order.snapshot.treatment){
|
||||
const n=Number(order.snapshot.treatment.arts)||1;
|
||||
out.push(['warn','Ajuste Fino · '+n+(n===1?' arte':' artes'),
|
||||
'O designer faz o Ajuste Fino antes de imprimir; prazo +24 h']);
|
||||
}
|
||||
if(order.proof_parent)out.push(['warn','Prova do #'+order.proof_parent.number,'Card da prova do pedido #'+order.proof_parent.number]);
|
||||
if(live&&waitingProof(order)&&order.state!=='tra')out.push(['warn','Aguardando prova','Entra na fila com Prova OK no card #'+order.proof_card.number]);
|
||||
if(live&&proofRejected(order))out.push(['bad','Prova reprovada',order.proof_card.proof_reason+' · '+order.proof_card.proof_decided_by]);
|
||||
@@ -1600,9 +1604,9 @@ function contractionList(order){
|
||||
}
|
||||
function approveParts(order,main=true){
|
||||
if(order.snapshot.treatment){
|
||||
const approve=button('Enviar arte tratada',()=>treatDialog(order),'btn lg'+(main?' pri':''));
|
||||
const approve=button('Enviar arte do Ajuste Fino',()=>treatDialog(order),'btn lg'+(main?' pri':''));
|
||||
approve.dataset.treat='';
|
||||
return {text:'Tratamento pago: o designer precisa enviar o PNG tratado de cada item antes da fila.',
|
||||
return {text:'Ajuste Fino pago: o designer precisa enviar o PNG do Ajuste Fino de cada item antes da fila.',
|
||||
files:null,approve,extra:[]};
|
||||
}
|
||||
const ready=readyFinals(order), all=ready.every(Boolean), many=ready.length>1;
|
||||
@@ -1694,8 +1698,8 @@ function nextBox(order){
|
||||
}
|
||||
if(st==='rec'||st==='cor'){
|
||||
if(st==='rec'&&order.snapshot.treatment&&!treatmentDone(order)&&finalDone(order)){
|
||||
title='Enviar a arte tratada';
|
||||
note('O tratamento foi pago. Envie o PNG tratado de cada item antes de colocar o pedido na fila.');
|
||||
title='Enviar a arte do Ajuste Fino';
|
||||
note('O Ajuste Fino foi pago. Envie o PNG ajustado de cada item antes de colocar o pedido na fila.');
|
||||
if(may('produce'))main.push(button('Tratar a arte',()=>treatDialog(order),'btn pri lg'));
|
||||
return composeNext(title,body,main,more);
|
||||
}
|
||||
@@ -2392,7 +2396,7 @@ function filesView(order,revisions,view){
|
||||
// Rework (Dropstar's rules D-02 to D-04). Gestão opens it with its cause,
|
||||
// which never changes after; an Administrador authorizes or declines it,
|
||||
// never one they opened. Bad art the customer approved is outside the goal.
|
||||
const REWORK_CAUSES={impressao:'Falha de impressão',perfil_cor:'Perfil de cor',tratamento:'Erro de tratamento',
|
||||
const REWORK_CAUSES={impressao:'Falha de impressão',perfil_cor:'Perfil de cor',tratamento:'Erro de Ajuste Fino',
|
||||
pedido:'Erro de pedido',arte_cliente:'Arte aprovada pelo cliente'};
|
||||
const REWORK_OUTSIDE='arte_cliente';
|
||||
function reworkForm(order){
|
||||
|
||||
115
web/site-cart.js
115
web/site-cart.js
@@ -4,6 +4,77 @@
|
||||
scope and run top to bottom, exactly as the original did. */
|
||||
// ── carrinho
|
||||
let itemAtual=null;
|
||||
// Ajuste Fino (front 1a): each art may be chosen under its warning, or the
|
||||
// general switch chooses every art of the paying items.
|
||||
function artesDoItem(it){
|
||||
if(it.partes && it.partes.length)
|
||||
return it.partes.reduce((t,p)=>t+((p.production&&p.production.sources||[]).length),0);
|
||||
return (it.production&&it.production.sources||[]).length;
|
||||
}
|
||||
function artesSelecionadas(aPagar=itensAPagar()){
|
||||
if(ajusteTudo) return aPagar.reduce((t,it)=>t+artesDoItem(it),0);
|
||||
return aPagar.reduce((t,it)=>{
|
||||
if(it.partes && it.partes.length)
|
||||
return t+it.partes.reduce((s,p)=>s+(p.ajusteSources||[]).length,0);
|
||||
return t+(it.ajusteSources||[]).length;
|
||||
},0);
|
||||
}
|
||||
// While a product is open, its files are not in the cart yet; the rule must
|
||||
// still see the arts the customer already checked under their warnings.
|
||||
function artesEscolhidasNaTela(){
|
||||
if(!modo) return 0;
|
||||
return (ehFolha()?folhas:artes).filter(x=>x.ajuste).length;
|
||||
}
|
||||
// What the cart snapshot compares: the switch and every chosen source.
|
||||
function ajusteSnapshot(){
|
||||
return {tudo:!!ajusteTudo, itens:itensAPagar().map(it=>({
|
||||
escolhas:it.ajusteSources||[],
|
||||
partes:(it.partes||[]).map(p=>p.ajusteSources||[])
|
||||
}))};
|
||||
}
|
||||
// A final cart item (after a split sheet becomes its own items) to the pairs.
|
||||
function tratamentoParaItens(itens){
|
||||
if(!(TAXA_TRATAMENTO>0)) return false;
|
||||
if(ajusteTudo) return true;
|
||||
const pairs=[];
|
||||
itens.forEach((it,itemIndex)=>{
|
||||
for(const source of it.ajusteSources||[]) pairs.push([itemIndex,source]);
|
||||
});
|
||||
return pairs.length?pairs:false;
|
||||
}
|
||||
function materializaAjuste(){
|
||||
if(!ajusteTudo) return;
|
||||
ajusteTudo=false;
|
||||
for(const it of itensAPagar()){
|
||||
if(it.partes && it.partes.length){
|
||||
for(const part of it.partes)
|
||||
part.ajusteSources=Array.from({length:(part.production&&part.production.sources||[]).length},(_,i)=>i);
|
||||
}else{
|
||||
it.ajusteSources=Array.from({length:(it.production&&it.production.sources||[]).length},(_,i)=>i);
|
||||
}
|
||||
}
|
||||
for(const x of folhas) x.ajuste=true;
|
||||
for(const a of artes) a.ajuste=true;
|
||||
}
|
||||
function limpaAjuste(){
|
||||
ajusteTudo=false;
|
||||
for(const it of itensAPagar()){
|
||||
it.ajusteSources=[];
|
||||
for(const part of it.partes||[]) part.ajusteSources=[];
|
||||
}
|
||||
for(const x of folhas) x.ajuste=false;
|
||||
for(const a of artes) a.ajuste=false;
|
||||
}
|
||||
// Update the per-art boxes without repainting the list, which would discard
|
||||
// the item the customer is still building.
|
||||
function pintaAjusteCheckboxes(){
|
||||
document.querySelectorAll('[data-ajuste]').forEach(el=>{
|
||||
const x=folhas[+el.dataset.ajuste]; if(x)el.checked=ajusteTudo||!!x.ajuste;
|
||||
});
|
||||
document.querySelectorAll('[data-ajustea]').forEach(el=>{
|
||||
const a=artes[+el.dataset.ajustea]; if(a)el.checked=ajusteTudo||!!a.ajuste;
|
||||
});
|
||||
}
|
||||
function invalidaItemAtual(){
|
||||
if(!itemAtual) return;
|
||||
itemAtual=null;
|
||||
@@ -31,7 +102,8 @@ function limpaPaineis(){
|
||||
}
|
||||
|
||||
// Front 8.5: when the worst grade of the paying items is below the rule and
|
||||
// the treatment is offered, the designer's treatment is required.
|
||||
// Ajuste Fino is offered, it is required. The simple rule the server keeps:
|
||||
// at least one art must be chosen; with none, the general switch selects all.
|
||||
function mostraAvisoTratamento(texto){
|
||||
const box=$('tratamentoBox'); if(!box)return;
|
||||
let el=$('tratamentoAviso');
|
||||
@@ -48,12 +120,27 @@ function aplicaTratamento(aPagar){
|
||||
const required=offered&&rule>0&&worst!==null&&worst<rule;
|
||||
box.hidden=!offered;
|
||||
if(!offered){
|
||||
check.checked=false;check.disabled=false;mostraAvisoTratamento('');
|
||||
check.checked=false;check.disabled=false;
|
||||
ajusteTudo=false;
|
||||
for(const it of aPagar){
|
||||
it.ajusteSources=[];
|
||||
for(const part of it.partes||[]) part.ajusteSources=[];
|
||||
}
|
||||
for(const x of folhas) x.ajuste=false;
|
||||
for(const a of artes) a.ajuste=false;
|
||||
mostraAvisoTratamento('');
|
||||
}else if(required){
|
||||
check.checked=true;check.disabled=true;
|
||||
mostraAvisoTratamento('Sua arte tem nota '+worst+': para imprimir com qualidade, o tratamento pelo designer é obrigatório neste pedido.');
|
||||
const chosen=!!ajusteTudo || artesSelecionadas(aPagar)>0 || artesEscolhidasNaTela()>0;
|
||||
if(!chosen){
|
||||
ajusteTudo=true;
|
||||
for(const x of folhas) x.ajuste=true;
|
||||
for(const a of artes) a.ajuste=true;
|
||||
document.querySelectorAll('[data-ajuste],[data-ajustea]').forEach(el=>{el.checked=true;});
|
||||
}
|
||||
check.checked=ajusteTudo;check.disabled=true;
|
||||
mostraAvisoTratamento('Sua arte tem nota '+worst+': para imprimir com qualidade, o Ajuste Fino é obrigatório neste pedido.');
|
||||
}else{
|
||||
check.disabled=false;mostraAvisoTratamento('');
|
||||
check.checked=ajusteTudo;check.disabled=false;mostraAvisoTratamento('');
|
||||
}
|
||||
}
|
||||
// O carrinho junta itens de produtos diferentes e cobra uma vez só.
|
||||
@@ -100,7 +187,8 @@ function pintaPedido(){
|
||||
$('bEsvaziar').hidden = pedido.length+(itemAtual?1:0) < 2;
|
||||
const itens = aPagar.reduce((t,it)=>t+it.total,0);
|
||||
const frete = entrega.tipo==='frete' && entrega.cotado ? entrega.valor : 0;
|
||||
const tratamento=$('fTratamento')?.checked&&TAXA_TRATAMENTO>0?TAXA_TRATAMENTO:0;
|
||||
const artesAjuste = TAXA_TRATAMENTO>0 ? artesSelecionadas(aPagar) : 0;
|
||||
const tratamento = artesAjuste ? Math.round(precoAjuste(artesAjuste)*artesAjuste*100)/100 : 0;
|
||||
const soma = itens + frete + tratamento;
|
||||
const n = aPagar.length, noCarrinho = pedido.length + (itemAtual?1:0);
|
||||
$('resLin').innerHTML =
|
||||
@@ -110,7 +198,8 @@ function pintaPedido(){
|
||||
'</span><b>'+
|
||||
(entrega.tipo==='retira' ? '<span style="color:var(--verde-ml)">Grátis</span>'
|
||||
: entrega.cotado ? rs(frete) : 'a cotar')+'</b></div>'+
|
||||
(tratamento?'<div class="l"><span>Tratamento da arte · +24 h</span><b>'+rs(tratamento)+'</b></div>':'')+
|
||||
(tratamento?'<div class="l"><span>Ajuste Fino · '+artesAjuste+(artesAjuste===1?' arte':' artes')+
|
||||
' · +24 h</span><b>'+rs(tratamento)+'</b></div>':'')+
|
||||
'<div class="l"><span>Revisão e reencaixe</span>'+
|
||||
'<b><span style="color:var(--verde-ml)">Grátis</span></b></div>';
|
||||
$('carrTot').textContent=rs(soma);
|
||||
@@ -151,6 +240,7 @@ 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 escolhidas=lista=>lista.map((x,i)=>ajusteTudo||x.ajuste?i:null).filter(i=>i!==null);
|
||||
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,
|
||||
@@ -175,6 +265,7 @@ function carrinho(){
|
||||
localFiles:f.artes.map(x=>x.f), fotos:f.artes.map(x=>x.fotoSrc||null),
|
||||
metros:+(f.layout.height_cm/100).toFixed(4),
|
||||
production:{version:3,film_width_cm:larguraFilme(),sources:f.artes.map(fonteDaArte),...f.layout},
|
||||
ajusteSources:escolhidas(f.artes),
|
||||
residueAccepted:residuosDasArtes(f.artes), ...tracoDoItem(f.artes,f.layout)}));
|
||||
layout=null;
|
||||
}else{
|
||||
@@ -189,6 +280,7 @@ function carrinho(){
|
||||
arquivos:(ehFolha()?folhas:artes).length,
|
||||
production:layout?{version:3,film_width_cm:larguraFilme(),sources,...layout}:null,
|
||||
partes,
|
||||
...(partes?{}:{ajusteSources:escolhidas(ehFolha()?folhas:artes)}),
|
||||
qualityStatus:$('ciente').classList.contains('recusa')?'rejected':
|
||||
$('ciente').classList.contains('on')?'warning':nota===0?'unverified':'ok',
|
||||
qualityAcknowledged:false,
|
||||
@@ -210,7 +302,14 @@ function avisaDesfazer(texto,acao){
|
||||
function fechaDesfazer(){ clearTimeout(desfazerTimer); desfazerAcao=null; $('desfazer').hidden=true; }
|
||||
addEventListener('dtf-page-changed',fechaDesfazer);
|
||||
$('desfazerBtn').addEventListener('click',()=>{ const acao=desfazerAcao; fechaDesfazer(); if(acao) acao(); });
|
||||
$('fTratamento')?.addEventListener('change',()=>pintaPedido());
|
||||
$('fTratamento')?.addEventListener('change',()=>{
|
||||
if($('fTratamento').checked) ajusteTudo=true;
|
||||
else limpaAjuste();
|
||||
// The art cards show the same choice, one checkbox under each warning; do
|
||||
// not repaint them, or the item being built is discarded.
|
||||
pintaAjusteCheckboxes();
|
||||
pintaPedido();
|
||||
});
|
||||
$('bEsvaziar').addEventListener('click',()=>{
|
||||
const antes=pedido.slice();
|
||||
pedido=[]; invalidaItemAtual(); pintaPedido();
|
||||
|
||||
@@ -66,8 +66,11 @@ const FAIXAS={};
|
||||
// Folha que alguém abre na mão (CDR, AI, PSD, TIFF): R$ a mais por metro.
|
||||
// Vem do servidor (/api/session), que cobra o mesmo; zero não soma nada.
|
||||
let TAXA_MANUAL=0;
|
||||
// Fixed price of the designer treatment, set by the server (TREATMENT_CENTS).
|
||||
// Ajuste Fino, per art, set by the server (TREATMENT_CENTS).
|
||||
let TAXA_TRATAMENTO=0;
|
||||
// Ajuste Fino for every art of the cart: the general switch, or true when
|
||||
// the grade rule requires it. Individual choices live on the art objects.
|
||||
let ajusteTudo=false;
|
||||
const folhaManual=()=>ehFolha() && folhas.some(x=>!x.med);
|
||||
const ehFolha=m=>!!MODOS[m||modo].folha;
|
||||
const precoMetro=m=>PRECO[m||modo];
|
||||
@@ -79,6 +82,16 @@ function precoNaMetragem(m, metros){
|
||||
for(const band of bands) if(metros>=Number(band.from_metres) && (!alta || Number(band.from_metres)>=Number(alta.from_metres))) alta=band;
|
||||
return alta ? alta.unit_cents/100 : PRECO[m];
|
||||
}
|
||||
// Ajuste Fino: the price of one art when the order has n arts. Below the first
|
||||
// band it is the base, then the highest band reached, as app/catalog.py does.
|
||||
function precoAjuste(n, base = TAXA_TRATAMENTO, bands = FAIXAS.tratamento) {
|
||||
let price = base, best = null;
|
||||
for (const band of bands || []) {
|
||||
const start = Number(band.from_metres);
|
||||
if (n >= start && (best === null || start >= best)) { best = start; price = band.unit_cents / 100; }
|
||||
}
|
||||
return price;
|
||||
}
|
||||
// A próxima faixa à frente, para o aviso de quanto falta.
|
||||
function proximaFaixa(m, metros){
|
||||
const bands=FAIXAS[m]||[];
|
||||
|
||||
@@ -483,6 +483,27 @@ function avisosDaFolha(a,nome,i,aceito,aceitavel=false){
|
||||
'usou e envie de novo. '+(varios?'Os círculos vermelhos na prévia mostram onde estão.':'O círculo vermelho na prévia mostra onde está.')+
|
||||
(aceitavel?' Se '+(varios?'os pontos são':'o ponto é')+' da própria arte, marque abaixo.</p>'+aceite:'</p>');
|
||||
}
|
||||
// Ajuste Fino (front 1a): under a Prumo warning, the customer may hand this
|
||||
// art to the designer. One choice per art; the cart has the general switch.
|
||||
function temAvisoFolha(x){
|
||||
const a=x.an;
|
||||
if(!a || a.grande) return false;
|
||||
return !!(a.fundoChapado || a.residuos || a.dpi<DPI_AVISA ||
|
||||
(typeof tracoDoArquivo==='function' && typeof mista==='function' && mista(tracoDoArquivo(x))));
|
||||
}
|
||||
function temAvisoArte(a){
|
||||
const an=analiseDaArte(a);
|
||||
if(!an || an.grande) return false;
|
||||
return !!(an.fundoChapado || an.residuos || an.dpi<DPI_AVISA ||
|
||||
(typeof mista==='function' && mista(tracoDaArte(a))));
|
||||
}
|
||||
function ajusteLinha(i,attr){
|
||||
if(!(TAXA_TRATAMENTO>0)) return '';
|
||||
const marcado=ajusteTudo || (attr==='data-ajuste' ? folhas[i].ajuste : artes[i].ajuste);
|
||||
return '<label class="aceiteRes ajusteArte"><input type="checkbox" '+attr+'="'+i+'"'+
|
||||
(marcado?' checked':'')+'>'+
|
||||
'<span>Quer que um designer resolva? <b>Ajuste Fino</b> — '+rs(TAXA_TRATAMENTO)+'</span></label>';
|
||||
}
|
||||
function detalhesDaFolha(a,i,aberto){
|
||||
const linhas = a.grande
|
||||
? ['Resolução '+a.dpi+' DPI, lida do arquivo',
|
||||
@@ -514,6 +535,7 @@ function pintaFolha(){
|
||||
medida='<div class="repMed"><b>'+n1(x.med.larg)+' × '+n1(x.med.alt)+' cm</b>'+
|
||||
'<span>'+escapeHTML(extDe(x.f.name))+' · '+fmt(x.f.size)+'</span></div>'+
|
||||
(a? '<ul class="chips">'+chipsDaFolha(a,residuoAceito(x))+'</ul>'+avisosDaFolha(a,x.f.name,i,residuoAceito(x),true)+
|
||||
(temAvisoFolha(x)?ajusteLinha(i,'data-ajuste'):'')+
|
||||
detalhesDaFolha(a,i,x.detAberto) : '')+
|
||||
// Over 150 MB the browser cannot check a PDF: said before payment, as
|
||||
// for a file opened by hand (Dropstar, 2026-10-23).
|
||||
@@ -524,7 +546,7 @@ function pintaFolha(){
|
||||
'Exportando em <b>PNG</b>, ou num PDF menor, a conferência sai aqui, antes de pagar.</p>' : '')+
|
||||
(suspeito? '<p class="avisoF"><b>Este PDF passa do tamanho que o formato comporta.</b> '+
|
||||
'A especificação para em 508 cm e o seu tem '+n1(x.med.alt)+' cm. '+
|
||||
'Ele abre certo só em quem o gerou — aqui vai precisar de tratamento. '+
|
||||
'Ele abre certo só em quem o gerou — aqui vai precisar do Ajuste Fino. '+
|
||||
'Manda em <b>PNG ou TIFF</b>, ou divide em partes de até 5 m, que sai na hora.</p>':'')+
|
||||
(larga? '<p class="avisoF"><b>Esta folha não roda neste filme.</b> Ela tem '+n1(x.med.larg)+
|
||||
' cm de largura e o filme aqui tem '+n1(L)+' cm. Não dá para reduzir: '+
|
||||
@@ -588,6 +610,11 @@ function pintaFolha(){
|
||||
$('lista').querySelectorAll('[data-residuo]').forEach(el=>el.addEventListener('change',()=>{
|
||||
folhas[+el.dataset.residuo].residuoAceito=el.checked; pintaFolha();
|
||||
}));
|
||||
$('lista').querySelectorAll('[data-ajuste]').forEach(el=>el.addEventListener('change',()=>{
|
||||
if(ajusteTudo) materializaAjuste();
|
||||
folhas[+el.dataset.ajuste].ajuste=el.checked;
|
||||
pintaFolha(); pintaPedido();
|
||||
}));
|
||||
$('lista').querySelectorAll('[data-det]').forEach(d=>d.addEventListener('toggle',()=>{
|
||||
folhas[+d.dataset.det].detAberto=d.open;
|
||||
}));
|
||||
@@ -688,7 +715,8 @@ function pintaArtes(){
|
||||
'<button data-rm="'+i+'" aria-label="Remover '+escapeHTML(a.f.name)+'">'+icone('fechar')+'</button></div>'+
|
||||
'<div class="repMed">'+medida+'<span>'+(a.px>0? a.px+' × '+a.py+' px · ' : '')+
|
||||
escapeHTML(extDe(a.f.name))+' · '+fmt(a.f.size)+'</span></div>'+
|
||||
barra+chips+aviso+dica+
|
||||
barra+chips+aviso+
|
||||
(a.cm>0 && (a.src||a.semPrevia) && temAvisoArte(a) ? ajusteLinha(i,'data-ajustea') : '')+dica+
|
||||
'</div></div>'+
|
||||
'<div class="cps">'+
|
||||
'<div class="campo"><label for="cm'+i+'">Largura</label>'+
|
||||
@@ -715,6 +743,11 @@ function pintaArtes(){
|
||||
$('lista').querySelectorAll('[data-rm]').forEach(b=>b.addEventListener('click',()=>{artes.splice(+b.dataset.rm,1);pintaArtes();}));
|
||||
$('lista').querySelectorAll('[data-residuoa]').forEach(el=>el.addEventListener('change',()=>{
|
||||
artes[+el.dataset.residuoa].residuoAceito=el.checked; pintaArtes();}));
|
||||
$('lista').querySelectorAll('[data-ajustea]').forEach(el=>el.addEventListener('change',()=>{
|
||||
if(ajusteTudo) materializaAjuste();
|
||||
artes[+el.dataset.ajustea].ajuste=el.checked;
|
||||
pintaArtes(); pintaPedido();
|
||||
}));
|
||||
$('lista').querySelectorAll('[data-cm]').forEach(i=>i.addEventListener('change',()=>{artes[+i.dataset.cm].cm=+i.value||0;pintaArtes();}));
|
||||
$('lista').querySelectorAll('[data-q]').forEach(i=>i.addEventListener('change',()=>{artes[+i.dataset.q].q=Math.max(1,Math.min(200,Math.floor(+i.value||1)));pintaArtes();}));
|
||||
$('lista').querySelectorAll('[data-cm], [data-q]').forEach(i=>i.addEventListener('input',()=>{
|
||||
|
||||
Reference in New Issue
Block a user