Commit be7b891885e37a1288a01abe687432e91c09edce
1 parent
14a144eb22
Exists in
master
and in
2 other branches
Agregada funcion para ingresar articulos al carrito
Showing
3 changed files
with
21 additions
and
22 deletions
Show diff stats
src/app/modules/seleccion-articulos/seleccion-articulos.component.html
| ... | ... | @@ -150,17 +150,21 @@ |
| 150 | 150 | </div> |
| 151 | 151 | <div class="col-6 col-sm-8 col-md-9 col-lg-10 h-100"> |
| 152 | 152 | <div #templateCarrito class="row flex-row flex-nowrap h-100 mx-0 scroll-x"> |
| 153 | + <div *ngIf="!articuloService.carrito.length" class="col h-100"> | |
| 154 | + <p>No hay articulos en el carrito</p> | |
| 155 | + </div> | |
| 153 | 156 | <div |
| 154 | - class="col-10 col-sm-4 col-lg-2 col-xl-auto px-2 px-xl-4 my-2 h-100 align-self-center border-right border-primary" | |
| 155 | - (click)="selectCategoria(i)" | |
| 156 | - *ngFor="let categoria of [{},{},{},{},{},{},{},{},{},{},{},{},{},{}]; let i = index;"> | |
| 157 | + class="col-10 col-sm-4 col-lg-2 px-2 px-xl-4 my-2 h-100 align-self-center border-right border-primary swing-in-top-fwd" | |
| 158 | + *ngFor="let articulo of articuloService.carrito; let i = index;"> | |
| 157 | 159 | <img |
| 158 | 160 | draggable="false" |
| 159 | 161 | ondragstart="return false;" |
| 160 | 162 | (contextmenu)="false" |
| 161 | - class="d-block h-55 p-2 mx-auto" | |
| 162 | - src="assets/img/ir-color.svg"> | |
| 163 | - <p class="d-block mt-auto text-center text-primary"><small>{{'articulo'}}</small></p> | |
| 163 | + class="d-block h-55 img-fluid p-2 mx-auto" | |
| 164 | + src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}"> | |
| 165 | + <p class="d-block mt-auto text-center text-primary text-truncate"> | |
| 166 | + <small>{{articulo.DetArt}}</small> | |
| 167 | + </p> | |
| 164 | 168 | </div> |
| 165 | 169 | </div> |
| 166 | 170 | </div> |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
| ... | ... | @@ -125,13 +125,8 @@ export class SeleccionArticulosComponent implements OnInit { |
| 125 | 125 | this.filterItems(); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - elegirArticulo(articulo: any) { | |
| 129 | - if (articulo.promo) { | |
| 130 | - this.modalRef = this.modalService.show(PromocionComponent, { | |
| 131 | - class: 'custom-modal modal-dialog-centered', | |
| 132 | - ignoreBackdropClick: true, | |
| 133 | - }) | |
| 134 | - } | |
| 128 | + elegirArticulo(articulo: IArticulo) { | |
| 129 | + this.articuloService.setArticulo(articulo); | |
| 135 | 130 | } |
| 136 | 131 | |
| 137 | 132 | increaseShow() { |
src/app/services/articulo/articulo.service.ts
| ... | ... | @@ -9,7 +9,7 @@ import { Observable } from 'rxjs'; |
| 9 | 9 | providedIn: 'root' |
| 10 | 10 | }) |
| 11 | 11 | export class ArticuloService { |
| 12 | - articulos: IArticulo[] = []; | |
| 12 | + carrito: IArticulo[] = []; | |
| 13 | 13 | articuloAcargar: IArticulo; |
| 14 | 14 | promoAcargar: IArticulo; |
| 15 | 15 | mostrar: string; |
| ... | ... | @@ -33,15 +33,15 @@ export class ArticuloService { |
| 33 | 33 | return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - setArticulos(articulo: IArticulo) { | |
| 37 | - for (let i = 0; i < this.articulos.length; i++) { | |
| 38 | - if (this.articulos[i].id === articulo.id) { | |
| 36 | + setArticulo(articulo: IArticulo) { | |
| 37 | + for (let i = 0; i < this.carrito.length; i++) { | |
| 38 | + if (this.carrito[i].id === articulo.id) { | |
| 39 | 39 | if (articulo.PRO) break; |
| 40 | - this.articulos[i].cantidad++; | |
| 40 | + this.carrito[i].cantidad++; | |
| 41 | 41 | return; |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | - this.articulos.unshift(articulo); | |
| 44 | + this.carrito.unshift(articulo); | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | getPromocionByCodigos(sector, codigo) { |
| ... | ... | @@ -71,7 +71,7 @@ export class ArticuloService { |
| 71 | 71 | let puntoVenta = parseInt(localStorage.getItem('impresoraPVE')); |
| 72 | 72 | this.markArticuloInPromoAsRemoved(); |
| 73 | 73 | this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${dataPago.medioPago}`, { |
| 74 | - productos: this.articulos, | |
| 74 | + productos: this.carrito, | |
| 75 | 75 | cliente: cliente, |
| 76 | 76 | origen: 'autoservicio', |
| 77 | 77 | codigoVendedor: 5, |
| ... | ... | @@ -90,7 +90,7 @@ export class ArticuloService { |
| 90 | 90 | cleanShoppingCar() { |
| 91 | 91 | this.articuloAcargar = undefined; |
| 92 | 92 | this.promoAcargar = undefined; |
| 93 | - this.articulos = []; | |
| 93 | + this.carrito = []; | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | setArticulosSinImagen(articulos: IArticulo[]) { |
| ... | ... | @@ -101,7 +101,7 @@ export class ArticuloService { |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | markArticuloInPromoAsRemoved() { |
| 104 | - this.articulos.forEach((articulo: IArticulo) => { | |
| 104 | + this.carrito.forEach((articulo: IArticulo) => { | |
| 105 | 105 | if (articulo.PRO) { |
| 106 | 106 | articulo.productos.forEach((articulo: IArticulo) => { |
| 107 | 107 | if (articulo.cantidadAdicionada === 0) { |