presupuesto cliente para perfil cliente

This commit is contained in:
2024-10-31 08:42:41 +01:00
parent d0ee0b27bc
commit 83c8628645
5 changed files with 50 additions and 77 deletions

View File

@ -64,7 +64,9 @@ class DatosGenerales {
// Selects
this.formatoLibro.init();
this.cliente.init();
if (this.excluirRotativa.length != 0) {
this.cliente.init();
}
// Inicializa el tipo de impresion
this.#handlePaginas();
@ -100,6 +102,8 @@ class DatosGenerales {
message: window.translations["validation"].cliente,
callback: function (input) {
// Get the selected options
if(this.excluirRotativa.length == 0)
return true;
const options = $("#clienteId").select2('data');
const hasValidOption = options.some(option => parseInt(option.id) > 0);
return options !== null && options.length > 0 && hasValidOption;
@ -382,9 +386,11 @@ class DatosGenerales {
this.coleccion.val(datos.coleccion);
this.referenciaCliente.val(datos.referenciaCliente);
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
if (this.excluirRotativa.length != 0) {
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
}
if (datos.excluirRotativa) {
this.excluirRotativa.prop('checked', true);
@ -434,6 +440,12 @@ class DatosGenerales {
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
}
getCliente(){
if (this.excluirRotativa.length == 0)
return $('#clienteId').val();
return this.cliente.getVal();
}
getDimensionLibro() {
let ancho = 0;

View File

@ -37,7 +37,7 @@ class Direcciones {
init() {
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
this.direccionesCliente.init();
this.btnAdd.on('click', this.#insertDireccion.bind(this));

View File

@ -62,6 +62,11 @@ class PresupuestoCliente {
this.disenioCubierta.init();
this.direcciones.init();
if(this.datosGenerales.excluirRotativa.length == 0){
this.direcciones.direccionesCliente.setParams({ 'cliente_id': $("#clienteId").val() })
}
this.btnNext.on('click', this.#nextStep.bind(this));
this.btnPrev.on('click', this.#prevtStep.bind(this));
@ -189,63 +194,6 @@ class PresupuestoCliente {
}
/*RELLENAR_PRESUPUESTO(finalizar) {
if (finalizar) {
$("#titulo").val("Titulo del libro");
$("#titulo").trigger('change');
const clienteId = $("#clienteId");
const newOption = new Option("Cliente Potencial", "1817", true, true);
clienteId.append(newOption).trigger('change');
const papelFormatoId = $("#papelFormatoId");
const newOption2 = new Option("148 x 210", "1", true, true);
papelFormatoId.append(newOption2).trigger('change');
$("#paginasColor").val("6");
$("#paginasColor").trigger('change');
$("#fresado").trigger("click");
$("#colorPremium").trigger("click");
$("#offsetBlanco").trigger("click");
setTimeout(function () {
$("#gramaje90").trigger("click");
}, 0);
setTimeout(function () {
$("#tapaDura").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#btnNext").trigger("click");
}, 0);
setTimeout(function () {
$("#unidadesEnvio").val("50");
}, 0);
}
else {
$("#titulo").trigger('change');
}
}*/
#handleTitulosMenu(event) {
$('.titulos-menu').removeClass('crossed');
@ -266,7 +214,7 @@ class PresupuestoCliente {
}
#goToForm(form) {
switch (form) {
case '#datos-generales':
this.validationStepper.to(1);
@ -439,7 +387,7 @@ class PresupuestoCliente {
}
}
else {
if(response.error){
if (response.error) {
popErrorAlert("No se ha podido guardar el presupuesto. Por favor, póngase en contacto con el departamento comercial.");
}
else
@ -546,7 +494,7 @@ class PresupuestoCliente {
this.datos = {
clienteId: this.datosGenerales.cliente.getVal(),
clienteId: this.datosGenerales.getCliente(),
tamanio: this.datosGenerales.getDimensionLibro(),
tirada: this.datosGenerales.getTiradas(),
@ -651,7 +599,9 @@ class PresupuestoCliente {
this.calcularPresupuesto = false;
this.datosGenerales.cargarDatos(response.data.datosGenerales);
this.direcciones.handleChangeCliente();
if (this.datosGenerales.excluirRotativa.length !== 0) {
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);