Merge branch 'main' into feat/ordenes-trabajo

This commit is contained in:
amazuecos
2025-01-02 17:19:52 +01:00
13 changed files with 216 additions and 92 deletions

View File

@ -74,6 +74,8 @@ class DatosGenerales {
this.rl_retractilado = $("#rl_retractilado");
this.rl_retractilado5 = $("#rl_retractilado5");
this.cargando = false;
this.initValidation();
}
@ -340,8 +342,9 @@ class DatosGenerales {
</div>
</div>
`);
return false;
}
return false;
return true;
}
return true;
@ -354,8 +357,9 @@ class DatosGenerales {
</div>
</div>
`);
return false;
}
return false;
},
}
}
@ -532,6 +536,8 @@ class DatosGenerales {
cargarDatos(datos) {
this.cargando = true;
this.titulo.val(datos.titulo);
this.autor.val(datos.autor);
this.isbn.val(datos.isbn);
@ -598,6 +604,8 @@ class DatosGenerales {
this.retractilado5.prop('checked', datos.retractilado5);
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
this.cargando = false;
}
getCliente() {
@ -734,8 +742,6 @@ class DatosGenerales {
this.checkPaginasMultiplo4();
// Para recalcular el presupuesto
$('#divGramajeInterior').empty();
$('#divGramajeInteriorColor').empty();
element.trigger('change');
}
@ -780,6 +786,7 @@ class DatosGenerales {
this.formValidation.revalidateField('paginas');
// Se configura dependiento si hay color o no
const lastLayoutColor = $('#negroEstandar').hasClass('d-none');
if (paginasColor == 0) {
this.#handleInteriorLayout('negro');
@ -787,6 +794,13 @@ class DatosGenerales {
this.divPosPaginasColor.addClass('d-none');
this.posPaginasColor.val("");
this.pagColorConsecutivas.prop('checked', false);
if(lastLayoutColor && !this.cargando){
$('#divPapelInterior').empty();
$('#divGramajeInterior').empty();
$('#negroEstandar').trigger('click');
}
}
else {
if (this.papelDiferente.is(":checked"))
@ -795,8 +809,17 @@ class DatosGenerales {
this.#handleInteriorLayout('color');
this.divPaginasColorConsecutivas.removeClass('d-none');
this.divPosPaginasColor.removeClass('d-none');
if(!lastLayoutColor && !this.cargando){
$('#divPapelInterior').empty();
$('#divGramajeInterior').empty();
$('#colorEstandar').trigger('click');
}
}
$('.calcular-lomo').trigger('change');
this.checkPaginasMultiplo4();
}

View File

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

View File

@ -105,8 +105,6 @@ class DisenioInterior {
}
updatePapeles(papeles = null) {
const context = this;
@ -1034,6 +1032,7 @@ class DisenioInterior {
const gramaje = element[0].id;
this.presupuestoCliente.calcularSolapas(event);
this.presupuestoCliente.checkLomoInterior(event);
this.presupuestoCliente.checkForm(event);
});

View File

@ -113,6 +113,7 @@ class PresupuestoCliente {
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
$(".calcular-solapas").on('change', this.calcularSolapas.bind(this));
$(".calcular-lomo").on('change', this.checkLomoInterior.bind(this));
}
@ -180,6 +181,31 @@ class PresupuestoCliente {
}
}
checkLomoInterior() {
/* Limites lomo */
this.#getDatos(false, true);
if (Object.values(this.datos).every(this.#isValidDataForm)) {
new Ajax('/presupuestocliente/checklomo',
this.datos,
{},
(response) => {
if (response === null || response === undefined || response === "") {
console.log("Error en el calculo del lomo interior.");
return;
}
if(response.errors.status == 1){
popErrorAlert('' + response.errors.value, "sk-alert", false);
}
else{
popAlert2Hide('sk-alert');
}
},
() => { }
).post();
}
}
checkForm(event) {
this.#processResumenLateral();
@ -461,7 +487,7 @@ class PresupuestoCliente {
return;
}
if ($('.invalid-feedback').length > 0) {
if (!this.datosGenerales.checkPaginasMultiplo4()) {
popErrorAlert("Compruebe que todos los campos son correctos.");
$('#loader').modal('hide');
return;
@ -526,9 +552,6 @@ class PresupuestoCliente {
}
}
popAlert2Hide();
if (response.tiradas && response.tiradas.length) {
let tiradas = { ...response.tiradas };
@ -536,6 +559,8 @@ class PresupuestoCliente {
tiradas.sort((a, b) => a - b);
this.divTiradasPrecios.empty();
popAlert2Hide();
for (let i = 0; i < tiradas.length; i++) {
new tarjetaTiradasPrecio(
this.divTiradasPrecios,
@ -550,10 +575,11 @@ class PresupuestoCliente {
}
}
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
setTimeout(() => {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
$(`#containerTiradasEnvios .tirada-envio input[tirada="${this.direcciones.tiradaSeleccionada}"]`).trigger('click');
}, 0);
}
$('#loader').modal('hide');