mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
cambios
This commit is contained in:
@ -92,6 +92,63 @@ class EnvioEdit {
|
||||
]
|
||||
});
|
||||
|
||||
$('#btnImprimirEtiquetas').on('click', () => {
|
||||
const table = this.table;
|
||||
const selectedRows = table.rows({ page: 'current' }).nodes().filter((node) => {
|
||||
const checkbox = $(node).find('.checkbox-linea-envio');
|
||||
return checkbox.is(':checked');
|
||||
}
|
||||
);
|
||||
const ids = selectedRows.map((node) => {
|
||||
const rowData = table.row(node).data();
|
||||
return rowData.id;
|
||||
}).toArray();
|
||||
if (ids.length <= 0) {
|
||||
Swal.fire({
|
||||
title: 'Atención!',
|
||||
text: 'Debe seleccionar al menos una línea de envío para imprimir etiquetas.',
|
||||
icon: 'info',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
const idEnvio = $('#id').val();
|
||||
let num_cajas = this.cajas.val();
|
||||
if(ids.length != table.rows().count()){
|
||||
// se preguntará el numero de cajas en un swal con un input para obtener el valor
|
||||
Swal.fire({
|
||||
title: 'Atención!',
|
||||
text: 'No se ha seleccionado todas las líneas de envío. Ingrese el número de cajas a imprimir.',
|
||||
icon: 'info',
|
||||
input: 'text',
|
||||
inputLabel: 'Número de cajas',
|
||||
inputValue: num_cajas,
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Imprimir etiquetas',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
cancelButton: 'btn btn-secondary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
num_cajas = result.value;
|
||||
this._imprimirEtiquetas(idEnvio, ids, num_cajas);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
this._imprimirEtiquetas(idEnvio, ids, num_cajas);
|
||||
}
|
||||
});
|
||||
|
||||
this.cajas.on('change', (e) => {
|
||||
const value = $(e.currentTarget).val();
|
||||
if (value < 0) {
|
||||
@ -429,6 +486,58 @@ class EnvioEdit {
|
||||
this._getAlbaranes();
|
||||
}
|
||||
|
||||
_imprimirEtiquetas(envio_id, ids, num_cajas) {
|
||||
|
||||
$.post('/logistica/imprimirEtiquetas', {
|
||||
|
||||
envio_id: envio_id,
|
||||
envio_lineas: ids,
|
||||
cajas: num_cajas
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
Swal.fire({
|
||||
title: 'Etiquetas generadas',
|
||||
text: 'Las etiquetas se han generado correctamente.',
|
||||
icon: 'success',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then(() => {
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
}
|
||||
).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo generar las etiquetas.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_checkDatosFinalizar() {
|
||||
|
||||
if (this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user