mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en guardar
This commit is contained in:
@ -9,6 +9,7 @@ import PreviewFormasAdmin from './sections/previewFormasAdmin.js';
|
||||
import Servicios from './sections/servicios.js';
|
||||
import Envios from './sections/envios.js';
|
||||
import TiradasAlernativas from './sections/tiradasAlternativas.js';
|
||||
import Resumen from './sections/resumen.js';
|
||||
|
||||
class PresupuestoAdminEdit {
|
||||
|
||||
@ -44,6 +45,10 @@ class PresupuestoAdminEdit {
|
||||
this.tiradasAlternativas = new TiradasAlernativas({
|
||||
getDimensionLibro: this.getDimensionLibro,
|
||||
});
|
||||
this.resumen = new Resumen();
|
||||
|
||||
this.guardar = $('#saveForm');
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
}
|
||||
|
||||
@ -89,6 +94,7 @@ class PresupuestoAdminEdit {
|
||||
this.servicios.init();
|
||||
this.envios.init();
|
||||
this.tiradasAlternativas.init();
|
||||
this.resumen.init();
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
|
||||
@ -103,8 +109,62 @@ class PresupuestoAdminEdit {
|
||||
}
|
||||
}
|
||||
this.downloadPreviewImage();
|
||||
|
||||
$(document).on('update-presupuesto', this.updatePresupuesto.bind(this));
|
||||
|
||||
this.guardar.on('click', this.guardarPresupuesto.bind(this));
|
||||
}
|
||||
|
||||
|
||||
guardarPresupuesto() {
|
||||
|
||||
this.servicios.guardar();
|
||||
}
|
||||
|
||||
|
||||
async updatePresupuesto(event, {
|
||||
update_lineas = true,
|
||||
update_servicios = true,
|
||||
update_envios = true,
|
||||
update_resumen = true,
|
||||
update_tiradas_alternativas = true
|
||||
}) {
|
||||
const waitForEvent = (eventName) => {
|
||||
return new Promise((resolve) => {
|
||||
$(document).one(eventName, () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Ejecutar los pasos de forma secuencial si están habilitados
|
||||
if (update_lineas) {
|
||||
$(document).trigger('update-lineas-presupuesto');
|
||||
await waitForEvent('update-lineas-presupuesto-completed');
|
||||
}
|
||||
|
||||
if (update_servicios) {
|
||||
$(document).trigger('update-servicios');
|
||||
await waitForEvent('update-servicios-completed');
|
||||
}
|
||||
|
||||
if (update_envios) {
|
||||
$(document).trigger('update-envios');
|
||||
await waitForEvent('update-envios-completed');
|
||||
}
|
||||
|
||||
if (update_resumen) {
|
||||
$(document).trigger('update-totales');
|
||||
await waitForEvent('update-totales-completed');
|
||||
}
|
||||
|
||||
if (update_tiradas_alternativas) {
|
||||
$(document).trigger('update-tiradas-alternativas');
|
||||
await waitForEvent('update-tiradas-alternativas-completed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#cargarPresupuesto() {
|
||||
|
||||
const self = this;
|
||||
@ -140,14 +200,9 @@ class PresupuestoAdminEdit {
|
||||
$('#comentariosProduccion').val(response.data.comentarios_produccion);
|
||||
|
||||
self.tiradasAlternativas.cargar(response.data.tiradasAlternativas);
|
||||
|
||||
/*self.direcciones.handleChangeCliente();
|
||||
|
||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||
self.resumen.cargar(response.data.resumen);
|
||||
|
||||
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
*/
|
||||
setTimeout(() => {
|
||||
|
||||
$('#loader').modal('hide');
|
||||
@ -187,7 +242,7 @@ class PresupuestoAdminEdit {
|
||||
cantidad_total += parseInt(rowData.paginas)
|
||||
})
|
||||
htmlString = ''
|
||||
|
||||
|
||||
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||
htmlString = `
|
||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||
|
||||
Reference in New Issue
Block a user