Merge branch 'fix/ser_solapas_repetido_en_admin' into 'main'

arreglado. añadida comprobación para los demás servicios

See merge request jjimenez/safekat!579
This commit is contained in:
2025-02-27 15:41:02 +00:00
2 changed files with 87 additions and 76 deletions

View File

@ -390,6 +390,7 @@ class PresupuestoAdminEdit {
self.tiradasAlternativas.cargar(response.data.tiradasAlternativas);
self.resumen.cargar(response.data.resumen);
self.datosLibro.calcular_mermas();
setTimeout(() => {

View File

@ -72,7 +72,7 @@ class Servicios {
showBreadCrumbSaveButton(true);
});
$(document).on('update-servicios', async function(){
$(document).on('update-servicios', async function () {
await self.updateServicios()
$(document).trigger('update-servicios-completed');
@ -94,7 +94,7 @@ class Servicios {
}
async guardar(){
async guardar() {
await this.serviciosAcabado.guardarServiciosAcabado();
await this.serviciosPreimpresion.guardarServiciosPreimpresion();
await this.ServiciosEncuadernacion.guardarServiciosEncuadernacion();
@ -114,71 +114,81 @@ class Servicios {
else if (servicio == 'acabadoFaja') {
this.serviciosAcabado.updateAcabadosExteriores(0, 0, 1);
}
else if (servicio == 'ferro'){
else if (servicio == 'ferro') {
const id = $('#ferro').attr('service-id');
if(!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'prototipo'){
else if (servicio == 'prototipo') {
const id = $('#prototipo').attr('service-id');
this.serviciosExtra.getPresupuestoExtra(id);
if (!this.checkServiceInTable(this.serviciosExtra.table, id))
this.serviciosExtra.getPresupuestoExtra(id);
}
else if (servicio == 'retractilado'){
else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id');
this.serviciosAcabado.getPresupuestoAcabado(id);
if (!this.checkServiceInTable(this.serviciosAcabado.table, id))
this.serviciosAcabado.getPresupuestoAcabado(id);
}
else if (servicio == 'retractilado5'){
else if (servicio == 'retractilado5') {
const id = $('#retractilado5').attr('service-id');
this.serviciosAcabado.getPresupuestoAcabado(id);
if (!this.checkServiceInTable(this.serviciosAcabado.table, id))
this.serviciosAcabado.getPresupuestoAcabado(id);
}
else if(servicio == 'plegado_guardas'){
else if (servicio == 'plegado_guardas') {
const id = $('#plegado_guardas').attr('service-id');
for(let i = 0; i < this.ServiciosManipulado.table.rows().count(); i++){
var data = this.ServiciosManipulado.table.row(i).data();
if (data.tarifa_id == id) {
return;
}
};
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_cubierta'){
else if (servicio == 'solapas_cubierta') {
const id = $('#serv_solapas_cubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_sobrecubierta'){
else if (servicio == 'solapas_sobrecubierta') {
const id = $('#serv_solapas_sobrecubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_faja'){
else if (servicio == 'solapas_faja') {
const id = $('#solapas_faja').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_grandes_cubierta'){
else if (servicio == 'solapas_grandes_cubierta') {
const id = $('#solapas_grandes_cubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_grandes_sobrecubierta'){
else if (servicio == 'solapas_grandes_sobrecubierta') {
const id = $('#solapas_grandes_sobrecubierta').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'solapas_grandes_faja'){
else if (servicio == 'solapas_grandes_faja') {
const id = $('#solapas_grandes_faja').attr('service-id');
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
else if (servicio == 'lomo_redondo'){
else if (servicio == 'lomo_redondo') {
const id = $('#compLomoRedondo').attr('service-id');
for(let i = 0; i < this.ServiciosManipulado.table.rows().count(); i++){
var data = this.ServiciosManipulado.table.row(i).data();
if (data.tarifa_id == id) {
return;
}
};
this.ServiciosManipulado.getPresupuestoManipulado(id);
if (!this.checkServiceInTable(this.ServiciosManipulado.table, id))
this.ServiciosManipulado.getPresupuestoManipulado(id);
}
}
checkServiceInTable(table, id) {
for (let i = 0; i < table.rows().count(); i++) {
let data = table.row(i).data();
if (data && data.tarifa_id == id) {
return true;
}
}
return false;
}
removeServicio(event, servicio) {
if (servicio == 'ferro'){
if (servicio == 'ferro') {
const id = $('#ferro').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
let data = this.data();
@ -188,7 +198,7 @@ class Servicios {
});
this.serviciosExtra.table.draw();
}
else if (servicio == 'prototipo'){
else if (servicio == 'prototipo') {
const id = $('#prototipo').attr('service-id');
this.serviciosExtra.table.rows().every(function () {
var data = this.data();
@ -198,7 +208,7 @@ class Servicios {
});
this.serviciosExtra.table.draw();
}
else if (servicio == 'retractilado'){
else if (servicio == 'retractilado') {
const id = $('#retractilado').attr('service-id');
this.serviciosAcabado.table.rows().every(function () {
let data = this.data();
@ -208,7 +218,7 @@ class Servicios {
});
this.serviciosAcabado.table.draw();
}
else if (servicio == 'retractilado5'){
else if (servicio == 'retractilado5') {
const id = $('#retractilado5').attr('service-id');
this.serviciosAcabado.table.rows().every(function () {
let data = this.data();
@ -218,7 +228,7 @@ class Servicios {
});
this.serviciosAcabado.table.draw();
}
else if(servicio == 'plegado_guardas'){
else if (servicio == 'plegado_guardas') {
const id = $('#plegado_guardas').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
var data = this.data();
@ -228,7 +238,7 @@ class Servicios {
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_cubierta'){
else if (servicio == 'solapas_cubierta') {
const id = $('#serv_solapas_cubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
let data = this.data();
@ -238,7 +248,7 @@ class Servicios {
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_sobrecubierta'){
else if (servicio == 'solapas_sobrecubierta') {
const id = $('#serv_solapas_sobrecubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
let data = this.data();
@ -248,7 +258,7 @@ class Servicios {
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_faja'){
else if (servicio == 'solapas_faja') {
const id = $('#solapas_faja').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
let data = this.data();
@ -258,7 +268,7 @@ class Servicios {
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_grandes_cubierta'){
else if (servicio == 'solapas_grandes_cubierta') {
const id = $('#solapas_grandes_cubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
let data = this.data();
@ -268,7 +278,7 @@ class Servicios {
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_grandes_sobrecubierta'){
else if (servicio == 'solapas_grandes_sobrecubierta') {
const id = $('#solapas_grandes_sobrecubierta').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
var data = this.data();
@ -278,7 +288,7 @@ class Servicios {
});
this.ServiciosManipulado.table.draw();
}
else if (servicio == 'solapas_grandes_faja'){
else if (servicio == 'solapas_grandes_faja') {
const id = $('#solapas_grandes_faja').attr('service-id');
this.ServiciosManipulado.table.rows().every(function () {
var data = this.data();
@ -315,9 +325,9 @@ class Servicios {
};
this.serviciosAcabado.table.draw();
}
else if (servicio == 'lomo_redondo'){
else if (servicio == 'lomo_redondo') {
const id = $('#compLomoRedondo').attr('service-id');
for(let i = this.ServiciosManipulado.table.rows().count(); i >= 0; i--){
for (let i = this.ServiciosManipulado.table.rows().count(); i >= 0; i--) {
var data = this.ServiciosManipulado.table.row(i).data();
if (data && data.tarifa_id == id) {
this.ServiciosManipulado.table.row(i).remove();
@ -403,7 +413,7 @@ class ServiciosAcabado {
{
data: 'precio_total', render: function (data, type, row) {
let total = 0;
if(data !==undefined)
if (data !== undefined)
total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
return `
<input class="update-totales-servicios form-control" id="precio_acabado_${row.tarifa_id}" value="${total}"></input>`;
@ -468,8 +478,8 @@ class ServiciosAcabado {
self.check_serv_acabado_error();
$(document).trigger('update-presupuesto', {
update_lineas : false,
update_servicios : false,
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
@ -577,7 +587,7 @@ class ServiciosAcabado {
new Ajax('/serviciosacabados/getvalues', datos, {},
function (response) {
if (response.values) {
for(let i=0; i<response.values.length; i++){
for (let i = 0; i < response.values.length; i++) {
response.values[i].cubierta = 0;
response.values[i].sobrecubierta = 0;
response.values[i].faja = 0;
@ -651,9 +661,9 @@ class ServiciosAcabado {
});
const domain = window.location.origin;
const id = window.location.href.split('/').pop();
await fetch(domain + "/presupuestos/presupuestoacabados/edit/" + id , {
await fetch(domain + "/presupuestos/presupuestoacabados/edit/" + id, {
method: "POST",
body: JSON.stringify({datos: datos}),
body: JSON.stringify({ datos: datos }),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
@ -740,7 +750,7 @@ class ServiciosPreimpresion {
data: 'precio', render: function (data, type, row) {
let total = 0;
if(data !==undefined)
if (data !== undefined)
total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
return `
<input class="update-totales-servicios totales-preimpresion form-control" id="precio_preimpresion_${row.tarifa_id}" value="${total}"></input>`;
@ -761,8 +771,8 @@ class ServiciosPreimpresion {
self.check_serv_preimpresion_error();
$(document).trigger('update-presupuesto', {
update_lineas : false,
update_servicios : false,
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
@ -887,9 +897,9 @@ class ServiciosPreimpresion {
});
const domain = window.location.origin;
const id = window.location.href.split('/').pop();
await fetch(domain + "/presupuestos/presupuestopreimpresiones/edit/" + id , {
await fetch(domain + "/presupuestos/presupuestopreimpresiones/edit/" + id, {
method: "POST",
body: JSON.stringify({datos: datos}),
body: JSON.stringify({ datos: datos }),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
@ -974,7 +984,7 @@ class ServiciosEncuadernacion {
{
data: 'precio_total', render: function (data, type, row) {
let total = 0;
if(data !==undefined)
if (data !== undefined)
total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
return `
<input class="update-totales-servicios form-control" id="precio_enc_${row.tarifa_id}" value="${total}"></input>`;
@ -1077,8 +1087,8 @@ class ServiciosEncuadernacion {
self.check_serv_enc_error();
$(document).trigger('update-presupuesto', {
update_lineas : false,
update_servicios : false,
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
@ -1271,9 +1281,9 @@ class ServiciosEncuadernacion {
});
const domain = window.location.origin;
const id = window.location.href.split('/').pop();
await fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id , {
await fetch(domain + "/presupuestos/presupuestoencuadernaciones/edit/" + id, {
method: "POST",
body: JSON.stringify({datos: datos}),
body: JSON.stringify({ datos: datos }),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
@ -1403,7 +1413,7 @@ class ServiciosManipulado {
{
data: 'precio_total', render: function (data, type, row) {
let total = 0;
if(data !==undefined)
if (data !== undefined)
total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
else
data = 0;
@ -1425,8 +1435,8 @@ class ServiciosManipulado {
self.check_serv_manipulado_error();
$(document).trigger('update-presupuesto', {
update_lineas : false,
update_servicios : false,
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
@ -1582,9 +1592,9 @@ class ServiciosManipulado {
});
const domain = window.location.origin;
const id = window.location.href.split('/').pop();
await fetch(domain + "/presupuestos/presupuestomanipulados/edit/" + id , {
await fetch(domain + "/presupuestos/presupuestomanipulados/edit/" + id, {
method: "POST",
body: JSON.stringify({datos: datos}),
body: JSON.stringify({ datos: datos }),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
@ -1669,7 +1679,7 @@ class ServiciosExtra {
data: 'precio', render: function (data, type, row) {
let total = 0;
if(data !==undefined)
if (data !== undefined)
total = parseFloat(data).toLocaleString('es-ES', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
return `
<input class="update-totales-servicios totales-extra form-control" id="precio_extra_${row.tarifa_id}" value="${total}"></input>`;
@ -1690,8 +1700,8 @@ class ServiciosExtra {
self.check_serv_extra_error();
$(document).trigger('update-presupuesto', {
update_lineas : false,
update_servicios : false,
update_lineas: false,
update_servicios: false,
update_envios: false,
update_resumen: true,
update_tiradas_alternativas: true
@ -1758,9 +1768,9 @@ class ServiciosExtra {
});
const domain = window.location.origin;
const id = window.location.href.split('/').pop();
await fetch(domain + "/presupuestos/presupuestoserviciosextra/edit/" + id , {
await fetch(domain + "/presupuestos/presupuestoserviciosextra/edit/" + id, {
method: "POST",
body: JSON.stringify({datos: datos}),
body: JSON.stringify({ datos: datos }),
headers: {
"Content-type": "application/json; charset=UTF-8"
}