Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 60e15dbed3 |
Binary file not shown.
Binary file not shown.
+39
-6
@@ -1284,11 +1284,37 @@ ${data.observacoes ? `<div class="obs">Obs: ${data.observacoes}</div>` : ''}
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openPrintPreview(data) {
|
function openPrintPreview(data) {
|
||||||
|
// Gera HTML e injeta no body de uma div temporária para window.print()
|
||||||
const html = buildPrintHTML(data);
|
const html = buildPrintHTML(data);
|
||||||
const win = window.open('', 'print_preview', 'width=400,height=700,scrollbars=yes,resizable=yes');
|
const style = document.createElement('style');
|
||||||
if (!win) { alert('Bloqueador de pop-up impediu abrir a pré-visualização.'); return; }
|
style.textContent = `
|
||||||
win.document.write(html);
|
@media print {
|
||||||
win.document.close();
|
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() {
|
function triggerWindowPrint() {
|
||||||
@@ -1453,10 +1479,17 @@ document.getElementById('confirm-send').addEventListener('click', async () => {
|
|||||||
const r = await tauriEnviar();
|
const r = await tauriEnviar();
|
||||||
estado.sync_status = 'synced';
|
estado.sync_status = 'synced';
|
||||||
saveState();
|
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) {
|
} catch(e) {
|
||||||
await tauriSaveLocal();
|
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 {
|
} finally {
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.textContent = '💾 Enviar Fechamento';
|
btn.textContent = '💾 Enviar Fechamento';
|
||||||
|
|||||||
Reference in New Issue
Block a user