mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into refactor/messages-view
This commit is contained in:
@ -1,20 +1,44 @@
|
||||
import { getToken } from '../../common/common.js';
|
||||
import { capitalizeFirstLetter } from '../../common/common.js';
|
||||
|
||||
import Ajax from '../../components/ajax.js';
|
||||
import ClassSelect from '../../components/select2.js';
|
||||
|
||||
|
||||
class DisenioCubierta {
|
||||
|
||||
constructor(domItem, wizardForm, validatorStepper) {
|
||||
|
||||
constructor(domItem, wizardForm, validatorStepper, presupuestoCliente) {
|
||||
|
||||
this.domItem = domItem;
|
||||
this.allowNext = true;
|
||||
|
||||
this.presupuestoCliente = presupuestoCliente;
|
||||
|
||||
this.csrf_token = getToken();
|
||||
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||
|
||||
this.wizardStep = wizardForm.querySelector('#cubierta-libro');
|
||||
this.validatorStepper = validatorStepper;
|
||||
|
||||
this.disenioCubierta = this.domItem.find(".tipo-cubierta");
|
||||
this.solapasCubierta = this.domItem.find(".solapas-cubierta");
|
||||
this.papelCubierta = this.domItem.find(".papel-cubierta");
|
||||
this.textoPapelCubierta = this.domItem.find("#textoPapelCubierta");
|
||||
|
||||
this.divPapelEspecial = this.domItem.find("#divPapelEspecialCubierta");
|
||||
this.papelEspecial = new ClassSelect($("#papelEspecialCubiertaSel"),
|
||||
'/papelesgenericos/selectpapelespecial',
|
||||
window.translations["selectPapel"],
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
}
|
||||
);
|
||||
|
||||
this.divSolapas = this.domItem.find("#divSolapasCubierta");
|
||||
this.divCarasImpresion = this.domItem.find("#divCarasImpresion");
|
||||
this.divConfigGuardas = this.domItem.find("#divConfigGuardas");
|
||||
this.divConfigGuardas = this.domItem.find("#divConfigTapaDura");
|
||||
|
||||
this.carasCubierta = this.domItem.find("#carasCubierta");
|
||||
|
||||
@ -25,6 +49,7 @@ class DisenioCubierta {
|
||||
this.sinSolapas = this.domItem.find("#solapasCubiertaNo");
|
||||
this.conSolapas = this.domItem.find("#solapasCubiertaSi");
|
||||
this.divTamanioSolapas = this.domItem.find("#divTamanioSolapas");
|
||||
this.textoSolapasCubierta = this.domItem.find("#textoSolapasCubierta");
|
||||
this.tamanioSolapasCubierta = $(this.domItem.find("#solapasCubierta"));
|
||||
|
||||
this.papelGuardas = this.domItem.find("#papelGuardas");
|
||||
@ -35,16 +60,7 @@ class DisenioCubierta {
|
||||
this.estucadoMate = this.domItem.find("#estucadoMate");
|
||||
|
||||
this.divPapelCubierta = this.domItem.find("#divPapelCubierta");
|
||||
|
||||
this.divGramajeCubierta = this.domItem.find("#divGramajeCubierta");
|
||||
this.gramaje = this.domItem.find(".check-gramaje-cubierta");
|
||||
this.gramaje170 = $(this.domItem.find("#divGramaje170Cubierta"));
|
||||
this.gramaje250 = $(this.domItem.find("#divGramaje250Cubierta"));
|
||||
this.gramaje270 = $(this.domItem.find("#divGramaje270Cubierta"));
|
||||
this.gramaje300 = $(this.domItem.find("#divGramaje300Cubierta"));
|
||||
this.gramaje350 = $(this.domItem.find("#divGramaje350Cubierta"));
|
||||
|
||||
this.checksGramaje = $('.check-gramaje-cubierta');
|
||||
|
||||
this.cubiertaPlastificado = this.domItem.find("#plastificado");
|
||||
this.cubiertaBarniz = this.domItem.find("#barniz");
|
||||
@ -60,6 +76,7 @@ class DisenioCubierta {
|
||||
this.faja = this.domItem.find("#addFaja");
|
||||
|
||||
this.solapasSobrecubierta = this.domItem.find("#solapasSobrecubierta");
|
||||
this.textoSolapasSobrecubierta = this.domItem.find("#textoLimitesSolapasSobrecubierta");
|
||||
this.solapasFaja = this.domItem.find("#solapasFaja");
|
||||
this.altoFaja = this.domItem.find("#altoFaja");
|
||||
|
||||
@ -91,12 +108,14 @@ class DisenioCubierta {
|
||||
else if (targetElement.classList.contains('solapas-cubierta')) {
|
||||
this.#handleMenuSolapas();
|
||||
}
|
||||
else if (targetElement.classList.contains('papel-cubierta')) {
|
||||
this.#handleMenuPapel();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.papelCubierta = null;
|
||||
this.gramaje = null;
|
||||
|
||||
this.cargando = true;
|
||||
}
|
||||
|
||||
|
||||
@ -104,10 +123,12 @@ class DisenioCubierta {
|
||||
|
||||
const self = this;
|
||||
|
||||
this.papelEspecial.init();
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
|
||||
// Eventos
|
||||
this.disenioCubierta.on('click', this.#handleDisenioCubierta.bind(this));
|
||||
this.solapasCubierta.on('click', this.#handleSolapasCubierta.bind(this));
|
||||
this.papelCubierta.on('click', this.#handlePapelCubierta.bind(this));
|
||||
this.tamanioSolapasCubierta.on('change', this.#handleTamanioSolapas.bind(this));
|
||||
this.altoFaja.on('blur', this.#handleInputs);
|
||||
this.solapasSobrecubierta.on('blur', this.#handleInputs);
|
||||
@ -129,23 +150,16 @@ class DisenioCubierta {
|
||||
this.observer.observe(this.tapaBlanda[0], { attributes: true });
|
||||
this.observer.observe(this.tapaDuraLomoRecto[0], { attributes: true });
|
||||
this.observer.observe(this.tapaDuraLomoRedondo[0], { attributes: true });
|
||||
this.observer.observe(this.cartulinaEstucada[0], { attributes: true });
|
||||
this.observer.observe(this.estucadoMate[0], { attributes: true });
|
||||
this.observer.observe(this.conSolapas[0], { attributes: true });
|
||||
this.observer.observe(this.sinSolapas[0], { attributes: true });
|
||||
|
||||
this.checksGramaje.each(function () {
|
||||
|
||||
const customOptionEL = $(this);
|
||||
customOptionEL.on('click', function () {
|
||||
self.#handleClickGramaje(customOptionEL);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datosCubierta, datosGuardas, datosSobrecubierta) {
|
||||
|
||||
this.papelCubierta = datosCubierta.papel.id;
|
||||
this.gramaje = datosCubierta.gramaje;
|
||||
|
||||
if (datosCubierta.lomoRedondo) {
|
||||
this.tapaDuraLomoRedondo.trigger('click');
|
||||
}
|
||||
@ -259,17 +273,19 @@ class DisenioCubierta {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const div = $('#divPapelCubierta');
|
||||
if (div.hasClass("d-none")) return true;
|
||||
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
if ($('.papel-cubierta.selected').length > 0) {
|
||||
$('#divPapelCubierta').find('.fv-plugins-message-container').remove();
|
||||
$('#divPapelEspecialCubierta').find('.fv-plugins-message-container').remove();
|
||||
|
||||
const papelSeleccionado = $('.custom-selector-papel-cubierta input[type="radio"]:checked');
|
||||
if (papelSeleccionado.length > 0) {
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
div.append(`
|
||||
$('#divPapelCubierta').append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_papel_cubierta" data-validator="callback" style="margin-top: 50px;">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].papel_interior}
|
||||
</div>
|
||||
</div>
|
||||
@ -280,20 +296,48 @@ class DisenioCubierta {
|
||||
}
|
||||
}
|
||||
},
|
||||
div_papel_especial_cubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
|
||||
$('#divPapelEspecialCubierta').find('.fv-plugins-message-container').remove();
|
||||
if ($('#divPapelEspecialCubierta').hasClass("d-none")) return true;
|
||||
|
||||
if ($('#papelEspecialCubiertaSel').select2('data').length > 0)
|
||||
return true;
|
||||
else {
|
||||
$('#divPapelEspecialCubierta').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"].papel_interior}
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
div_gramaje_cubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const div = $('#divGramajeCubierta'); // Selecciona el div
|
||||
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
if ($('.check-gramaje-cubierta:checked').length > 0) {
|
||||
const divGramajeInterior = $('#divGramajeCubierta'); // Selecciona el div
|
||||
divGramajeInterior.find('.fv-plugins-message-container').remove();
|
||||
|
||||
const gramajeSeleccionado = $('.custom-selector-gramaje-cubierta input[type="radio"]:checked');
|
||||
if (gramajeSeleccionado.length > 0) {
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
div.append(`
|
||||
divGramajeInterior.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_gramaje_cubierta" data-validator="callback" style="margin-top: 50px;">
|
||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
||||
${window.translations["validation"].gramaje_interior}
|
||||
</div>
|
||||
</div>
|
||||
@ -319,6 +363,7 @@ class DisenioCubierta {
|
||||
case 'div_solapas_cubierta':
|
||||
case 'div_papel_cubierta':
|
||||
case 'div_gramaje_cubierta':
|
||||
case 'div_papel_especial_cubierta':
|
||||
return '.col-sm-10';
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
@ -338,45 +383,48 @@ class DisenioCubierta {
|
||||
processMenuLateral() {
|
||||
|
||||
let menu_off = true;
|
||||
|
||||
if($('.papel-cubierta.selected').length>0 && this.getGramaje() != null){
|
||||
this.rl_papel_cubierta.text($($('.papel-cubierta.selected').find('.form-label')).text() + " " +
|
||||
this.getGramaje() + " gr");
|
||||
|
||||
const papel = this.getPapel(true);
|
||||
const gramaje = this.getGramaje();
|
||||
|
||||
if (papel != null && gramaje != null) {
|
||||
|
||||
this.rl_papel_cubierta.text(papel + " " + gramaje + " gr");
|
||||
this.rl_acabado_cubierta.text(this.domItem.find("#plastificado").children("option:selected").text());
|
||||
this.rl_papel_cubierta.removeClass('d-none');
|
||||
this.rl_acabado_cubierta.removeClass('d-none');
|
||||
|
||||
if(this.carasCubierta.find('option:selected').length>0){
|
||||
if (this.carasCubierta.find('option:selected').length > 0) {
|
||||
this.rl_caras_cubierta.text("Impresa " + this.carasCubierta.find('option:selected').text());
|
||||
this.rl_caras_cubierta.removeClass('d-none');
|
||||
menu_off = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_caras_cubierta.addClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
menu_off = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_papel_cubierta.addClass('d-none');
|
||||
this.rl_acabado_cubierta.addClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
if (!menu_off)
|
||||
this.rl_cubierta.removeClass('d-none');
|
||||
else
|
||||
this.rl_cubierta.addClass('d-none');
|
||||
|
||||
// Sobrecubierta solo se muestra si cubierta ok
|
||||
if(!this.rl_cubierta.hasClass('d-none')){
|
||||
if (!this.rl_cubierta.hasClass('d-none')) {
|
||||
this.rl_sobrecubierta.removeClass('d-none');
|
||||
if(!this.sobrecubierta.is(":checked")){
|
||||
if (!this.sobrecubierta.is(":checked")) {
|
||||
this.rl_no_sobrecubierta.removeClass('d-none');
|
||||
this.rl_papel_sobrecubierta.addClass('d-none');
|
||||
this.rl_tamanio_sobrecubierta.addClass('d-none');
|
||||
this.rl_acabado_sobrecubierta.addClass('d-none');
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_no_sobrecubierta.addClass('d-none');
|
||||
this.rl_papel_sobrecubierta.removeClass('d-none');
|
||||
this.rl_tamanio_sobrecubierta.removeClass('d-none');
|
||||
@ -386,12 +434,12 @@ class DisenioCubierta {
|
||||
this.rl_papel_sobrecubierta.text(sobrecubierta.papel + " " + sobrecubierta.gramaje + " gr")
|
||||
this.rl_tamanio_sobrecubierta.text("Solapas: " + sobrecubierta.solapas + " mm")
|
||||
let acabado_text = sobrecubierta.plastificado;
|
||||
if(acabado_text.includes("Sin plastificar"))
|
||||
if (acabado_text.includes("Sin plastificar"))
|
||||
acabado_text = "Sin plastificar";
|
||||
this.rl_acabado_sobrecubierta.text(acabado_text);
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.rl_sobrecubierta.addClass('d-none');
|
||||
}
|
||||
|
||||
@ -419,11 +467,30 @@ class DisenioCubierta {
|
||||
}
|
||||
|
||||
|
||||
getPapel() {
|
||||
getPapel(forResumen = false) {
|
||||
|
||||
try {
|
||||
if (this.papelCubierta.filter('.selected').length > 0) {
|
||||
return this.papelCubierta.filter('.selected').attr('cod');
|
||||
let checkedPapel = $('.custom-selector-papel-cubierta input[type="radio"]:checked');
|
||||
if (this.papelCubierta != null && checkedPapel != null && checkedPapel.length > 0) {
|
||||
if (forResumen) {
|
||||
|
||||
if (checkedPapel.length == 0)
|
||||
return null;
|
||||
let radioButtonId = checkedPapel[0].id;
|
||||
if (radioButtonId == 'papelEspecialCubierta')
|
||||
return capitalizeFirstLetter(this.papelEspecial.getText());
|
||||
else {
|
||||
let associatedLabel = $('label[for="' + radioButtonId + '"]');
|
||||
return capitalizeFirstLetter($(associatedLabel[0]).text().toLocaleLowerCase());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.divPapelEspecial.hasClass('d-none'))
|
||||
return this.papelCubierta;
|
||||
else {
|
||||
return this.papelEspecial.getVal();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -435,17 +502,13 @@ class DisenioCubierta {
|
||||
|
||||
getGramaje() {
|
||||
|
||||
let checkedGramaje = $('.custom-selector-gramaje-cubierta input[type="radio"]:checked');
|
||||
|
||||
try {
|
||||
|
||||
if (this.divGramajeCubierta.hasClass("d-none"))
|
||||
return null;
|
||||
|
||||
if (this.gramaje.filter(':checked').length > 0)
|
||||
return this.gramaje.filter(':checked').attr('data-value');
|
||||
|
||||
else
|
||||
return null;
|
||||
|
||||
if (checkedGramaje.length == 0)
|
||||
return null;
|
||||
return checkedGramaje[0].id.split('_')[1];
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@ -606,8 +669,6 @@ class DisenioCubierta {
|
||||
element.closest(class2Find).toggleClass('selected');
|
||||
element.closest('.image-presupuesto').toggleClass('selected');
|
||||
|
||||
$(".papel-cubierta").removeClass("selected");
|
||||
|
||||
if (this.tapaBlanda.hasClass("selected")) {
|
||||
if (this.carasCubierta.val() == 2) {
|
||||
this.cartulinaEstucada.removeClass("d-none");
|
||||
@ -618,12 +679,6 @@ class DisenioCubierta {
|
||||
this.cartulinaEstucada.addClass("d-none");
|
||||
this.estucadoMate.addClass("selected");
|
||||
this.divGramajeCubierta.removeClass("d-none");
|
||||
this.gramaje170.removeClass("d-none");
|
||||
this.gramaje170.closest(".checkbox-presupuesto-container").addClass("checked");
|
||||
this.gramaje250.addClass("d-none");
|
||||
this.gramaje270.addClass("d-none");
|
||||
this.gramaje300.addClass("d-none");
|
||||
this.gramaje350.addClass("d-none");
|
||||
}
|
||||
|
||||
element.trigger('change');
|
||||
@ -651,30 +706,10 @@ class DisenioCubierta {
|
||||
}
|
||||
|
||||
|
||||
#handlePapelCubierta(event) {
|
||||
// Accede al ID del elemento que disparó el evento
|
||||
const element = $(event.target);
|
||||
|
||||
let class2Find = '.papel-cubierta';
|
||||
|
||||
let containers = element.closest(class2Find).parent().find(class2Find);
|
||||
for (let container of containers) {
|
||||
if (container != element.closest(class2Find)[0]) {
|
||||
$(container).removeClass('selected');
|
||||
$(container).find('.image-presupuesto').removeClass('selected');
|
||||
}
|
||||
}
|
||||
|
||||
element.closest(class2Find).toggleClass('selected');
|
||||
element.closest('.image-presupuesto').toggleClass('selected');
|
||||
|
||||
element.trigger('change');
|
||||
}
|
||||
|
||||
#handleMenuTipoCubierta() {
|
||||
|
||||
if (this.tapaBlanda.hasClass("selected")) {
|
||||
|
||||
|
||||
this.divSolapas.removeClass("d-none");
|
||||
this.divCarasImpresion.removeClass("d-none");
|
||||
this.divConfigGuardas.addClass("d-none");
|
||||
@ -684,15 +719,14 @@ class DisenioCubierta {
|
||||
this.divSolapas.addClass("d-none");
|
||||
this.divCarasImpresion.addClass("d-none");
|
||||
this.divConfigGuardas.removeClass("d-none");
|
||||
this.#handleMenuPapel();
|
||||
|
||||
}
|
||||
else {
|
||||
this.divSolapas.addClass("d-none");
|
||||
this.divCarasImpresion.addClass("d-none");
|
||||
this.divConfigGuardas.addClass("d-none");
|
||||
this.#handleMenuPapel();
|
||||
}
|
||||
|
||||
this.#handleMenuPapel();
|
||||
}
|
||||
|
||||
|
||||
@ -708,42 +742,234 @@ class DisenioCubierta {
|
||||
|
||||
#handleMenuPapel() {
|
||||
|
||||
$(".check-gramaje-cubierta").prop("checked", false);
|
||||
this.divGramajeCubierta.empty();
|
||||
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
tapa_dura: tapa_dura
|
||||
},
|
||||
{},
|
||||
(response) => { this.fillPapeles(response); },
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
}
|
||||
|
||||
if (!this.tapaBlanda.hasClass("selected") && !this.tapaDuraLomoRecto.hasClass("selected") && !this.tapaDuraLomoRedondo.hasClass("selected")) {
|
||||
this.divGramajeCubierta.addClass("d-none");
|
||||
this.estucadoMate.removeClass("selected");
|
||||
this.cartulinaEstucada.removeClass("selected");
|
||||
|
||||
#handlePapelCubiertaEspecial() {
|
||||
|
||||
const context = this;
|
||||
|
||||
this.papelCubierta = this.papelEspecial.getVal();
|
||||
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
|
||||
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
papel: this.papelCubierta,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
tapa_dura: tapa_dura,
|
||||
},
|
||||
{},
|
||||
this.fillGramajes.bind(context),
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
|
||||
}
|
||||
|
||||
|
||||
fillPapeles(response) {
|
||||
|
||||
this.divPapelCubierta.empty();
|
||||
this.divGramajeCubierta.empty();
|
||||
|
||||
if (response.papeles.length > 0) {
|
||||
this.textoPapelCubierta.removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
this.textoPapelCubierta.addClass("d-none");
|
||||
}
|
||||
|
||||
response.papeles.forEach(papel => {
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-papel-cubierta d-flex flex-column align-items-center justify-content-center'
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto papel-cubierta',
|
||||
id: 'papelCubierta_' + papel.id, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: 'papelCubierta_' + papel.id,
|
||||
text: papel.nombre
|
||||
});
|
||||
|
||||
radioButton.on('click', this.#handleGramajeCubierta.bind(this));
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divPapelCubierta').append(container);
|
||||
|
||||
if (this.papelCubierta == papel.id) {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
if (response.papeles_especiales.length > 0) {
|
||||
this.divPapelCubierta.removeClass('d-none');
|
||||
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-papel-cubierta d-flex flex-column align-items-center justify-content-center'
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio',
|
||||
name: 'calcular-presupuesto papel-cubierta',
|
||||
id: 'papelEspecialCubierta',
|
||||
value: 'option1'
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: 'papelEspecialCubierta',
|
||||
text: 'PAPEL ESPECIAL'
|
||||
});
|
||||
|
||||
radioButton.on('click', this.#handleGramajeCubierta.bind(this));
|
||||
|
||||
response.papeles_especiales.forEach(papel => {
|
||||
if (papel.id == this.papelCubierta) {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
|
||||
this.papelEspecial.setOption(papel.id, papel.nombre);
|
||||
this.#handlePapelCubiertaEspecial();
|
||||
}
|
||||
});
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divPapelCubierta').append(container);
|
||||
}
|
||||
}
|
||||
|
||||
#handleGramajeCubierta() {
|
||||
|
||||
const context = this;
|
||||
|
||||
// Accede al ID del elemento que disparó el evento
|
||||
const element = $(event.target);
|
||||
const papel = element[0].id.split('_')[1];
|
||||
this.papelCubierta = papel;
|
||||
|
||||
$('#' + papel).prop('checked', true);
|
||||
|
||||
|
||||
if (element[0].id == 'papelEspecialCubierta') {
|
||||
|
||||
if(!this.cargando)
|
||||
this.gramaje = null;
|
||||
this.divGramajeCubierta.empty();
|
||||
this.divPapelEspecial.removeClass("d-none");
|
||||
$('#papelEspecialCubiertaSel').off("change");
|
||||
this.papelEspecial.empty();
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
this.divPapelEspecial.addClass("d-none");
|
||||
$('#papelEspecialCubiertaSel').off("change");
|
||||
this.papelEspecial.empty();
|
||||
$('#papelEspecialCubiertaSel').on("change", this.#handlePapelCubiertaEspecial.bind(this));
|
||||
this.divGramajeCubierta.empty();
|
||||
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
papel: papel,
|
||||
tipo: 'colorhq',
|
||||
cubierta: 1,
|
||||
tapa_dura: tapa_dura
|
||||
},
|
||||
{},
|
||||
this.fillGramajes.bind(context),
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
}
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
else {
|
||||
this.cargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fillGramajes(response) {
|
||||
|
||||
|
||||
this.divGramajeCubierta.empty()
|
||||
let showGramaje = false;
|
||||
|
||||
if (response.papeles.length <= 0 && response.papeles_especiales.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.cartulinaEstucada.hasClass("selected")) {
|
||||
this.divGramajeCubierta.removeClass("d-none");
|
||||
this.gramaje170.addClass("d-none");
|
||||
this.gramaje250.removeClass("d-none");
|
||||
this.gramaje270.removeClass("d-none");
|
||||
this.gramaje300.removeClass("d-none");
|
||||
this.gramaje350.removeClass("d-none");
|
||||
}
|
||||
else if (this.estucadoMate.hasClass("selected")) {
|
||||
if (this.tapaBlanda.hasClass("selected")) {
|
||||
this.divGramajeCubierta.removeClass("d-none");
|
||||
this.gramaje170.addClass("d-none");
|
||||
this.gramaje250.removeClass("d-none");
|
||||
this.gramaje270.addClass("d-none");
|
||||
this.gramaje300.removeClass("d-none");
|
||||
this.gramaje350.removeClass("d-none");
|
||||
}
|
||||
else {
|
||||
this.divGramajeCubierta.removeClass("d-none");
|
||||
this.gramaje170.removeClass("d-none");
|
||||
this.gramaje250.addClass("d-none");
|
||||
this.gramaje270.addClass("d-none");
|
||||
this.gramaje300.addClass("d-none");
|
||||
this.gramaje350.addClass("d-none");
|
||||
let papel = response.papeles.length > 0 ? response.papeles : response.papeles_especiales;
|
||||
|
||||
$('#gramaje170Cubierta').trigger("click");
|
||||
papel.forEach(valor => {
|
||||
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-gramaje-cubierta d-flex flex-column align-items-center justify-content-center gramaje-cubierta',
|
||||
});
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto gramaje-cubierta',
|
||||
id: 'gramajeCubierta_' + valor.gramaje, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
|
||||
// Crear una etiqueta para el radio button
|
||||
var label = $('<label>', {
|
||||
for: "gramajeCubierta_" + valor.gramaje,
|
||||
text: valor.gramaje + " gr"
|
||||
});
|
||||
|
||||
radioButton.on('click', (event) => {
|
||||
const element = $(event.target);
|
||||
const gramaje = element[0].id;
|
||||
|
||||
this.presupuestoCliente.checkForm(event);
|
||||
});
|
||||
|
||||
|
||||
container.append(radioButton).append(label);
|
||||
$('#divGramajeCubierta').append(container);
|
||||
|
||||
if (this.gramaje != null) {
|
||||
if (this.gramaje == parseInt(valor.gramaje)) {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
}
|
||||
}
|
||||
|
||||
showGramaje = true;
|
||||
});
|
||||
|
||||
if ($("#divGramajeCubierta").hasClass("d-none") && showGramaje) {
|
||||
$("#divGramajeCubierta").removeClass("d-none");
|
||||
}
|
||||
else if (!showGramaje) {
|
||||
$("#divGramajeCubierta").addClass("d-none");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ class DisenioInterior {
|
||||
|
||||
const context = this;
|
||||
|
||||
if (papeles == 'color' || papeles == null) {
|
||||
if (papeles == 'color') {
|
||||
this.divGramajeInteriorColor.empty();
|
||||
new Ajax('/papelesgenericos/getpapelcliente',
|
||||
{
|
||||
@ -214,7 +214,7 @@ class DisenioInterior {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
|
||||
this.papelEspecial.setVal(papel.id);
|
||||
this.papelEspecial.setOption(papel.id, papel.nombre);
|
||||
}
|
||||
});
|
||||
|
||||
@ -291,7 +291,7 @@ class DisenioInterior {
|
||||
radioButton.prop('checked', true);
|
||||
radioButton.trigger('click');
|
||||
|
||||
this.papelEspecialColor.setVal(papel.id);
|
||||
this.papelEspecialColor.setOption(papel.id, papel.nombre);
|
||||
}
|
||||
});
|
||||
|
||||
@ -837,19 +837,15 @@ class DisenioInterior {
|
||||
const element = $(event.target);
|
||||
const papel = element[0].id.split('_')[1];
|
||||
this.papelInterior = papel;
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
else {
|
||||
this.cargando = false;
|
||||
}
|
||||
|
||||
|
||||
$('#' + papel).prop('checked', true);
|
||||
|
||||
let tipo = this.getTipoImpresion();
|
||||
|
||||
if (element[0].id == 'papelEspecialInterior') {
|
||||
|
||||
this.gramaje = null;
|
||||
if(!this.cargando)
|
||||
this.gramaje = null;
|
||||
this.divGramajeInterior.empty();
|
||||
this.divPapelEspecialInterior.removeClass("d-none");
|
||||
this.papelEspecialInterior.empty();
|
||||
@ -872,6 +868,11 @@ class DisenioInterior {
|
||||
(response) => { console.log(response); }
|
||||
).get();
|
||||
}
|
||||
if (!this.cargando)
|
||||
this.gramaje = null;
|
||||
else {
|
||||
this.cargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
#handlePapelInteriorEspecial() {
|
||||
@ -971,11 +972,13 @@ class DisenioInterior {
|
||||
this.divGramajeInterior.empty()
|
||||
let showGramaje = false;
|
||||
|
||||
if (response.papeles.length <= 0) {
|
||||
if (response.papeles.length <= 0 && response.papeles_especiales.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
response.papeles.forEach(valor => {
|
||||
let papel = response.papeles.length > 0 ? response.papeles : response.papeles_especiales;
|
||||
|
||||
papel.forEach(valor => {
|
||||
|
||||
var container = $('<div>', {
|
||||
class: 'custom-selector custom-selector-gramaje d-flex flex-column align-items-center justify-content-center gramaje-interior',
|
||||
@ -983,7 +986,7 @@ class DisenioInterior {
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto gramaje-interior',
|
||||
name: ' calcular-solapas calcular-presupuesto gramaje-interior',
|
||||
id: 'gramaje_' + valor.gramaje, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
@ -998,6 +1001,7 @@ class DisenioInterior {
|
||||
const element = $(event.target);
|
||||
const gramaje = element[0].id;
|
||||
|
||||
this.presupuestoCliente.calcularSolapas(event);
|
||||
this.presupuestoCliente.checkForm(event);
|
||||
});
|
||||
|
||||
@ -1041,7 +1045,7 @@ class DisenioInterior {
|
||||
|
||||
var radioButton = $('<input>', {
|
||||
type: 'radio', // Tipo de input
|
||||
name: 'calcular-presupuesto gramaje-interior-color',
|
||||
name: ' calcular-solapas calcular-presupuesto gramaje-interior-color',
|
||||
id: 'gramajeColor_' + valor.gramaje, // ID único
|
||||
value: 'option1' // Valor del radio button
|
||||
});
|
||||
@ -1056,6 +1060,7 @@ class DisenioInterior {
|
||||
const element = $(event.target);
|
||||
const gramaje = element[0].id;
|
||||
|
||||
this.presupuestoCliente.calcularSolapas(event);
|
||||
this.presupuestoCliente.checkForm(event);
|
||||
});
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import tarjetaTiradasPrecio from './tarjetaTiradasPrecio.js';
|
||||
class PresupuestoCliente {
|
||||
|
||||
constructor() {
|
||||
|
||||
|
||||
this.clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
|
||||
|
||||
this.validationStepper = new Stepper(this.clientePresupuestoWizard, {
|
||||
@ -34,7 +34,7 @@ class PresupuestoCliente {
|
||||
|
||||
this.datosGenerales = new DatosGenerales($("#datos-generales"), this.clientePresupuestoWizard, this.validationStepper);
|
||||
this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper, this);
|
||||
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
||||
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper, this);
|
||||
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
||||
this.resumen = new Resumen($("#resumen-libro"), this.datosGenerales, this.disenioInterior, this.disenioCubierta, this.direcciones);
|
||||
|
||||
@ -110,6 +110,7 @@ class PresupuestoCliente {
|
||||
|
||||
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
$(".calcular-solapas").on('change', this.calcularSolapas.bind(this));
|
||||
}
|
||||
|
||||
|
||||
@ -154,6 +155,28 @@ class PresupuestoCliente {
|
||||
return !(noPOD && siPOD);
|
||||
}
|
||||
|
||||
calcularSolapas(){
|
||||
|
||||
/* Solapas Max */
|
||||
this.#getDatos(false, true);
|
||||
if (Object.values(this.datos).every(this.#isValidDataForm)) {
|
||||
new Ajax('/presupuestocliente/calcularsolapas',
|
||||
this.datos,
|
||||
{},
|
||||
(response) => {
|
||||
if (response === null || response === undefined || response === "") {
|
||||
console.log("Error en el calculo máximo de solapas.");
|
||||
return;
|
||||
}
|
||||
this.disenioCubierta.tamanioSolapasCubierta.attr('max', response);
|
||||
this.disenioCubierta.solapasSobrecubierta.attr('max', response);
|
||||
this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm");
|
||||
this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm");
|
||||
},
|
||||
() => { }
|
||||
).post();
|
||||
}
|
||||
}
|
||||
|
||||
checkForm(event) {
|
||||
|
||||
@ -163,6 +186,7 @@ class PresupuestoCliente {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (this.calcularPresupuesto) {
|
||||
|
||||
if (event.target.id === 'divDirecciones') {
|
||||
@ -580,7 +604,7 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
|
||||
#getDatos(save = false) {
|
||||
#getDatos(save = false, calcularSolapas = false) {
|
||||
|
||||
this.datos = {
|
||||
|
||||
@ -590,20 +614,12 @@ class PresupuestoCliente {
|
||||
tirada: this.datosGenerales.getTiradas(),
|
||||
paginas: this.datosGenerales.paginas.val(),
|
||||
paginasColor: this.datosGenerales.paginasColor.val(),
|
||||
posPaginasColor: this.datosGenerales.posPaginasColor.val(),
|
||||
pagColorConsecutivas: this.datosGenerales.pagColorConsecutivas.is(':checked') ? 1 : 0,
|
||||
papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked') ? 1 : 0,
|
||||
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
|
||||
|
||||
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
|
||||
|
||||
prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
|
||||
ferro: this.datosGenerales.ferro.is(':checked') ? 1 : 0,
|
||||
ferroDigital: this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
|
||||
marcapaginas: this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
|
||||
retractilado: this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
|
||||
retractilado5: this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
|
||||
|
||||
isColor: this.datosGenerales.getIsColor() ? 1 : 0,
|
||||
isHq: this.disenioInterior.getIsHq() ? 1 : 0,
|
||||
|
||||
@ -612,31 +628,46 @@ class PresupuestoCliente {
|
||||
gramajeInterior: this.disenioInterior.getGramaje(),
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
cubierta: {
|
||||
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||
papelCubierta: this.disenioCubierta.getPapel(),
|
||||
gramajeCubierta: this.disenioCubierta.getGramaje(),
|
||||
cabezada: this.disenioCubierta.getCabezada(),
|
||||
acabados: this.disenioCubierta.getAcabados(),
|
||||
carasImpresion: this.disenioCubierta.carasCubierta.val(),
|
||||
},
|
||||
if (calcularSolapas) {
|
||||
return;
|
||||
}
|
||||
|
||||
guardas: this.disenioCubierta.getGuardas(),
|
||||
sobrecubierta: this.disenioCubierta.getSobrecubierta(),
|
||||
faja: this.disenioCubierta.getFaja(),
|
||||
this.datos.posPaginasColor = this.datosGenerales.posPaginasColor.val();
|
||||
|
||||
excluirRotativa: this.datosGenerales.excluirRotativa.is(':checked') ? 1 : 0,
|
||||
ivaReducido: this.datosGenerales.ivaReducido.find('option:selected').val(),
|
||||
servicios: {
|
||||
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
|
||||
'ferro': this.datosGenerales.ferro.is(':checked') ? 1 : 0,
|
||||
'ferroDigital': this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
|
||||
'marcapaginas': this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
|
||||
'retractilado': this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
|
||||
'retractilado5': this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
|
||||
},
|
||||
this.datos.prototipo = this.datosGenerales.prototipo.is(':checked') ? 1 : 0;
|
||||
this.datos.ferro = this.datosGenerales.ferro.is(':checked') ? 1 : 0;
|
||||
this.datos.ferroDigital = this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0;
|
||||
this.datos.marcapaginas = this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0;
|
||||
this.datos.retractilado = this.datosGenerales.retractilado.is(':checked') ? 1 : 0;
|
||||
this.datos.retractilado5 = this.datosGenerales.retractilado5.is(':checked') ? 1 : 0;
|
||||
|
||||
|
||||
this.datos.cubierta = {
|
||||
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||
papelCubierta: this.disenioCubierta.getPapel(),
|
||||
gramajeCubierta: this.disenioCubierta.getGramaje(),
|
||||
cabezada: this.disenioCubierta.getCabezada(),
|
||||
acabados: this.disenioCubierta.getAcabados(),
|
||||
carasImpresion: this.disenioCubierta.carasCubierta.val(),
|
||||
};
|
||||
|
||||
this.datos.guardas = this.disenioCubierta.getGuardas();
|
||||
this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta();
|
||||
this.datos.faja = this.disenioCubierta.getFaja();
|
||||
|
||||
this.datos.excluirRotativa = this.datosGenerales.excluirRotativa.is(':checked') ? 1 : 0;
|
||||
this.datos.ivaReducido = this.datosGenerales.ivaReducido.find('option:selected').val();
|
||||
this.datos.servicios = {
|
||||
'prototipo': this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
|
||||
'ferro': this.datosGenerales.ferro.is(':checked') ? 1 : 0,
|
||||
'ferroDigital': this.datosGenerales.ferroDigital.is(':checked') ? 1 : 0,
|
||||
'marcapaginas': this.datosGenerales.marcapaginas.is(':checked') ? 1 : 0,
|
||||
'retractilado': this.datosGenerales.retractilado.is(':checked') ? 1 : 0,
|
||||
'retractilado5': this.datosGenerales.retractilado5.is(':checked') ? 1 : 0,
|
||||
};
|
||||
|
||||
let lomoRedondo = 0;
|
||||
if (this.disenioCubierta.disenioCubierta.filter('.selected').length > 0)
|
||||
lomoRedondo = this.disenioCubierta.disenioCubierta.filter('.selected').attr('id').includes('Redondo') ? 1 : 0;
|
||||
@ -706,7 +737,7 @@ class PresupuestoCliente {
|
||||
|
||||
this.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||
this.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
|
||||
@ -280,7 +280,7 @@ class Resumen {
|
||||
this.cabezada.text(this.disenioCubierta.getCabezada(true));
|
||||
|
||||
}
|
||||
this.papelCubierta.text($($('.papel-cubierta.selected').find('.form-label')).text())
|
||||
this.papelCubierta.text(this.disenioCubierta.getPapel(true));
|
||||
this.gramajeCubierta.text(this.disenioCubierta.getGramaje());
|
||||
this.cubiertaAcabados.text(this.disenioCubierta.getAcabados(true));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user