Commit 5ecbcd777de6bb23ab4e2f05850e3c4389fba70b
1 parent
ba604922f0
Exists in
develop
Add
Seleccionar sinonimos.
Showing
5 changed files
with
44 additions
and
12 deletions
Show diff stats
src/app/interfaces/IArticulo.ts
| ... | ... | @@ -14,6 +14,7 @@ export interface IArticulo { |
| 14 | 14 | FPP?: boolean; |
| 15 | 15 | id: number; |
| 16 | 16 | idSinonimo?: number; |
| 17 | + ID_SIN?: number; | |
| 17 | 18 | imagenes?: any[]; |
| 18 | 19 | ImpInt: number; |
| 19 | 20 | ImpInt2: number; |
| ... | ... | @@ -25,7 +26,10 @@ export interface IArticulo { |
| 25 | 26 | seleccionado?: boolean; |
| 26 | 27 | tieneSinonimo?: boolean; |
| 27 | 28 | tipo_articulo?: number; |
| 28 | - comentario?: string; | |
| 29 | + CODA?: number; | |
| 30 | + CODP?: number; | |
| 31 | + SECA?: number; | |
| 32 | + SECP?: number; | |
| 29 | 33 | } |
| 30 | 34 | |
| 31 | 35 | export interface ICodigoBarra { |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
| 1 | -import { Component, OnInit, TemplateRef, OnDestroy, HostListener } from '@angular/core'; | |
| 1 | +import { Component, OnInit, OnDestroy, HostListener } from '@angular/core'; | |
| 2 | 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; |
| 3 | 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 4 | 4 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| ... | ... | @@ -6,7 +6,6 @@ import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 6 | 6 | import { ICategoria } from 'src/app/interfaces/ICategoria'; |
| 7 | 7 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 8 | 8 | import { CategoriaService } from 'src/app/services/categoria/categoria.service'; |
| 9 | -import { PromocionService } from 'src/app/services/promocion/promocion.service'; | |
| 10 | 9 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; |
| 11 | 10 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; |
| 12 | 11 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; |
| ... | ... | @@ -152,7 +151,7 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy { |
| 152 | 151 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) |
| 153 | 152 | .subscribe((res: ISinonimo[]) => { |
| 154 | 153 | if (res.length) { |
| 155 | - this.openModalSinonimos(res); | |
| 154 | + this.openModalSinonimos(res, articulo); | |
| 156 | 155 | } else { |
| 157 | 156 | this.articuloService.setArticulo(articulo); |
| 158 | 157 | } |
| ... | ... | @@ -166,14 +165,26 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy { |
| 166 | 165 | }); |
| 167 | 166 | } |
| 168 | 167 | |
| 169 | - openModalSinonimos(sinonimosData: ISinonimo[]) { | |
| 168 | + openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { | |
| 170 | 169 | this.modalRef = this.modalService.show(SinonimoComponent, { |
| 171 | 170 | initialState: { sinonimos: sinonimosData }, |
| 172 | 171 | class: 'modal-promo modal-dialog-centered' |
| 173 | 172 | }); |
| 174 | 173 | |
| 175 | 174 | this.modalRef.content.onClose |
| 176 | - .subscribe((articulo: IArticulo) => { | |
| 175 | + .subscribe((res: any) => { | |
| 176 | + for (const a of articulo.productos) { | |
| 177 | + if (a.idSinonimo === res.ID_SIN) { | |
| 178 | + a.CODA = res.articulo.CodArt; | |
| 179 | + a.CodArt = res.articulo.CodArt; | |
| 180 | + a.SECA = res.articulo.CodSec; | |
| 181 | + a.CodSec = res.articulo.CodSec; | |
| 182 | + a.PreVen = res.articulo.PreVen; | |
| 183 | + a.id = res.articulo.id; | |
| 184 | + a.DET_LAR = res.articulo.DET_LAR; | |
| 185 | + a.DetArt = res.articulo.DetArt; | |
| 186 | + } | |
| 187 | + } | |
| 177 | 188 | this.articuloService.setArticulo(articulo); |
| 178 | 189 | }); |
| 179 | 190 | } |
src/app/services/articulo/articulo.service.ts
| ... | ... | @@ -44,7 +44,7 @@ export class ArticuloService { |
| 44 | 44 | setArticulo(articulo: IArticulo) { |
| 45 | 45 | articulo.cantidad = 1; |
| 46 | 46 | for (const articuloCarrito of this.carrito) { |
| 47 | - if (articuloCarrito.id === articulo.id) { | |
| 47 | + if (articuloCarrito.id === articulo.id && !articulo.productos.length) { | |
| 48 | 48 | articuloCarrito.cantidad++; |
| 49 | 49 | this.calcularTotal(); |
| 50 | 50 | return; |
src/app/shared/promocion/promocion.component.ts
| ... | ... | @@ -40,7 +40,7 @@ export class PromocionComponent implements OnInit { |
| 40 | 40 | this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt) |
| 41 | 41 | .subscribe((res: ISinonimo[]) => { |
| 42 | 42 | if (res.length) { |
| 43 | - this.openModalSinonimos(res); | |
| 43 | + this.openModalSinonimos(res, promo); | |
| 44 | 44 | } else { |
| 45 | 45 | promo.cantidad = 1; |
| 46 | 46 | this.articuloService.setArticulo(promo); |
| ... | ... | @@ -50,14 +50,26 @@ export class PromocionComponent implements OnInit { |
| 50 | 50 | this.mediaPantalla(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - openModalSinonimos(sinonimosData: ISinonimo[]) { | |
| 53 | + openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { | |
| 54 | 54 | const modalSinonimo = this.modalService.show(SinonimoComponent, { |
| 55 | 55 | initialState: { sinonimos: sinonimosData }, |
| 56 | 56 | class: 'modal-promo modal-dialog-centered' |
| 57 | 57 | }); |
| 58 | 58 | |
| 59 | 59 | modalSinonimo.content.onClose |
| 60 | - .subscribe((articulo: IArticulo) => { | |
| 60 | + .subscribe((res: any) => { | |
| 61 | + for (const a of articulo.productos) { | |
| 62 | + if (a.idSinonimo === res.ID_SIN) { | |
| 63 | + a.CODA = res.articulo.CodArt; | |
| 64 | + a.CodArt = res.articulo.CodArt; | |
| 65 | + a.SECA = res.articulo.CodSec; | |
| 66 | + a.CodSec = res.articulo.CodSec; | |
| 67 | + a.PreVen = res.articulo.PreVen; | |
| 68 | + a.id = res.articulo.id; | |
| 69 | + a.DET_LAR = res.articulo.DET_LAR; | |
| 70 | + a.DetArt = res.articulo.DetArt; | |
| 71 | + } | |
| 72 | + } | |
| 61 | 73 | this.articuloService.setArticulo(articulo); |
| 62 | 74 | this.modalPromocion.hide(); |
| 63 | 75 | }); |
src/app/shared/sinonimo/sinonimo.component.ts
| ... | ... | @@ -49,11 +49,16 @@ export class SinonimoComponent implements OnInit { |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | continue() { |
| 52 | + if (!this.isValid) return; | |
| 53 | + const ID_SIN = this.articuloSelected.ID_SIN; | |
| 52 | 54 | this.articuloService.getById(this.articuloSelected.id) |
| 53 | 55 | .subscribe((res: IArticulo) => { |
| 54 | 56 | this.modalRef.hide(); |
| 55 | - this.onClose.next(res); | |
| 56 | - }); | |
| 57 | + this.onClose.next({ | |
| 58 | + articulo: res, | |
| 59 | + ID_SIN | |
| 60 | + }); | |
| 61 | + }, err => console.error(err)); | |
| 57 | 62 | } |
| 58 | 63 | |
| 59 | 64 | } |