mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Implementados cambios del loader
This commit is contained in:
@ -28,7 +28,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 mb-3 d-flex align-items-end">
|
||||
<button type="button" id="importBtn" class="btn btn-success w-100">
|
||||
<button type="button" id="importBtn" class="btn btn-success w-100" disabled>
|
||||
<i class="fas fa-file-import me-2"></i> <?= lang('Importador.importar') ?? 'Importar' ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -2,6 +2,8 @@ import Ajax from '../../../components/ajax.js';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
document.getElementById('importBtn').disabled = true;
|
||||
|
||||
const TABLE_COLUMNS = ["input", "idlinea", "descripcion", "cnt_pedida", "precio_compra"];
|
||||
let dataTable;
|
||||
|
||||
@ -35,6 +37,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const file = e.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
// Deshabilitar botón importar al comenzar nuevo procesamiento
|
||||
document.getElementById('importBtn').disabled = true;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
const data = new Uint8Array(e.target.result);
|
||||
@ -51,6 +56,18 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
async function validateAndLoadDataTable(data) {
|
||||
if (data.length === 0) return;
|
||||
|
||||
// Mostrar loader (ajústalo según tu HTML)
|
||||
Swal.fire({
|
||||
title: 'Procesando...',
|
||||
text: 'Cargando datos del Excel...',
|
||||
allowOutsideClick: false,
|
||||
showDenyButton: false,
|
||||
cancelButtonText: 'Cancelar',
|
||||
didOpen: () => {
|
||||
Swal.showLoading();
|
||||
}
|
||||
});
|
||||
|
||||
const headers = data[0].map(h => h.toString().trim());
|
||||
const headerMap = {};
|
||||
headers.forEach((name, idx) => {
|
||||
@ -60,6 +77,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const requiredColumns = ["idpedido", ...TABLE_COLUMNS];
|
||||
const missing = requiredColumns.filter(col => !(col in headerMap));
|
||||
if (missing.length > 0) {
|
||||
Swal.close(); // Cierra el loader
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'Faltan las siguientes columnas: ' + missing.join(', '),
|
||||
@ -127,6 +145,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
dataTable.clear().rows.add(rows).draw();
|
||||
|
||||
setupEventListeners();
|
||||
|
||||
Swal.close(); // Ocultar loader
|
||||
|
||||
// Habilitar botón importar si hay filas válidas
|
||||
const tieneFilas = rows.length > 0;
|
||||
document.getElementById('importBtn').disabled = !tieneFilas;
|
||||
}
|
||||
|
||||
async function validarFila(rowData) {
|
||||
|
||||
Reference in New Issue
Block a user