trabajando en la lista de envios proximos

This commit is contained in:
2025-05-15 23:55:09 +02:00
parent cfdc8d64e1
commit decdcf3703
10 changed files with 453 additions and 213 deletions

View File

@ -14,6 +14,7 @@ class MaquinistaTareaView {
this.tareaCardClass = '.tarea-card-action-block'
this.inputClick = $('.ot-tarea-click')
this.btnPrintLabels = this.item.find('#btn-print-labels')
this.btnFicharEmbalaje = this.item.find('#btn-fichar-embalaje')
}
init() {
this.actionButtons.on('click', this.eventActionButton.bind(this))
@ -22,6 +23,7 @@ class MaquinistaTareaView {
this.handleGetTareaProgress();
this.inputClick.on('input', this.handleUpdateClickInput.bind(this))
this.btnPrintLabels.on('click', this.handlePrintLabels.bind(this))
this.btnFicharEmbalaje.on('click', this.handleFicharEmbalaje.bind(this))
}
eventActionButton(event) {
@ -301,6 +303,51 @@ class MaquinistaTareaView {
});
}
handleFicharEmbalaje() {
const ot_id = [$('#otId').html()];
$.post('/logistica/ficharEmbalaje', {
ids: ot_id,
}, function (response) {
if (response.status) {
Swal.fire({
text: response.message,
icon: 'success',
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
} else {
Swal.fire({
title: 'Error',
text: response.message,
icon: 'error',
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
table.ajax.reload();
}
}).fail(() => {
Swal.fire({
title: 'Error',
text: 'No se pudo realizar el fichaje.',
icon: 'error',
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
table.ajax.reload();
});
}
}
export default MaquinistaTareaView;

View File

@ -7,6 +7,7 @@ class EnvioEdit {
constructor() {
this.tableCols = [
{ data: "rowSelected" },
{ data: "ordenTrabajo" },
{ data: "pedido" },
{ data: "presupuesto" },
{ data: "titulo" },
@ -42,6 +43,12 @@ class EnvioEdit {
this.proveedor.init();
}
if ($("#proximosEnvios").length) {
new PerfectScrollbar(document.getElementById('proximosEnvios'), {
wheelPropagation: false
});
}
this.table = $('#tableLineasEnvio').DataTable({
processing: true,
serverSide: true,
@ -84,11 +91,11 @@ class EnvioEdit {
"searchable": false,
},
{
"targets": [1, 2, 4, 5, 6],
"targets": [1, 2, 4, 5, 6, 7],
"className": "text-center",
},
{
targets: [7, 8, 9],
targets: [8, 9, 10],
visible: false
}
]
@ -121,7 +128,7 @@ class EnvioEdit {
}
const idEnvio = $('#id').val();
let num_cajas = this.cajas.val();
if(ids.length != table.rows().count()){
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!',
@ -146,7 +153,7 @@ class EnvioEdit {
}
});
}
else{
else {
this._imprimirEtiquetas(idEnvio, ids, num_cajas);
}
});
@ -485,9 +492,14 @@ class EnvioEdit {
});
});
$('#ficharEmbalaje').on('click', (e) => {
this._ficharEmbalajeLineas();
});
this._getAlbaranes();
}
_imprimirEtiquetas(envio_id, ids, num_cajas) {
$.post('/logistica/imprimirEtiquetas', {
@ -510,7 +522,7 @@ class EnvioEdit {
},
buttonsStyling: false
}).then(() => {
if(response.data){
if (response.data) {
// show xml in a new tab
const blob = new Blob([response.data], { type: 'application/xml' });
const url = URL.createObjectURL(blob);
@ -520,7 +532,7 @@ class EnvioEdit {
a.click();
URL.revokeObjectURL(url);
a.remove();
}
});
}
@ -671,6 +683,95 @@ class EnvioEdit {
});
}
_ficharEmbalajeLineas() {
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();
const parser = new DOMParser();
const doc = parser.parseFromString(rowData.ordenTrabajo, 'text/html');
return doc.body.textContent.trim(); // extrae solo el texto dentro del <a>
}).toArray();
if (ids.length > 0) {
Swal.fire({
title: 'Fichar embalaje',
text: '¿Está seguro de fichar el embalaje de las líneas seleccionadas?',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Sí',
cancelButtonText: 'Cancelar',
customClass: {
confirmButton: 'btn btn-danger me-1',
cancelButton: 'btn btn-secondary'
},
buttonsStyling: false
}).then((result) => {
if (result.isConfirmed) {
$.post('/logistica/ficharEmbalaje', {
ids: ids
}, function (response) {
if (response.status) {
Swal.fire({
text: response.message,
icon: 'success',
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
} else {
Swal.fire({
title: 'Error',
text: response.message,
icon: 'error',
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
table.ajax.reload();
}
}).fail(() => {
Swal.fire({
title: 'Error',
text: 'No se pudo realizar el fichaje.',
icon: 'error',
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
table.ajax.reload();
});
}
});
} else {
Swal.fire({
title: 'Sin filas seleccionadas',
text: 'Marca al menos una línea para eliminarla.',
icon: 'info',
confirmButtonColor: '#3085d6',
confirmButtonText: 'Ok',
customClass: {
confirmButton: 'btn btn-primary me-1',
},
buttonsStyling: false
});
}
}
_deleteLineas() {
const table = this.table;
const selectedRows = table.rows({ page: 'current' }).nodes().filter((node) => {