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