acabando el tema de las direcciones

This commit is contained in:
2024-10-14 00:50:15 +02:00
parent 0eaac5af28
commit 7ad3133a15
7 changed files with 192 additions and 104 deletions

View File

@ -67,6 +67,18 @@ class Direcciones {
});
}
getDirecciones(){
let direcciones = this.divDirecciones.find('.direccion-cliente')
if(direcciones.length > 0){
direcciones.forEach(element => {
});
}
}
#insertDireccion() {
self = this;
@ -76,7 +88,7 @@ class Direcciones {
let id = this.direccionesCliente.getValue();
let unidades = this.unidadesAdd.val();
let entregaPalets = this.entregaPieCallero.is(':checked');
let dirId = "dirEnvio-1";
let dirId = "dirEnvio-" + id;
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
if (direccionesActuales.length > 0) {
// the the lass item
@ -99,7 +111,7 @@ class Direcciones {
tarjeta.card.find('.direccion-editar').on('click', this.#editUnits.bind(self));
tarjeta.card.find('.direccion-eliminar').on('click', this.#deleteDireccion.bind(self));
this.divDirecciones.append(tarjeta.card);
this.direcciones.push({ "id": dirId, "unidades": unidades, "enPallets": entregaPalets, "direccion": response.data[0] });
this.direcciones.push({ "id": id, "unidades": unidades, "enPallets": entregaPalets});
self.divDirecciones.trigger('change');
$('#loader').hide();
},

View File

@ -27,11 +27,13 @@ class PresupuestoCliente {
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
this.divTiradasPrecios = $("#divTiradasPrecio");
this.datos = {};
this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
{}, this.datos,
this.#procesarPresupuesto,
() => { $('#loader').hide(); console.log("Error") });
this.#procesarPresupuesto.bind(this),
() => { $('#loader').hide(); });
}
@ -54,12 +56,12 @@ class PresupuestoCliente {
this.disenioCubierta.init();
this.direcciones.init();
this.RELLENAR_PRESUPUESTO();
//this.RELLENAR_PRESUPUESTO();
}
checkForm() {
checkForm(event) {
this.#getDatos();
@ -154,8 +156,24 @@ class PresupuestoCliente {
#procesarPresupuesto(response) {
$('#loader').hide();
console.log("Success");
console.log(response);
// checj if response.tiradas exists and is not empty
if (response.tiradas && response.tiradas.length) {
this.divTiradasPrecios.empty();
for (let i = 0; i < response.tiradas.length; i++) {
new tarjetaTiradasPrecio(
this.divTiradasPrecios,
('precio-tiradas-' + response.tiradas[i]),
response.tiradas[i],
(parseFloat(response.precio_u[i])*parseInt(response.tiradas[i])).toFixed(2),
response.precio_u[i]
);
}
}
// DEBUG
//console.log(response);
}
@ -228,7 +246,7 @@ class PresupuestoCliente {
excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked'),
ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(),
servicios: {
'prototipo' : this.datosGenerales.servicios.prototipo.is(':checked'),
'prototipo' : this.datosGenerales.prototipo.is(':checked'),
},
};
@ -248,6 +266,10 @@ class PresupuestoCliente {
else{
this.datos.cubierta.solapas = false;
}
if(this.direcciones.direcciones.length > 0){
this.datos.direcciones = this.direcciones.direcciones;
}
}

View File

@ -15,12 +15,12 @@ class tarjetaTiradasPrecio {
let $html = $('<div>', {
id: id,
class: 'list-group'
class: 'list-group mb-2'
});
let $link = $('<a>', {
href: 'javascript:void(0);',
class: 'list-group-item list-group-item-action'
class: 'list-group-item'
});
let $liWrapper = $('<div>', {