mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en eventos de lineas
This commit is contained in:
@ -55,6 +55,9 @@ class PresupuestoAdminEdit {
|
||||
this.guardar = $('#saveForm');
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
this.cargandoPresupuesto = false;
|
||||
|
||||
|
||||
this.configUploadDropzone = {
|
||||
domElement: '#dropzone-presupuesto-admin-files',
|
||||
nameId: "presupuesto_id",
|
||||
@ -130,10 +133,6 @@ class PresupuestoAdminEdit {
|
||||
|
||||
$('#lomo_cubierta').on('change', this.datosLibro.changeAnchoSolapasCubierta);
|
||||
$('#lomo_sobrecubierta').on('change', this.datosLibro.changeAnchoSolapasSobrecubierta);
|
||||
if ($(this.configUploadDropzone.domElement).length > 0) {
|
||||
this.fileUploadDropzone.init()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -282,6 +281,8 @@ class PresupuestoAdminEdit {
|
||||
update_resumen = true,
|
||||
update_tiradas_alternativas = true
|
||||
}) {
|
||||
|
||||
const self = this;
|
||||
const waitForEvent = (eventName) => {
|
||||
return new Promise((resolve) => {
|
||||
$(document).one(eventName, () => {
|
||||
@ -290,30 +291,32 @@ class PresupuestoAdminEdit {
|
||||
});
|
||||
};
|
||||
|
||||
// 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 (self.cargandoPresupuesto == false) {
|
||||
// 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_servicios) {
|
||||
$(document).trigger('update-servicios');
|
||||
await waitForEvent('update-servicios-completed');
|
||||
}
|
||||
|
||||
if (update_envios) {
|
||||
$(document).trigger('update-envios');
|
||||
await waitForEvent('update-envios-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_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');
|
||||
if (update_tiradas_alternativas) {
|
||||
$(document).trigger('update-tiradas-alternativas');
|
||||
await waitForEvent('update-tiradas-alternativas-completed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,6 +324,7 @@ class PresupuestoAdminEdit {
|
||||
#cargarPresupuesto() {
|
||||
|
||||
const self = this;
|
||||
this.cargandoPresupuesto = true;
|
||||
|
||||
$('#loader').modal('show');
|
||||
let id = window.location.href.split("/").pop()
|
||||
@ -338,15 +342,18 @@ class PresupuestoAdminEdit {
|
||||
self.POD.val(response.data.POD);
|
||||
|
||||
self.calcularPresupuesto = false;
|
||||
self.comparador.cargando = true;
|
||||
|
||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
self.datosLibro.cargarDatos(response.data.datosLibro);
|
||||
self.comparador.cargarDatos(response.data.comparador);
|
||||
|
||||
self.lineasPresupuesto.cargarDatos(response.data.lineasPresupuesto);
|
||||
|
||||
self.servicios.cargar(response.data.servicios);
|
||||
self.envios.cargar(response.data.direcciones);
|
||||
|
||||
self.comparador.cargarDatos(response.data.comparador);
|
||||
|
||||
$('#comentariosCliente').val(response.data.comentarios_cliente);
|
||||
$('#comentariosSafekat').val(response.data.comentarios_safekat);
|
||||
$('#comentariosPdf').val(response.data.comentarios_presupuesto);
|
||||
@ -363,8 +370,10 @@ class PresupuestoAdminEdit {
|
||||
if (response.data.state != 2) {
|
||||
|
||||
self.calcularPresupuesto = true;
|
||||
self.cargandoPresupuesto = false;
|
||||
}
|
||||
|
||||
|
||||
}, 0);
|
||||
|
||||
this.calcularSolapas();
|
||||
@ -380,6 +389,7 @@ class PresupuestoAdminEdit {
|
||||
() => {
|
||||
$('#loader').modal('hide');
|
||||
this.calcularPresupuesto = true;
|
||||
self.cargandoPresupuesto = false;
|
||||
}
|
||||
).get();
|
||||
}
|
||||
@ -389,12 +399,12 @@ class PresupuestoAdminEdit {
|
||||
|
||||
let cantidad_total = 0;
|
||||
|
||||
this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
var rowData = this.data();
|
||||
if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
|
||||
cantidad_total += parseInt(rowData.paginas)
|
||||
})
|
||||
htmlString = ''
|
||||
let htmlString = ''
|
||||
|
||||
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||
htmlString = `
|
||||
@ -430,7 +440,7 @@ class PresupuestoAdminEdit {
|
||||
|
||||
calcularSolapas() {
|
||||
|
||||
let anchoTotal = 2*this.getDimensionLibro().ancho;
|
||||
let anchoTotal = 2 * this.getDimensionLibro().ancho;
|
||||
let maxSolapas = 120;
|
||||
|
||||
let mano = 0;
|
||||
@ -443,29 +453,28 @@ class PresupuestoAdminEdit {
|
||||
}
|
||||
});
|
||||
|
||||
if (mano > 0) {
|
||||
if (mano > 0) {
|
||||
anchoTotal += 6 + 5; // dobleces + sangre
|
||||
maxSolapas = Math.min(Math.floor((865-anchoTotal)/2), 0.75*this.getDimensionLibro().ancho);
|
||||
maxSolapas = Math.min(Math.floor((865 - anchoTotal) / 2), 0.75 * this.getDimensionLibro().ancho);
|
||||
}
|
||||
else{
|
||||
maxSolapas = 0.75*this.getDimensionLibro().ancho;
|
||||
else {
|
||||
maxSolapas = 0.75 * this.getDimensionLibro().ancho;
|
||||
}
|
||||
if($('#solapas_ancho').length>0 && $('#solapas_ancho').attr('max') != maxSolapas){
|
||||
if ($('#solapas_ancho').length > 0 && $('#solapas_ancho').attr('max') != maxSolapas) {
|
||||
$('#solapas_ancho').attr('max', maxSolapas);
|
||||
$('#solapas_ancho').trigger('change');
|
||||
$('#solapas_ancho').trigger('change');
|
||||
$('#solapas_ancho').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
||||
}
|
||||
if($('#solapas_ancho_sobrecubierta').length>0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas){
|
||||
if ($('#solapas_ancho_sobrecubierta').length > 0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas) {
|
||||
$('#solapas_ancho_sobrecubierta').attr('max', maxSolapas);
|
||||
$('#solapas_ancho_sobrecubierta').trigger('change');
|
||||
$('#solapas_ancho_sobrecubierta').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
||||
}
|
||||
if($('#solapas_ancho_faja').length>0 && $('#solapas_ancho_faja').attr('max') != maxSolapas){
|
||||
if ($('#solapas_ancho_faja').length > 0 && $('#solapas_ancho_faja').attr('max') != maxSolapas) {
|
||||
$('#solapas_ancho_faja').attr('max', maxSolapas);
|
||||
$('#solapas_ancho_faja').trigger('change');
|
||||
$('#solapas_ancho_faja').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm');
|
||||
}
|
||||
console.log('maxSolapas', maxSolapas);
|
||||
}
|
||||
|
||||
getDimensionLibro() {
|
||||
|
||||
Reference in New Issue
Block a user