mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en eventos datosLibro
This commit is contained in:
@ -1,17 +1,27 @@
|
||||
import ClassSelect from '../../../components/select2.js';
|
||||
import { getToken } from '../../../common/common.js';
|
||||
|
||||
class DatosLibro {
|
||||
|
||||
constructor(domItem) {
|
||||
constructor(domItem, functions = {}) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
this.addService = functions.addService;
|
||||
this.removeService = functions.removeService;
|
||||
this.checkPaginasPresupuesto = functions.checkPaginasPresupuesto;
|
||||
|
||||
this.csrf_token = getToken();
|
||||
this.csrf_hash = $('#mainContainer').find('input[name="' + this.csrf_token + '"]').val();
|
||||
|
||||
this.paginas = this.domItem.find('#paginas');
|
||||
this.tirada = this.domItem.find('#tirada');
|
||||
this.tamanio = this.domItem.find('#papelFormatoId');
|
||||
this.tamanio = new ClassSelect($("#papelFormatoId"), '/papel-formato/getSelect2', window.language["formatoLibro"]);
|
||||
this.tamanioPersonalizado = this.domItem.find('#papelFormatoPersonalizado');
|
||||
this.anchoPersonalizado = this.domItem.find('#papelFormatoAncho');
|
||||
this.altoPersonalizado = this.domItem.find('#papelFormatoAlto');
|
||||
this.merma = this.domItem.find('#merma');
|
||||
this.mermaCubierta = this.domItem.find('#mermaCubierta');
|
||||
this.mermaCubierta = this.domItem.find('#mermacubierta');
|
||||
this.solapasCubierta = this.domItem.find('#solapas');
|
||||
this.solapasSobrecubierta = this.domItem.find('#solapas_sobrecubierta');
|
||||
this.anchoSolapasCubierta = this.domItem.find('#anchoSolapasCubierta');
|
||||
@ -20,12 +30,28 @@ class DatosLibro {
|
||||
this.divSolapasCubierta = this.domItem.find('#div_solapas_ancho');
|
||||
this.divSolapasSobrecubierta = this.domItem.find('#div_solapas_ancho_sobrecubierta');
|
||||
|
||||
this.acabadoCubierta = this.domItem.find('#acabado_cubierta_id');
|
||||
this.acabadoSobrecubierta = this.domItem.find('#acabado_sobrecubierta_id');
|
||||
this.acabadoCubierta = new ClassSelect($("#acabado_cubierta_id"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
"cubierta": 1
|
||||
}
|
||||
);
|
||||
this.acabadoSobrecubierta = new ClassSelect($("#acabado_sobrecubierta_id"),
|
||||
'/serviciosacabados/getacabados',
|
||||
'',
|
||||
false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
"sobrecubierta": 1
|
||||
}
|
||||
);
|
||||
|
||||
this.retractilado = this.domItem.find('#retractilado');
|
||||
this.retractilado5 = this.domItem.find('#retractilado5');
|
||||
this.imprimirFajaColor = this.domItem.find('#imprimirFajaColor');
|
||||
this.imprimirFajaColor = this.domItem.find('#fajaColor');
|
||||
this.prototipo = this.domItem.find('#prototipo');
|
||||
this.ferro = this.domItem.find('#ferro');
|
||||
this.ferroDigital = this.domItem.find('#ferroDigital');
|
||||
@ -35,20 +61,193 @@ class DatosLibro {
|
||||
|
||||
init() {
|
||||
|
||||
this.tamanio.init();
|
||||
this.acabadoCubierta.init();
|
||||
this.acabadoSobrecubierta.init();
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
this.retractilado.on('change', this.checkRetractilado.bind(this));
|
||||
this.retractilado5.on('change', this.checkRetractilado.bind(this));
|
||||
this.imprimirFajaColor.on('change', (this.changeFajaColor.bind(this)));
|
||||
this.ferro.on('change', this.changeFerro.bind(this));
|
||||
this.prototipo.on('change', this.changePrototipo.bind(this));
|
||||
|
||||
this.tamanio.item.on('select2:select', this.changeFormato.bind(this));
|
||||
$('.formato_libro').on('change', this.changeFormato.bind(this));
|
||||
|
||||
if ($('#tipo_impresion_id').val() != 1 && $('#tipo_impresion_id').val() != 3 &&
|
||||
$('#tipo_impresion_id').val() != 5 && $('#tipo_impresion_id').val() != 7) {
|
||||
this.solapasCubierta.on('change', this.changeSolapasCubierta.bind(this));
|
||||
}
|
||||
|
||||
this.solapasSobrecubierta.on('change', this.changeSolapasSobrecubierta.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
changeFajaColor() {
|
||||
|
||||
if (this.imprimirFajaColor.prop('checked')) {
|
||||
this.addService('fajaColor');
|
||||
}
|
||||
else {
|
||||
this.removeService('fajaColor');
|
||||
}
|
||||
}
|
||||
|
||||
changeFerro() {
|
||||
|
||||
if (this.ferro.prop('checked')) {
|
||||
this.addService('ferro');
|
||||
}
|
||||
else {
|
||||
this.removeService('ferro');
|
||||
}
|
||||
}
|
||||
|
||||
changePrototipo() {
|
||||
|
||||
if (this.prototipo.prop('checked')) {
|
||||
this.addService('prototipo');
|
||||
}
|
||||
else {
|
||||
this.removeService('prototipo');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkRetractilado(element) {
|
||||
|
||||
switch (element.id) {
|
||||
case 'retractilado':
|
||||
if ($('#' + element.id).prop('checked')) {
|
||||
$('#retractilado5').prop('checked', false);
|
||||
this.removeService('retractilado5');
|
||||
this.addService('retractilado');
|
||||
}
|
||||
break;
|
||||
case 'retractilado5':
|
||||
if ($('#' + element.id).prop('checked')) {
|
||||
$('#retractilado').prop('checked', false);
|
||||
this.removeService('retractilado');
|
||||
this.addService('retractilado5');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
changeFormato() {
|
||||
|
||||
// Si es negro o color
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negro' ||
|
||||
$('#tipoImpresion').select2('data')[0].id == 'color') {
|
||||
$('#compPaginasNegro').trigger('change')
|
||||
}
|
||||
// Si es negrohq o colorhq
|
||||
if ($('#tipoImpresion').select2('data')[0].id == 'negrohq' ||
|
||||
$('#tipoImpresion').select2('data')[0].id == 'colorhq') {
|
||||
$('#compPaginasNegrohq').trigger('change');
|
||||
}
|
||||
|
||||
$('.solapas_cubierta').trigger('change');
|
||||
$('.solapas_sobrecubierta').trigger('change');
|
||||
|
||||
this.checkPaginasPresupuesto();
|
||||
|
||||
// TO-DO
|
||||
/*updatePresupuesto({
|
||||
update_lineas: true,
|
||||
update_servicios: true,
|
||||
update_envios: true,
|
||||
update_resumen: true,
|
||||
update_tiradas_alternativas: true
|
||||
})*/
|
||||
}
|
||||
|
||||
changeSolapasCubierta() {
|
||||
|
||||
if (this.solapasCubierta.prop('checked', true)) {
|
||||
this.divSolapasCubierta.removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
this.divSolapasCubierta.addClass('d-none');
|
||||
this.anchoSolapasCubierta.val(0);
|
||||
}
|
||||
$('#serv_default').trigger('click');
|
||||
}
|
||||
|
||||
|
||||
changeSolapasSobrecubierta() {
|
||||
|
||||
if (this.solapasSobrecubierta.prop('checked', true)) {
|
||||
this.divSolapasSobrecubierta.removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
this.divSolapasSobrecubierta.addClass('d-none');
|
||||
this.anchoSolapasSobrecubierta.val(0);
|
||||
}
|
||||
$('#serv_default').trigger('click');
|
||||
}
|
||||
|
||||
|
||||
cargarDatos(datos) {
|
||||
|
||||
this.paginas.val(datos.paginas);
|
||||
this.tirada.val(datos.tirada);
|
||||
if (datos.papelFormatoPersonalizado) {
|
||||
this.tamanioPersonalizado.prop('checked', true);
|
||||
$(".tamanio-personalizado").removeClass('d-none');
|
||||
$(".tamanio-estandar").addClass('d-none');
|
||||
this.anchoPersonalizado.val(datos.papelFormatoAlto);
|
||||
this.altoPersonalizado.val(datos.papelFormatoAncho);
|
||||
}
|
||||
else {
|
||||
$(".tamanio-personalizado").addClass('d-none');
|
||||
$(".tamanio-estandar").removeClass('d-none');
|
||||
this.tamanio.setOption(datos.papelFormatoId, datos.papelFormatoNombre);
|
||||
}
|
||||
|
||||
this.merma.val(datos.merma);
|
||||
this.mermaCubierta.val(datos.mermaCubierta);
|
||||
|
||||
if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 ||
|
||||
$('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) {
|
||||
$(".impresion-con-solapas").addClass('d-none');
|
||||
}
|
||||
else {
|
||||
if (datos.solapas) {
|
||||
this.solapasCubierta.val(datos.solapas);
|
||||
this.anchoSolapasCubierta.val(datos.ancho_solapas);
|
||||
$('#div_solapas_ancho').removeClass('d-none');
|
||||
}
|
||||
if (datos.solapas_sobrecubierta) {
|
||||
this.solapasSobrecubierta.prop('checked', true);
|
||||
this.anchoSolapasSobrecubierta.val(datos.ancho_solapas_sobrecubierta);
|
||||
$('#div_solapas_ancho_sobrecubierta').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
this.acabadoCubierta.setOption(datos.acabadoCubierta.id, datos.acabadoCubierta.text);
|
||||
|
||||
if ($('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 6 ||
|
||||
$('#tipo_impresion_id').val() == 7 || $('#tipo_impresion_id').val() == 8
|
||||
|| $('#tipo_impresion_id').val() == 21) {
|
||||
$(".impresion-con-sobrecubierta").addClass('d-none');
|
||||
}
|
||||
else {
|
||||
|
||||
this.acabadoSobrecubierta.setOption(datos.acabadoSobrecubierta.id, datos.acabadoSobrecubierta.text);
|
||||
}
|
||||
|
||||
this.retractilado.prop('checked', datos.retractilado);
|
||||
this.retractilado5.prop('checked', datos.retractilado5);
|
||||
this.imprimirFajaColor.prop('checked', datos.fajaColor);
|
||||
this.prototipo.prop('checked', datos.prototipo);
|
||||
this.ferro.prop('checked', datos.ferro);
|
||||
this.ferroDigital.prop('checked', datos.ferroDigital);
|
||||
this.marcapaginas.prop('checked', datos.marcapaginas);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user