mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into fix/importador_bubok
This commit is contained in:
@ -11,19 +11,18 @@ class OrdenTrabajoDatatable {
|
||||
this.datatableWaiting = this.item.find("#ot-datatable-waiting")
|
||||
this.datatableRevisionComerical = this.item.find("#ot-datatable-revision-com")
|
||||
|
||||
|
||||
this.columnIdIndex = 1;
|
||||
|
||||
this.tableLayout = "lrtip"
|
||||
this.datatableColumns = [
|
||||
{ data: 'pdf_check', searchable: false, sortable: false, render: d => `<input class="form-check-input pdf-check" data-id="${d}" type="checkbox">` },
|
||||
{ data: 'id', searchable: true, sortable: true },
|
||||
{ data: 'id', searchable: true, sortable: true},
|
||||
{ data: 'pedido_id', searchable: true, sortable: true },
|
||||
{ data: 'fecha_encuadernado_at',name:"pedidos.fecha_encuadernado", searchable: true, sortable: true },
|
||||
{ data: 'cliente_nombre', name:"clientes.nombre", searchable: true, sortable: false },
|
||||
{ data: 'presupuesto_titulo', name:"presupuestos.titulo", searchable: true, sortable: true },
|
||||
{ data: 'ubicacion_nombre', name:"ubicaciones.nombre", searchable: true, sortable: true },
|
||||
{ data: 'total_tirada', name:"pedidos.total_tirada",searchable: true, sortable: true, render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'tipo_presupuesto_impresion', name:"tipos_presupuestos.codigo", searchable: true, sortable: true },
|
||||
{ data: 'fecha_encuadernado_at', name: "pedidos.fecha_encuadernado", searchable: true, sortable: true },
|
||||
{ data: 'cliente_nombre', name: "clientes.nombre", searchable: true, sortable: false },
|
||||
{ data: 'presupuesto_titulo', name: "presupuestos.titulo", searchable: true, sortable: true },
|
||||
{ data: 'ubicacion_nombre', name: "ubicaciones.nombre", searchable: true, sortable: true },
|
||||
{ data: 'total_tirada', name: "pedidos.total_tirada", searchable: true, sortable: true, render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'tipo_presupuesto_impresion', name: "tipos_presupuestos.codigo", searchable: true, sortable: true },
|
||||
{
|
||||
data: 'logo', searchable: false, sortable: false, render: (d, t) => {
|
||||
return `<div class="logo-container">
|
||||
@ -33,7 +32,7 @@ class OrdenTrabajoDatatable {
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'progreso',name:"ordenes_trabajo.progreso", searchable: false, sortable: true, render: (d, t) => {
|
||||
data: 'progreso', name: "ordenes_trabajo.progreso", searchable: false, sortable: true, render: (d, t) => {
|
||||
return `<div class="progress border rounded-2" style="height: 1rem;">
|
||||
<div id="ot-progress-bar" class="progress-bar" role="progressbar" style="width: ${parseInt(d)}%;" aria-valuenow="${d}" aria-valuemin="0" aria-valuemax="100">${d}%</div>
|
||||
</div>
|
||||
@ -57,7 +56,7 @@ class OrdenTrabajoDatatable {
|
||||
console.log(order)
|
||||
this.focusDatatable = this.datatableOrder[order]
|
||||
}
|
||||
events(){
|
||||
events() {
|
||||
this.datatableOrder = [
|
||||
this.datatableN,
|
||||
this.datatableP,
|
||||
@ -74,12 +73,8 @@ class OrdenTrabajoDatatable {
|
||||
init() {
|
||||
this.datatable = this.datatableItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
columnDefs: [
|
||||
{ className: 'dt-center', targets: '_all' },
|
||||
@ -97,16 +92,17 @@ class OrdenTrabajoDatatable {
|
||||
$(row).css("border-right", `10px solid ${data.logo.color}`)
|
||||
}
|
||||
});
|
||||
this.datatableItem.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatable.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatable.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
initPendientes() {
|
||||
this.datatableP = this.datatablePendientesItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
columnDefs: [
|
||||
{ className: 'dt-center', targets: '_all' },
|
||||
@ -125,16 +121,17 @@ class OrdenTrabajoDatatable {
|
||||
|
||||
}
|
||||
});
|
||||
this.datatablePendientesItem.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatableP.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableP.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
initFerroPendiente() {
|
||||
this.datatableFP = this.datatableFerroPendienteItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
serverSide: true,
|
||||
pageLength: 25,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
@ -152,16 +149,17 @@ class OrdenTrabajoDatatable {
|
||||
$(row).css("border-right", `20px solid ${data.logo.color}`)
|
||||
}
|
||||
});
|
||||
this.datatableFerroPendienteItem.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatableFP.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableFP.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
initFerroOk() {
|
||||
this.datatableFO = this.datatableFerroOkItem.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
serverSide: true,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
columnDefs: [
|
||||
@ -179,16 +177,17 @@ class OrdenTrabajoDatatable {
|
||||
$(row).css("border-right", `20px solid ${data.logo.color}`)
|
||||
}
|
||||
});
|
||||
this.datatableFerroOkItem.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatableFO.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableFO.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
initNews() {
|
||||
this.datatableN = this.datatableNews.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
serverSide: true,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
columnDefs: [
|
||||
@ -207,17 +206,17 @@ class OrdenTrabajoDatatable {
|
||||
}
|
||||
});
|
||||
this.focusDatatable = this.datatableN
|
||||
|
||||
this.datatableNews.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatableN.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableN.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
initWaiting() {
|
||||
this.datatableW = this.datatableWaiting.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
serverSide: true,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
columnDefs: [
|
||||
@ -235,16 +234,17 @@ class OrdenTrabajoDatatable {
|
||||
$(row).css("border-right", `20px solid ${data.logo.color}`)
|
||||
}
|
||||
});
|
||||
this.datatableWaiting.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatableW.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableW.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
initProd() {
|
||||
this.datatableProduccion = this.datatableProd.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
serverSide: true,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
columnDefs: [
|
||||
@ -262,16 +262,17 @@ class OrdenTrabajoDatatable {
|
||||
$(row).css("border-right", `20px solid ${data.logo.color}`)
|
||||
}
|
||||
});
|
||||
this.datatableProd.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatableProduccion.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableProduccion.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
initRevisionComercial() {
|
||||
this.datatableRC = this.datatableRevisionComerical.DataTable({
|
||||
processing: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
dom: this.tableLayout,
|
||||
orderCellsTop: true,
|
||||
serverSide: true,
|
||||
order: [[this.columnIdIndex, 'desc']],
|
||||
columnDefs: [
|
||||
@ -289,6 +290,11 @@ class OrdenTrabajoDatatable {
|
||||
$(row).css("border-right", `20px solid ${data.logo.color}`)
|
||||
}
|
||||
});
|
||||
this.datatableRevisionComerical.on("change", ".ot-filter", (event) => {
|
||||
console.log(this.datatableRC.column($(event.currentTarget).attr("name")))
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatableRC.column(columnIndex).search($(event.currentTarget).val()).draw()
|
||||
})
|
||||
}
|
||||
getSelectIDs() {
|
||||
return this.focusDatatable.rows((idx, data, node) => {
|
||||
|
||||
@ -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) {
|
||||
@ -176,7 +200,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const skId = result.data?.sk_id ?? '';
|
||||
|
||||
// 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>`;
|
||||
// La columna de notas es la posición 6 (índice 6)
|
||||
rowData[6] = notasHtml;
|
||||
|
||||
Reference in New Issue
Block a user