preview casi

This commit is contained in:
2024-10-22 10:29:34 +02:00
parent 2f83526d7e
commit 9f61faf67a
4 changed files with 14476 additions and 310 deletions

View File

@ -42,6 +42,7 @@ class PresupuestoCliente {
() => { $('#loader').modal('hide'); });
this.actualizarTiradasEnvio = false;
this.calcularPresupuesto = false;
}
@ -65,7 +66,7 @@ class PresupuestoCliente {
this.btnSave.on('click', this.#savePresupuesto.bind(this));
if (window.location.href.includes("edit")) {
$(".calcular-presupuesto").on('change', () => { });
this.#cargarPresupuesto();
const successMessage = sessionStorage.getItem('message');
if (successMessage) {
@ -74,61 +75,67 @@ class PresupuestoCliente {
}
}
else {
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
this.calcularPresupuesto = true;
}
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
}
checkForm(event) {
if (event.target.id === 'divDirecciones') {
if (!this.direcciones.calcularPresupuesto) {
this.actualizarTiradasEnvio = false;
$('#loader').modal('hide');
return;
if (this.calcularPresupuesto) {
if (event.target.id === 'divDirecciones') {
if (!this.direcciones.calcularPresupuesto) {
this.actualizarTiradasEnvio = false;
$('#loader').modal('hide');
return;
}
}
else {
this.actualizarTiradasEnvio = true;
this.direcciones.divTiradas.empty();
}
}
else {
this.actualizarTiradasEnvio = true;
this.direcciones.divTiradas.empty();
}
this.#getDatos();
this.#getDatos();
this.divTiradasPrecios.empty();
this.divTiradasPrecios.empty();
let datos_to_check = { ...this.datos };
if (datos_to_check.direcciones) {
delete datos_to_check.direcciones;
}
if (datos_to_check.posPaginasColor) {
delete datos_to_check.posPaginasColor;
}
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try {
setTimeout(function () {
$('#loader').modal('show');
}, 0);
// Si se está ejecutando la petición, abortar la petición anterior
this.ajax_calcular.abort();
this.ajax_calcular.setData(this.datos);
this.ajax_calcular.post();
this.direcciones.calcularPresupuesto = false;
let datos_to_check = { ...this.datos };
if (datos_to_check.direcciones) {
delete datos_to_check.direcciones;
}
catch (e) {
console.log(e);
$('#loader').modal('hide');
if (datos_to_check.posPaginasColor) {
delete datos_to_check.posPaginasColor;
}
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try {
setTimeout(function () {
$('#loader').modal('show');
}, 0);
// Si se está ejecutando la petición, abortar la petición anterior
this.ajax_calcular.abort();
this.ajax_calcular.setData(this.datos);
this.ajax_calcular.post();
this.direcciones.calcularPresupuesto = false;
}
catch (e) {
console.log(e);
$('#loader').modal('hide');
}
}
}
}
/*RELLENAR_PRESUPUESTO(finalizar) {
if (finalizar) {
@ -267,9 +274,11 @@ class PresupuestoCliente {
$('#loader').modal('hide');
if (Object.values(response.errors).some((value) => value !== "")) {
popErrorAlert("No se ha podido calcular el presupuesto para los datos proporcionados. Por favor, póngase en contacto con el departamento comercial."
, "sk-alert-2", false);
return;
if (response.errors.status == 1) {
popErrorAlert("No se ha podido calcular el presupuesto para los datos proporcionados. Por favor, póngase en contacto con el departamento comercial."
, "sk-alert-2", false);
return;
}
}
else {
popAlert2Hide();
@ -277,7 +286,7 @@ class PresupuestoCliente {
if (response.tiradas && response.tiradas.length) {
let tiradas = {...response.tiradas};
let tiradas = { ...response.tiradas };
tiradas = Object.keys(tiradas).map((key) => tiradas[key]);
tiradas.sort((a, b) => a - b);
this.divTiradasPrecios.empty();
@ -301,6 +310,7 @@ class PresupuestoCliente {
$(`#containerTiradasEnvios .tirada-envio input[tirada="${response.tiradas[0]}"]`).trigger('click');
}, 0);
}
// DEBUG
//console.log(response);
}
@ -437,33 +447,34 @@ class PresupuestoCliente {
{},
(response) => {
setTimeout(() => {
if (response.status === 1) {
if (response.status === 1) {
this.lc.val(parseFloat(response.data.lc).toFixed(2));
this.lsc.val(parseFloat(response.data.lsc).toFixed(2));
this.lc.val(parseFloat(response.data.lc).toFixed(2));
this.lsc.val(parseFloat(response.data.lsc).toFixed(2));
this.datosGenerales.cargarDatos(response.data.datosGenerales);
this.direcciones.handleChangeCliente();
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
this.calcularPresupuesto = false;
setTimeout(() => {
this.checkForm({ target: { id: 'tirada' } });
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
$('#loader').modal('hide');
}, 0);
}
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
}, 0);
this.datosGenerales.cargarDatos(response.data.datosGenerales);
this.direcciones.handleChangeCliente();
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
setTimeout(() => {
//this.checkForm({ target: { id: 'tirada' } });
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
this.validationStepper.next();
$('#loader').modal('hide');
this.calcularPresupuesto = true;
this.checkForm({ target: { id: 'tirada' } });
}, 0);
}
},
() => {
$('#loader').modal('hide');
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
this.calcularPresupuesto = true;
}
).get();
}