mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminados datos generales e interior
This commit is contained in:
@ -5,7 +5,6 @@ class DatosGenerales {
|
||||
constructor(domItem, wizardForm, validatorStepper) {
|
||||
|
||||
this.domItem = domItem;
|
||||
this.allowNext = true;
|
||||
|
||||
this.wizardStep = wizardForm.querySelector('#datos-generales');
|
||||
this.validatorStepper = validatorStepper;
|
||||
@ -78,7 +77,7 @@ class DatosGenerales {
|
||||
|
||||
this.cargando = false;
|
||||
|
||||
this.initValidation();
|
||||
this.errores = [];
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +87,6 @@ class DatosGenerales {
|
||||
this.formatoLibro.init();
|
||||
this.cliente.init();
|
||||
|
||||
|
||||
// Inicializa el tipo de impresion
|
||||
this.#handlePaginas();
|
||||
|
||||
@ -111,303 +109,147 @@ class DatosGenerales {
|
||||
this.retractilado5.on('change', this.#eventRetractilado.bind(this));
|
||||
}
|
||||
|
||||
initValidation() {
|
||||
|
||||
const stepper = this.validatorStepper;
|
||||
validate(goToNext = true) {
|
||||
|
||||
this.formValidation = FormValidation.formValidation(this.wizardStep, {
|
||||
fields: {
|
||||
titulo: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: window.translations["validation"].requerido_short
|
||||
},
|
||||
}
|
||||
},
|
||||
cliente_id: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].cliente,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
if (!$(this.excluirRotativa).prop('hidden'))
|
||||
return true;
|
||||
const options = $("#clienteId").select2('data');
|
||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||
return options !== null && options.length > 0 && hasValidOption;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tirada: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
const value2 = $("#tirada2").val();
|
||||
const value3 = $("#tirada3").val();
|
||||
const value4 = $("#tirada4").val();
|
||||
let tiradas = [value];
|
||||
this.errores = [];
|
||||
|
||||
if (!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)) {
|
||||
return {
|
||||
valid: false,
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
};
|
||||
}
|
||||
if (value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0) {
|
||||
tiradas.push(value2);
|
||||
}
|
||||
if (value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0) {
|
||||
tiradas.push(value3);
|
||||
}
|
||||
if (value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0) {
|
||||
tiradas.push(value4);
|
||||
}
|
||||
// comprobar si hay valores > 30
|
||||
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
||||
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
||||
if (noPOD && siPOD) {
|
||||
return {
|
||||
valid: false,
|
||||
message: "No se pueden mezclar tiradas <30 con >30",
|
||||
}
|
||||
}
|
||||
// Titulo
|
||||
if (this.titulo.val().trim() === '') {
|
||||
this.errores.push(window.translations["validation"].titulo_requerido);
|
||||
this.titulo.addClass('is-invalid');
|
||||
} else {
|
||||
this.titulo.removeClass('is-invalid');
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tirada2: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
let field = $("#tirada2");
|
||||
field.val(field.val().replace(/[^0-9]/g, ''));
|
||||
let value = field.value;
|
||||
if (value == '')
|
||||
return true;
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tirada3: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
let field = $("#tirada3");
|
||||
field.val(field.val().replace(/[^0-9]/g, ''));
|
||||
let value = field.value;
|
||||
if (value == '')
|
||||
return true;
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tirada4: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
let field = $("#tirada4");
|
||||
field.val(field.val().replace(/[^0-9]/g, ''));
|
||||
let value = field.value;
|
||||
if (value == '')
|
||||
return true;
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
papel_formato_id: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].papelFormato,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const options = $("#papelFormatoId").select2('data');
|
||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||
const custom_format = $("#papelFormatoPersonalizado").is(":checked");
|
||||
if (custom_format)
|
||||
return true;
|
||||
return options !== null && options.length > 0 && hasValidOption;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
papel_formato_ancho: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const custom_format = $("#papelFormatoPersonalizado").is(":checked");
|
||||
if (!custom_format)
|
||||
return true;
|
||||
const value = $("#papelFormatoAncho").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
papel_formato_alto: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const custom_format = $("#papelFormatoPersonalizado").is(":checked");
|
||||
if (!custom_format)
|
||||
return true;
|
||||
const value = $("#papelFormatoAlto").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginasColor: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const value = $("#paginasColor").val();
|
||||
if (value.length >= 0 && Number.isInteger(parseInt(value)) && parseInt(value) >= 0) {
|
||||
// Cliente
|
||||
if ($(this.excluirRotativa).prop('hidden')) {
|
||||
if ($('#clienteId').val() === null || $('#clienteId').val().length === 0) {
|
||||
this.errores.push(window.translations["validation"].cliente);
|
||||
$('#clienteId').addClass('is-invalid');
|
||||
} else {
|
||||
$('#clienteId').removeClass('is-invalid');
|
||||
}
|
||||
} else {
|
||||
if (this.cliente.getVal() <= 0) {
|
||||
this.errores.push(window.translations["validation"].cliente);
|
||||
this.cliente.item.addClass('is-invalid');
|
||||
} else {
|
||||
this.cliente.item.removeClass('is-invalid');
|
||||
}
|
||||
}
|
||||
|
||||
if (parseInt(value) % 2 != 0) {
|
||||
return {
|
||||
valid: false,
|
||||
message: window.translations["validation"].paginas_pares
|
||||
};
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginasNegro: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const value = $("#paginasNegro").val();
|
||||
if (value.length >= 0 && Number.isInteger(parseInt(value)) && parseInt(value) >= 0) {
|
||||
// Tirada
|
||||
let tiradas = this.getTiradas();
|
||||
if (tiradas.length === 0 || tiradas.some(tirada =>
|
||||
!Number.isInteger(tirada) ||
|
||||
parseInt(tirada) <= 0 ||
|
||||
tirada == "")) {
|
||||
|
||||
if (parseInt(value) % 2 != 0) {
|
||||
return {
|
||||
valid: false,
|
||||
message: window.translations["validation"].paginas_pares
|
||||
};
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginas: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const value = $("#paginas").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
div_tipo_libro: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const divTipoLibro = $('#divTipoLibro'); // Selecciona el div
|
||||
this.errores.push(window.translations["validation"].tirada_integer_greatherThan_0);
|
||||
this.tirada1.addClass('is-invalid');
|
||||
|
||||
divTipoLibro.find('.fv-plugins-message-container').remove();
|
||||
if ($('.tipo-libro.selected').length > 0) {
|
||||
if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) {
|
||||
const value = parseInt($("#paginas").val());
|
||||
if (value % 4 != 0) {
|
||||
divTipoLibro.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_tipo_libro" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].paginas_multiplo_4}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
this.tirada1.removeClass('is-invalid');
|
||||
// Comprobar tiradas POD
|
||||
const noPOD = tiradas.some(tirada => parseInt(tirada) > 30);
|
||||
const siPOD = tiradas.some(tirada => parseInt(tirada) <= 30);
|
||||
if (noPOD && siPOD) {
|
||||
this.errores.push(window.translations["validation"].tirada_pod_nopod);
|
||||
this.tirada1.addClass('is-invalid');
|
||||
}
|
||||
else {
|
||||
this.tirada1.removeClass('is-invalid');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
divTipoLibro.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_tipo_libro" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].tipo_libro}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
// formato libro
|
||||
if (this.checkFormatoPersonalizado.is(':checked')) {
|
||||
if (this.anchoPersonalizado.val().length === 0 || isNaN(this.anchoPersonalizado.val()) ||
|
||||
parseFloat(this.anchoPersonalizado.val()) <= 0) {
|
||||
this.errores.push(window.translations["validation"].papelFormatoAncho);
|
||||
this.anchoPersonalizado.addClass('is-invalid');
|
||||
} else {
|
||||
this.anchoPersonalizado.removeClass('is-invalid');
|
||||
}
|
||||
if (this.altoPersonalizado.val().length === 0 || isNaN(this.altoPersonalizado.val()) ||
|
||||
parseFloat(this.altoPersonalizado.val()) <= 0) {
|
||||
this.errores.push(window.translations["validation"].papelFormatoAlto);
|
||||
this.altoPersonalizado.addClass('is-invalid');
|
||||
} else {
|
||||
this.altoPersonalizado.removeClass('is-invalid');
|
||||
}
|
||||
} else {
|
||||
const options = $("#papelFormatoId").select2('data');
|
||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||
if (options !== null && options.length > 0 && hasValidOption) {
|
||||
this.papelFormatoId.removeClass('is-invalid');
|
||||
} else {
|
||||
this.errores.push(window.translations["validation"].papelFormato);
|
||||
this.papelFormatoId.addClass('is-invalid');
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
// Paginas
|
||||
if (this.paginasColor.val() == '' || isNaN(this.paginasColor.val()) || parseInt(this.paginasColor.val()) < 0) {
|
||||
this.errores.push(window.translations["validation"].paginasColor);
|
||||
this.paginasColor.addClass('is-invalid');
|
||||
} else {
|
||||
this.paginasColor.removeClass('is-invalid');
|
||||
}
|
||||
if (this.paginasNegro.val() == '' || isNaN(this.paginasNegro.val()) || parseInt(this.paginasNegro.val()) < 0) {
|
||||
this.errores.push(window.translations["validation"].paginasNegro);
|
||||
this.paginasNegro.addClass('is-invalid');
|
||||
} else {
|
||||
this.paginasNegro.removeClass('is-invalid');
|
||||
}
|
||||
if (this.paginas.val() == '' || isNaN(this.paginas.val()) || parseInt(this.paginas.val()) <= 0) {
|
||||
this.errores.push(window.translations["validation"].paginas);
|
||||
this.paginas.addClass('is-invalid');
|
||||
} else {
|
||||
this.paginas.removeClass('is-invalid');
|
||||
}
|
||||
|
||||
// Tipo de libro
|
||||
if ($('.tipo-libro.selected').length > 0) {
|
||||
if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) {
|
||||
const value = parseInt($("#paginas").val());
|
||||
if (value % 4 != 0) {
|
||||
if (parseInt(this.paginas.val()) % 4 != 0) {
|
||||
this.errores.push(window.translations["validation"].paginas_multiplo_4);
|
||||
this.paginas.addClass('is-invalid');
|
||||
} else {
|
||||
this.paginas.removeClass('is-invalid');
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: function (field, ele) {
|
||||
// field is the field name
|
||||
// ele is the field element
|
||||
switch (field) {
|
||||
case 'div_tipo_libro':
|
||||
return '.col-sm-10';
|
||||
case 'titulo':
|
||||
return '.col-sm-8';
|
||||
case 'cliente_id':
|
||||
return '.col-sm-5';
|
||||
case 'papel_formato_id':
|
||||
return '.col-sm-4';
|
||||
case 'papel_formato_ancho':
|
||||
case 'papel_formato_ancho':
|
||||
return '.col-sm-3';
|
||||
case 'tirada':
|
||||
case 'tirada2':
|
||||
case 'tirada3':
|
||||
case 'tirada4':
|
||||
return '.col-sm-2';
|
||||
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
}
|
||||
}
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', () => {
|
||||
if (this.allowNext)
|
||||
this.domItem.find('#divTipoLibro').removeClass('is-invalid');
|
||||
} else {
|
||||
this.errores.push(window.translations["validation"].tipo_libro);
|
||||
this.domItem.find('#divTipoLibro').addClass('is-invalid');
|
||||
}
|
||||
|
||||
stepper.next();
|
||||
});
|
||||
const skAlert = document.getElementById('sk-alert');
|
||||
skAlert.innerHTML = '';
|
||||
const uniqueErrors = [...new Set(this.errores)];
|
||||
|
||||
if (uniqueErrors.length > 0) {
|
||||
const message = window.translations["validation"].fix_errors +
|
||||
`<ul class="mb-0">
|
||||
${uniqueErrors.map(err => `<li>${err}</li>`).join('')}
|
||||
</ul>`;
|
||||
popErrorAlert(message, 'sk-alert', false);
|
||||
this.errores = [];
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
document.getElementById('sk-alert').innerHTML = '';
|
||||
this.errores = [];
|
||||
if (goToNext)
|
||||
this.validatorStepper.next();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -425,11 +267,11 @@ class DatosGenerales {
|
||||
else {
|
||||
this.rl_tipo.addClass('d-none');
|
||||
}
|
||||
if($('.tipo-cubierta.selected').length>0){
|
||||
if ($('.tipo-cubierta.selected').length > 0) {
|
||||
this.rl_tipo_cubierta.text($($('.tipo-cubierta.selected').find('.form-label')).text());
|
||||
this.rl_tipo_cubierta.removeClass('d-none');
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_tipo_cubierta.addClass('d-none');
|
||||
}
|
||||
if (this.checkFormatoPersonalizado.is(':checked')) {
|
||||
@ -478,33 +320,9 @@ class DatosGenerales {
|
||||
|
||||
// servicios extra
|
||||
menu_off = true;
|
||||
/*if(this.prototipo.is(':checked')){
|
||||
this.rl_prototipo.removeClass("d-none");
|
||||
menu_off = false;
|
||||
}
|
||||
else{
|
||||
this.rl_prototipo.addClass('d-none');
|
||||
}
|
||||
|
||||
if(this.ferro.is(':checked')){
|
||||
this.rl_ferro.removeClass("d-none");
|
||||
menu_off = false;
|
||||
}
|
||||
else{
|
||||
this.rl_ferro.addClass('d-none');
|
||||
}
|
||||
|
||||
if(this.ferroDigital.is(':checked')){
|
||||
this.rl_ferroDigital.removeClass("d-none");
|
||||
menu_off = false;
|
||||
}
|
||||
else{
|
||||
this.rl_ferroDigital.addClass('d-none');
|
||||
}
|
||||
*/
|
||||
$('#rl-servicios-extra-items').empty();
|
||||
|
||||
if(this.marcapaginas.is(':checked')){
|
||||
if (this.marcapaginas.is(':checked')) {
|
||||
let $ul = $('<ul>', {
|
||||
class: 'list-group list-group-timeline'
|
||||
});
|
||||
@ -519,7 +337,7 @@ class DatosGenerales {
|
||||
menu_off = false;
|
||||
}
|
||||
|
||||
if(this.retractilado.is(':checked')){
|
||||
if (this.retractilado.is(':checked')) {
|
||||
let $ul = $('<ul>', {
|
||||
class: 'list-group list-group-timeline'
|
||||
});
|
||||
@ -534,7 +352,7 @@ class DatosGenerales {
|
||||
menu_off = false;
|
||||
}
|
||||
|
||||
if(this.retractilado5.is(':checked')){
|
||||
if (this.retractilado5.is(':checked')) {
|
||||
let $ul = $('<ul>', {
|
||||
class: 'list-group list-group-timeline'
|
||||
});
|
||||
@ -550,7 +368,7 @@ class DatosGenerales {
|
||||
}
|
||||
|
||||
const serviciosExtra = $('input[type="checkbox"][data-tarifa-tipo="extra"]:checked');
|
||||
for(let i=0; i<serviciosExtra.length; i++){
|
||||
for (let i = 0; i < serviciosExtra.length; i++) {
|
||||
let $ul = $('<ul>', {
|
||||
class: 'list-group list-group-timeline'
|
||||
});
|
||||
@ -564,10 +382,10 @@ class DatosGenerales {
|
||||
$('#rl-servicios-extra-items').append($ul);
|
||||
}
|
||||
|
||||
if(!menu_off){
|
||||
if (!menu_off) {
|
||||
this.rl_servicios_extra.removeClass('d-none');
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_servicios_extra.addClass('d-none');
|
||||
}
|
||||
|
||||
@ -588,7 +406,7 @@ class DatosGenerales {
|
||||
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
|
||||
this.cliente.setVal(datos.clienteId);
|
||||
|
||||
if(datos.selectedTirada){
|
||||
if (datos.selectedTirada) {
|
||||
this.selectedTirada = datos.selectedTirada;
|
||||
}
|
||||
$(this.cliente).trigger('change');
|
||||
@ -609,7 +427,6 @@ class DatosGenerales {
|
||||
this.checkFormatoPersonalizado.prop('checked', true);
|
||||
this.formatoEstandar.addClass('d-none');
|
||||
this.formatoPersonalizado.removeClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_id');
|
||||
this.altoPersonalizado.val(datos.papelFormatoAlto);
|
||||
this.anchoPersonalizado.val(datos.papelFormatoAncho);
|
||||
}
|
||||
@ -636,17 +453,17 @@ class DatosGenerales {
|
||||
this.tiposLibro.find('.image-presupuesto').removeClass('selected');
|
||||
this.domItem.find('#' + datos.tipo).addClass('selected');
|
||||
|
||||
if(datos.tipo == 'cosido'){
|
||||
if (datos.tipo == 'cosido') {
|
||||
this.divPaginasCuaderillo.removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(datos.serviciosExtra){
|
||||
if (datos.serviciosExtra) {
|
||||
|
||||
let serviciosExtra = $('input[type="checkbox"][data-tarifa-tipo="extra"]');
|
||||
|
||||
$(serviciosExtra).each(function() {
|
||||
$(serviciosExtra).each(function () {
|
||||
let tarifaId = $(this).data('tarifa-id') + "";
|
||||
|
||||
if (datos.serviciosExtra.includes(tarifaId)) {
|
||||
@ -654,10 +471,6 @@ class DatosGenerales {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//this.prototipo.prop('checked', datos.prototipo);
|
||||
//this.ferro.prop('checked', datos.ferro);
|
||||
//this.ferroDigital.prop('checked', datos.ferroDigital);
|
||||
this.marcapaginas.prop('checked', datos.marcapaginas);
|
||||
this.retractilado.prop('checked', datos.retractilado);
|
||||
this.retractilado5.prop('checked', datos.retractilado5);
|
||||
@ -702,11 +515,11 @@ class DatosGenerales {
|
||||
getTiradas() {
|
||||
let tiradas = [];
|
||||
tiradas.push(parseInt(this.tirada1.val()));
|
||||
if (this.tirada2.val().length > 0 && parseInt(this.tirada2.val()) > 0)
|
||||
if (this.tirada2.val().length > 0)
|
||||
tiradas.push(parseInt(this.tirada2.val()));
|
||||
if (this.tirada3.val().length > 0 && parseInt(this.tirada3.val()) > 0)
|
||||
if (this.tirada3.val().length > 0)
|
||||
tiradas.push(parseInt(this.tirada3.val()));
|
||||
if (this.tirada4.val().length > 0 && parseInt(this.tirada4.val()) > 0)
|
||||
if (this.tirada4.val().length > 0)
|
||||
tiradas.push(parseInt(this.tirada4.val()));
|
||||
return tiradas;
|
||||
}
|
||||
@ -725,21 +538,18 @@ class DatosGenerales {
|
||||
if (this.checkFormatoPersonalizado.is(':checked')) {
|
||||
this.formatoEstandar.addClass('d-none');
|
||||
this.formatoPersonalizado.removeClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_id');
|
||||
}
|
||||
else {
|
||||
this.formatoEstandar.removeClass('d-none');
|
||||
this.formatoPersonalizado.addClass('d-none');
|
||||
this.formValidation.revalidateField('papel_formato_ancho');
|
||||
this.formValidation.revalidateField('papel_formato_alto');
|
||||
}
|
||||
const alto = this.getDimensionLibro().alto;
|
||||
$('#altoFaja').closest('.config-faja').find('.form-text').text('Entre 50 y ' + alto + ' mm');
|
||||
}
|
||||
|
||||
#checkValue(event){
|
||||
#checkValue(event) {
|
||||
let target = event.target;
|
||||
if(target.value < target.min){
|
||||
if (target.value < target.min) {
|
||||
target.value = target.min;
|
||||
}
|
||||
}
|
||||
@ -800,8 +610,6 @@ class DatosGenerales {
|
||||
}
|
||||
}
|
||||
|
||||
this.checkPaginasMultiplo4();
|
||||
|
||||
// Para recalcular el presupuesto
|
||||
element.trigger('change');
|
||||
}
|
||||
@ -844,7 +652,6 @@ class DatosGenerales {
|
||||
else {
|
||||
this.domItem.find('#grapado').show();
|
||||
}
|
||||
this.formValidation.revalidateField('paginas');
|
||||
|
||||
// Se configura dependiento si hay color o no
|
||||
const lastLayoutColor = $('#negroEstandar').hasClass('d-none');
|
||||
@ -856,7 +663,7 @@ class DatosGenerales {
|
||||
this.posPaginasColor.val("");
|
||||
this.pagColorConsecutivas.prop('checked', false);
|
||||
|
||||
if(lastLayoutColor && !this.cargando){
|
||||
if (lastLayoutColor && !this.cargando) {
|
||||
|
||||
$('#divPapelInterior').empty();
|
||||
$('#divGramajeInterior').empty();
|
||||
@ -871,7 +678,7 @@ class DatosGenerales {
|
||||
this.divPaginasColorConsecutivas.removeClass('d-none');
|
||||
this.divPosPaginasColor.removeClass('d-none');
|
||||
|
||||
if(!lastLayoutColor && !this.cargando){
|
||||
if (!lastLayoutColor && !this.cargando) {
|
||||
|
||||
$('#divPapelInterior').empty();
|
||||
$('#divGramajeInterior').empty();
|
||||
@ -880,29 +687,6 @@ class DatosGenerales {
|
||||
}
|
||||
|
||||
$('.calcular-lomo').trigger('change');
|
||||
|
||||
this.checkPaginasMultiplo4();
|
||||
}
|
||||
|
||||
checkPaginasMultiplo4(){
|
||||
|
||||
const divTipoLibro = $('#divTipoLibro'); // Selecciona el div
|
||||
divTipoLibro.find('.fv-plugins-message-container').remove();
|
||||
|
||||
if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) {
|
||||
const value = parseInt($("#paginas").val());
|
||||
if (value % 4 != 0) {
|
||||
divTipoLibro.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_tipo_libro" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].paginas_multiplo_4}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -982,7 +766,7 @@ class DatosGenerales {
|
||||
|
||||
let servicios = [];
|
||||
|
||||
$(serviciosExtra).each(function() {
|
||||
$(serviciosExtra).each(function () {
|
||||
let tarifaId = $(this).data('tarifa-id');
|
||||
if (tarifaId) {
|
||||
servicios.push(tarifaId);
|
||||
|
||||
Reference in New Issue
Block a user