Commit de017db2117a4ba937a2c06975f7ee3a91bf199e
1 parent
b083123269
Exists in
develop
Fix
Al abrir sinonimos
Showing
1 changed file
with
17 additions
and
9 deletions
Show diff stats
src/app/shared/header-publicidad/header-publicidad.component.ts
... | ... | @@ -84,6 +84,12 @@ export class HeaderPublicidadComponent implements OnInit { |
84 | 84 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) |
85 | 85 | .subscribe((res: ISinonimo[]) => { |
86 | 86 | if (res.length) { |
87 | + const sinonimos = []; | |
88 | + const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); | |
89 | + Object.keys(gruposArticulos).forEach(key => { | |
90 | + sinonimos.push({ productos: gruposArticulos[key] }); | |
91 | + }); | |
92 | + res = sinonimos; | |
87 | 93 | this.openModalSinonimos(res, articulo); |
88 | 94 | } else { |
89 | 95 | articulo.cantidad = 1; |
... | ... | @@ -102,15 +108,17 @@ export class HeaderPublicidadComponent implements OnInit { |
102 | 108 | modalSinonimo.content.onClose |
103 | 109 | .subscribe((res: any) => { |
104 | 110 | for (const a of articulo.productos) { |
105 | - if (a.idSinonimo === res.ID_SIN) { | |
106 | - a.CODA = res.articulo.CodArt; | |
107 | - a.CodArt = res.articulo.CodArt; | |
108 | - a.SECA = res.articulo.CodSec; | |
109 | - a.CodSec = res.articulo.CodSec; | |
110 | - a.PreVen = res.articulo.PreVen; | |
111 | - a.id = res.articulo.id; | |
112 | - a.DET_LAR = res.articulo.DET_LAR; | |
113 | - a.DetArt = res.articulo.DetArt; | |
111 | + for (const aRes of res.articulos) { | |
112 | + if (a.idSinonimo === aRes.ID_SIN) { | |
113 | + a.CODA = aRes.CodArt; | |
114 | + a.CodArt = aRes.CodArt; | |
115 | + a.SECA = aRes.CodSec; | |
116 | + aRes.CodSec = aRes.CodSec; | |
117 | + a.PreVen = aRes.PreVen; | |
118 | + a.id = aRes.id; | |
119 | + a.DET_LAR = aRes.DET_LAR; | |
120 | + a.DetArt = aRes.DetArt; | |
121 | + } | |
114 | 122 | } |
115 | 123 | } |
116 | 124 | this.articuloService.setArticulo(articulo); |