Merge branch 'fix/update_dir_tiradas_selected' into 'main'

Fix/update dir tiradas selected

See merge request jjimenez/safekat!454
This commit is contained in:
2024-12-26 13:17:37 +00:00
3 changed files with 22 additions and 15 deletions

View File

@ -340,8 +340,9 @@ class DatosGenerales {
</div> </div>
</div> </div>
`); `);
return false;
} }
return false; return true;
} }
return true; return true;
@ -354,8 +355,9 @@ class DatosGenerales {
</div> </div>
</div> </div>
`); `);
return false;
} }
return false;
}, },
} }
} }

View File

@ -30,6 +30,8 @@ class Direcciones {
this.direcciones = []; this.direcciones = [];
this.tiradaSeleccionada = null;
this.direcciones.calcularPresupuesto = false; this.direcciones.calcularPresupuesto = false;
this.initValidation(); this.initValidation();
@ -42,14 +44,14 @@ class Direcciones {
$("#clienteId").on('change', this.handleChangeCliente.bind(this)); $("#clienteId").on('change', this.handleChangeCliente.bind(this));
this.recogidaTaller.on('change', () => { this.recogidaTaller.on('change', () => {
if (this.recogidaTaller.is(':checked')) { if (this.recogidaTaller.is(':checked')) {
this.divDirecciones.empty(); this.divDirecciones.empty();
this.direcciones = []; this.direcciones = [];
$('.div-direcciones').addClass('d-none'); $('.div-direcciones').addClass('d-none');
} }
else{ else {
$('.div-direcciones').removeClass('d-none'); $('.div-direcciones').removeClass('d-none');
} }
}); });
@ -104,13 +106,7 @@ class Direcciones {
let id = datos[i].id; let id = datos[i].id;
let unidades = datos[i].unidades; let unidades = datos[i].unidades;
let entregaPalets = datos[i].palets; let entregaPalets = datos[i].palets;
let divId = "dirEnvio-1";
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
if (direccionesActuales.length > 0) {
// the the lass item
let last = direccionesActuales[direccionesActuales.length - 1];
divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1);
}
if (id == null || id <= 0 || id == undefined) if (id == null || id <= 0 || id == undefined)
return; return;
@ -119,6 +115,13 @@ class Direcciones {
let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {}, let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
(response) => { (response) => {
let divId = "dirEnvio-1";
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
if (direccionesActuales.length > 0) {
// the the lass item
let last = direccionesActuales[direccionesActuales.length - 1];
divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1);
}
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]); let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
tarjeta.setUnidades(unidades); tarjeta.setUnidades(unidades);
tarjeta.setEntregaPalets(entregaPalets); tarjeta.setEntregaPalets(entregaPalets);
@ -215,7 +218,7 @@ class Direcciones {
let customOption = tarjeta.card.find('.check-tirada-envio'); let customOption = tarjeta.card.find('.check-tirada-envio');
customOption.on('click', function () { customOption.on('click', function () {
self.#handleTiradaEnvio(customOption); self.#handleTiradaEnvio(customOption, self);
}); });
} }
@ -256,7 +259,7 @@ class Direcciones {
dialog.init(); dialog.init();
} }
#handleTiradaEnvio(customOption) { #handleTiradaEnvio(customOption, self) {
const el = customOption[0]; const el = customOption[0];
@ -269,6 +272,7 @@ class Direcciones {
}) })
} }
el.closest('.custom-option').classList.add('checked') el.closest('.custom-option').classList.add('checked')
self.tiradaSeleccionada = parseInt(el.getAttribute('tirada'));
} else { } else {
el.closest('.custom-option').classList.remove('checked') el.closest('.custom-option').classList.remove('checked')
} }

View File

@ -461,7 +461,7 @@ class PresupuestoCliente {
return; return;
} }
if ($('.invalid-feedback').length > 0) { if (!this.datosGenerales.checkPaginasMultiplo4()) {
popErrorAlert("Compruebe que todos los campos son correctos."); popErrorAlert("Compruebe que todos los campos son correctos.");
$('#loader').modal('hide'); $('#loader').modal('hide');
return; return;
@ -550,10 +550,11 @@ class PresupuestoCliente {
} }
} }
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2)); this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2)); this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
setTimeout(() => { setTimeout(() => {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click'); $(`#containerTiradasEnvios .tirada-envio input[tirada="${this.direcciones.tiradaSeleccionada}"]`).trigger('click');
}, 0); }, 0);
} }
$('#loader').modal('hide'); $('#loader').modal('hide');