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:
@ -20,7 +20,12 @@ class PresupuestoAdminEdit {
|
||||
this.cosido = $("#isCosido");
|
||||
|
||||
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip',
|
||||
{
|
||||
addService: this.addService,
|
||||
removeService: this.removeService,
|
||||
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
||||
}));
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
}
|
||||
@ -33,6 +38,7 @@ class PresupuestoAdminEdit {
|
||||
});
|
||||
|
||||
this.datosGenerales.init();
|
||||
this.datosLibro.init();
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
|
||||
@ -69,6 +75,7 @@ class PresupuestoAdminEdit {
|
||||
self.calcularPresupuesto = false;
|
||||
|
||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
self.datosLibro.cargarDatos(response.data.datosLibro);
|
||||
|
||||
/*self.direcciones.handleChangeCliente();
|
||||
|
||||
@ -103,6 +110,65 @@ class PresupuestoAdminEdit {
|
||||
).get();
|
||||
}
|
||||
|
||||
|
||||
addService() {
|
||||
|
||||
}
|
||||
|
||||
removeService() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
checkPaginasPresupuesto() {
|
||||
|
||||
cantidad_total = 0
|
||||
|
||||
tableLineasPresupuesto.rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
var rowData = this.data();
|
||||
if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas')
|
||||
cantidad_total += parseInt(rowData.paginas)
|
||||
})
|
||||
htmlString = ''
|
||||
|
||||
if (cantidad_total != parseInt($('#paginas').val())) {
|
||||
htmlString = `
|
||||
<div class="alert alert-warning d-flex align-items-baseline" role="alert">
|
||||
<span class="alert-icon alert-icon-lg text-primary me-2">
|
||||
<i class="ti ti-bell ti-sm"></i>
|
||||
</span>
|
||||
<div class="d-flex flex-column ps-1">
|
||||
<h5 class="alert-heading mb-2">` +
|
||||
window.Presupuestos.errores.paginasLP +
|
||||
`</h5>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
$('#divAlarmasLineasPresupuesto').html(htmlString)
|
||||
}
|
||||
|
||||
getDimensionLibro() {
|
||||
|
||||
var ancho = 0;
|
||||
var alto = 0;
|
||||
|
||||
|
||||
if ($('#papelFormatoPersonalizado').is(':checked')) {
|
||||
ancho = parseFloat($('#papelFormatoAncho').val());
|
||||
alto = parseFloat($('#papelFormatoAlto').val());
|
||||
}
|
||||
else {
|
||||
ancho = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[0]);
|
||||
alto = parseFloat($('#papelFormatoId').getText().trim().split(" x ")[1]);
|
||||
}
|
||||
|
||||
return {
|
||||
ancho: ancho,
|
||||
alto: alto
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#checkChangesPresupuesto() {
|
||||
// Detectar cambios en inputs de texto
|
||||
$('input[type="text"]').on('change', function () {
|
||||
@ -150,7 +216,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Maquinas'] }, {},
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Presupuestos'] }, {},
|
||||
function (translations) {
|
||||
window.language = JSON.parse(translations);
|
||||
new PresupuestoAdminEdit().init();
|
||||
|
||||
@ -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