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

@ -14,7 +14,7 @@ class DisenioCubierta {
this.divSolapas = this.domItem.find("#divSolapasCubierta");
this.divCarasImpresion = this.domItem.find("#divCarasImpresion");
this.divConfigTapaDura = this.domItem.find("#divConfigTapaDura");
this.divConfigGuardas = this.domItem.find("#divConfigGuardas");
this.carasCubierta = this.domItem.find("#carasCubierta");
@ -63,6 +63,9 @@ class DisenioCubierta {
this.solapasFaja = this.domItem.find("#solapasFaja");
this.altoFaja = this.domItem.find("#altoFaja");
this.fresado = $(this.domItem.find("#fresado")[0]);
this.cosido = $(this.domItem.find("#cosido")[0]);
this.initValidation();
// Creamos un nuevo observador que detecta cambios en los atributos
@ -597,22 +600,23 @@ class DisenioCubierta {
#handleMenuTipoCubierta() {
if (this.tapaBlanda.hasClass("selected")) {
this.divSolapas.removeClass("d-none");
this.divCarasImpresion.removeClass("d-none");
this.divConfigTapaDura.addClass("d-none");
this.divConfigGuardas.addClass("d-none");
}
else if (this.tapaDuraLomoRecto.hasClass("selected") || this.tapaDuraLomoRedondo.hasClass("selected")) {
this.solapasCubierta.removeClass("selected");
this.divSolapas.addClass("d-none");
this.divCarasImpresion.addClass("d-none");
this.divConfigTapaDura.removeClass("d-none");
this.divConfigGuardas.removeClass("d-none");
this.#handleMenuPapel();
}
else {
this.divSolapas.addClass("d-none");
this.divCarasImpresion.addClass("d-none");
this.divConfigTapaDura.addClass("d-none");
this.divConfigGuardas.addClass("d-none");
this.#handleMenuPapel();
}
}

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);

View File

@ -217,12 +217,12 @@ class previewFormas {
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(lomoLibro.toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((altoLibro + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
previewEC.makeText(this.lomo.toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((this.alto + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(((2 * this.ancho) + (2 * (this.solapa + this.offsetSolapa)) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);