Commit 57ce386197479e20007a25c5b7dd9c434b2f0202

Authored by Marcelo Puebla
1 parent 5b61bc60ed
Exists in master and in 1 other branch validar_pve

Creado componente de configuracion

src/app/app.module.ts
... ... @@ -33,6 +33,7 @@ import { MensajeFinalComponent } from './components/mensaje-final/mensaje-final.
33 33 import { ComandaComponent } from './components/comanda/comanda.component';
34 34 import { PedidosSalientesComponent } from './components/pedidos-salientes/pedidos-salientes.component';
35 35 import { PagoConTarjetaComponent } from './components/pago-con-tarjeta/pago-con-tarjeta.component';
  36 +import { ConfiguracionComponent } from './components/configuracion/configuracion.component';
36 37 //#endregion
37 38  
38 39 @NgModule({
... ... @@ -51,7 +52,8 @@ import { PagoConTarjetaComponent } from './components/pago-con-tarjeta/pago-con-
51 52 MensajeFinalComponent,
52 53 ComandaComponent,
53 54 PedidosSalientesComponent,
54   - PagoConTarjetaComponent
  55 + PagoConTarjetaComponent,
  56 + ConfiguracionComponent
55 57 ],
56 58 imports: [
57 59 BrowserModule,
... ... @@ -71,6 +73,6 @@ import { PagoConTarjetaComponent } from './components/pago-con-tarjeta/pago-con-
71 73 ],
72 74 providers: [],
73 75 bootstrap: [AppComponent],
74   - entryComponents: [PagoConTarjetaComponent]
  76 + entryComponents: [PagoConTarjetaComponent, ConfiguracionComponent]
75 77 })
76 78 export class AppModule { }
src/app/components/configuracion/configuracion.component.html
... ... @@ -0,0 +1,75 @@
  1 +<form [formGroup]="form" class="modal-body" id="modal-body">
  2 +
  3 + <div class="row">
  4 + <div class="col-12">
  5 +
  6 + <p>¿Este punto de venta trabaja con planilla propia?</p>
  7 +
  8 + <!-- RADIO BUTTONS -->
  9 + <div class="text-center">
  10 + <div class="disabled form-check form-check-inline">
  11 + <input
  12 + class="form-check-input"
  13 + type="radio"
  14 + id="radio1"
  15 + formControlName="usePlanillaPropia"
  16 + [value]="true">
  17 +
  18 + <label class="form-check-label" for="radio1">Si</label>
  19 + </div>
  20 + <div class="form-check form-check-inline">
  21 + <input
  22 + class="form-check-input"
  23 + type="radio"
  24 + id="radio2"
  25 + formControlName="usePlanillaPropia"
  26 + [value]="false">
  27 + <label class="form-check-label" for="radio2">No</label>
  28 + </div>
  29 + </div>
  30 + <div *ngIf="form.get('usePlanillaPropia').value === false" class="form-group">
  31 + <select
  32 + formControlName="puntoVenta"
  33 + class="form-control form-control-sm w-50 mx-auto mt-2">
  34 + <option [ngValue]="null" disabled>Seleccione una opción</option>
  35 + <option
  36 + *ngFor="let ptoVenta of puntosVenta"
  37 + [ngValue]="ptoVenta.ID">
  38 + {{ptoVenta.ID}} {{ptoVenta.NOM}}
  39 + </option>
  40 + </select>
  41 + </div>
  42 + </div>
  43 + </div>
  44 +
  45 + <div *ngIf="impresoras.length > 0" class="row">
  46 + <div class="col-12">
  47 + <p>Salida de impresión de comprobantes</p>
  48 + <select
  49 + formControlName="impresora"
  50 + class="form-control form-control-sm w-50 mx-auto mt-2">
  51 + <option [ngValue]="null" disabled>Seleccione una opción</option>
  52 + <option
  53 + *ngFor="let imp of impresoras"
  54 + [ngValue]="imp.PVE">
  55 + {{imp.PVE}} {{imp.DES}}
  56 + </option>
  57 + </select>
  58 + </div>
  59 + </div>
  60 +
  61 +</form>
  62 +
  63 +<div class="modal-footer py-1">
  64 + <button
  65 + class="btn btn-sm btn-secondary"
  66 + type="button"
  67 + (click)="close()">Cancelar
  68 + </button>
  69 + <button
  70 + class="btn btn-sm btn-primary"
  71 + type="button"
  72 + (click)="acept()"
  73 + >Aceptar
  74 + </button>
  75 +</div>
