Gestão de Trabalhos | Decalcer
A iniciar sistema...
'; } // ======================================================================== // MODAL DE PRÉ-VISUALIZAÇÃO (3 fichas) + botão imprimir // ======================================================================== window.previewFichas = function (jobId) { var job = getJob(jobId); if (!job) { if (typeof showToast === 'function') showToast('Trabalho não encontrado', 'error'); return; } var overlay = document.createElement('div'); overlay.className = 'fixed inset-0 bg-slate-900/80 flex flex-col items-center backdrop-blur-sm p-2 sm:p-4'; overlay.style.zIndex = '9999999'; var bar = document.createElement('div'); bar.className = 'w-full max-w-5xl bg-white rounded-t-2xl px-4 py-3 flex justify-between items-center shadow-lg'; bar.innerHTML = '
Pré-visualização das Fichas · ' + esc(job.reference || '') + '
' + '
' + '' + '' + '
'; var frame = document.createElement('iframe'); frame.className = 'w-full max-w-5xl flex-grow bg-slate-200 border-none rounded-b-2xl'; frame.style.height = '80vh'; overlay.appendChild(bar); overlay.appendChild(frame); document.body.appendChild(overlay); var doc = frame.contentWindow.document; doc.open(); doc.write(buildDocumento(job)); doc.close(); bar.querySelector('#pf-close').onclick = function () { document.body.removeChild(overlay); }; bar.querySelector('#pf-print').onclick = function () { frame.contentWindow.focus(); frame.contentWindow.print(); }; }; // ---- ligar o botão do modal de edição (criado no HTML) ---------------- function wireButton() { var btn = document.getElementById('btn-print-fichas'); if (btn && !btn.dataset.wired) { btn.dataset.wired = '1'; btn.addEventListener('click', function () { var id = (document.getElementById('edit-job-id') || {}).value; if (id) window.previewFichas(id); }); } } document.addEventListener('click', wireButton, true); wireButton(); })(); });