agrega un boton para imprimir un informe en excel, debera de incluir todos los registros creados - Follow Up Deployment
Browse files- index.html +48 -1
index.html
CHANGED
|
@@ -101,7 +101,12 @@
|
|
| 101 |
|
| 102 |
<!-- Parts List -->
|
| 103 |
<div class="bg-white rounded-lg shadow-md p-6">
|
| 104 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
<div class="overflow-x-auto">
|
| 107 |
<table class="min-w-full divide-y divide-gray-200">
|
|
@@ -512,6 +517,48 @@
|
|
| 512 |
updatePartsList();
|
| 513 |
}
|
| 514 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
// Initialize the app
|
| 516 |
init();
|
| 517 |
</script>
|
|
|
|
| 101 |
|
| 102 |
<!-- Parts List -->
|
| 103 |
<div class="bg-white rounded-lg shadow-md p-6">
|
| 104 |
+
<div class="flex justify-between items-center mb-6">
|
| 105 |
+
<h2 class="text-2xl font-semibold text-gray-800">N煤meros de Parte Registrados</h2>
|
| 106 |
+
<button id="exportExcelBtn" class="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition">
|
| 107 |
+
<i class="fas fa-file-excel mr-2"></i>Exportar a Excel
|
| 108 |
+
</button>
|
| 109 |
+
</div>
|
| 110 |
|
| 111 |
<div class="overflow-x-auto">
|
| 112 |
<table class="min-w-full divide-y divide-gray-200">
|
|
|
|
| 517 |
updatePartsList();
|
| 518 |
}
|
| 519 |
|
| 520 |
+
// Export to Excel function
|
| 521 |
+
function exportToExcel() {
|
| 522 |
+
if (partsDatabase.length === 0) {
|
| 523 |
+
alert('No hay datos para exportar');
|
| 524 |
+
return;
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
// Create CSV content
|
| 528 |
+
let csvContent = "N煤mero de Parte,Tipo,Descripci贸n,Fecha de Creaci贸n,Creado por\n";
|
| 529 |
+
|
| 530 |
+
partsDatabase.forEach(part => {
|
| 531 |
+
const row = [
|
| 532 |
+
`"${part.partNumber}"`,
|
| 533 |
+
`"${part.partType}"`,
|
| 534 |
+
`"${part.description || ''}"`,
|
| 535 |
+
`"${new Date(part.createdAt).toLocaleString()}"`,
|
| 536 |
+
`"${part.createdBy}"`
|
| 537 |
+
];
|
| 538 |
+
|
| 539 |
+
// Add features to the row
|
| 540 |
+
part.features.forEach(feat => {
|
| 541 |
+
row.push(`"${feat.name}: ${feat.value}"`);
|
| 542 |
+
});
|
| 543 |
+
|
| 544 |
+
csvContent += row.join(',') + '\n';
|
| 545 |
+
});
|
| 546 |
+
|
| 547 |
+
// Create download link
|
| 548 |
+
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
| 549 |
+
const url = URL.createObjectURL(blob);
|
| 550 |
+
const link = document.createElement('a');
|
| 551 |
+
link.setAttribute('href', url);
|
| 552 |
+
link.setAttribute('download', `numeros_de_parte_${new Date().toISOString().slice(0,10)}.csv`);
|
| 553 |
+
link.style.visibility = 'hidden';
|
| 554 |
+
document.body.appendChild(link);
|
| 555 |
+
link.click();
|
| 556 |
+
document.body.removeChild(link);
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
// Add event listener for export button
|
| 560 |
+
document.getElementById('exportExcelBtn').addEventListener('click', exportToExcel);
|
| 561 |
+
|
| 562 |
// Initialize the app
|
| 563 |
init();
|
| 564 |
</script>
|