mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-24 01:30:21 +00:00
acabando presupuesto
This commit is contained in:
@ -3,7 +3,6 @@ import { formateaMoneda } from "../utils.js";
|
||||
|
||||
|
||||
$(document).on('change', '#maquetacion', function (e) {
|
||||
|
||||
e.preventDefault();
|
||||
if ($('#maquetacion').is(':checked')) {
|
||||
$.get("/presupuesto/public/maquetacion/form", function (data) {
|
||||
|
||||
@ -211,6 +211,7 @@ export default class PresupuestoWizard {
|
||||
this.#initDatosGenerales();
|
||||
|
||||
if (presupuestoId && mode !== 'public') {
|
||||
|
||||
await fetch(`/presupuesto/api/get?id=${encodeURIComponent(presupuestoId)}`, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
@ -218,12 +219,16 @@ export default class PresupuestoWizard {
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(dto => {
|
||||
sessionStorage.removeItem("formData");
|
||||
this.formData = dto;
|
||||
this.#cacheFormData();
|
||||
this.#loadDatosGeneralesData();
|
||||
});
|
||||
} else {
|
||||
if (stored) {
|
||||
sessionStorage.removeItem("formData");
|
||||
this.formData = JSON.parse(stored);
|
||||
this.#cacheFormData();
|
||||
this.#loadDatosGeneralesData();
|
||||
}
|
||||
}
|
||||
@ -290,8 +295,29 @@ export default class PresupuestoWizard {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Usa function() para que `this` sea el botón
|
||||
$('.btn-imprimir').on('click', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
// obtén el id de donde lo tengas (data-attr o variable global)
|
||||
const id = this.opts.presupuestoId;
|
||||
|
||||
const url = `/api/pdf/presupuesto/${id}?mode=download`;
|
||||
|
||||
// Truco: crear <a> y hacer click
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.target = '_self'; // descarga en la misma pestaña
|
||||
// a.download = `presupuesto-${id}.pdf`; // opcional, tu server ya pone filename
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
async #guardarPresupuesto() {
|
||||
@ -1742,7 +1768,7 @@ export default class PresupuestoWizard {
|
||||
this.divExtras.append(item.render());
|
||||
}
|
||||
|
||||
if (!this.formData.servicios.servicios.includes(s => s.id === "ferro-digital")) {
|
||||
if (!this.formData.servicios.servicios.some(s => s.id === "ferro-digital")) {
|
||||
this.formData.servicios.servicios.push({
|
||||
id: "ferro-digital",
|
||||
label: "Ferro Digital",
|
||||
@ -1776,6 +1802,15 @@ export default class PresupuestoWizard {
|
||||
...result,
|
||||
};
|
||||
|
||||
if (!this.formData.servicios.servicios.some(s => s.id === "maquetacion") && result.precio > 0) {
|
||||
this.formData.servicios.servicios.push({
|
||||
id: "maquetacion",
|
||||
label: $(`label[for="maquetacion"] .service-title`).text().trim(),
|
||||
units: 1,
|
||||
price: result.precio,
|
||||
});
|
||||
}
|
||||
|
||||
this.#cacheFormData();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user