mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
papel y gramaje sobrecubierta y guardas seleccionable
This commit is contained in:
@ -4,11 +4,12 @@
|
||||
* @param {String} url
|
||||
* @param {String} placeholder
|
||||
*/
|
||||
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "") {
|
||||
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "", hideSearch = false) {
|
||||
this.url = url;
|
||||
this.item = domItem;
|
||||
this.params = params;
|
||||
this.dropdownParent = dropdownParent;
|
||||
this.hideSearch = hideSearch;
|
||||
|
||||
this.config = {
|
||||
placeholder: placeholder,
|
||||
@ -48,6 +49,11 @@ let ClassSelect = function (domItem, url, placeholder, allowClear = false, param
|
||||
};
|
||||
this.init = function () {
|
||||
if (this.item.length) {
|
||||
|
||||
if(this.hideSearch){
|
||||
this.config.minimumResultsForSearch = -1;
|
||||
}
|
||||
|
||||
this.item = this.item.select2(this.config);
|
||||
// $.fn.modal.Constructor.prototype.enforceFocus = function () {};
|
||||
}
|
||||
|
||||
@ -58,7 +58,43 @@ class DisenioCubierta {
|
||||
this.textoSolapasCubierta = this.domItem.find("#textoSolapasCubierta");
|
||||
this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta"));
|
||||
|
||||
this.papelGuardas = this.domItem.find("#papelGuardas");
|
||||
this.papelGuardas = new ClassSelect($("#papelGuardas"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectPapel"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: () => 'colorhq',
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
|
||||
solapas: 0,
|
||||
lomo: 0,
|
||||
guardas: 1,
|
||||
forSelect2: 1,
|
||||
},
|
||||
"",
|
||||
true,
|
||||
);
|
||||
this.gramajeGuardas = new ClassSelect($("#gramajeGuardas"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectGramaje"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
papel: () => { return this.papelGuardas.getVal() },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return $('#altoFaja').val() },
|
||||
solapas: 0,
|
||||
lomo: 0,
|
||||
guardas: 1,
|
||||
forSelect2: 1,
|
||||
},
|
||||
"",
|
||||
true
|
||||
);
|
||||
this.guardasImpresas = this.domItem.find("#guardasImpresas");
|
||||
this.cabezada = this.domItem.find("#cabezada");
|
||||
|
||||
@ -72,7 +108,43 @@ class DisenioCubierta {
|
||||
|
||||
this.configuracionSobrecubierta = this.domItem.find(".config-sobrecubierta");
|
||||
this.sobrecubierta = this.domItem.find("#addSobrecubierta");
|
||||
this.papelSobrecubierta = this.domItem.find("#papelSobrecubierta");
|
||||
this.papelSobrecubierta = new ClassSelect($("#papelSobrecubierta"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectPapel"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
sobrecubierta: 1,
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
|
||||
solapas: () => { return $('#solapasSobrecubierta').val() },
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
},
|
||||
"",
|
||||
true,
|
||||
);
|
||||
this.gramajeSobrecubierta = new ClassSelect($("#gramajeSobrecubierta"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
window.translations["selectPapel"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
sobrecubierta: 1,
|
||||
papel: () => { return this.papelSobrecubierta.getVal() },
|
||||
ancho: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho },
|
||||
alto: () => { return this.presupuestoCliente.datosGenerales.getDimensionLibro().alto },
|
||||
solapas: () => { return $('#solapasSobrecubierta').val() },
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
},
|
||||
"",
|
||||
true,
|
||||
);
|
||||
this.acabadoSobrecubierta = this.domItem.find("#acabadoSobrecubierta");
|
||||
|
||||
this.configuracionFaja = this.domItem.find(".config-faja");
|
||||
@ -91,7 +163,9 @@ class DisenioCubierta {
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
}
|
||||
},
|
||||
"",
|
||||
true,
|
||||
);
|
||||
this.gramajeFaja = new ClassSelect($("#gramajeFaja"),
|
||||
'/papelesgenericos/getpapelcliente',
|
||||
@ -108,7 +182,9 @@ class DisenioCubierta {
|
||||
lomo: () => { return parseFloat($('#lsc').val()) + parseFloat($('#lc').val()) },
|
||||
tirada: () => { return this.presupuestoCliente.datosGenerales.getTiradas()[0] },
|
||||
forSelect2: 1,
|
||||
}
|
||||
},
|
||||
"",
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
@ -201,6 +277,12 @@ class DisenioCubierta {
|
||||
this.acabadoSobrecubierta.init();
|
||||
this.acabadoFaja.init();
|
||||
|
||||
this.papelGuardas.init();
|
||||
this.gramajeGuardas.init();
|
||||
|
||||
this.papelSobrecubierta.init();
|
||||
this.gramajeSobrecubierta.init();
|
||||
|
||||
this.papelFaja.init();
|
||||
this.gramajeFaja.init();
|
||||
|
||||
@ -228,6 +310,8 @@ class DisenioCubierta {
|
||||
|
||||
this.papelFaja.item.on('change', () => { this.gramajeFaja.empty(); });
|
||||
|
||||
this.papelGuardas.item.on('change', () => { this.gramajeGuardas.empty(); });
|
||||
|
||||
// Observadores
|
||||
this.observer.observe(this.tapaBlanda[0], { attributes: true });
|
||||
this.observer.observe(this.tapaDuraLomoRecto[0], { attributes: true });
|
||||
@ -255,7 +339,8 @@ class DisenioCubierta {
|
||||
}
|
||||
|
||||
if (datosCubierta.tapa == "dura") {
|
||||
this.papelGuardas.val(datosGuardas.papel.code + "_" + datosGuardas.gramaje).trigger('change');
|
||||
this.papelGuardas.setOption(datosGuardas.papel_id, datosGuardas.papel);
|
||||
this.gramajeGuardas.setOption(datosGuardas.gramaje, datosGuardas.gramaje);
|
||||
this.guardasImpresas.val(datosGuardas.paginas).trigger('change');
|
||||
this.cabezada.val(datosCubierta.cabezada).trigger('change');
|
||||
}
|
||||
@ -281,7 +366,8 @@ class DisenioCubierta {
|
||||
|
||||
if (datosSobrecubierta && datosSobrecubierta.papel) {
|
||||
this.sobrecubierta.trigger('click');
|
||||
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
|
||||
this.papelSobrecubierta.setOption(datosSobrecubierta.papel_id, datosSobrecubierta.papel);
|
||||
this.gramajeSobrecubierta.setOption(datosSobrecubierta.gramaje, datosSobrecubierta.gramaje);
|
||||
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
|
||||
this.acabadoSobrecubierta.setOption(datosSobrecubierta.acabado.id, datosSobrecubierta.acabado.text);
|
||||
}
|
||||
@ -432,6 +518,37 @@ class DisenioCubierta {
|
||||
}
|
||||
}
|
||||
},
|
||||
div_config_tapa_dura: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
|
||||
const div = $('#divConfigTapaDura'); // Selecciona el div
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
|
||||
if ($('divConfigTapaDura').hasClass('d-none'))
|
||||
return true;
|
||||
|
||||
const papelGuardas = $('#papelGuardas').select2('data').length > 0;
|
||||
const gramajeGuardas = $('#gramajeGuardas').select2('data').length > 0;
|
||||
if (papelGuardas && gramajeGuardas) {
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
div.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].extras_cubierta}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
div_extras: {
|
||||
validators: {
|
||||
callback: {
|
||||
@ -440,22 +557,33 @@ class DisenioCubierta {
|
||||
const div = $('#divExtras'); // Selecciona el div
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
|
||||
if($("#addFaja").prop("checked") == false)
|
||||
return true;
|
||||
const papelFaja = $('#papelFaja').select2('data').length > 0;
|
||||
const gramajeFaja = $('#gramajeFaja').select2('data').length > 0;
|
||||
if (papelFaja && gramajeFaja) {
|
||||
return true;
|
||||
let error = false;
|
||||
|
||||
if ($("#addFaja").prop("checked") == true) {
|
||||
const papelFaja = $('#papelFaja').select2('data').length > 0;
|
||||
const gramajeFaja = $('#gramajeFaja').select2('data').length > 0;
|
||||
if (!papelFaja || !gramajeFaja) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if ($("#addSobrecubierta").prop("checked") == true) {
|
||||
const papelSobrecubierta = $('#papelSobrecubierta').select2('data').length > 0;
|
||||
const gramajeSobrecubierta = $('#gramajeSobrecubierta').select2('data').length > 0;
|
||||
if (!papelSobrecubierta || !gramajeSobrecubierta) {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (error) {
|
||||
div.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].extras_cubierta}
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].extras_cubierta}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -478,6 +606,7 @@ class DisenioCubierta {
|
||||
case 'div_papel_cubierta':
|
||||
case 'div_gramaje_cubierta':
|
||||
case 'div_papel_especial_cubierta':
|
||||
case 'div_config_tapa_dura':
|
||||
return '.col-sm-10';
|
||||
case 'div_extras':
|
||||
return '.col-sm-12';
|
||||
@ -675,15 +804,13 @@ class DisenioCubierta {
|
||||
let guardas = {};
|
||||
|
||||
if (forResumen) {
|
||||
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").text();
|
||||
guardas.papel = papelGuardas.split(' ')[0] + ' ' + papelGuardas.split(' ')[1];
|
||||
guardas.gramaje = papelGuardas.split(' ')[2];
|
||||
guardas.papel = this.papelGuardas.getText();
|
||||
guardas.gramaje = this.gramajeGuardas.getText();
|
||||
guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").text();
|
||||
}
|
||||
else {
|
||||
let papelGuardas = this.domItem.find("#papelGuardas").children("option:selected").val();
|
||||
guardas.papel = papelGuardas.split('_')[0];
|
||||
guardas.gramaje = papelGuardas.split('_')[1];
|
||||
guardas.papel = this.papelGuardas.getVal();
|
||||
guardas.gramaje = this.gramajeGuardas.getVal();
|
||||
guardas.caras = this.domItem.find("#guardasImpresas").children("option:selected").val();
|
||||
}
|
||||
return guardas;
|
||||
@ -703,18 +830,16 @@ class DisenioCubierta {
|
||||
else {
|
||||
if (forResumen) {
|
||||
let sobrecubierta = {};
|
||||
const papel = this.domItem.find("#papelSobrecubierta").children("option:selected").text();
|
||||
sobrecubierta.papel = papel.split(' ')[0] + ' ' + papel.split(' ')[1];
|
||||
sobrecubierta.gramaje = papel.split(' ')[2];
|
||||
sobrecubierta.papel = this.papelSobrecubierta.getText();
|
||||
sobrecubierta.gramaje = this.gramajeSobrecubierta.getText();
|
||||
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
|
||||
sobrecubierta.acabado = this.acabadoSobrecubierta.getText();
|
||||
return sobrecubierta;
|
||||
}
|
||||
else {
|
||||
let sobrecubierta = {};
|
||||
let papel = this.domItem.find("#papelSobrecubierta").children("option:selected").val();
|
||||
sobrecubierta.papel = papel.split('_')[0];
|
||||
sobrecubierta.gramaje = papel.split('_')[1];
|
||||
sobrecubierta.papel = this.papelSobrecubierta.getVal();
|
||||
sobrecubierta.gramaje = this.gramajeSobrecubierta.getVal();
|
||||
sobrecubierta.solapas = this.domItem.find("#solapasSobrecubierta").val();
|
||||
sobrecubierta.acabado = this.acabadoSobrecubierta.getVal();
|
||||
return sobrecubierta;
|
||||
|
||||
Reference in New Issue
Block a user