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>
|
||||||
|
|
||||||
<div class="col-md-4 mb-3 d-flex align-items-end">
|
<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' ?>
|
<i class="fas fa-file-import me-2"></i> <?= lang('Importador.importar') ?? 'Importar' ?>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -2,6 +2,8 @@ import Ajax from '../../../components/ajax.js';
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
|
document.getElementById('importBtn').disabled = true;
|
||||||
|
|
||||||
const TABLE_COLUMNS = ["input", "idlinea", "descripcion", "cnt_pedida", "precio_compra"];
|
const TABLE_COLUMNS = ["input", "idlinea", "descripcion", "cnt_pedida", "precio_compra"];
|
||||||
let dataTable;
|
let dataTable;
|
||||||
|
|
||||||
@ -35,6 +37,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const file = e.target.files[0];
|
const file = e.target.files[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
|
// Deshabilitar botón importar al comenzar nuevo procesamiento
|
||||||
|
document.getElementById('importBtn').disabled = true;
|
||||||
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
const data = new Uint8Array(e.target.result);
|
const data = new Uint8Array(e.target.result);
|
||||||
@ -51,6 +56,18 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
async function validateAndLoadDataTable(data) {
|
async function validateAndLoadDataTable(data) {
|
||||||
if (data.length === 0) return;
|
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 headers = data[0].map(h => h.toString().trim());
|
||||||
const headerMap = {};
|
const headerMap = {};
|
||||||
headers.forEach((name, idx) => {
|
headers.forEach((name, idx) => {
|
||||||
@ -60,6 +77,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const requiredColumns = ["idpedido", ...TABLE_COLUMNS];
|
const requiredColumns = ["idpedido", ...TABLE_COLUMNS];
|
||||||
const missing = requiredColumns.filter(col => !(col in headerMap));
|
const missing = requiredColumns.filter(col => !(col in headerMap));
|
||||||
if (missing.length > 0) {
|
if (missing.length > 0) {
|
||||||
|
Swal.close(); // Cierra el loader
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
text: 'Faltan las siguientes columnas: ' + missing.join(', '),
|
text: 'Faltan las siguientes columnas: ' + missing.join(', '),
|
||||||
@ -127,6 +145,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
dataTable.clear().rows.add(rows).draw();
|
dataTable.clear().rows.add(rows).draw();
|
||||||
|
|
||||||
setupEventListeners();
|
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) {
|
async function validarFila(rowData) {
|
||||||
@ -176,7 +200,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const skId = result.data?.sk_id ?? '';
|
const skId = result.data?.sk_id ?? '';
|
||||||
|
|
||||||
// Actualizar campo "Notas" con el enlace
|
// Actualizar campo "Notas" con el enlace
|
||||||
if (skUrl) {
|
if (skUrl) {
|
||||||
const notasHtml = `<a href="${skUrl}" target="_blank" class="btn btn-sm btn-secondary">Ver presupuesto (${skId})</a>`;
|
const notasHtml = `<a href="${skUrl}" target="_blank" class="btn btn-sm btn-secondary">Ver presupuesto (${skId})</a>`;
|
||||||
// La columna de notas es la posición 6 (índice 6)
|
// La columna de notas es la posición 6 (índice 6)
|
||||||
rowData[6] = notasHtml;
|
rowData[6] = notasHtml;
|
||||||
|
|||||||
Reference in New Issue
Block a user