Commit 041b572f22c094f2eea393837db5d4d380d7afcd
1 parent
b034142316
Exists in
master
and in
1 other branch
se agrega validar pve si está seteado, sino oculta el componente inicio
Showing
3 changed files
with
15 additions
and
1 deletions
Show diff stats
src/app/components/configuracion/configuracion.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { BsModalRef } from 'ngx-bootstrap'; | 2 | import { BsModalRef } from 'ngx-bootstrap'; |
| 3 | import { PuntoVentaService } from 'src/app/services/punto-venta.service'; | 3 | import { PuntoVentaService } from 'src/app/services/punto-venta.service'; |
| 4 | import { PuntoVenta } from 'src/app/wrappers/puntoVenta'; | 4 | import { PuntoVenta } from 'src/app/wrappers/puntoVenta'; |
| 5 | import { ImpresoraService } from 'src/app/services/impresora.service'; | 5 | import { ImpresoraService } from 'src/app/services/impresora.service'; |
| 6 | import { Impresora } from 'src/app/wrappers/impresora'; | 6 | import { Impresora } from 'src/app/wrappers/impresora'; |
| 7 | import { FormGroup, FormControl } from '@angular/forms'; | 7 | import { FormGroup, FormControl } from '@angular/forms'; |
| 8 | import { Router } from '@angular/router'; | ||
| 8 | 9 | ||
| 9 | @Component({ | 10 | @Component({ |
| 10 | selector: 'app-configuracion', | 11 | selector: 'app-configuracion', |
| 11 | templateUrl: './configuracion.component.html', | 12 | templateUrl: './configuracion.component.html', |
| 12 | styleUrls: ['./configuracion.component.scss'] | 13 | styleUrls: ['./configuracion.component.scss'] |
| 13 | }) | 14 | }) |
| 14 | export class ConfiguracionComponent implements OnInit { | 15 | export class ConfiguracionComponent implements OnInit { |
| 15 | 16 | ||
| 16 | puntosVenta: PuntoVenta[] = []; | 17 | puntosVenta: PuntoVenta[] = []; |
| 17 | impresoras: Impresora[] = []; | 18 | impresoras: Impresora[] = []; |
| 18 | form: FormGroup; | 19 | form: FormGroup; |
| 20 | reiniciar: boolean = false; | ||
| 19 | 21 | ||
| 20 | constructor( | 22 | constructor( |
| 21 | private activeModal: BsModalRef, | 23 | private activeModal: BsModalRef, |
| 22 | private puntoVentaService: PuntoVentaService, | 24 | private puntoVentaService: PuntoVentaService, |
| 23 | private impresoraService: ImpresoraService, | 25 | private impresoraService: ImpresoraService, |
| 26 | private router: Router | ||
| 24 | ) { } | 27 | ) { } |
| 25 | 28 | ||
| 26 | ngOnInit() { | 29 | ngOnInit() { |
| 27 | 30 | ||
| 28 | this.form = new FormGroup({ | 31 | this.form = new FormGroup({ |
| 29 | usePlanillaPropia: new FormControl(false, []), | 32 | usePlanillaPropia: new FormControl(false, []), |
| 30 | puntoVenta: new FormControl(null, []), | 33 | puntoVenta: new FormControl(null, []), |
| 31 | impresora: new FormControl(null, []), | 34 | impresora: new FormControl(null, []), |
| 32 | }) | 35 | }) |
| 33 | 36 | ||
| 34 | this.puntoVentaService.getAll() | 37 | this.puntoVentaService.getAll() |
| 35 | .subscribe((res: PuntoVenta[]) => { | 38 | .subscribe((res: PuntoVenta[]) => { |
| 36 | 39 | ||
| 37 | this.puntosVenta = res; | 40 | this.puntosVenta = res; |
| 38 | this.setPuntoVenta(); | 41 | this.setPuntoVenta(); |
| 39 | }, console.error); | 42 | }, console.error); |
| 40 | 43 | ||
| 41 | this.impresoraService.getAll() | 44 | this.impresoraService.getAll() |
| 42 | .subscribe((res: Impresora[]) => { | 45 | .subscribe((res: Impresora[]) => { |
| 43 | 46 | ||
| 44 | this.impresoras = res; | 47 | this.impresoras = res; |
| 45 | this.setImpresora(); | 48 | this.setImpresora(); |
| 46 | }, console.error); | 49 | }, console.error); |
| 47 | 50 | ||
| 48 | } | 51 | } |
| 49 | 52 | ||
| 50 | close() { | 53 | close() { |
| 51 | 54 | ||
| 52 | this.activeModal.hide(); | 55 | this.activeModal.hide(); |
| 56 | if (this.reiniciar) { | ||
| 57 | this.router.navigate(['inicio']); | ||
| 58 | } | ||
| 53 | } | 59 | } |
| 54 | 60 | ||
| 55 | acept() { | 61 | acept() { |
| 62 | this.reiniciar = !localStorage.getItem('impresoraPVE') ? true : false; | ||
| 56 | 63 | ||
| 57 | let auxPuntoVenta = this.puntosVenta.find(p => p.ID === this.form.get('puntoVenta').value); | 64 | let auxPuntoVenta = this.puntosVenta.find(p => p.ID === this.form.get('puntoVenta').value); |
| 58 | let auxImpresora = this.impresoras.find(p => p.PVE === this.form.get('impresora').value); | 65 | let auxImpresora = this.impresoras.find(p => p.PVE === this.form.get('impresora').value); |
| 59 | localStorage.setItem('pve', auxPuntoVenta ? auxPuntoVenta.ID.toString() : null); | 66 | localStorage.setItem('pve', auxPuntoVenta ? auxPuntoVenta.ID.toString() : null); |
| 60 | localStorage.setItem('impresoraPVE', auxImpresora ? auxImpresora.PVE.toString() : null); | 67 | localStorage.setItem('impresoraPVE', auxImpresora ? auxImpresora.PVE.toString() : null); |
| 61 | this.close(); | 68 | this.close(); |
| 62 | } | 69 | } |
| 63 | 70 | ||
| 64 | setPuntoVenta() { | 71 | setPuntoVenta() { |
| 65 | 72 | ||
| 66 | let pve = parseInt(localStorage.getItem('pve')); | 73 | let pve = parseInt(localStorage.getItem('pve')); |
| 67 | let auxPuntoVenta = this.puntosVenta.find(x => x.ID === pve); | 74 | let auxPuntoVenta = this.puntosVenta.find(x => x.ID === pve); |
| 68 | this.form.get('puntoVenta').setValue(auxPuntoVenta ? auxPuntoVenta.ID : null); | 75 | this.form.get('puntoVenta').setValue(auxPuntoVenta ? auxPuntoVenta.ID : null); |
| 69 | } | 76 | } |
| 70 | 77 | ||
| 71 | setImpresora() { | 78 | setImpresora() { |
| 72 | 79 | ||
| 73 | let impresoraPVE = parseInt(localStorage.getItem('impresoraPVE')); | 80 | let impresoraPVE = parseInt(localStorage.getItem('impresoraPVE')); |
| 74 | let auxImpresora = this.impresoras.find(x => x.PVE === impresoraPVE); | 81 | let auxImpresora = this.impresoras.find(x => x.PVE === impresoraPVE); |
| 75 | this.form.get('impresora').setValue(auxImpresora ? auxImpresora.PVE : null); | 82 | this.form.get('impresora').setValue(auxImpresora ? auxImpresora.PVE : null); |
| 76 | } | 83 | } |
| 77 | 84 | ||
| 78 | } | 85 | } |
| 79 | 86 |
src/app/components/inicio/inicio.component.html
| 1 | <div class="row m-0 fade-in"> | 1 | <div class="row m-0 fade-in" [hidden]="!mostrarPantalla"> |
| 2 | <div class="col-12 p-0"> | 2 | <div class="col-12 p-0"> |
| 3 | 3 | ||
| 4 | <!-- NOMBRE DE SECCION --> | 4 | <!-- NOMBRE DE SECCION --> |
| 5 | <div class="row m-0"> | 5 | <div class="row m-0"> |
| 6 | <div class="col-12 p-0"> | 6 | <div class="col-12 p-0"> |
| 7 | <p class="h5 m-0 py-1 bg-gray text-muted text-center">Inicio</p> | 7 | <p class="h5 m-0 py-1 bg-gray text-muted text-center">Inicio</p> |
| 8 | </div> | 8 | </div> |
| 9 | </div> | 9 | </div> |
| 10 | 10 | ||
| 11 | <div class="row m-0 d-flex align-items-start disable-user-select"> | 11 | <div class="row m-0 d-flex align-items-start disable-user-select"> |
| 12 | <div class="col-md-5 py-3 pr-0 d-flex align-items-end flex-column"> | 12 | <div class="col-md-5 py-3 pr-0 d-flex align-items-end flex-column"> |
| 13 | 13 | ||
| 14 | <!-- PROMOCIONES --> | 14 | <!-- PROMOCIONES --> |
| 15 | <div | 15 | <div |
| 16 | (click)="irBusquedaProductos('promociones')" | 16 | (click)="irBusquedaProductos('promociones')" |
| 17 | class="card card-effect bg-white border-0 shadow rounded w-100 mb-auto"> | 17 | class="card card-effect bg-white border-0 shadow rounded w-100 mb-auto"> |
| 18 | <div class="card-body text-left px-4 py-3"> | 18 | <div class="card-body text-left px-4 py-3"> |
| 19 | <div class="row"> | 19 | <div class="row"> |
| 20 | <div class="col-auto"> | 20 | <div class="col-auto"> |
| 21 | <p class="m-0 h3 card-title">Promociones</p> | 21 | <p class="m-0 h3 card-title">Promociones</p> |
| 22 | </div> | 22 | </div> |
| 23 | <div class="col-auto p-0"> | 23 | <div class="col-auto p-0"> |
| 24 | <img src="{{apiImagenes}}/imagenes/primario.promociones.png" class="w-15 m-0"> | 24 | <img src="{{apiImagenes}}/imagenes/primario.promociones.png" class="w-15 m-0"> |
| 25 | </div> | 25 | </div> |
| 26 | </div> | 26 | </div> |
| 27 | <p class="h5 card-text text-muted font-weight-light">Conozca las ofertas del momento.</p> | 27 | <p class="h5 card-text text-muted font-weight-light">Conozca las ofertas del momento.</p> |
| 28 | </div> | 28 | </div> |
| 29 | <!-- CAROUSEL --> | 29 | <!-- CAROUSEL --> |
| 30 | <carousel [showIndicators]="false" [interval]="1500"> | 30 | <carousel [showIndicators]="false" [interval]="1500"> |
| 31 | <slide class="h-100"> | 31 | <slide class="h-100"> |
| 32 | <img | 32 | <img |
| 33 | src="{{apiImagenes}}/imagenes/beldent.jpg" | 33 | src="{{apiImagenes}}/imagenes/beldent.jpg" |
| 34 | class="fade-in d-block w-75 m-auto rounded"> | 34 | class="fade-in d-block w-75 m-auto rounded"> |
| 35 | </slide> | 35 | </slide> |
| 36 | <slide class="h-100"> | 36 | <slide class="h-100"> |
| 37 | <img | 37 | <img |
| 38 | src="{{apiImagenes}}/imagenes/cafe con leche y medialunas.jpg" | 38 | src="{{apiImagenes}}/imagenes/cafe con leche y medialunas.jpg" |
| 39 | class="fade-in d-block w-75 m-auto rounded"> | 39 | class="fade-in d-block w-75 m-auto rounded"> |
| 40 | </slide> | 40 | </slide> |
| 41 | <slide class="h-100"> | 41 | <slide class="h-100"> |
| 42 | <img | 42 | <img |
| 43 | src="{{apiImagenes}}/imagenes/Surtido bagley.jpg" | 43 | src="{{apiImagenes}}/imagenes/Surtido bagley.jpg" |
| 44 | class="fade-in d-block w-75 m-auto rounded"> | 44 | class="fade-in d-block w-75 m-auto rounded"> |
| 45 | </slide> | 45 | </slide> |
| 46 | <slide class="h-100"> | 46 | <slide class="h-100"> |
| 47 | <img | 47 | <img |
| 48 | src="{{apiImagenes}}/imagenes/yogurisimo.jpg" | 48 | src="{{apiImagenes}}/imagenes/yogurisimo.jpg" |
| 49 | class="fade-in d-block w-75 m-auto rounded"> | 49 | class="fade-in d-block w-75 m-auto rounded"> |
| 50 | </slide> | 50 | </slide> |
| 51 | </carousel> | 51 | </carousel> |
| 52 | </div> | 52 | </div> |
| 53 | 53 | ||
| 54 | <!-- ORDENAR --> | 54 | <!-- ORDENAR --> |
| 55 | <div (click)="irBusquedaProductos('ordenar')" | 55 | <div (click)="irBusquedaProductos('ordenar')" |
| 56 | class="card card-effect bg-white border-0 shadow rounded w-100 mt-3"> | 56 | class="card card-effect bg-white border-0 shadow rounded w-100 mt-3"> |
| 57 | <div class="card-body text-left px-4 py-3"> | 57 | <div class="card-body text-left px-4 py-3"> |
| 58 | <div class="row"> | 58 | <div class="row"> |
| 59 | <div class="col-auto"> | 59 | <div class="col-auto"> |
| 60 | <p class="m-0 h3 card-title">Ordenar Pedido</p> | 60 | <p class="m-0 h3 card-title">Ordenar Pedido</p> |
| 61 | </div> | 61 | </div> |
| 62 | <div class="col-auto p-0"> | 62 | <div class="col-auto p-0"> |
| 63 | <img src="{{apiImagenes}}/imagenes/primario.ordenar.png" class="w-15"> | 63 | <img src="{{apiImagenes}}/imagenes/primario.ordenar.png" class="w-15"> |
| 64 | </div> | 64 | </div> |
| 65 | </div> | 65 | </div> |
| 66 | <p class="h5 card-text text-muted font-weight-light">Arme su pedido y solo pase a retirar.</p> | 66 | <p class="h5 card-text text-muted font-weight-light">Arme su pedido y solo pase a retirar.</p> |
| 67 | </div> | 67 | </div> |
| 68 | <img | 68 | <img |
| 69 | class="card-img-bottom d-block w-100 mx-auto rounded" | 69 | class="card-img-bottom d-block w-100 mx-auto rounded" |
| 70 | src="{{apiImagenes}}/imagenes/cafe.jpg"> | 70 | src="{{apiImagenes}}/imagenes/cafe.jpg"> |
| 71 | </div> | 71 | </div> |
| 72 | </div> | 72 | </div> |
| 73 | 73 | ||
| 74 | <div class="col-md-7 py-3 d-flex align-items-end flex-column mt-4 mt-md-0"> | 74 | <div class="col-md-7 py-3 d-flex align-items-end flex-column mt-4 mt-md-0"> |
| 75 | 75 | ||
| 76 | <!-- CARGAR PRODUCTOS --> | 76 | <!-- CARGAR PRODUCTOS --> |
| 77 | <ng-template #popTemplate> | 77 | <ng-template #popTemplate> |
| 78 | <app-popover-promos | 78 | <app-popover-promos |
| 79 | *ngIf="promociones.length > 0 && sinonimos.length === 0" | 79 | *ngIf="promociones.length > 0 && sinonimos.length === 0" |
| 80 | [popover]="popoverDirective" | 80 | [popover]="popoverDirective" |
| 81 | [popoverContent]="promociones" | 81 | [popoverContent]="promociones" |
| 82 | (promoSeleccionada)="promoSeleccionada($event, false)" | 82 | (promoSeleccionada)="promoSeleccionada($event, false)" |
| 83 | class="text-white rounded-sm border-0"> | 83 | class="text-white rounded-sm border-0"> |
| 84 | </app-popover-promos> | 84 | </app-popover-promos> |
| 85 | <app-popover-sinonimos | 85 | <app-popover-sinonimos |
| 86 | *ngIf="sinonimos.length > 0" | 86 | *ngIf="sinonimos.length > 0" |
| 87 | [popover]="popoverDirective" | 87 | [popover]="popoverDirective" |
| 88 | [popoverContent]="sinonimos" | 88 | [popoverContent]="sinonimos" |
| 89 | (productosPersonalizados)="productosPersonalizados($event)" | 89 | (productosPersonalizados)="productosPersonalizados($event)" |
| 90 | class="text-white rounded-sm border-0"> | 90 | class="text-white rounded-sm border-0"> |
| 91 | </app-popover-sinonimos> | 91 | </app-popover-sinonimos> |
| 92 | </ng-template> | 92 | </ng-template> |
| 93 | <div | 93 | <div |
| 94 | placement="left" | 94 | placement="left" |
| 95 | triggers="" | 95 | triggers="" |
| 96 | [popover]="popTemplate" | 96 | [popover]="popTemplate" |
| 97 | class="w-100" | 97 | class="w-100" |
| 98 | #pop="bs-popover"> | 98 | #pop="bs-popover"> |
| 99 | <div class="card bg-white border-0 shadow rounded mb-auto"> | 99 | <div class="card bg-white border-0 shadow rounded mb-auto"> |
| 100 | <div class="card-body text-left px-4 py-3"> | 100 | <div class="card-body text-left px-4 py-3"> |
| 101 | <div class="row"> | 101 | <div class="row"> |
| 102 | <div class="col-auto"> | 102 | <div class="col-auto"> |
| 103 | <p class="m-0 h3 card-title">Cargar Productos</p> | 103 | <p class="m-0 h3 card-title">Cargar Productos</p> |
| 104 | </div> | 104 | </div> |
| 105 | <div class="col-auto p-0"> | 105 | <div class="col-auto p-0"> |
| 106 | <img src="../../../assets/img/escanear.png" class="w-15"> | 106 | <img src="../../../assets/img/escanear.png" class="w-15"> |
| 107 | </div> | 107 | </div> |
| 108 | </div> | 108 | </div> |
| 109 | <p class="h5 card-text text-muted font-weight-light"> | 109 | <p class="h5 card-text text-muted font-weight-light"> |
| 110 | Coloque un producto frente<br> | 110 | Coloque un producto frente<br> |
| 111 | al lector de códigos o selecciónelo en pantalla. | 111 | al lector de códigos o selecciónelo en pantalla. |
| 112 | </p> | 112 | </p> |
| 113 | </div> | 113 | </div> |
| 114 | <div class="row mx-3 mb-3"> | 114 | <div class="row mx-3 mb-3"> |
| 115 | <div class="col card bg-white shadow border-0 w-75 p-0 mx-auto rounded-sm"> | 115 | <div class="col card bg-white shadow border-0 w-75 p-0 mx-auto rounded-sm"> |
| 116 | <!-- IMAGEN DE ESCANER --> | 116 | <!-- IMAGEN DE ESCANER --> |
| 117 | <img | 117 | <img |
| 118 | *ngIf="!productoAcargar" | 118 | *ngIf="!productoAcargar" |
| 119 | class="card-img-top d-block w-100 mx-auto rounded-sm" | 119 | class="card-img-top d-block w-100 mx-auto rounded-sm" |
| 120 | src="../../../assets/img/escanner.jpg"> | 120 | src="../../../assets/img/escanner.jpg"> |
| 121 | 121 | ||
| 122 | <!-- PRODUCTO A CARGAR --> | 122 | <!-- PRODUCTO A CARGAR --> |
| 123 | <div class="fade-in m-0" *ngIf="productoAcargar && !promoAcargar"> | 123 | <div class="fade-in m-0" *ngIf="productoAcargar && !promoAcargar"> |
| 124 | <img | 124 | <img |
| 125 | class="card-img-top d-block w-75 shadow mx-auto rounded-sm" | 125 | class="card-img-top d-block w-75 shadow mx-auto rounded-sm" |
| 126 | src="{{apiImagenes}}/imagenes/{{productoAcargar.imagenes[0].imagen}}"> | 126 | src="{{apiImagenes}}/imagenes/{{productoAcargar.imagenes[0].imagen}}"> |
| 127 | 127 | ||
| 128 | <div class="row justify-content-between m-3"> | 128 | <div class="row justify-content-between m-3"> |
| 129 | <div class="col-12 text-left px-1"> | 129 | <div class="col-12 text-left px-1"> |
| 130 | <p class="h6 font-weight-bold mb-0">{{productoAcargar.DET_LAR}}</p> | 130 | <p class="h6 font-weight-bold mb-0">{{productoAcargar.DET_LAR}}</p> |
| 131 | </div> | 131 | </div> |
| 132 | <div class="col-12 text-right mt-2"> | 132 | <div class="col-12 text-right mt-2"> |
| 133 | <p class="h5 font-weight-bold mb-0">{{productoAcargar.PreVen | currency}}</p> | 133 | <p class="h5 font-weight-bold mb-0">{{productoAcargar.PreVen | currency}}</p> |
| 134 | </div> | 134 | </div> |
| 135 | </div> | 135 | </div> |
| 136 | </div> | 136 | </div> |
| 137 | 137 | ||
| 138 | <!-- PROMO A CARGAR --> | 138 | <!-- PROMO A CARGAR --> |
| 139 | <div class="fade-in m-0" *ngIf="promoAcargar"> | 139 | <div class="fade-in m-0" *ngIf="promoAcargar"> |
| 140 | <img | 140 | <img |
| 141 | class="card-img-top d-block w-100 mx-auto rounded-sm" | 141 | class="card-img-top d-block w-100 mx-auto rounded-sm" |
| 142 | src="{{apiImagenes}}/imagenes/{{promoAcargar.imagenes[0].imagen}}"> | 142 | src="{{apiImagenes}}/imagenes/{{promoAcargar.imagenes[0].imagen}}"> |
| 143 | 143 | ||
| 144 | <div class="row justify-content-between m-3"> | 144 | <div class="row justify-content-between m-3"> |
| 145 | <div class="col-12 text-left px-1"> | 145 | <div class="col-12 text-left px-1"> |
| 146 | <p class="h6 font-weight-bold mb-0">{{promoAcargar.DET_LAR}}</p> | 146 | <p class="h6 font-weight-bold mb-0">{{promoAcargar.DET_LAR}}</p> |
| 147 | </div> | 147 | </div> |
| 148 | <div class="col-12 text-right mt-2 align-self-end"> | 148 | <div class="col-12 text-right mt-2 align-self-end"> |
| 149 | <p class="h5 font-weight-bold mb-0">{{promoAcargar.PreVen | currency}}</p> | 149 | <p class="h5 font-weight-bold mb-0">{{promoAcargar.PreVen | currency}}</p> |
| 150 | </div> | 150 | </div> |
| 151 | </div> | 151 | </div> |
| 152 | </div> | 152 | </div> |
| 153 | 153 | ||
| 154 | </div> | 154 | </div> |
| 155 | <!-- BOTONES DE CARGAR PRODUCTOS--> | 155 | <!-- BOTONES DE CARGAR PRODUCTOS--> |
| 156 | <div | 156 | <div |
| 157 | class="col-5 pr-0" | 157 | class="col-5 pr-0" |
| 158 | *ngIf="promociones.length > 0"> | 158 | *ngIf="promociones.length > 0"> |
| 159 | <button | 159 | <button |
| 160 | *ngIf="!promoAcargar || sinonimos.length == 0" | 160 | *ngIf="!promoAcargar || sinonimos.length == 0" |
| 161 | type="button" | 161 | type="button" |
| 162 | class="btn btn-primary btn-block shadow-sm" | 162 | class="btn btn-primary btn-block shadow-sm" |
| 163 | (click)="pop.show()"> | 163 | (click)="pop.show()"> |
| 164 | <span class="pr-2">Mostrar promociones</span> | 164 | <span class="pr-2">Mostrar promociones</span> |
| 165 | <i class="fa fa-bullhorn fa-flip-horizontal" aria-hidden="true"></i> | 165 | <i class="fa fa-bullhorn fa-flip-horizontal" aria-hidden="true"></i> |
| 166 | </button> | 166 | </button> |
| 167 | <button | 167 | <button |
| 168 | *ngIf="sinonimos.length == 0" | 168 | *ngIf="sinonimos.length == 0" |
| 169 | type="button" | 169 | type="button" |
| 170 | class="btn btn-light btn-block shadow-sm my-3" | 170 | class="btn btn-light btn-block shadow-sm my-3" |
| 171 | (click)="confirmarProducto()"> | 171 | (click)="confirmarProducto()"> |
| 172 | <span class="pr-2 font-weight-bold">Confirmar</span> | 172 | <span class="pr-2 font-weight-bold">Confirmar</span> |
| 173 | <i class="fa fa-check text-success" aria-hidden="true"></i> | 173 | <i class="fa fa-check text-success" aria-hidden="true"></i> |
| 174 | </button> | 174 | </button> |
| 175 | <button | 175 | <button |
| 176 | type="button" | 176 | type="button" |
| 177 | class="btn btn-light btn-block shadow-sm" | 177 | class="btn btn-light btn-block shadow-sm" |
| 178 | (click)="deshacerCarga()"> | 178 | (click)="deshacerCarga()"> |
| 179 | <span class="pr-2">Deshacer</span> | 179 | <span class="pr-2">Deshacer</span> |
| 180 | <i class="fa fa-undo text-warning" aria-hidden="true"></i> | 180 | <i class="fa fa-undo text-warning" aria-hidden="true"></i> |
| 181 | </button> | 181 | </button> |
| 182 | </div> | 182 | </div> |
| 183 | </div> | 183 | </div> |
| 184 | </div> | 184 | </div> |
| 185 | </div> | 185 | </div> |
| 186 | 186 | ||
| 187 | <!-- BUSCAR PRODUCTOS --> | 187 | <!-- BUSCAR PRODUCTOS --> |
| 188 | <div (click)="irBusquedaProductos('todos')" | 188 | <div (click)="irBusquedaProductos('todos')" |
| 189 | class="card card-effect bg-white border-0 shadow rounded w-100 mt-3"> | 189 | class="card card-effect bg-white border-0 shadow rounded w-100 mt-3"> |
| 190 | <div class="card-body text-left px-4 py-3"> | 190 | <div class="card-body text-left px-4 py-3"> |
| 191 | <div class="row"> | 191 | <div class="row"> |
| 192 | <div class="col-auto"> | 192 | <div class="col-auto"> |
| 193 | <p class="m-0 h3 card-title">Buscar Productos</p> | 193 | <p class="m-0 h3 card-title">Buscar Productos</p> |
| 194 | <p class="h5 card-text text-muted font-weight-light"> | 194 | <p class="h5 card-text text-muted font-weight-light"> |
| 195 | Busque aquí los productos<br> | 195 | Busque aquí los productos<br> |
| 196 | que no tienen código.</p> | 196 | que no tienen código.</p> |
| 197 | </div> | 197 | </div> |
| 198 | <div class="col-auto p-0"> | 198 | <div class="col-auto p-0"> |
| 199 | <img src="../../../assets/img/primario.buscar.png" class="w-15"> | 199 | <img src="../../../assets/img/primario.buscar.png" class="w-15"> |
| 200 | </div> | 200 | </div> |
| 201 | </div> | 201 | </div> |
| 202 | 202 | ||
| 203 | </div> | 203 | </div> |
| 204 | </div> | 204 | </div> |
| 205 | 205 | ||
| 206 | </div> | 206 | </div> |
| 207 | 207 | ||
| 208 | </div> | 208 | </div> |
| 209 | 209 | ||
| 210 | </div> | 210 | </div> |
| 211 | </div> | 211 | </div> |
| 212 | |||
| 213 | <div class="row m-0 fade-in" [hidden]="mostrarPantalla"> | ||
| 214 | <p class="w-100 text-center">No esá configurado el punto de venta</p> | ||
| 215 | </div> |
src/app/components/inicio/inicio.component.ts
| 1 | import { Component, OnInit, ViewChild, HostListener, AfterViewInit } from '@angular/core'; | 1 | import { Component, OnInit, ViewChild, HostListener, AfterViewInit } from '@angular/core'; |
| 2 | import { PopoverDirective } from 'ngx-bootstrap'; | 2 | import { PopoverDirective } from 'ngx-bootstrap'; |
| 3 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 3 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 4 | import { Router } from '@angular/router'; | 4 | import { Router } from '@angular/router'; |
| 5 | import { ProductoService } from 'src/app/services/producto.service'; | 5 | import { ProductoService } from 'src/app/services/producto.service'; |
| 6 | import { Producto } from 'src/app/wrappers/producto'; | 6 | import { Producto } from 'src/app/wrappers/producto'; |
| 7 | import { Sinonimo } from 'src/app/wrappers/sinonimo'; | 7 | import { Sinonimo } from 'src/app/wrappers/sinonimo'; |
| 8 | 8 | ||
| 9 | @Component({ | 9 | @Component({ |
| 10 | selector: 'app-inicio', | 10 | selector: 'app-inicio', |
| 11 | templateUrl: './inicio.component.html', | 11 | templateUrl: './inicio.component.html', |
| 12 | styleUrls: ['./inicio.component.scss'] | 12 | styleUrls: ['./inicio.component.scss'] |
| 13 | }) | 13 | }) |
| 14 | export class InicioComponent implements OnInit, AfterViewInit { | 14 | export class InicioComponent implements OnInit, AfterViewInit { |
| 15 | 15 | ||
| 16 | private tienePromo = false; | 16 | private tienePromo = false; |
| 17 | private productoEsPromo = false; | 17 | private productoEsPromo = false; |
| 18 | private busqueda: string = ''; | 18 | private busqueda: string = ''; |
| 19 | private productoAcargar: Producto; | 19 | private productoAcargar: Producto; |
| 20 | private promoAcargar: Producto; | 20 | private promoAcargar: Producto; |
| 21 | private productos: Producto[] = []; | 21 | private productos: Producto[] = []; |
| 22 | private promociones: Producto[] = []; | 22 | private promociones: Producto[] = []; |
| 23 | private sinonimos: Sinonimo[] = []; | 23 | private sinonimos: Sinonimo[] = []; |
| 24 | private apiImagenes: string = APP_SETTINGS.apiImagenes; | 24 | private apiImagenes: string = APP_SETTINGS.apiImagenes; |
| 25 | private mostrarPantalla : boolean = false; | ||
| 25 | 26 | ||
| 26 | @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective; | 27 | @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective; |
| 27 | 28 | ||
| 28 | @HostListener('document:keypress', ["$event"]) catchInput(e: KeyboardEvent) { | 29 | @HostListener('document:keypress', ["$event"]) catchInput(e: KeyboardEvent) { |
| 29 | 30 | ||
| 30 | if (e.keyCode == 13) { | 31 | if (e.keyCode == 13) { |
| 31 | this.buscarByCodigoBarras(this.busqueda); | 32 | this.buscarByCodigoBarras(this.busqueda); |
| 32 | this.busqueda = ''; | 33 | this.busqueda = ''; |
| 33 | } else { | 34 | } else { |
| 34 | this.busqueda += e.key; | 35 | this.busqueda += e.key; |
| 35 | } | 36 | } |
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | constructor( | 39 | constructor( |
| 39 | private router: Router, | 40 | private router: Router, |
| 40 | private productoService: ProductoService | 41 | private productoService: ProductoService |
| 41 | ) { } | 42 | ) { } |
| 42 | 43 | ||
| 43 | ngOnInit() { | 44 | ngOnInit() { |
| 44 | 45 | ||
| 46 | localStorage.removeItem('pve') | ||
| 45 | this.productoAcargar = this.productoService.productoAcargar; | 47 | this.productoAcargar = this.productoService.productoAcargar; |
| 46 | this.getProductos(); | 48 | this.getProductos(); |
| 49 | this.mostrarPantalla = localStorage.getItem('impresoraPVE') ? true : false; | ||
| 47 | } | 50 | } |
| 48 | 51 | ||
| 49 | ngAfterViewInit() { | 52 | ngAfterViewInit() { |
| 50 | 53 | ||
| 51 | setTimeout(() => { | 54 | setTimeout(() => { |
| 52 | if (!this.productoAcargar) return; | 55 | if (!this.productoAcargar) return; |
| 53 | 56 | ||
| 54 | if (this.productoAcargar.PRO) { | 57 | if (this.productoAcargar.PRO) { |
| 55 | this.promociones.push(this.productoAcargar); | 58 | this.promociones.push(this.productoAcargar); |
| 56 | this.promoSeleccionada(this.productoAcargar, true); | 59 | this.promoSeleccionada(this.productoAcargar, true); |
| 57 | } | 60 | } |
| 58 | else { | 61 | else { |
| 59 | this.getPromociones(); | 62 | this.getPromociones(); |
| 60 | } | 63 | } |
| 61 | }) | 64 | }) |
| 62 | } | 65 | } |
| 63 | 66 | ||
| 64 | getProductos() { | 67 | getProductos() { |
| 65 | 68 | ||
| 66 | this.productoService.getAll() | 69 | this.productoService.getAll() |
| 67 | .subscribe((productos: Producto[]) => { | 70 | .subscribe((productos: Producto[]) => { |
| 68 | this.productos = productos; | 71 | this.productos = productos; |
| 69 | }); | 72 | }); |
| 70 | } | 73 | } |
| 71 | 74 | ||
| 72 | getPromociones() { | 75 | getPromociones() { |
| 73 | 76 | ||
| 74 | var sector = this.productoAcargar.CodSec; | 77 | var sector = this.productoAcargar.CodSec; |
| 75 | var codigo = this.productoAcargar.CodArt; | 78 | var codigo = this.productoAcargar.CodArt; |
| 76 | this.productoService.getPromociones(sector, codigo) | 79 | this.productoService.getPromociones(sector, codigo) |
| 77 | .subscribe((res: Producto[]) => { | 80 | .subscribe((res: Producto[]) => { |
| 78 | 81 | ||
| 79 | if (res.length === 0) { | 82 | if (res.length === 0) { |
| 80 | 83 | ||
| 81 | this.productoAcargar.cantidad ? false : this.productoAcargar.cantidad = 1; | 84 | this.productoAcargar.cantidad ? false : this.productoAcargar.cantidad = 1; |
| 82 | this.productoService.setProductos(this.productoAcargar); | 85 | this.productoService.setProductos(this.productoAcargar); |
| 83 | this.productoAcargar = this.productoService.productoAcargar = undefined; | 86 | this.productoAcargar = this.productoService.productoAcargar = undefined; |
| 84 | } else { | 87 | } else { |
| 85 | 88 | ||
| 86 | this.promociones = res; | 89 | this.promociones = res; |
| 87 | this.popoverDirective.show(); | 90 | this.popoverDirective.show(); |
| 88 | } | 91 | } |
| 89 | }, error => { console.error(error); }) | 92 | }, error => { console.error(error); }) |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | confirmarProducto(cantidad?: number) { | 95 | confirmarProducto(cantidad?: number) { |
| 93 | 96 | ||
| 94 | let producto = this.promoAcargar ? this.promoAcargar : this.productoAcargar; | 97 | let producto = this.promoAcargar ? this.promoAcargar : this.productoAcargar; |
| 95 | 98 | ||
| 96 | if (cantidad) { | 99 | if (cantidad) { |
| 97 | producto.cantidad = cantidad; | 100 | producto.cantidad = cantidad; |
| 98 | } else { | 101 | } else { |
| 99 | producto.cantidad = producto.cantidad ? producto.cantidad : 1; | 102 | producto.cantidad = producto.cantidad ? producto.cantidad : 1; |
| 100 | } | 103 | } |
| 101 | 104 | ||
| 102 | this.productoService.setProductos(producto); | 105 | this.productoService.setProductos(producto); |
| 103 | this.productoService.productoAcargar = this.promoAcargar = this.productoAcargar = undefined; | 106 | this.productoService.productoAcargar = this.promoAcargar = this.productoAcargar = undefined; |
| 104 | this.productoService.esPromoPersonalizada = false; | 107 | this.productoService.esPromoPersonalizada = false; |
| 105 | this.promociones = []; | 108 | this.promociones = []; |
| 106 | this.popoverDirective.hide(); | 109 | this.popoverDirective.hide(); |
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | promoSeleccionada($event: Producto, showPopover: boolean) { | 112 | promoSeleccionada($event: Producto, showPopover: boolean) { |
| 110 | 113 | ||
| 111 | this.productoService.getProductoById($event.id) | 114 | this.productoService.getProductoById($event.id) |
| 112 | .subscribe((res: Producto) => { | 115 | .subscribe((res: Producto) => { |
| 113 | 116 | ||
| 114 | $event.imagenes = res.imagenes.length == 0 ? [{ imagen: 'noImage.jpg' }] : res.imagenes; | 117 | $event.imagenes = res.imagenes.length == 0 ? [{ imagen: 'noImage.jpg' }] : res.imagenes; |
| 115 | this.promoAcargar = $event; | 118 | this.promoAcargar = $event; |
| 116 | 119 | ||
| 117 | if ($event.tieneSinonimos) { | 120 | if ($event.tieneSinonimos) { |
| 118 | this.getSinonimos(this.promoAcargar.CodSec, this.promoAcargar.CodArt); | 121 | this.getSinonimos(this.promoAcargar.CodSec, this.promoAcargar.CodArt); |
| 119 | } else if (showPopover) { | 122 | } else if (showPopover) { |
| 120 | this.popoverDirective.show(); | 123 | this.popoverDirective.show(); |
| 121 | } else { | 124 | } else { |
| 122 | this.popoverDirective.hide(); | 125 | this.popoverDirective.hide(); |
| 123 | } | 126 | } |
| 124 | 127 | ||
| 125 | }, | 128 | }, |
| 126 | error => { console.log(error); }) | 129 | error => { console.log(error); }) |
| 127 | } | 130 | } |
| 128 | 131 | ||
| 129 | getSinonimos(sector, codigo) { | 132 | getSinonimos(sector, codigo) { |
| 130 | 133 | ||
| 131 | this.productoService.getPromocionSinonimos(sector, codigo) | 134 | this.productoService.getPromocionSinonimos(sector, codigo) |
| 132 | .subscribe((res: Sinonimo[]) => { | 135 | .subscribe((res: Sinonimo[]) => { |
| 133 | 136 | ||
| 134 | res.forEach(sinonimo => { | 137 | res.forEach(sinonimo => { |
| 135 | 138 | ||
| 136 | sinonimo.cantidad = 0; | 139 | sinonimo.cantidad = 0; |
| 137 | this.promoAcargar.productos.forEach(productoPromo => { | 140 | this.promoAcargar.productos.forEach(productoPromo => { |
| 138 | 141 | ||
| 139 | sinonimo.productos.forEach(productoSinonimo => { | 142 | sinonimo.productos.forEach(productoSinonimo => { |
| 140 | 143 | ||
| 141 | if (productoSinonimo.id === productoPromo.id) { | 144 | if (productoSinonimo.id === productoPromo.id) { |
| 142 | productoSinonimo.cantidad = productoPromo.cantidad; | 145 | productoSinonimo.cantidad = productoPromo.cantidad; |
| 143 | sinonimo.cantidad += productoPromo.cantidad; | 146 | sinonimo.cantidad += productoPromo.cantidad; |
| 144 | } | 147 | } |
| 145 | }) | 148 | }) |
| 146 | }) | 149 | }) |
| 147 | }) | 150 | }) |
| 148 | this.sinonimos = res; | 151 | this.sinonimos = res; |
| 149 | (this.sinonimos.length > 0) ? this.popoverDirective.show() : this.popoverDirective.hide(); | 152 | (this.sinonimos.length > 0) ? this.popoverDirective.show() : this.popoverDirective.hide(); |
| 150 | }) | 153 | }) |
| 151 | } | 154 | } |
| 152 | 155 | ||
| 153 | productosPersonalizados($event: any) { | 156 | productosPersonalizados($event: any) { |
| 154 | 157 | ||
| 155 | let productosPersonalizados = $event.productosAenviar; | 158 | let productosPersonalizados = $event.productosAenviar; |
| 156 | 159 | ||
| 157 | productosPersonalizados.forEach(productoElegido => { | 160 | productosPersonalizados.forEach(productoElegido => { |
| 158 | 161 | ||
| 159 | this.promoAcargar.productos = this.promoAcargar.productos.filter(productoPromo => { | 162 | this.promoAcargar.productos = this.promoAcargar.productos.filter(productoPromo => { |
| 160 | return productoPromo.idSinonimo != productoElegido.idSinonimo; | 163 | return productoPromo.idSinonimo != productoElegido.idSinonimo; |
| 161 | }); | 164 | }); |
| 162 | }); | 165 | }); |
| 163 | 166 | ||
| 164 | this.promoAcargar.productos = this.promoAcargar.productos.concat(productosPersonalizados); | 167 | this.promoAcargar.productos = this.promoAcargar.productos.concat(productosPersonalizados); |
| 165 | this.confirmarProducto($event.cantidadPromo); | 168 | this.confirmarProducto($event.cantidadPromo); |
| 166 | } | 169 | } |
| 167 | 170 | ||
| 168 | buscarByCodigoBarras(busqueda) { | 171 | buscarByCodigoBarras(busqueda) { |
| 169 | 172 | ||
| 170 | let producto = this.productos.filter(producto => { | 173 | let producto = this.productos.filter(producto => { |
| 171 | return producto.codigoBarra == busqueda; | 174 | return producto.codigoBarra == busqueda; |
| 172 | }); | 175 | }); |
| 173 | 176 | ||
| 174 | if (producto.length) { | 177 | if (producto.length) { |
| 175 | 178 | ||
| 176 | this.productoAcargar = producto[0]; | 179 | this.productoAcargar = producto[0]; |
| 177 | this.getPromociones(); | 180 | this.getPromociones(); |
| 178 | 181 | ||
| 179 | } else { | 182 | } else { |
| 180 | alert('No se encuentra el producto'); | 183 | alert('No se encuentra el producto'); |
| 181 | } | 184 | } |
| 182 | 185 | ||
| 183 | } | 186 | } |
| 184 | 187 | ||
| 185 | irBusquedaProductos(value) { | 188 | irBusquedaProductos(value) { |
| 186 | 189 | ||
| 187 | this.productoService.mostrar = value; | 190 | this.productoService.mostrar = value; |
| 188 | this.router.navigate(['busqueda-productos']); | 191 | this.router.navigate(['busqueda-productos']); |
| 189 | } | 192 | } |
| 190 | 193 | ||
| 191 | deshacerCarga() { | 194 | deshacerCarga() { |
| 192 | 195 | ||
| 193 | if (this.sinonimos.length > 0) { | 196 | if (this.sinonimos.length > 0) { |
| 194 | this.sinonimos = []; | 197 | this.sinonimos = []; |
| 195 | this.productoService.esPromoPersonalizada = false; | 198 | this.productoService.esPromoPersonalizada = false; |
| 196 | this.popoverDirective.hide(); | 199 | this.popoverDirective.hide(); |
| 197 | } | 200 | } |
| 198 | 201 | ||
| 199 | if (this.promoAcargar) { | 202 | if (this.promoAcargar) { |
| 200 | this.promoAcargar = undefined; | 203 | this.promoAcargar = undefined; |
| 201 | if (this.productoAcargar.PRO) { | 204 | if (this.productoAcargar.PRO) { |
| 202 | this.productoAcargar = undefined; | 205 | this.productoAcargar = undefined; |
| 203 | this.promociones = []; | 206 | this.promociones = []; |
| 204 | this.popoverDirective.hide(); | 207 | this.popoverDirective.hide(); |
| 205 | } else { | 208 | } else { |
| 206 | this.popoverDirective.show(); | 209 | this.popoverDirective.show(); |
| 207 | } | 210 | } |
| 208 | } else { | 211 | } else { |
| 209 | this.productoAcargar = undefined; | 212 | this.productoAcargar = undefined; |
| 210 | this.promociones = []; | 213 | this.promociones = []; |
| 211 | this.popoverDirective.hide(); | 214 | this.popoverDirective.hide(); |
| 212 | } | 215 | } |
| 213 | } | 216 | } |
| 214 | 217 | ||
| 215 | } | 218 | } |
| 216 | 219 |