lineas presupuesto actualizadas con tirada

This commit is contained in:
2025-01-08 17:34:29 +01:00
parent a88f3fb009
commit 642b445cd2
7 changed files with 106 additions and 35 deletions

View File

@ -1,4 +1,3 @@
class previewFormas {
constructor(container, tipoLibro, tipoTapa, size, datos) {
@ -11,6 +10,7 @@ class previewFormas {
this.ancho = datos.ancho;
this.alto = datos.alto;
this.lomo = datos.lomo;
this.lomoSobrecubierta = datos.lomoSobrecubierta;
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
this.solapa = 0;
@ -43,6 +43,7 @@ class previewFormas {
this.ancho = datos.ancho;
this.alto = datos.alto;
this.lomo = datos.lomo;
this.lomoSobrecubierta = datos.lomoSobrecubierta;
if (datos.solapas == undefined || datos.solapas == null || datos.solapas == false) {
this.solapa = 0;
@ -96,6 +97,7 @@ class previewFormas {
gramajeLibro: parseInt(rowData.gramaje),
manoLP: parseFloat(rowData.lomo),
lomoLibro: this.lomo(),
lomoLibroSobrecubierta: this.lomoSobrecubierta(),
anchoSolapa: $('#solapas').is(':checked') ? parseFloat($('#solapas_ancho').val()) : parseFloat(0),
nFormas: parseInt(rowData.formas),
nFormasH: parseInt(rowData.formas_h),
@ -178,15 +180,15 @@ class previewFormas {
break;
case 'sobrecubierta':
sangre = parseFloat(5); // mm
let sangre = parseFloat(5); // mm
let anchoSolapaSobrecubierta = $('#solapas_sobrecubierta').is(':checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : parseFloat(0); // mm
if (_isTapaDura) {
let anchoPliegue = parseFloat(7); // mm
let altoPliegue = parseFloat(7); // mm
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibro);
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * anchoPliegue) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibroSobrecubierta);
this.pvObj.altoForma += altoPliegue + (2 * sangre);
} else {
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibro);
this.pvObj.anchoForma = ((2 * this.pvObj.anchoLibro) + (2 * (anchoSolapaSobrecubierta + this.pvObj.offsetSolapa)) + (2 * sangre) + this.pvObj.lomoLibroSobrecubierta);
this.pvObj.altoForma += (2 * sangre);
}
@ -207,7 +209,7 @@ class previewFormas {
// Conditional assignements depending on rotation of the printing shape
if (this.pvObj.orientacionFormas == 'v') {
let auxReg = this.pvObj.altoForma;
this.pvObj.altoForma = pvObj.anchoForma;
this.pvObj.altoForma = this.pvObj.anchoForma;
this.pvObj.anchoForma = auxReg;
}
$(pvName + '_forma').text(this.pvObj.anchoForma + "x" + this.pvObj.altoForma);
@ -362,12 +364,14 @@ class previewFormas {
// offset Y
let nTopForms = (this.pvObj.altoImpresion / 2.0 - margenTop) / (LVo + guardaV);
let yOffset = LVo * getDecimalPart(nTopForms);
const int_part = Math.trunc(nTopForms);
const float_part = Number((nTopForms - int_part).toFixed(2));
let yOffset = LVo * float_part;
//console.log(yOffset);
// Clear the canvas element
$('#pv_' + pvObj.idIndex + '_shape').empty();
$('#pv_' + this.pvObj.idIndex + '_shape').empty();
// Get the element for placing the graphical elements
var divRotativa = document.getElementById('pv_' + this.pvObj.idIndex + '_shape');
var _pvRotativa = new Two({ fitted: true }).appendTo(divRotativa);
@ -457,6 +461,15 @@ class previewFormas {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa;
if(typeof this.lomo === 'function') {
this.lomo = this.lomo();
this.ancho = this.ancho();
this.alto = this.alto();
this.lomoRedondo = this.lomoRedondo();
this.solapa = this.solapa();
}
let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat(5); // mm
@ -468,7 +481,7 @@ class previewFormas {
anchoSangrado = 350; // px
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
} else {
anchoSangrado = 800; // px
anchoSangrado = 750; // px
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
}
@ -625,12 +638,18 @@ class previewFormas {
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
// Cotas
previewEC.makeText(this.lomo.toFixed(1) + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
let lomoTotal = 0;
if(typeof this.lomo === 'function') {
lomoTotal = this.lomo().toFixed(1);
} else {
lomoTotal = this.lomo.toFixed(1);
}
previewEC.makeText(lomoTotal + " mm", origenEC.x, origenEC.y + (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText((this.ancho + this.offsetSolapa).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
previewEC.makeText(this.alto.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText((this.alto + (2 * sangradoValor)).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
previewEC.makeText(((2 * this.ancho) + (2 * (this.solapa + this.offsetSolapa)) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
previewEC.makeText(((2 * this.ancho) + (2 * (this.solapa + this.offsetSolapa)) + lomoTotal + (2 * sangradoValor)).toFixed(1) + " mm",
origenEC.x,
origenEC.y + (altoLibro / 2) + 50,
styleCotas);
@ -646,6 +665,14 @@ class previewFormas {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoCubierta, altoSangrado, anchoSangrado;
if(typeof this.lomo === 'function') {
this.lomo = this.lomo();
this.ancho = this.ancho();
this.alto = this.alto();
this.lomoRedondo = this.lomoRedondo();
}
let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = "Sangrado 20 mm";
let sangradoValor = parseFloat(20); // mm
@ -786,11 +813,19 @@ class previewFormas {
// Variables locales
let altoLibro, anchoLibro, anchoSolapa, anchoCalle, altoSangrado, anchoSangrado, offsetCubierta, anchoCubierta;
if(typeof this.lomo === 'function') {
this.lomo = this.lomo();
this.ancho = this.ancho();
this.alto = this.alto();
this.lomoRedondo = this.lomoRedondo();
this.solapa = this.solapa();
}
let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
// Definicion de los parametros del Esquema de Cubierta (EC)
if ((this.solapa !== 0) && (!isTapaDura)) {
if (this.size == "thumbnail") {
@ -995,6 +1030,15 @@ class previewFormas {
// Variables locales
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
if(typeof this.lomo === 'function') {
this.lomo = this.lomo();
this.ancho = this.ancho();
this.alto = this.alto();
this.lomoRedondo = this.lomoRedondo();
this.solapa = this.solapa();
}
let styleCotas = { size: 12, family: 'Public Sans' };
let sangradoTexto = "Sangrado 5 mm";
let sangradoValor = parseFloat(5); // mm

View File

@ -36,7 +36,7 @@ class PresupuestoAdminEdit {
{
getDimensionLibro: this.getDimensionLibro,
});
this.previewFormasAdmin = null;
this.calcularPresupuesto = false;
}
@ -53,29 +53,30 @@ class PresupuestoAdminEdit {
if (impresion_id == 1 || impresion_id == 2) {
tipoLibro = 'fresado';
} else if (impresion_id == 3 || impresion_id == 4) {
tipoLibro ='cosido';
tipoLibro = 'cosido';
} else if (impresion_id == 5 || impresion_id == 6) {
tipoLibro ='espiral';
tipoLibro = 'espiral';
} else if (impresion_id == 7 || impresion_id == 8) {
tipoLibro = 'wireo';
} else if (impresion_id == 21) {
tipoLibro = 'grapado';
}
this.datosGenerales.init();
this.datosLibro.init();
this.comparador.init();
this.lineasPresupuesto.init();
this.previewFormasAdmin = new PreviewFormasAdmin(tipoLibro, this.tipoTapa,
this.previewFormasAdmin = new PreviewFormasAdmin(tipoLibro, this.tipoTapa,
{
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
lomo: () => $('#lc').val() === '' ? parseFloat('0.0') : parseFloat($('#lc').val()),
solapas: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0,
solapas_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0,
lomoRedondo: () => (this.tipo_impresion == 1 || this.tipo_impresion == 3) ? parseFloat($('#compLomoRedondo').val()) : 0,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
lomo: () => $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
lomoSobrecubierta: () => $('#lomo_sobrecubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_sobrecubierta').val()),
solapa: () => $('#solapas').prop('checked') ? parseFloat($('#solapas_ancho').val()) : 0,
solapa_sobrecubierta: () => $('#solapas_sobrecubierta').prop('checked') ? parseFloat($('#solapas_ancho_sobrecubierta').val()) : 0,
lomoRedondo: () => (this.tipo_impresion == 1 || this.tipo_impresion == 3) ? parseFloat($('#compLomoRedondo').val()) : 0,
}
);
this.previewFormasAdmin.init();
@ -109,7 +110,7 @@ class PresupuestoAdminEdit {
self.lc.val(parseFloat(response.data.lc).toFixed(2));
self.lsc.val(parseFloat(response.data.lsc).toFixed(2));
self.cosido.val(response.data.cosido?1:0);
self.cosido.val(response.data.cosido ? 1 : 0);
self.tipo_impresion.val(response.data.tipo_impresion);
self.POD.val(response.data.POD);

View File

@ -887,7 +887,7 @@ class Comparador {
for (let element of gramajes) {
if (element.getVal() == 0 || element.getVal() == null) {
const tipo = element.item.attr('id').split('Papel')[1];
const tipo = element.item.attr('id').split('Gramaje')[1];
if ($('#compPaginas' + tipo).val() > 0) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} };
@ -1079,7 +1079,7 @@ class Comparador {
datosComp.data,
{},
(response) => {
if (response.data.negro.length > 0) {
if (response.data.negro && response.data.negro.length > 0) {
let sorted = response.data.negro.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
@ -1090,7 +1090,7 @@ class Comparador {
.draw()
});
}
if (response.data.color.length > 0) {
if (response.data.color && response.data.color.length > 0) {
let sorted = response.data.color.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
@ -1136,7 +1136,7 @@ class Comparador {
datosComp.data,
{},
(response) => {
if (response.data.rotativa.length > 0) {
if (response.data.rotativa && response.data.rotativa.length > 0) {
let sorted = response.data.rotativa.sort(
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);

View File

@ -265,8 +265,11 @@ class DatosLibro {
const url_parts2 = url2.split('/');
if(url_parts2[url_parts2.length-2] == 'edit'){
$(document).trigger('update-lineas-presupuesto');
//update_servicios(false)
//updateLineasPresupuesto()
/* TO-DO
if(update_tiradas_alternativas)
updatePresupuesto({
update_lineas: true,
@ -283,7 +286,9 @@ class DatosLibro {
update_resumen: false,
update_tiradas_alternativas: false
})
checkInsertar()
*/
}
}

View File

@ -53,6 +53,9 @@ class LineasPresupuesto {
}
});
// Evento para recalcular las lineas de presupuesto
$(document).on('update-lineas-presupuesto', this.updateLineasPresupuesto.bind(this));
$('.insertarLinea').on("click", this.#insertarLineaComparador.bind(this));
$('.paginas-lp').on('change', this.checkPaginasLineasPresupuesto.bind(this));
}
@ -354,6 +357,14 @@ class LineasPresupuesto {
}
updateLineasPresupuesto() {
$('#tableLineasPresupuesto tbody tr:visible ').each(function () {
$('#' + this.id + '_maquina').trigger('change');
})
}
cargarDatos(data) {
const self = this;
@ -1600,6 +1611,7 @@ class LineasPresupuesto {
}
#addEventosLineas(tipoLinea, isInkjet = false) {
const self = this;

View File

@ -8,7 +8,8 @@ class PreviewFormasAdmin{
this.isCosido = $("#isCosido").val();
this.tipoTapa = tipoTapa;
this.preview = new preview(null, tipoLibro, tipoTapa, "thumbnail", data);
// Container para el esquema de cubierta
this.preview = new preview($('#pv_ec_shape'), tipoLibro, tipoTapa, "fullImage", data);
}
setData(data){
@ -68,6 +69,7 @@ class PreviewFormasAdmin{
$('#tab-pv-esquema-cubierta').on( "click", function() {
self.preview.setData(self.data);
self.preview.getObjetoLP('ec', self.isCosido, self.tipoTapa.includes("dura")?1:0);
self.preview.previewEsquemaCubierta('ec', self.isCosido, self.tipoTapa.includes("dura")?1:0);
} );

View File

@ -194,10 +194,10 @@ class PresupuestoCliente {
console.log("Error en el calculo del lomo interior.");
return;
}
if(response.errors.status == 1){
if (response.errors.status == 1) {
popErrorAlert('' + response.errors.value, "sk-alert", false);
}
else{
else {
popAlert2Hide('sk-alert');
}
},
@ -477,6 +477,13 @@ class PresupuestoCliente {
try {
$('#loader').modal('show');
if (this.direcciones.tiradaSeleccionada == null || this.direcciones.tiradaSeleccionada == undefined
|| this.direcciones.tiradaSeleccionada == "" || this.direcciones.tiradaSeleccionada == 0) {
popErrorAlert("Seleccione una tirada en la pestaña direcciones para guardar el presupuesto.");
$('#loader').modal('hide');
return;
}
this.#getDatos();
let datos_to_check = this.#prepareData();
@ -780,16 +787,16 @@ class PresupuestoCliente {
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
try{
try {
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
}
catch(e){
catch (e) {
console.log("Error al cargar diseño interior: " + e);
}
try{
try {
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
}
catch(e){
catch (e) {
console.log("Error al cargar diseño cubierta: " + e);
}