From 76ffa82e73c2736ec9a54ff000038d83280c3fd2 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Thu, 27 Aug 2026 11:41:44 +0000 Subject: [PATCH] feat(report): new unified compact report A4 portrait mode --- index.html | 1 + src/main.js | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) diff --git a/index.html b/index.html index 6058983..f09e1a6 100644 --- a/index.html +++ b/index.html @@ -157,6 +157,7 @@
+
diff --git a/src/main.js b/src/main.js index c973a0c..efdd385 100644 --- a/src/main.js +++ b/src/main.js @@ -1207,8 +1207,158 @@ window.calculateOptimization = calculateOptimization; window.clearAll = clearAll; window.exportHTML = exportHTML; window.printReport = printReport; +window.printCompactReport = printCompactReport; window.saveJob = saveJob; +function printCompactReport() { + const html = generateCompactReportHTML(); + if (!html) { + showToast('Calcule a otimização primeiro', 'warning'); + return; + } + const win = window.open('', '_blank'); + win.document.write(html); + win.document.close(); + setTimeout(() => { + win.print(); + }, 500); +} + +function generateCompactReportHTML() { + if (!lastResults) return null; + + const { usedBars, totalWeight } = lastResults; + const dateStr = new Date().toLocaleDateString('pt-BR'); + const timeStr = new Date().toLocaleTimeString('pt-BR'); + const totalPieces = demandPieces.reduce((s, p) => s + p.qty, 0); + const jobTitle = document.getElementById('jobTitle').value.trim() || 'Relatório de Corte - Compacto'; + + const renderPieceGroups = (pieces) => { + const groups = {}; + pieces.forEach(p => { + if (!groups[p.tag]) groups[p.tag] = 0; + groups[p.tag]++; + }); + return Object.entries(groups).map(([tag, qt]) => `${tag} (${qt}x)`).join(', '); + }; + + let tableRows = usedBars.map((bar, idx) => { + const composition = renderPieceGroups(bar.pieces); + return ` + + ${idx + 1} + ${bar.barType} + ${bar.count} + ${bar.length} mm + ${bar.remaining} mm + ${composition} + + `; + }).join(''); + + return ` + + + + + Relatório Compacto - ${dateStr} + + + +
+
+
+
+

📊 ${jobTitle}

+

Gerado em: ${dateStr} às ${timeStr}

+
+
+
+ +
+
+
Total de Peças${totalPieces}
+
Barras (Padrões)${usedBars.length}
+
Peso Total (kg)${totalWeight.toFixed(2)}
+
Aproveitamento Global${((1 - (lastResults.usedBars.reduce((s, b) => s + b.remaining, 0) / lastResults.usedBars.reduce((s, b) => s + b.length, 0))) * 100).toFixed(2)}%
+
+ + + + + + + + + + + + + + ${tableRows} + +
#Perfil/BarraQtdComp. (mm)Sobra (mm)Composição (Tag x Qtd)
+
+ + +
+ + `; +} + window.loadJob = loadJob; window.closeModal = closeModal;