Compare commits

...

1 Commits

Author SHA1 Message Date
root 60e15dbed3 fix impressão: window.print() in-app em vez de window.open(); alert com tabela destino no envio
Build Fechamento de Caixa / build (macos-14, app) (push) Has been cancelled
Build Fechamento de Caixa / build (ubuntu-22.04, deb) (push) Has been cancelled
Build Fechamento de Caixa / build (windows-2022, msi) (push) Has been cancelled
2026-06-23 18:28:58 +00:00
3 changed files with 39 additions and 6 deletions
Binary file not shown.
Binary file not shown.
+39 -6
View File
@@ -1284,11 +1284,37 @@ ${data.observacoes ? `<div class="obs">Obs: ${data.observacoes}</div>` : ''}
}
function openPrintPreview(data) {
// Gera HTML e injeta no body de uma div temporária para window.print()
const html = buildPrintHTML(data);
const win = window.open('', 'print_preview', 'width=400,height=700,scrollbars=yes,resizable=yes');
if (!win) { alert('Bloqueador de pop-up impediu abrir a pré-visualização.'); return; }
win.document.write(html);
win.document.close();
const style = document.createElement('style');
style.textContent = `
@media print {
body { width: 80mm; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 13px; }
.no-print { display: none !important; }
}
.print-actions { position: fixed; top: 10px; right: 10px; z-index: 9999; }
.print-actions button { padding: 8px 16px; cursor: pointer; background: #2563eb; color: #fff; border: none; border-radius: 4px; font-size: 14px; }
.print-actions button:hover { background: #1d4ed8; }
`;
const actions = document.createElement('div');
actions.className = 'print-actions no-print';
actions.innerHTML = '<button onclick="window.print()">🖨️ Imprimir (Ctrl+P)</button>';
// Guarda conteúdo original
const originalBody = document.body.innerHTML;
document.body.innerHTML = html;
document.head.appendChild(style);
document.body.insertBefore(actions, document.body.firstChild);
// Quando fechar print dialog, restaura
const onAfterPrint = () => {
document.body.innerHTML = originalBody;
window.removeEventListener('afterprint', onAfterPrint);
// Re-carrega scripts essenciais
location.reload();
};
window.addEventListener('afterprint', onAfterPrint);
}
function triggerWindowPrint() {
@@ -1453,10 +1479,17 @@ document.getElementById('confirm-send').addEventListener('click', async () => {
const r = await tauriEnviar();
estado.sync_status = 'synced';
saveState();
alert('✅ Enviado com sucesso!');
alert('✅ Enviado com sucesso!\n\n📋 Tabela: fechamentos_web\n🌐 Servidor: supabase.ofrangao.com.br\n\nAbra o Supabase Studio para verificar.');
} catch(e) {
await tauriSaveLocal();
alert('Erro ao enviar: ' + (e.message || e) + '\n(Dados salvos localmente)');
const msg = e?.message || e?.toString?.() || String(e);
alert(
'⚠️ Erro ao enviar para o Supabase.\n\n' +
'📋 Tabela: fechamentos_web\n' +
'🌐 Servidor: supabase.ofrangao.com.br\n\n' +
'O servidor pode estar offline. Dados salvos localmente.\n\n' +
'Erro: ' + msg
);
} finally {
btn.disabled = false;
btn.textContent = '💾 Enviar Fechamento';