mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Creado concepto de ISK
This commit is contained in:
@ -10,9 +10,10 @@ class Catalogo {
|
||||
|
||||
this.cliente = new ClassSelect($("#clienteId"), '/catalogo/libros/clientlist', "Seleccione un cliente");
|
||||
this.tipo_impresion = $("#tipoImpresion");
|
||||
this.caras_cubierta = $("#compCarasCubierta");
|
||||
|
||||
this.encuadernacion = new ClassSelect($("#encuadernacion"), '/importador/getencuadernacion', "Seleccione una encuadernación");
|
||||
|
||||
|
||||
this.compPapelNegro = new ClassSelect($("#compPapelNegro"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
|
||||
@ -91,10 +92,10 @@ class Catalogo {
|
||||
lomo: 0,
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
this.compSobrecubierta = new ClassSelect($("#compPapelSobrecubierta"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
this.compPapelSobrecubierta = new ClassSelect($("#compPapelSobrecubierta"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
|
||||
{
|
||||
tipo_impresion: this.encuadernacion.getVal(),
|
||||
tirada: () => $('#tirada').val(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#compSolapasSobrecubierta').val(),
|
||||
@ -105,8 +106,8 @@ class Catalogo {
|
||||
this.compGramajeSobrecubierta = new ClassSelect($('#compGramajeSobrecubierta'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
|
||||
{
|
||||
tipo_impresion: () => this.encuadernacion.getVal(),
|
||||
papel_generico: () => this.compPapelCubierta.getVal(),
|
||||
tirada: () => $('#tirada').val(),
|
||||
papel_generico: () => this.compPapelSobrecubierta.getVal(),
|
||||
tirada: () => this.tirada_no_pod,
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => this.getDimensionLibro().alto,
|
||||
sopalas: () => $('#compSolapasSobrecubierta').val(),
|
||||
@ -114,7 +115,7 @@ class Catalogo {
|
||||
tipo: 'colorhq',
|
||||
});
|
||||
|
||||
this.acabadoCubierta = new ClassSelect($("#compAcabadoCubiertaSelected"),
|
||||
this.acabadoCubierta = new ClassSelect($("#compAcabadoCubierta"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
@ -122,7 +123,7 @@ class Catalogo {
|
||||
"cubierta": 1
|
||||
}
|
||||
);
|
||||
this.acabadosSobrecubierta = new ClassSelect($("#compAcabadoSobrecubiertaSelected"),
|
||||
this.acabadosSobrecubierta = new ClassSelect($("#compAcabadoSobrecubierta"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
@ -131,7 +132,8 @@ class Catalogo {
|
||||
}
|
||||
);
|
||||
|
||||
this.openBtn = $('#openOld');
|
||||
this.sobrecubiertaItems = $('.comp_sobrecubierta_items');
|
||||
this.compPaginasSobrecubierta = $('#compSobrecubierta');
|
||||
|
||||
}
|
||||
|
||||
@ -146,6 +148,9 @@ class Catalogo {
|
||||
|
||||
this.cliente.init();
|
||||
this.tipo_impresion.select2();
|
||||
this.caras_cubierta.select2();
|
||||
this.compPaginasSobrecubierta .select2();
|
||||
|
||||
this.encuadernacion.init();
|
||||
|
||||
this.compPapelNegro.init();
|
||||
@ -154,12 +159,15 @@ class Catalogo {
|
||||
this.compGramajeColor.init();
|
||||
this.compPapelCubierta.init();
|
||||
this.compGramajeCubierta.init();
|
||||
this.compSobrecubierta.init();
|
||||
this.compPapelSobrecubierta.init();
|
||||
this.compGramajeSobrecubierta.init();
|
||||
|
||||
this.acabadoCubierta.init();
|
||||
this.acabadosSobrecubierta.init();
|
||||
|
||||
|
||||
// Al cargar la página
|
||||
this.toggleSobrecubiertaFields();
|
||||
|
||||
this.compPapelNegro.item.on('select2:select', function () {
|
||||
self.compGramajeNegro.empty();
|
||||
@ -173,6 +181,9 @@ class Catalogo {
|
||||
// Inicializacino de eventos
|
||||
this.tipo_impresion.on("change", this.updateOpcionesComparador.bind(this));
|
||||
|
||||
// Al cambiar el selector de paginas de sobrecubierta
|
||||
this.compPaginasSobrecubierta.on('change', this.toggleSobrecubiertaFields.bind(this));
|
||||
|
||||
this.updateOpcionesComparador();
|
||||
|
||||
$(document).on('change', '.warning-change', function () {
|
||||
@ -181,7 +192,7 @@ class Catalogo {
|
||||
select2Container.addClass('bg-warning');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
updateOpcionesComparador() {
|
||||
|
||||
@ -241,144 +252,22 @@ class Catalogo {
|
||||
}
|
||||
|
||||
|
||||
|
||||
getDimensionLibro() {
|
||||
let ancho = $('#ancho').val();
|
||||
let alto = $('#alto').val();;
|
||||
return { ancho, alto };
|
||||
}
|
||||
|
||||
|
||||
fillInitialData(data) {
|
||||
|
||||
$('#paginas').val(data.datosGenerales.paginas);
|
||||
$('#tirada').val(data.datosGenerales.tirada);
|
||||
if (data.datosGenerales.papel_formato_personalizado) {
|
||||
$('#papelFormatoPersonalizado').prop('checked', true);
|
||||
$('#tamanio').addClass('d-none');
|
||||
$('#formatoPersonalizado').removeClass('d-none');
|
||||
$('#papelFormatoAncho').val(data.datosGenerales.papel_formato_ancho);
|
||||
$('#papelFormatoAlto').val(data.datosGenerales.papel_formato_alto);
|
||||
}
|
||||
else {
|
||||
$('#tamanio').removeClass('d-none');
|
||||
$('#formatoPersonalizado').addClass('d-none');
|
||||
$('#papelFormatoPersonalizado').prop('checked', false);
|
||||
$('#tamanio').append('<option value="' + data.datosGenerales.papel_formato_id + '" selected>' + data.datosGenerales.papel_formato_texto + '</option>');
|
||||
$('#tamanio').val(data.datosGenerales.papel_formato_id).trigger('change');
|
||||
}
|
||||
|
||||
if (data.encuadernacion) {
|
||||
$('#encuadernacion_old').val(data.encuadernacion.encuadernacionOld);
|
||||
// check if data.encuadernacion.encuadernacion exists and is not empty
|
||||
if (data.encuadernacion.encuadernacion) {
|
||||
this.encuadernacion.setOption(data.encuadernacion.encuadernacion.id, data.encuadernacion.encuadernacion.encuadernacion);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.lineas) {
|
||||
if (data.lineas.isHq) {
|
||||
$('#isHq').val(data.lineas.isHq);
|
||||
}
|
||||
else {
|
||||
$('#isHq').val(0);
|
||||
}
|
||||
|
||||
if (data.lineas.bn && data.lineas.bn.paginas) {
|
||||
$('#compPaginasNegro').val(data.lineas.bn.paginas);
|
||||
$('#compPapelNegroOrigen').val(data.lineas.bn.papel_nombre);
|
||||
this.compGramajeNegro.setOption(parseFloat(data.lineas.bn.gramaje).toFixed(0), parseFloat(data.lineas.bn.gramaje).toFixed(0));
|
||||
this.compPapelNegro.item.prop('disabled', false);
|
||||
this.compPapelNegro.setOption(data.lineas.bn.new_papel_id, data.lineas.bn.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compPaginasNegro').val(0);
|
||||
$('#compPapelNegroOrigen').val("");
|
||||
this.compGramajeNegro.empty();
|
||||
this.compPapelNegro.empty();
|
||||
this.compPapelNegro.item.prop('disabled', true);
|
||||
this.compGramajeNegro.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.lineas.color && data.lineas.color.paginas) {
|
||||
$('#compPaginasColor').val(data.lineas.color.paginas);
|
||||
$('#compPapelColorOrigen').val(data.lineas.color.papel_nombre);
|
||||
this.compGramajeColor.setOption(parseFloat(data.lineas.color.gramaje).toFixed(0), parseFloat(data.lineas.color.gramaje).toFixed(0));
|
||||
this.compPapelColor.item.prop('disabled', false);
|
||||
this.compPapelColor.setOption(data.lineas.color.new_papel_id, data.lineas.color.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compPaginasColor').val(0);
|
||||
$('#compPapelColorOrigen').val("");
|
||||
this.compGramajeColor.empty();
|
||||
this.compPapelColor.empty();
|
||||
this.compPapelColor.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.lineas.cubierta && data.lineas.cubierta.paginas) {
|
||||
$('#compPaginasCubierta').val(data.lineas.cubierta.paginas);
|
||||
$('#compPapelCubiertaOrigen').val(data.lineas.cubierta.papel_nombre);
|
||||
this.compGramajeCubierta.setOption(parseFloat(data.lineas.cubierta.gramaje).toFixed(0), parseFloat(data.lineas.cubierta.gramaje).toFixed(0));
|
||||
$('#compSolapasCubierta').val(parseFloat(data.lineas.cubierta.solapas).toFixed(0));
|
||||
this.compPapelCubierta.item.prop('disabled', false);
|
||||
this.compPapelCubierta.setOption(data.lineas.cubierta.new_papel_id, data.lineas.cubierta.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compPaginasCubierta').val(0);
|
||||
$('#compPapelCubiertaOrigen').val("");
|
||||
this.compGramajeCubierta.empty();
|
||||
$('#compSolapasCubierta').val("");
|
||||
this.compPapelCubierta.empty();
|
||||
this.compPapelCubierta.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.lineas.sobrecubierta && data.lineas.sobrecubierta.paginas) {
|
||||
$('#compSobrecubierta').val(1);
|
||||
$('#compPapelSobrecubiertaOrigen').val(data.lineas.sobrecubierta.papel_nombre);
|
||||
this.compGramajeSobrecubierta.setOption(parseFloat(data.lineas.sobrecubierta.gramaje).toFixed(0), parseFloat(data.lineas.sobrecubierta.gramaje).toFixed(0));
|
||||
$('#compSolapasSobrecubierta').val(parseFloat(data.lineas.sobrecubierta.solapas).toFixed(0));
|
||||
this.compSobrecubierta.item.prop('disabled', false);
|
||||
this.compSobrecubierta.setOption(data.lineas.sobrecubierta.new_papel_id, data.lineas.sobrecubierta.new_papel_nombre);
|
||||
}
|
||||
else {
|
||||
$('#compSobrecubierta').val(0);
|
||||
$('#compPapelSobrecubiertaOrigen').val("");
|
||||
this.compGramajeSobrecubierta.empty();
|
||||
$('#compSolapasSobrecubierta').val("");
|
||||
this.compSobrecubierta.empty();
|
||||
this.compSobrecubierta.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.acabados) {
|
||||
if (data.acabados.cubierta && data.acabados.cubierta.acabadoOld) {
|
||||
$('#compAcabadoCubiertaOrigen').val(data.acabados.cubierta.acabadoOld);
|
||||
this.acabadoCubierta.setOption(data.acabados.cubierta.acabado.id, data.acabados.cubierta.acabado.name);
|
||||
this.acabadoCubierta.item.prop('disabled', false);
|
||||
}
|
||||
else {
|
||||
$('#compAcabadoCubiertaOrigen').val("");
|
||||
this.acabadoCubierta.empty();
|
||||
this.acabadoCubierta.item.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (data.acabados.sobrecubierta && data.acabados.sobrecubierta.acabadoOld) {
|
||||
$('#compAcabadoSobrecubiertaOrigen').val(data.acabados.sobrecubierta.acabadoOld);
|
||||
this.acabadosSobrecubierta.setOption(data.acabados.sobrecubierta.acabado.id, data.acabados.sobrecubierta.acabado.name);
|
||||
this.acabadosSobrecubierta.item.prop('disabled', false);
|
||||
}
|
||||
else {
|
||||
$('#compAcabadoSobrecubiertaOrigen').val("");
|
||||
this.acabadosSobrecubierta.empty();
|
||||
this.acabadosSobrecubierta.item.prop('disabled', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
this.makeImport.prop('disabled', false);
|
||||
toggleSobrecubiertaFields() {
|
||||
if (this.compPaginasSobrecubierta.val() === '1') {
|
||||
this.sobrecubiertaItems.prop('disabled', false).trigger('change.select2');
|
||||
} else {
|
||||
this.sobrecubiertaItems.prop('disabled', true).trigger('change.select2');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
let catalogo = new Catalogo();
|
||||
|
||||
Reference in New Issue
Block a user