mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en eventos de lineas
This commit is contained in:
@ -220,6 +220,35 @@ class Comparador {
|
||||
this.btnInsertarGuardas = $('#insertarGuardasBtn');
|
||||
}
|
||||
|
||||
this.faja = $('#compFaja');
|
||||
this.papelFaja = new ClassSelect($('#compPapelFaja'),
|
||||
'/presupuestoadmin/papelgenerico', 'Seleccione papel', false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
tipo_impresion: this.tipo_impresion_id,
|
||||
tirada: () => $('#tirada').val(),
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => $('faja_alto').val(),
|
||||
sopalas: () => $('#faja_solapas_ancho').val(),
|
||||
lomo: () => $('#lomo_sobrecubierta').val(),
|
||||
tipo: 'colorhq',
|
||||
uso: 'sobrecubierta',
|
||||
});
|
||||
this.gramajeFaja = new ClassSelect($('#compGramajeFaja'),
|
||||
'/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false,
|
||||
{
|
||||
[this.csrf_token]: this.csrf_hash,
|
||||
papel_generico: () => this.papelFaja.getVal(),
|
||||
tipo_impresion: this.tipo_impresion_id,
|
||||
tirada: () => $('#tirada').val(),
|
||||
ancho: () => this.getDimensionLibro().ancho,
|
||||
alto: () => $('faja_alto').val(),
|
||||
sopalas: () => $('#faja_solapas_ancho').val(),
|
||||
lomo: () => $('#lomo_sobrecubierta').val(),
|
||||
tipo: 'colorhq',
|
||||
uso: 'sobrecubierta',
|
||||
});
|
||||
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3) {
|
||||
this.lomoRedondo = $('#compLomoRedondo');
|
||||
this.cabezada = $('#cabezada');
|
||||
@ -232,9 +261,11 @@ class Comparador {
|
||||
this.tableCompGuardas = null;
|
||||
this.tableCompIntPlana = null;
|
||||
this.tableCompIntRotativa = null;
|
||||
this.tableCompFaja = null;
|
||||
this.btnInsertarPlana = $('#insertarPlanaBtn');
|
||||
this.btnInsertarRotativa = $('#insertarRotativaBtn');
|
||||
this.btnInsertarCubierta = $('#insertarCubiertaBtn');
|
||||
this.btnInsertarFaja = $('#insertarFajaBtn');
|
||||
|
||||
this.cargando = false;
|
||||
this.comparadorPlanaRunning = false;
|
||||
@ -292,6 +323,14 @@ class Comparador {
|
||||
});
|
||||
}
|
||||
|
||||
this.faja.select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: Infinity,
|
||||
});
|
||||
this.papelFaja.init();
|
||||
this.gramajeFaja.init();
|
||||
this.papelFaja.onChange(() => self.gramajeFaja.empty());
|
||||
|
||||
if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) {
|
||||
|
||||
this.sobrecubierta.select2({
|
||||
@ -323,6 +362,28 @@ class Comparador {
|
||||
});
|
||||
}
|
||||
|
||||
this.faja.on('change', () => {
|
||||
if (this.faja.select2('data')[0].id == 1) {
|
||||
if ($('#faja').prop('checked') == false) {
|
||||
this.faja.val(0);
|
||||
popErrorAlert(window.language.Presupuestos.errores.error_faja_sin_solapas, 'divAlarmasComparador');
|
||||
}
|
||||
$('#faja').prop('checked', true);
|
||||
$('.faja-div').removeClass('d-none');
|
||||
$('#faja_solapas_ancho').val(60);
|
||||
$('#faja_alto').val(50);
|
||||
$('#compPapelFaja').prop('disabled', false);
|
||||
$('#compGramajeFaja').prop('disabled', false);
|
||||
}
|
||||
else {
|
||||
this.papelFaja.setVal(0);
|
||||
this.gramajeFaja.setVal(0);
|
||||
$('#compPapelFaja').prop('disabled', true);
|
||||
$('#compGramajeFaja').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
|
||||
this.papelGuardas.init();
|
||||
this.gramajeGuardas.init();
|
||||
@ -360,6 +421,9 @@ class Comparador {
|
||||
else if (e.target.id.includes("guardas")) {
|
||||
$("#tableCompGuardas").DataTable().columns.adjust();
|
||||
}
|
||||
else if (e.target.id.includes("faja")) {
|
||||
$("#tableCompFaja").DataTable().columns.adjust();
|
||||
}
|
||||
else if (e.target.id.includes("LineasPresupuesto")) {
|
||||
$("#tableLineasPresupuesto").DataTable().columns.adjust();
|
||||
}
|
||||
@ -378,6 +442,8 @@ class Comparador {
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
|
||||
$('.comp_guardas_items').on('change', this.obtenerComparadorGuardas.bind(this));
|
||||
}
|
||||
|
||||
$('.comp_faja_items').on('change', this.obtenerComparadorFaja.bind(this));
|
||||
}
|
||||
|
||||
#changePaginasComparador(element) {
|
||||
@ -477,22 +543,25 @@ class Comparador {
|
||||
}
|
||||
|
||||
this.cargando = false;
|
||||
if (this.paginasNegro.val() > 0) {
|
||||
this.paginasNegro.trigger('change');
|
||||
}
|
||||
else if (this.paginasNegrohq.val() > 0) {
|
||||
this.paginasNegrohq.trigger('change');
|
||||
}
|
||||
else if (this.paginasColor.val() > 0) {
|
||||
|
||||
if (this.paginasColor.val() > 0) {
|
||||
this.paginasColor.trigger('change');
|
||||
}
|
||||
else if (this.paginasColorhq.val() > 0) {
|
||||
this.paginasColorhq.trigger('change');
|
||||
}
|
||||
else if (this.paginasNegro.val() > 0) {
|
||||
this.paginasNegro.trigger('change');
|
||||
}
|
||||
else if (this.paginasNegrohq.val() > 0) {
|
||||
this.paginasNegrohq.trigger('change');
|
||||
}
|
||||
|
||||
this.paginasCubierta.trigger('change');
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
|
||||
this.carasGuardas.trigger('change');
|
||||
}
|
||||
this.faja.trigger('change');
|
||||
|
||||
}
|
||||
|
||||
@ -673,6 +742,57 @@ class Comparador {
|
||||
"order": [[0, 'asc'], [15, 'asc']]
|
||||
});
|
||||
|
||||
this.tableCompFaja = new DataTable('#tableCompFaja', {
|
||||
scrollX: true,
|
||||
searching: false,
|
||||
paging: false,
|
||||
info: false,
|
||||
ordering: true,
|
||||
responsive: true,
|
||||
select: false,
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
'data': 'tipo',
|
||||
'render': function (data, type, row, meta) {
|
||||
if (data == 'faja')
|
||||
return window.language.Presupuestos.faja;
|
||||
}
|
||||
},
|
||||
{ 'data': 'paginas' },
|
||||
{ 'data': 'papel' },
|
||||
{ 'data': 'gramaje' },
|
||||
{ 'data': 'marca' },
|
||||
{ 'data': 'maquina' },
|
||||
{ 'data': 'numeroPliegos' },
|
||||
{ 'data': 'pliegosPedido' },
|
||||
{ 'data': 'precioPliego' },
|
||||
{ 'data': 'libro' },
|
||||
{ 'data': 'totalPapelPedido' },
|
||||
{ 'data': 'lomo' },
|
||||
{ 'data': 'peso' },
|
||||
{ 'data': 'horasMaquina' },
|
||||
{ 'data': 'precioImpresion' },
|
||||
{ 'data': 'total' },
|
||||
{ 'data': 'maquinaId' },
|
||||
{ 'data': 'maquinaVelocidad' },
|
||||
{ 'data': 'tiempoMaquina' },
|
||||
{ 'data': 'papelGenericoId' },
|
||||
{ 'data': 'papelImpresionId' },
|
||||
{ 'data': 'tarifa_impresion_id' }
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
target: [16, 17, 18, 19, 20, 21],
|
||||
visible: false,
|
||||
searchable: false
|
||||
},
|
||||
],
|
||||
"order": [[15, 'asc']]
|
||||
});
|
||||
|
||||
if (this.tipo_impresion_id == 1 || this.tipo_impresion_id == 3 || this.tipo_impresion_id == 5 || this.tipo_impresion_id == 7) {
|
||||
this.tableCompGuardas = new DataTable('#tableCompGuardas', {
|
||||
scrollX: true,
|
||||
@ -1019,6 +1139,23 @@ class Comparador {
|
||||
|
||||
}
|
||||
|
||||
else if (uso == 'faja') {
|
||||
if (this.papelFaja.getVal() == 0 || this.papelFaja.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
if (this.gramajeFaja.getVal() == 0 || this.gramajeFaja.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
|
||||
return { error: true, data: {} };
|
||||
}
|
||||
|
||||
papel_generico = { id: this.papelFaja.getVal(), nombre: this.papelFaja.getText() };
|
||||
gramaje = this.gramajeFaja.getVal();
|
||||
paginas = 4;
|
||||
alto = $('#faja_alto').val();
|
||||
|
||||
}
|
||||
|
||||
else if (uso == 'guardas') {
|
||||
if (this.papelGuardas.getVal() == 0 || this.papelGuardas.getVal() == null) {
|
||||
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
|
||||
@ -1053,7 +1190,7 @@ class Comparador {
|
||||
|
||||
let datos = {
|
||||
datosPedido: datosPedido,
|
||||
uso: uso,
|
||||
uso: uso == 'faja' ? 'sobrecubierta' : uso,
|
||||
tipo_impresion_id: this.tipo_impresion_id,
|
||||
cliente_id: $('#clienteId').select2('data')[0].id,
|
||||
papel_generico: papel_generico,
|
||||
@ -1076,6 +1213,13 @@ class Comparador {
|
||||
datos.datosPedido.solapas = $('#solapas_sobrecubierta').prop('checked') ? 1 : 0;
|
||||
datos.datosPedido.solapas_ancho = $('#solapas_sobrecubierta').prop('checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0;
|
||||
}
|
||||
|
||||
else if (uso == 'faja') {
|
||||
datos.datosPedido.lomo = $("#lomo_sobrecubierta").val();
|
||||
datos.datosPedido.solapas = 1;
|
||||
datos.datosPedido.solapas_ancho = parseInt($('#faja_solapas_ancho').val());
|
||||
}
|
||||
|
||||
else if (uso == 'guardas') {
|
||||
datos.datosPedido.isCosido = 1;
|
||||
datos.datosPedido.isHq = 1;
|
||||
@ -1273,7 +1417,7 @@ class Comparador {
|
||||
return;
|
||||
}
|
||||
if (this.tipo_impresion_id != 5 && this.tipo_impresion_id != 6 && this.tipo_impresion_id != 7 && this.tipo_impresion_id != 8 && this.tipo_impresion_id != 21) {
|
||||
if (this.sobrecubierta.select2('data')[0].id == 1) {
|
||||
if (this.sobrecubierta.val() == 1) {
|
||||
datosComp.sobrecubierta = this.getDataForComp('sobrecubierta');
|
||||
if (datosComp.sobrecubierta.error) {
|
||||
return;
|
||||
@ -1297,6 +1441,7 @@ class Comparador {
|
||||
},
|
||||
{},
|
||||
(response) => {
|
||||
this.tableCompCubierta.clear().draw();
|
||||
if (response.data.cubierta && Object.keys(response.data.cubierta).length > 0) {
|
||||
let sorted = Object.values(response.data.cubierta).sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
@ -1342,6 +1487,67 @@ class Comparador {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
obtenerComparadorFaja(event, actualizarLineaPlana = false, actualizarLineaRot = false) {
|
||||
|
||||
try {
|
||||
|
||||
const self = this;
|
||||
|
||||
if (this.cargando) {
|
||||
return
|
||||
}
|
||||
|
||||
this.tableCompFaja.clear().draw();
|
||||
this.btnInsertarFaja.addClass('d-none');
|
||||
$('#title_faja').html(window.language.Presupuestos.faja);
|
||||
|
||||
let datosComp = {};
|
||||
datosComp.sobrecubierta = this.getDataForComp('faja');
|
||||
|
||||
datosComp.sobrecubierta.data[this.csrf_token] = this.csrf_hash;
|
||||
|
||||
new Ajax('/presupuestoadmin/comparadorexteriores',
|
||||
{
|
||||
sobrecubierta: datosComp.sobrecubierta.data
|
||||
},
|
||||
{},
|
||||
(response) => {
|
||||
|
||||
if (response.data.sobrecubierta && Object.keys(response.data.sobrecubierta).length > 0) {
|
||||
let sorted = Object.values(response.data.sobrecubierta).sort(
|
||||
(p1, p2) => ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) < (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ?
|
||||
-1 : ((p1.fields.precio_pedido + p1.fields.precio_click_pedido) > (p2.fields.precio_pedido + p2.fields.precio_click_pedido)) ? 1 : 0);
|
||||
sorted[0].forEach(function (linea) {
|
||||
if (typeof linea.error == "undefined")
|
||||
self.tableCompFaja.row
|
||||
.add(self.getRowFromLinea('faja', linea))
|
||||
.draw()
|
||||
});
|
||||
}
|
||||
|
||||
self.selectLineas('faja');
|
||||
if (self.tableCompFaja.rows().count() > 0) {
|
||||
$('#title_faja').html(window.language.Presupuestos.faja +
|
||||
(' (' + self.tableCompFaja.rows().count() + ')'));
|
||||
self.btnInsertarFaja.removeClass('d-none');
|
||||
}
|
||||
else {
|
||||
$('#title_faja').html(window.language.Presupuestos.faja);
|
||||
self.btnInsertarFaja.addClass('d-none');
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
).post();
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
obtenerComparadorGuardas(event, actualizarLineaPlana = false, actualizarLineaRot = false) {
|
||||
|
||||
try {
|
||||
@ -1425,6 +1631,12 @@ class Comparador {
|
||||
total_label = '#total_comp_cubierta';
|
||||
break;
|
||||
|
||||
case 'faja':
|
||||
table = this.tableCompFaja;
|
||||
tipo1 = 'faja';
|
||||
total_label = '#total_comp_faja';
|
||||
break;
|
||||
|
||||
case 'rotativa':
|
||||
table = this.tableCompIntRotativa;
|
||||
tipo1 = 'rotativa';
|
||||
|
||||
Reference in New Issue
Block a user