añadido calculo dinamico de ancho maximo de solapas. Añadido servicio especial para solapas grandes. Corregidos algunos bugs

This commit is contained in:
2024-11-29 11:25:38 +01:00
parent 524eb68b1c
commit b314e4a1de
12 changed files with 258 additions and 69 deletions

View File

@ -11,7 +11,7 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
class PresupuestoCliente {
constructor() {
this.clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
this.validationStepper = new Stepper(this.clientePresupuestoWizard, {
@ -110,6 +110,7 @@ class PresupuestoCliente {
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
$(".calcular-solapas").on('change', this.calcularSolapas.bind(this));
}
@ -154,6 +155,28 @@ class PresupuestoCliente {
return !(noPOD && siPOD);
}
calcularSolapas(){
/* Solapas Max */
this.#getDatos(false, true);
if (Object.values(this.datos).every(this.#isValidDataForm)) {
new Ajax('/presupuestocliente/calcularsolapas',
this.datos,
{},
(response) => {
if (response === null || response === undefined || response === "") {
console.log("Error en el calculo máximo de solapas.");
return;
}
this.disenioCubierta.tamanioSolapasCubierta.attr('max', response);
this.disenioCubierta.solapasSobrecubierta.attr('max', response);
this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm");
this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm");
},
() => { }
).post();
}
}
checkForm(event) {
@ -163,6 +186,7 @@ class PresupuestoCliente {
return;
}
if (this.calcularPresupuesto) {
if (event.target.id === 'divDirecciones') {
@ -580,7 +604,7 @@ class PresupuestoCliente {
}
#getDatos(save = false) {
#getDatos(save = false, calcularSolapas = false) {
this.datos = {
@ -590,20 +614,12 @@ class PresupuestoCliente {
tirada: this.datosGenerales.getTiradas(),
paginas: this.datosGenerales.paginas.val(),
paginasColor: this.datosGenerales.paginasColor.val(),
posPaginasColor: this.datosGenerales.posPaginasColor.val(),
pagColorConsecutivas: this.datosGenerales.pagColorConsecutivas.is(':checked') ? 1 : 0,
papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked') ? 1 : 0,
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
ferro: this.datosGenerales.ferro.is(':checked') ? 1 : 0,
ferroDigital: this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
marcapaginas: this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
retractilado: this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
retractilado5: this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
isColor: this.datosGenerales.getIsColor() ? 1 : 0,
isHq: this.disenioInterior.getIsHq() ? 1 : 0,
@ -612,31 +628,46 @@ class PresupuestoCliente {
gramajeInterior: this.disenioInterior.getGramaje(),
},
}
cubierta: {
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
papelCubierta: this.disenioCubierta.getPapel(),
gramajeCubierta: this.disenioCubierta.getGramaje(),
cabezada: this.disenioCubierta.getCabezada(),
acabados: this.disenioCubierta.getAcabados(),
carasImpresion: this.disenioCubierta.carasCubierta.val(),
},
if (calcularSolapas) {
return;
}
guardas: this.disenioCubierta.getGuardas(),
sobrecubierta: this.disenioCubierta.getSobrecubierta(),
faja: this.disenioCubierta.getFaja(),
this.datos.posPaginasColor = this.datosGenerales.posPaginasColor.val();
excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked') ? 1 : 0,
ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(),
servicios: {
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
'ferro': this.datosGenerales.ferro.is(':checked') ? 1 : 0,
'ferroDigital': this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
'marcapaginas': this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
'retractilado': this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
'retractilado5': this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
},
this.datos.prototipo = this.datosGenerales.prototipo.is(':checked') ? 1 : 0;
this.datos.ferro = this.datosGenerales.ferro.is(':checked') ? 1 : 0;
this.datos.ferroDigital = this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0;
this.datos.marcapaginas = this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0;
this.datos.retractilado = this.datosGenerales.retractilado.is(':checked') ? 1 : 0;
this.datos.retractilado5 = this.datosGenerales.retractilado5.is(':checked') ? 1 : 0;
this.datos.cubierta = {
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
papelCubierta: this.disenioCubierta.getPapel(),
gramajeCubierta: this.disenioCubierta.getGramaje(),
cabezada: this.disenioCubierta.getCabezada(),
acabados: this.disenioCubierta.getAcabados(),
carasImpresion: this.disenioCubierta.carasCubierta.val(),
};
this.datos.guardas = this.disenioCubierta.getGuardas();
this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta();
this.datos.faja = this.disenioCubierta.getFaja();
this.datos.excluirRotativa = this.datosGenerales.excluirRotativa.is(':checked') ? 1 : 0;
this.datos.ivaReducido = this.datosGenerales.ivaReducido.find('option:selected').val();
this.datos.servicios = {
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
'ferro': this.datosGenerales.ferro.is(':checked') ? 1 : 0,
'ferroDigital': this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
'marcapaginas': this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
'retractilado': this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
'retractilado5': this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
};
let lomoRedondo = 0;
if (this.disenioCubierta.disenioCubierta.filter('.selected').length > 0)
lomoRedondo = this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0;
@ -706,7 +737,7 @@ class PresupuestoCliente {
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
setTimeout(() => {