src/app/components/configuracion/configuracion.component.scss
... ... @@ -0,0 +1,4 @@
  1 +.disabled {
  2 + pointer-events: none;
  3 + opacity: 0.5;
  4 +}
src/app/components/configuracion/configuracion.component.spec.ts
... ... @@ -0,0 +1,25 @@
  1 +import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  2 +
  3 +import { ConfiguracionComponent } from './configuracion.component';
  4 +
  5 +describe('ConfiguracionComponent', () => {
  6 + let component: ConfiguracionComponent;
  7 + let fixture: ComponentFixture<ConfiguracionComponent>;
  8 +
  9 + beforeEach(async(() => {
  10 + TestBed.configureTestingModule({
  11 + declarations: [ ConfiguracionComponent ]
  12 + })
  13 + .compileComponents();
  14 + }));
  15 +
  16 + beforeEach(() => {
  17 + fixture = TestBed.createComponent(ConfiguracionComponent);
  18 + component = fixture.componentInstance;
  19 + fixture.detectChanges();
  20 + });
  21 +
  22 + it('should create', () => {
  23 + expect(component).toBeTruthy();
  24 + });
  25 +});
src/app/components/configuracion/configuracion.component.ts
... ... @@ -0,0 +1,78 @@
  1 +import { Component, OnInit } from '@angular/core';
  2 +import { BsModalRef } from 'ngx-bootstrap';
  3 +import { PuntoVentaService } from 'src/app/services/punto-venta.service';
  4 +import { PuntoVenta } from 'src/app/wrappers/puntoVenta';
  5 +import { ImpresoraService } from 'src/app/services/impresora.service';
  6 +import { Impresora } from 'src/app/wrappers/impresora';
  7 +import { FormGroup, FormControl } from '@angular/forms';
  8 +
  9 +@Component({
  10 + selector: 'app-configuracion',
  11 + templateUrl: './configuracion.component.html',
  12 + styleUrls: ['./configuracion.component.scss']
  13 +})
  14 +export class ConfiguracionComponent implements OnInit {
  15 +
  16 + puntosVenta: PuntoVenta[] = [];
  17 + impresoras: Impresora[] = [];
  18 + form: FormGroup;
  19 +
  20 + constructor(
  21 + private activeModal: BsModalRef,
  22 + private puntoVentaService: PuntoVentaService,
  23 + private impresoraService: ImpresoraService,
  24 + ) { }
  25 +
  26 + ngOnInit() {
  27 +
  28 + this.form = new FormGroup({
  29 + usePlanillaPropia: new FormControl(false, []),
  30 + puntoVenta: new FormControl(null, []),
  31 + impresora: new FormControl(null, []),
  32 + })
  33 +
  34 + this.puntoVentaService.getAll()
  35 + .subscribe((res: PuntoVenta[]) => {
  36 +
  37 + this.puntosVenta = res;
  38 + this.setPuntoVenta();
  39 + }, console.error);
  40 +
  41 + this.impresoraService.getAll()
  42 + .subscribe((res: Impresora[]) => {
  43 +
  44 + this.impresoras = res;
  45 + this.setImpresora();
  46 + }, console.error);
  47 +
  48 + }
  49 +
  50 + close() {
  51 +
  52 + this.activeModal.hide();
  53 + }
  54 +
  55 + acept() {
  56 +
  57 + 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);
  59 + localStorage.setItem('pve', auxPuntoVenta ? auxPuntoVenta.ID.toString() : null);
  60 + localStorage.setItem('impresoraPVE', auxImpresora ? auxImpresora.PVE.toString() : null);
  61 + this.close();
  62 + }
  63 +
  64 + setPuntoVenta() {
  65 +
  66 + let pve = parseInt(localStorage.getItem('pve'));
  67 + let auxPuntoVenta = this.puntosVenta.find(x => x.ID === pve);
  68 + this.form.get('puntoVenta').setValue(auxPuntoVenta ? auxPuntoVenta.ID : null);
  69 + }
  70 +
  71 + setImpresora() {
  72 +
  73 + let impresoraPVE = parseInt(localStorage.getItem('impresoraPVE'));
  74 + let auxImpresora = this.impresoras.find(x => x.PVE === impresoraPVE);
  75 + this.form.get('impresora').setValue(auxImpresora ? auxImpresora.PVE : null);
  76 + }
  77 +
  78 +}