boton guardar en todas pags, resuelto preview cosido

This commit is contained in:
2024-11-09 12:15:32 +01:00
parent 11b14ccf76
commit 873adc5bf5
7 changed files with 2084 additions and 866 deletions

View File

@ -67,7 +67,7 @@ class PresupuestoCliente {
else {
this.resumen.init();
}
if (this.datosGenerales.excluirRotativa.length == 0) {
@ -154,29 +154,9 @@ class PresupuestoCliente {
this.direcciones.divTiradas.empty();
}
this.#getDatos();
this.divTiradasPrecios.empty();
let datos_to_check = { ...this.datos };
if (datos_to_check.direcciones) {
delete datos_to_check.direcciones;
}
if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
delete datos_to_check.posPaginasColor;
}
if (datos_to_check.cubierta.acabados.barniz == undefined) {
delete datos_to_check.cubierta.acabados.barniz;
}
if (datos_to_check.cubierta.acabados.plastificado == undefined) {
delete datos_to_check.cubierta.acabados.plastificado;
}
if (datos_to_check.cubierta.acabados.estampado == undefined) {
delete datos_to_check.cubierta.acabados.estampado;
}
if (datos_to_check.sobrecubierta.plastificado == undefined) {
delete datos_to_check.sobrecubierta.plastificado;
}
let datos_to_check = this.#prepareData();
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try {
@ -340,7 +320,6 @@ class PresupuestoCliente {
this.btnPrev.addClass('d-none');
this.btnNext.removeClass('d-none');
this.btnPrint.addClass('d-none');
this.btnSave.addClass('d-none');
this.btnConfirm.addClass('d-none');
break;
@ -350,7 +329,6 @@ class PresupuestoCliente {
this.btnPrev.removeClass('d-none');
this.btnNext.removeClass('d-none');
this.btnPrint.addClass('d-none');
this.btnSave.addClass('d-none');
this.btnConfirm.addClass('d-none');
break;
@ -358,7 +336,6 @@ class PresupuestoCliente {
this.btnPrev.removeClass('d-none');
this.btnNext.addClass('d-none');
this.btnPrint.removeClass('d-none');
this.btnSave.removeClass('d-none');
this.btnConfirm.removeClass('d-none');
this.resumen.generate();
break;
@ -383,16 +360,25 @@ class PresupuestoCliente {
#solicitudGuardarPresupuesto(confirmar = false) {
this.#getDatos(true);
if (confirmar) {
this.datos["confirmar"] = 1;
}
try {
$('#loader').modal('show');
this.#getDatos();
let datos_to_check = this.#prepareData();
if (!Object.values(datos_to_check).every(this.#isValidDataForm)) {
popErrorAlert("Por favor, rellene todos los datos del presupuesto antes de guardar.");
$('#loader').modal('hide');
return;
}
this.#getDatos(true);
if (confirmar) {
this.datos["confirmar"] = 1;
}
if (window.location.href.includes("edit")) {
this.datos["id"] = window.location.href.split("/").pop();
}
@ -407,12 +393,12 @@ class PresupuestoCliente {
window.location.href = response.url + '/' + response.status;
}
else {
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
popErrorAlert("Presupuesto no válido, corrija los errores antes de guardar.");
}
}
else {
if (response.error) {
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
popErrorAlert("Presupuesto no válido, corrija los errores antes de guardar.");
}
else
popSuccessAlert(response.message);
@ -514,6 +500,33 @@ class PresupuestoCliente {
}
#prepareData(save = false) {
this.#getDatos(save);
let datos_to_check = { ...this.datos };
if (datos_to_check.direcciones) {
delete datos_to_check.direcciones;
}
if (datos_to_check.posPaginasColor == "" || datos_to_check.posPaginasColor == null) {
delete datos_to_check.posPaginasColor;
}
if (datos_to_check.cubierta.acabados.barniz == undefined) {
delete datos_to_check.cubierta.acabados.barniz;
}
if (datos_to_check.cubierta.acabados.plastificado == undefined) {
delete datos_to_check.cubierta.acabados.plastificado;
}
if (datos_to_check.cubierta.acabados.estampado == undefined) {
delete datos_to_check.cubierta.acabados.estampado;
}
if (datos_to_check.sobrecubierta.plastificado == undefined) {
delete datos_to_check.sobrecubierta.plastificado;
}
return datos_to_check;
}
#getDatos(save = false) {
this.datos = {
@ -624,7 +637,7 @@ class PresupuestoCliente {
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);