mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'add/print_labels_maquinista' into 'main'
terminado See merge request jjimenez/safekat!775
This commit is contained in:
@ -13,6 +13,7 @@ class MaquinistaTareaView {
|
||||
this.actionButtons = this.item.find('.action-btn')
|
||||
this.tareaCardClass = '.tarea-card-action-block'
|
||||
this.inputClick = $('.ot-tarea-click')
|
||||
this.btnPrintLabels = this.item.find('#btn-print-labels')
|
||||
}
|
||||
init() {
|
||||
this.actionButtons.on('click', this.eventActionButton.bind(this))
|
||||
@ -20,6 +21,7 @@ class MaquinistaTareaView {
|
||||
this.btnDeleteProgress.on('click', this.handleDeleteTareaProgress.bind(this))
|
||||
this.handleGetTareaProgress();
|
||||
this.inputClick.on('input', this.handleUpdateClickInput.bind(this))
|
||||
this.btnPrintLabels.on('click', this.handlePrintLabels.bind(this))
|
||||
}
|
||||
|
||||
eventActionButton(event) {
|
||||
@ -53,8 +55,8 @@ class MaquinistaTareaView {
|
||||
}
|
||||
disableButtons() {
|
||||
this.actionButtons.attr('disabled', 'disabled')
|
||||
this.btnDelay.attr('disabled','disabled')
|
||||
this.btnDeleteProgress.attr('disabled','disabled')
|
||||
this.btnDelay.attr('disabled', 'disabled')
|
||||
this.btnDeleteProgress.attr('disabled', 'disabled')
|
||||
}
|
||||
enableButtons() {
|
||||
this.actionButtons.removeAttr('disabled')
|
||||
@ -127,7 +129,7 @@ class MaquinistaTareaView {
|
||||
let lastStatus = response.progress_dates.findLast(e => e.estado != null).estado
|
||||
console.log("Last status :", lastStatus)
|
||||
this.showBasedOnStatus(lastStatus)
|
||||
}else{
|
||||
} else {
|
||||
this.showBasedOnStatus('P')
|
||||
}
|
||||
this.item.find('#tiempo-real-info').html(response.tiempo_trabajado ?? "00:00")
|
||||
@ -148,14 +150,14 @@ class MaquinistaTareaView {
|
||||
this.handleUpdateTareaProgressError.bind(this),
|
||||
)
|
||||
if (this.tareaId) {
|
||||
if(status == "F"){
|
||||
if (status == "F") {
|
||||
alertConfirmAction('La tarea se marcará como finalizada')
|
||||
.then(result => {
|
||||
if (result.isConfirmed) {
|
||||
ajax.post();
|
||||
}
|
||||
})
|
||||
}else{
|
||||
.then(result => {
|
||||
if (result.isConfirmed) {
|
||||
ajax.post();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ajax.post();
|
||||
}
|
||||
}
|
||||
@ -224,6 +226,80 @@ class MaquinistaTareaView {
|
||||
})
|
||||
}
|
||||
|
||||
handlePrintLabels() {
|
||||
|
||||
const impresoras = JSON.parse($('#impresoras').val());
|
||||
|
||||
let options = '';
|
||||
impresoras.forEach(p => {
|
||||
options += `<option value="${p.id}">${p.name}</option>`;
|
||||
});
|
||||
|
||||
Swal.fire({
|
||||
title: 'Imprimir etiquetas',
|
||||
html: `
|
||||
<div class="mb-3 text-start">
|
||||
<label for="swal-impresora" class="form-label">Impresora</label>
|
||||
<select id="swal-impresora" class="form-control">
|
||||
${options}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3 text-start">
|
||||
<label for="swal-unidades" class="form-label">Unidades por caja</label>
|
||||
<input type="number" id="swal-unidades" class="form-control" min="1" value="${$("#tirada-info").html()}" />
|
||||
</div>
|
||||
`,
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Aceptar',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
cancelButton: 'btn btn-secondary'
|
||||
},
|
||||
buttonsStyling: false,
|
||||
preConfirm: () => {
|
||||
const impresora = $('#swal-impresora').val();
|
||||
const unidades = parseInt($('#swal-unidades').val(), 10);
|
||||
|
||||
if (!impresora || isNaN(unidades) || unidades <= 0) {
|
||||
Swal.showValidationMessage('Debe seleccionar una impresora y un número válido de unidades.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return { impresora, unidades };
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
$.post('/produccion/ordentrabajo/maquinista/maquinas/tareas/printLabels', {
|
||||
impresora_id: result.value.impresora,
|
||||
unidades_caja: result.value.unidades,
|
||||
ot_id: $('#otId').html(),
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
popSuccessAlert(response.message);
|
||||
if(response.data) {
|
||||
// show xml in new tab
|
||||
const blob = new Blob([response.data], { type: 'application/xml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const newTab = window.open(url, '_blank');
|
||||
if (newTab) {
|
||||
newTab.onload = function () {
|
||||
// Revoke the object URL after the new tab has loaded
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
} else {
|
||||
popErrorAlert('Error abriendo la pestaña');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
popErrorAlert(response.error)
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user