style: otimizacao de layout do relatorio para a4 retrato mais compacto e profissional
This commit is contained in:
@@ -33,37 +33,50 @@ export const RelatorioPecasProcessoPDF: React.FC<RelatorioPecasProcessoPDFProps>
|
||||
}
|
||||
|
||||
try {
|
||||
const doc = new jsPDF('l', 'mm', 'a4'); // Landscape orientation
|
||||
const doc = new jsPDF('p', 'mm', 'a4'); // Portrait orientation para otimizar espaço
|
||||
|
||||
const faseText = selectedFase === 'todas' ? '' : ` - Fase ${selectedFase}`;
|
||||
|
||||
// Título
|
||||
doc.setFontSize(20);
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text('Relatório de Status', 20, 20);
|
||||
|
||||
// Subtítulo
|
||||
doc.setFontSize(14);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text(`Ordem de Fabricação: ${selectedOF}${faseText}`, 20, 30);
|
||||
|
||||
// Data/hora
|
||||
doc.setFontSize(10);
|
||||
doc.text(`Gerado em: ${new Date().toLocaleString('pt-BR')}`, 20, 40);
|
||||
|
||||
// Resumo por Processo
|
||||
doc.setFontSize(16);
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text('Resumo por Processo', 20, 55);
|
||||
doc.text('Relatório de Status de Produção', 14, 16);
|
||||
|
||||
// Subtítulo e Data
|
||||
doc.setFontSize(10);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
let yPos = 65;
|
||||
doc.text(`Total de Peças: ${estatisticas.totalPecas}`, 20, yPos);
|
||||
doc.text(`Peso Corte: ${estatisticas.pesoTotalCorte.toFixed(2)} kg`, 80, yPos);
|
||||
doc.text(`Peso Solda: ${estatisticas.pesoTotalSolda.toFixed(2)} kg`, 140, yPos);
|
||||
doc.text(`Peso Pintura: ${estatisticas.pesoTotalPintura.toFixed(2)} kg`, 200, yPos);
|
||||
doc.text(`Peso Expedição: ${estatisticas.pesoTotalExpedicao.toFixed(2)} kg`, 260, yPos);
|
||||
doc.text(`OF: ${selectedOF}${faseText} | Gerado em: ${new Date().toLocaleString('pt-BR')}`, 14, 23);
|
||||
|
||||
// Resumo por Processo em linha mais compacta
|
||||
let yPos = 32;
|
||||
doc.setFontSize(9);
|
||||
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text(`Total Peças:`, 14, yPos);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text(`${estatisticas.totalPecas}`, 36, yPos);
|
||||
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text(`Corte:`, 50, yPos);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text(`${estatisticas.pesoTotalCorte.toFixed(0)} kg`, 62, yPos);
|
||||
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text(`Solda:`, 90, yPos);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text(`${estatisticas.pesoTotalSolda.toFixed(0)} kg`, 102, yPos);
|
||||
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text(`Pintura:`, 130, yPos);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text(`${estatisticas.pesoTotalPintura.toFixed(0)} kg`, 145, yPos);
|
||||
|
||||
doc.setFont('helvetica', 'bold');
|
||||
doc.text(`Expedição:`, 175, yPos);
|
||||
doc.setFont('helvetica', 'normal');
|
||||
doc.text(`${estatisticas.pesoTotalExpedicao.toFixed(0)} kg`, 192, yPos);
|
||||
|
||||
yPos = 38; // Ajusta yPos para o início da tabela
|
||||
|
||||
// Preparar dados para a tabela
|
||||
const tableData = pecasComStatus.map(peca => [
|
||||
@@ -88,36 +101,35 @@ export const RelatorioPecasProcessoPDF: React.FC<RelatorioPecasProcessoPDFProps>
|
||||
autoTable(doc, {
|
||||
head: headers,
|
||||
body: tableData,
|
||||
startY: yPos + 15,
|
||||
startY: yPos,
|
||||
styles: {
|
||||
fontSize: 9,
|
||||
cellPadding: 2,
|
||||
lineColor: [204, 204, 204],
|
||||
lineWidth: 0.5,
|
||||
fontSize: 8,
|
||||
cellPadding: 1.5,
|
||||
lineColor: [210, 210, 210],
|
||||
lineWidth: 0.1,
|
||||
},
|
||||
headStyles: {
|
||||
fillColor: [233, 236, 239],
|
||||
textColor: 0,
|
||||
fillColor: [240, 240, 240],
|
||||
textColor: [40, 40, 40],
|
||||
fontStyle: 'bold',
|
||||
lineColor: [204, 204, 204],
|
||||
lineWidth: 0.5,
|
||||
lineWidth: 0.1,
|
||||
},
|
||||
alternateRowStyles: {
|
||||
fillColor: [248, 249, 250],
|
||||
fillColor: [250, 250, 250],
|
||||
},
|
||||
columnStyles: {
|
||||
0: { cellWidth: 25, halign: 'center' }, // OF
|
||||
1: { cellWidth: 20, halign: 'center' }, // Fase
|
||||
2: { cellWidth: 25, halign: 'center' }, // Marca
|
||||
3: { cellWidth: 15, halign: 'center' }, // Qtd
|
||||
4: { cellWidth: 25, halign: 'right' }, // Peso Unit
|
||||
5: { cellWidth: 25, halign: 'right' }, // Peso Total
|
||||
6: { cellWidth: 20, halign: 'center' }, // Corte
|
||||
7: { cellWidth: 20, halign: 'center' }, // Solda
|
||||
8: { cellWidth: 25, halign: 'center' }, // Pint/Galv
|
||||
9: { cellWidth: 25, halign: 'center' }, // Expedição
|
||||
0: { cellWidth: 18, halign: 'center' }, // OF
|
||||
1: { cellWidth: 12, halign: 'center' }, // Fase
|
||||
2: { cellWidth: 20, halign: 'center' }, // Marca
|
||||
3: { cellWidth: 10, halign: 'center' }, // Qtd
|
||||
4: { cellWidth: 22, halign: 'right' }, // Peso Unit
|
||||
5: { cellWidth: 22, halign: 'right' }, // Peso Total
|
||||
6: { cellWidth: 16, halign: 'center' }, // Corte
|
||||
7: { cellWidth: 16, halign: 'center' }, // Solda
|
||||
8: { cellWidth: 22, halign: 'center' }, // Pint/Galv
|
||||
9: { cellWidth: 22, halign: 'center' }, // Expedição
|
||||
},
|
||||
margin: { left: 20, right: 20 },
|
||||
margin: { left: 14, right: 14, top: 20, bottom: 20 },
|
||||
tableWidth: 'auto',
|
||||
});
|
||||
|
||||
|
||||
@@ -41,15 +41,18 @@ export const RelatorioPecasProcessoPrint: React.FC<RelatorioPecasProcessoPrintPr
|
||||
printTemplate.innerHTML = `
|
||||
<style>
|
||||
@media print {
|
||||
@page { size: A4 portrait; margin: 1cm; }
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: white;
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
.a4-page {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 1.5cm;
|
||||
padding: 0;
|
||||
background: white;
|
||||
}
|
||||
table {
|
||||
@@ -58,18 +61,19 @@ export const RelatorioPecasProcessoPrint: React.FC<RelatorioPecasProcessoPrintPr
|
||||
page-break-inside: auto;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 4px 8px;
|
||||
font-size: 9pt;
|
||||
border: 1px solid #e5e7eb;
|
||||
padding: 3px 6px;
|
||||
font-size: 8pt;
|
||||
text-align: center;
|
||||
}
|
||||
th {
|
||||
background-color: #e9ecef;
|
||||
background-color: #f3f4f6;
|
||||
color: #374151;
|
||||
font-weight: 600;
|
||||
}
|
||||
.text-left { text-align: left; }
|
||||
.text-right { text-align: right; }
|
||||
.header-info, .summary-info { font-size: 10pt; }
|
||||
.header-info, .summary-info { font-size: 9pt; }
|
||||
tr { page-break-inside: avoid; }
|
||||
thead { display: table-header-group; }
|
||||
}
|
||||
@@ -81,7 +85,7 @@ export const RelatorioPecasProcessoPrint: React.FC<RelatorioPecasProcessoPrintPr
|
||||
.a4-page {
|
||||
width: 21cm;
|
||||
min-height: 29.7cm;
|
||||
padding: 1.5cm;
|
||||
padding: 1cm;
|
||||
margin: 1cm auto;
|
||||
background: white;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
@@ -91,44 +95,43 @@ export const RelatorioPecasProcessoPrint: React.FC<RelatorioPecasProcessoPrintPr
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 4px 8px;
|
||||
font-size: 9pt;
|
||||
border: 1px solid #e5e7eb;
|
||||
padding: 3px 6px;
|
||||
font-size: 8pt;
|
||||
text-align: center;
|
||||
}
|
||||
th {
|
||||
background-color: #e9ecef;
|
||||
background-color: #f3f4f6;
|
||||
color: #374151;
|
||||
font-weight: 600;
|
||||
}
|
||||
.text-left { text-align: left; }
|
||||
.text-right { text-align: right; }
|
||||
.header-info, .summary-info { font-size: 10pt; }
|
||||
.header-info, .summary-info { font-size: 9pt; }
|
||||
</style>
|
||||
|
||||
<div class="a4-page">
|
||||
<!-- Cabeçalho -->
|
||||
<header style="margin-bottom: 16px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid #ccc; padding-bottom: 8px;">
|
||||
<header style="margin-bottom: 12px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid #ccc; padding-bottom: 4px;">
|
||||
<div>
|
||||
<h1 style="font-size: 20px; font-weight: bold; color: #1f2937; margin: 0 0 4px 0;">Relatório de Status</h1>
|
||||
<p style="font-size: 14px; color: #6b7280; margin: 0;" class="header-info">Ordem de Fabricação: <span style="font-weight: 600;">${selectedOF}${faseText}</span></p>
|
||||
<h1 style="font-size: 18px; font-weight: bold; color: #1f2937; margin: 0 0 2px 0;">Relatório de Status de Produção</h1>
|
||||
<p style="font-size: 12px; color: #6b7280; margin: 0;" class="header-info">OF: <span style="font-weight: 600;">${selectedOF}${faseText}</span></p>
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
<p style="font-size: 14px; color: #6b7280; margin: 0;" class="header-info">Gerado em:</p>
|
||||
<p style="font-size: 14px; color: #9ca3af; margin: 0;" class="header-info">${currentDate}</p>
|
||||
<p style="font-size: 11px; color: #9ca3af; margin: 0;" class="header-info">Gerado em: ${currentDate}</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Resumo -->
|
||||
<section style="margin-bottom: 16px;">
|
||||
<h2 style="font-size: 16px; font-weight: 600; margin-bottom: 8px; color: #374151;">Resumo por Processo</h2>
|
||||
<div style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; font-size: 12px; color: #6b7280; padding: 8px; border: 1px solid #e5e7eb; border-radius: 8px; background-color: #f9fafb;" class="summary-info">
|
||||
<div><strong>Total de Peças:</strong> <span style="font-family: monospace;">${estatisticas.totalPecas}</span></div>
|
||||
<div><strong>Peso Corte:</strong> <span style="font-family: monospace;">${estatisticas.pesoTotalCorte.toFixed(2)} kg</span></div>
|
||||
<div><strong>Peso Solda:</strong> <span style="font-family: monospace;">${estatisticas.pesoTotalSolda.toFixed(2)} kg</span></div>
|
||||
<div><strong>Peso Pintura:</strong> <span style="font-family: monospace;">${estatisticas.pesoTotalPintura.toFixed(2)} kg</span></div>
|
||||
<div><strong>Peso Expedição:</strong> <span style="font-family: monospace;">${estatisticas.pesoTotalExpedicao.toFixed(2)} kg</span></div>
|
||||
<section style="margin-bottom: 12px;">
|
||||
<div style="display: flex; flex-wrap: wrap; justify-content: space-between; font-size: 11px; color: #4b5563; padding: 6px 12px; border: 1px solid #e5e7eb; border-radius: 6px; background-color: #f9fafb;" class="summary-info">
|
||||
<div><strong>Total Peças:</strong> ${estatisticas.totalPecas}</div>
|
||||
<div><strong>Corte:</strong> ${estatisticas.pesoTotalCorte.toFixed(0)} kg</div>
|
||||
<div><strong>Solda:</strong> ${estatisticas.pesoTotalSolda.toFixed(0)} kg</div>
|
||||
<div><strong>Pintura:</strong> ${estatisticas.pesoTotalPintura.toFixed(0)} kg</div>
|
||||
<div><strong>Expedição:</strong> ${estatisticas.pesoTotalExpedicao.toFixed(0)} kg</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user