mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-24 09:40:21 +00:00
trabajando en el envio de los datos al backend para generar el resumen. no recibe bien el objeto presupuesto
This commit is contained in:
@ -1388,6 +1388,20 @@ class PresupuestoCliente {
|
||||
this.#changeTab('pills-seleccion-tirada');
|
||||
this.summaryTableExtras.addClass('d-none');
|
||||
} else {
|
||||
const data = Summary.getSummaryData();
|
||||
$.ajax({
|
||||
url: '/presupuesto/public/getresumen',
|
||||
type: 'GET',
|
||||
data: {
|
||||
presupuesto: this.#getPresupuestoData(),
|
||||
summary: data,
|
||||
}
|
||||
}).then((data) => {
|
||||
console.log("Extras validados correctamente", data);
|
||||
}).catch((error) => {
|
||||
console.error("Error obtener resumen: ", error);
|
||||
});
|
||||
|
||||
this.#changeTab('pills-resumen');
|
||||
}
|
||||
});
|
||||
@ -1443,21 +1457,40 @@ class PresupuestoCliente {
|
||||
* END EXTRAS
|
||||
******************************/
|
||||
|
||||
|
||||
|
||||
/******************************
|
||||
* EXTRAS
|
||||
* RESUMEN
|
||||
******************************/
|
||||
#initResumen() {
|
||||
const $row = $('#presupuesto-row');
|
||||
|
||||
// 1) Transición al cambiar de pestaña (click o programático)
|
||||
$(document).on('shown.bs.tab', '.custom-nav .nav-link', (e) => {
|
||||
const targetSelector = $(e.target).data('bs-target'); // ej: "#pills-resumen"
|
||||
if (targetSelector === '#pills-resumen') {
|
||||
$row.addClass('expanded');
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
} else {
|
||||
$row.removeClass('expanded');
|
||||
}
|
||||
});
|
||||
|
||||
// 2) Botón "atrás" en Resumen
|
||||
$(document).on('click', '.btn-change-tab-resumen', (e) => {
|
||||
const id = e.currentTarget.id;
|
||||
if (id === 'btn-prev-resumen') {
|
||||
if (e.currentTarget.id === 'btn-prev-resumen') {
|
||||
this.#changeTab('pills-extras');
|
||||
}
|
||||
});
|
||||
|
||||
// 3) Estado inicial si ya cargas en Resumen
|
||||
$(function () {
|
||||
const activeTarget = $('.custom-nav .nav-link.active').data('bs-target');
|
||||
$('#presupuesto-row').toggleClass('expanded', activeTarget === '#pills-resumen');
|
||||
});
|
||||
}
|
||||
|
||||
/******************************
|
||||
* END EXTRAS
|
||||
* END RESUMEN
|
||||
******************************/
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ export function updateExtras() {
|
||||
const price = $(`label[for="${$servicio.attr('id')}"] .service-price`).text().trim() || $servicio.attr('price');
|
||||
const $row = $('<tr>').append(
|
||||
$('<td>').append($('<span>').text(resumen)),
|
||||
$('<td class="text-end">').text(price)
|
||||
$('<td class="text-end data-summary" data-id-summary="servicio-' + $servicio.attr('id') + '">').text(price)
|
||||
);
|
||||
$tbody.append($row);
|
||||
});
|
||||
@ -161,4 +161,22 @@ export function updateExtras() {
|
||||
} else {
|
||||
$table.addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
export function getSummaryData() {
|
||||
const data = {};
|
||||
|
||||
$(".data-summary").each(function () {
|
||||
const $el = $(this);
|
||||
|
||||
// comprobar si la tabla y el tr están visibles
|
||||
if ($el.closest("table").is(":visible") && $el.closest("tr").is(":visible")) {
|
||||
const key = $el.data("id-summary"); // atributo data-id-summary
|
||||
const value = $el.text().trim(); // texto visible
|
||||
|
||||
data[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user