Commit 13d8a7169e662ac901c0f9b944877c24511d40ab

Authored by Eric Fernandez

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !3
src/app/acciones/acciones.component.ts
... ... @@ -2,7 +2,8 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core';
2 2 @Component({
3 3 selector: 'app-acciones',
4 4 templateUrl: './acciones.component.html',
5   - styleUrls: ['./acciones.component.scss']
  5 + styleUrls: ['./acciones.component.scss'],
  6 + inputs: ['saveLoading']
6 7 })
7 8 export class AccionesComponent implements OnInit {
8 9  
... ... @@ -16,10 +17,6 @@ export class AccionesComponent implements OnInit {
16 17  
17 18 callSave() {
18 19 //llamo función guardar pasada en el componente
19   - this.saveLoading = true;
20   -
21   - setTimeout(() => {
22   - this.saveLoading = false;
23   - }, 10000);
  20 + this.guardar.emit();
24 21 }
25 22 }
src/app/app.module.ts
... ... @@ -32,6 +32,7 @@ import { BusquedaComprobanteComponent } from './busqueda-comprobante/busqueda-co
32 32 FormsModule,
33 33 LaddaModule
34 34 ],
  35 + entryComponents:[BusquedaComprobanteComponent],
35 36 providers: [],
36 37 bootstrap: [AppComponent]
37 38 })
src/app/busqueda-comprobante/busqueda-comprobante.component.html
... ... @@ -0,0 +1,61 @@
  1 +<div class="modal-header py-1">
  2 + <div class="row w-100">
  3 + <div class="col-lg-6">
  4 + <h5 class="modal-title">Búsqueda de Comprobantes</h5>
  5 + </div>
  6 + </div>
  7 +</div>
  8 +<div class="modal-body d-flex" id="modal-body">
  9 + <table class="table table-striped table-sm">
  10 + <thead>
  11 + <tr>
  12 + <th>Comprobante</th>
  13 + <th>Items</th>
  14 + <th></th>
  15 + </tr>
  16 + </thead>
  17 + <tbody>
  18 + <tr *ngFor="let comprobante of getPaginaFiltro()">
  19 + <td>
  20 + {{comprobante.cabecera.TCO + '-' + comprobante.cabecera.TIP + '-' + rellenar(4, comprobante.cabecera.SUC) + '-' + rellenar(8, comprobante.cabecera.NCO)}}
  21 + </td>
  22 + <td>{{comprobante.cuerpo.length}}</td>
  23 + <td>
  24 + <button type="button" class="btn btn-xs p-1 float-right btn-primary" (click)="selectItem(comprobante)">
  25 + <i class="fa fa-circle-thin" aria-hidden="true"></i>
  26 + </button>
  27 + </td>
  28 + </tr>
  29 + </tbody>
  30 + </table>
  31 +</div>
  32 +<div class="modal-footer py-1">
  33 + <nav *ngIf="comprobantes.length > 0" class="mr-auto mb-5">
  34 + <ul class="pagination pagination-sm justify-content mb-0">
  35 + <li class="page-item" [ngClass]="{'disabled': paginaActiva == 1}">
  36 + <a class="page-link" href="javascript:void();" (click)="paginaActiva = paginaActiva - 1">
  37 + <span aria-hidden="true">&laquo;</span>
  38 + <span class="sr-only">Anterior</span>
  39 + </a>
  40 + </li>
  41 + <li
  42 + class="page-item"
  43 + *ngFor="let pagina of paginas; index as i"
  44 + [ngClass]="{'active': pagina == paginaActiva}"
  45 + >
  46 + <a
  47 + class="page-link"
  48 + href="javascript:void();"
  49 + (click)="paginaActiva = pagina"
  50 + >{{pagina}}</a>
  51 + </li>
  52 + <li class="page-item" [ngClass]="{'disabled': paginaActiva == paginas.length}">
  53 + <a class="page-link" href="javascript:void();" (click)="paginaActiva = paginaActiva + 1">
  54 + <span aria-hidden="true">&raquo;</span>
  55 + <span class="sr-only">Siguiente</span>
  56 + </a>
  57 + </li>
  58 + </ul>
  59 + </nav>
  60 + <button class="btn btn-sm btn-secondary" type="button" (click)="close()">Cerrar</button>
  61 +</div>
src/app/busqueda-comprobante/busqueda-comprobante.component.scss
src/app/busqueda-comprobante/busqueda-comprobante.component.ts
... ... @@ -0,0 +1,78 @@
  1 +import { Component, OnInit} from '@angular/core';
  2 +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
  3 +import { BusquedaComprobantesService } from './busqueda-comprobantes.service';
  4 +
  5 +@Component({
  6 + templateUrl: './busqueda-comprobante.component.html',
  7 + styleUrls: ['./busqueda-comprobante.component.scss'],
  8 + providers: [BusquedaComprobantesService]
  9 +})
  10 +export class BusquedaComprobanteComponent implements OnInit {
  11 +
  12 + comprobantes: Array<Object> = [];
  13 + paginaActiva = 1;
  14 + paginas = [];
  15 + cantidadPorPagina = 10;
  16 +
  17 + constructor(public activeModal: NgbActiveModal, public comprobanteService: BusquedaComprobantesService) { }
  18 +
  19 + ngOnInit() {
  20 + this.comprobanteService.getComprobantes().subscribe((data: Array<Object>) => {
  21 + this.comprobantes = data;
  22 + this.comprobantes.push(this.comprobantes[0]);
  23 + this.comprobantes.push(this.comprobantes[1]);
  24 + this.comprobantes.push(this.comprobantes[0]);
  25 + this.comprobantes.push(this.comprobantes[1]);
  26 + this.comprobantes.push(this.comprobantes[0]);
  27 + this.comprobantes.push(this.comprobantes[1]);
  28 + this.comprobantes.push(this.comprobantes[0]);
  29 + this.comprobantes.push(this.comprobantes[1]);
  30 + this.comprobantes.push(this.comprobantes[0]);
  31 + this.comprobantes.push(this.comprobantes[1]);
  32 + this.comprobantes.push(this.comprobantes[0]);
  33 + this.comprobantes.push(this.comprobantes[1]);
  34 + this.comprobantes.push(this.comprobantes[0]);
  35 + this.comprobantes.push(this.comprobantes[1]);
  36 + this.comprobantes.push(this.comprobantes[0]);
  37 + this.comprobantes.push(this.comprobantes[1]);
  38 + this.paginar();
  39 + });
  40 + }
  41 +
  42 + getPaginaFiltro() {
  43 + return this.comprobantes.slice((this.paginaActiva - 1) * this.cantidadPorPagina,
  44 + this.paginaActiva * this.cantidadPorPagina);
  45 + }
  46 +
  47 + paginar() {
  48 +
  49 + var cantPaginas = Math.ceil(this.comprobantes.length / this.cantidadPorPagina);
  50 + this.paginas = [];
  51 + for (let i = 0; i < cantPaginas; i++) {
  52 + this.paginas.push(i + 1);
  53 + }
  54 + }
  55 +
  56 + rellenar(relleno: number, numero: number) {
  57 +
  58 + if (numero.toString().length >= relleno) {
  59 + return numero;
  60 + }
  61 +
  62 + let rellenar = '';
  63 +
  64 + for (let i = 0; i < relleno - numero.toString().length; i++) {
  65 + rellenar += '0'
  66 + }
  67 +
  68 + return rellenar + numero.toString();
  69 + }
  70 +
  71 + close() {
  72 + this.activeModal.dismiss();
  73 + }
  74 +
  75 + selectItem(comprobante: object) {
  76 + this.activeModal.close(comprobante);
  77 + }
  78 +}
src/app/busqueda-comprobante/busqueda-comprobantes.service.ts
... ... @@ -0,0 +1,13 @@
  1 +import { Injectable } from '@angular/core';
  2 +import { HttpClient } from '@angular/common/http';
  3 +import { AppSetings } from '../../etc/AppSetings';
  4 +
  5 +@Injectable()
  6 +export class BusquedaComprobantesService {
  7 +
  8 + constructor(private http: HttpClient) { }
  9 +
  10 + getComprobantes() {
  11 + return this.http.get(AppSetings.END_POINT + '/comprobantes/' + localStorage.getItem('gln'));
  12 + };
  13 +}
src/app/comprobantes/comprobantes.component.html
... ... @@ -6,8 +6,7 @@
6 6 <button
7 7 class="btn btn-xs btn-outline-light float-right"
8 8 type="button"
9   - ng-click="$ctrl.busqueda()"
10   - ng-if="$ctrl.busqueda"
  9 + (click)="busquedaComprobantes()"
11 10 title="Buscar"
12 11 >
13 12 <i class="fa fa-search"></i>
... ... @@ -51,12 +50,12 @@
51 50 <strong>Cuit:&nbsp;</strong>
52 51 <label>{{cabecera.CUI}}</label>
53 52 </div>
54   - <div class="col-12 col-sm-3 d-flex">
  53 + <div class="col-12 col-sm-6 d-flex">
55 54 <strong>Nombre:&nbsp;</strong>
56 55 <label>{{cabecera.NOM}}</label>
57 56 </div>
58 57 </div>
59   - <div class="row border">
  58 + <div class="row border pr-2">
60 59 <div class="col-4">
61 60 <button
62 61 type="button"
... ... @@ -108,7 +107,7 @@
108 107 <th *ngIf="estadoArticulos != 'rechazado'"><button type="button" class="" (click)="articulo.estado = 'rechazado'">
109 108 <i class="fa fa-window-close"></i>
110 109 </button></th>
111   - <th>{{articulo.LI0}}</th>
  110 + <th>{{articulo.TIO}}</th>
112 111 <th *ngIf="!articulo.input" (click)="articulo.input = true">
113 112 {{articulo.recibido ? articulo.recibido + '/' : ''}}{{articulo.CAN}}</th>
114 113 <th *ngIf="articulo.input">
... ... @@ -163,5 +162,5 @@
163 162 </table>
164 163 </div>
165 164 </form>
166   - <app-acciones (guardar)="guardarComprobante()"></app-acciones>
  165 + <app-acciones (guardar)="guardarComprobante()" [(saveLoading)]="saveLoading"></app-acciones>
167 166 </div>
src/app/comprobantes/comprobantes.component.ts
1 1 import { Component, OnInit} from '@angular/core';
  2 +import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
  3 +import { BusquedaComprobanteComponent } from '../busqueda-comprobante/busqueda-comprobante.component';
  4 +import { ComprobanteService } from './comprobantes.service';
2 5  
3 6 @Component({
4 7 templateUrl: './comprobantes.component.html',
5   - styleUrls: ['./comprobantes.component.scss']
  8 + styleUrls: ['./comprobantes.component.scss'],
  9 + providers:[ ComprobanteService ]
6 10 })
7 11 export class ComprobantesComponent implements OnInit {
8 12  
9   - constructor() { }
  13 + constructor(private modalService: NgbModal, public comprobanteService: ComprobanteService) { }
10 14  
11   - ngOnInit() {
12   -
13   - this.obtenerConsulta();
14   - }
  15 + ngOnInit() { }
15 16  
16 17 filter = '';
17 18 estadoArticulos = 'pendiente';
... ... @@ -21,7 +22,8 @@ export class ComprobantesComponent implements OnInit {
21 22 articulosFiltro = [];
22 23 paginaActiva = 1;
23 24 paginas = [];
24   -
  25 + saveLoading = false;
  26 +
25 27 fecha = new Date();
26 28  
27 29 paginar() {
... ... @@ -37,7 +39,7 @@ export class ComprobantesComponent implements OnInit {
37 39  
38 40 this.articulosFiltro = this.cuerpo.filter((articulo) => {
39 41 return articulo.estado == this.estadoArticulos &&
40   - (articulo.LI0.toLocaleUpperCase().includes(this.filter.toLocaleUpperCase()) ||
  42 + (articulo.TIO.toLocaleUpperCase().includes(this.filter.toLocaleUpperCase()) ||
41 43 articulo.codigoBarras == this.filter);
42 44 });
43 45  
... ... @@ -53,71 +55,30 @@ export class ComprobantesComponent implements OnInit {
53 55 }
54 56  
55 57 guardarComprobante(event: any) {
56   - alert('Guardando');
  58 +
  59 + if (this.getCantidadArticulosByEstado('pendiente')) {
  60 + alert('No deben quedar articulos pendientes');
  61 + }
  62 +
  63 + this.comprobanteService
  64 + .saveComprobantes({cabecera: this.cabecera, cuerpo: this.cuerpo})
  65 + .subscribe(data => {
  66 + console.log(data);
  67 + });
57 68 }
58 69  
59   - obtenerConsulta() {
60   -
61   - setTimeout(() => {
62   - this.cabecera = {
63   - TIP: 'A',
64   - TCO: 'FT',
65   - SUC: 623,
66   - NCO: 53979,
67   - COD: 1,
68   - FEC: new Date(),
69   - NOM: 'POTIGIAN GOLOCINAS',
70   - CUI: '30-54775125-2'
71   - };
72   -
73   - this.cuerpo = [
74   - {
75   - LI0: 'Mantel Combo Bolso CocaCola',
76   - CAN: 5,
77   - estado: 'pendiente',
78   - codigoBarras: '7790667006462'
79   - },
80   - {
81   - LI0: 'Papas',
82   - CAN: 5,
83   - estado: 'pendiente',
84   - },
85   - {
86   - LI0: 'Peras',
87   - CAN: 5,
88   - estado: 'pendiente',
89   - },
90   - {
91   - LI0: 'Cafe',
92   - CAN: 5,
93   - estado: 'pendiente',
94   - },
95   - {
96   - LI0: 'Cafe capuchino',
97   - CAN: 5,
98   - estado: 'pendiente',
99   - },
100   - {
101   - LI0: 'Menta',
102   - CAN: 5,
103   - estado: 'pendiente',
104   - },
105   - {
106   - LI0: 'Fernet',
107   - CAN: 5,
108   - estado: 'pendiente',
109   - },
110   - {
111   - LI0: 'Andes',
112   - CAN: 5,
113   - estado: 'pendiente',
114   - }
115   - ];
116   -
117   - this.articulosFiltro = this.cuerpo;
118   -
119   - this.paginar();
120   - }, 500);
  70 + busquedaComprobantes() {
  71 + this.modalService.open(BusquedaComprobanteComponent).result.then(comprobante => {
  72 +
  73 + this.cabecera = comprobante.cabecera;
  74 + this.cuerpo = comprobante.cuerpo;
  75 +
  76 + this.cuerpo.forEach(articulo => {
  77 + articulo['estado'] = 'pendiente';
  78 + });
  79 +
  80 + this.getPaginaFiltro();
  81 + }, (reason) => { });
121 82 }
122 83  
123 84 }
src/app/comprobantes/comprobantes.service.ts
... ... @@ -0,0 +1,13 @@
  1 +import { Injectable } from '@angular/core';
  2 +import { HttpClient } from '@angular/common/http';
  3 +import { AppSetings } from '../../etc/AppSetings';
  4 +
  5 +@Injectable()
  6 +export class ComprobanteService {
  7 +
  8 + constructor(private http: HttpClient) {}
  9 +
  10 + saveComprobantes(comprobante: object) {
  11 + return this.http.post(AppSetings.END_POINT + '/comprobante', comprobante);
  12 + }
  13 +}
src/app/login/login.component.html
... ... @@ -0,0 +1,65 @@
  1 +<div class="d-flex justify-content-center align-items-center">
  2 + <div class="login">
  3 + <form name="login">
  4 + <div class="login-titulo">
  5 + <span>Ingreso de usuario</span>
  6 + </div>
  7 + <div class="login-campo">
  8 + <label>Usuario</label>
  9 + <input
  10 + type="text"
  11 + [(ngModel)]="usuario.idUsuario"
  12 + [ngModelOptions]="{standalone: true}"
  13 + ng-keyup="$event.keyCode == 13 && irPaso(2)"
  14 + [ladda]="loginLoading"
  15 + />
  16 + </div>
  17 + <div class="login-campo">
  18 + <label>Contraseña</label>
  19 + <input
  20 + type="password"
  21 + [(ngModel)]="usuario.clave"
  22 + [ngModelOptions]="{standalone: true}"
  23 + foca-focus="paso == 2"
  24 + ng-keyup="$event.keyCode == 13 && enviar()"
  25 + [ladda]="loginLoading"
  26 + />
  27 + </div>
  28 + <div class="d-flex">
  29 + <button
  30 + type="button"
  31 + class="btn btn-outline-dark mt-3 mr-auto"
  32 + (click)="configuracionEstacion = !configuracionEstacion"
  33 + [ngClass]="{'active': configuracionEstacion}"
  34 + [disabled]="loginLoading"
  35 + >Configuración</button>
  36 + <button
  37 + type="button"
  38 + class="btn btn-dark mt-3 ml-auto"
  39 + (click)="ingresar()"
  40 + [ladda]="loginLoading"
  41 + >Ingresar</button>
  42 + </div>
  43 + <div *ngIf="configuracionEstacion" class="mt-3">
  44 + <strong>Configuración estación</strong>
  45 + <br/>
  46 + <div>
  47 + <label class="justify-content-left">Código estación:</label>
  48 + <input
  49 + class="form-control"
  50 + placeholder="Código estación"
  51 + [(ngModel)]="usuario.codigoEntidad"
  52 + [ngModelOptions]="{standalone: true}">
  53 + </div>
  54 + <div>
  55 + <label class="justify-content-left">GLN:</label>
  56 + <input
  57 + class="form-control"
  58 + placeholder="GLN ESTACIÓN"
  59 + [(ngModel)]="usuario.gln"
  60 + [ngModelOptions]="{standalone: true}"/>
  61 + </div>
  62 + </div>
  63 + </form>
  64 + </div>
  65 +</div>
src/app/login/login.component.scss
... ... @@ -0,0 +1,56 @@
  1 +.login {
  2 + background-color: #bdbdbd;
  3 + border: 1px solid #000000;
  4 + border-radius: 3px;
  5 + height: calc(193px + 1em);
  6 + left: calc(50% - 130px);
  7 + opacity: 0.7;
  8 + text-align: center;
  9 + top: 190px;
  10 + width: 260px;
  11 + margin-top: 3.5rem;
  12 + &-titulo {
  13 + border-bottom: 1px solid #ffffff;
  14 + padding: 5px 0;
  15 + }
  16 + &-campo {
  17 + label {
  18 + display: block;
  19 + font-size: 12px;
  20 + margin: 5px 0 0;
  21 + }
  22 + input {
  23 + -moz-border-radius: 10px;
  24 + -khtml-border-radius: 10px;
  25 + -webkit-border-radius: 10px;
  26 + -webkit-appearance: none;
  27 + padding-right: 5%;
  28 + padding-left: 5%;
  29 + border-radius: 10px;
  30 + outline: 0;
  31 + border-color: transparent;
  32 + &:focus {
  33 + border-color: #ff9900;
  34 + }
  35 + }
  36 + }
  37 +
  38 + &-button {
  39 + // width: 80%;
  40 + background-color: #cd9035;
  41 + color: white;
  42 + &:hover{
  43 + background-color: #a7743d;
  44 + color: white
  45 + }
  46 + &:focus{
  47 + color: white;
  48 + }
  49 + }
  50 +
  51 + &-alerta-error {
  52 + width: 260px;
  53 + left: calc(50% - 130px);
  54 + top: calc(383px + 1.5em);
  55 + }
  56 +}
src/app/login/login.component.ts
... ... @@ -0,0 +1,38 @@
  1 +import { Component, OnInit } from '@angular/core';
  2 +import { LoginService } from './login.service';
  3 +import { Router } from '@angular/router';
  4 +
  5 +@Component({
  6 + templateUrl: './login.component.html',
  7 + styleUrls: ['./login.component.scss'],
  8 + providers: [LoginService]
  9 +})
  10 +export class LoginComponent implements OnInit {
  11 +
  12 + loginLoading: boolean = false;
  13 + usuario: object = {};
  14 +
  15 + constructor(private loginService: LoginService, private router: Router) { }
  16 +
  17 + ngOnInit() {
  18 +
  19 + let glnPrevius = localStorage.getItem('gln')
  20 + if (glnPrevius) {
  21 + this.usuario['gln'] = glnPrevius;
  22 + }
  23 + }
  24 +
  25 + ingresar() {
  26 +
  27 + this.loginLoading = true;
  28 + this.loginService.getLogin(this.usuario).subscribe(login => {
  29 + if(login['data'] == 'ok') {
  30 + localStorage.setItem('gln', this.usuario['gln'])
  31 + this.router.navigateByUrl('/home');
  32 + } else {
  33 + alert('No se encontró la estación');
  34 + this.loginLoading = false;
  35 + }
  36 + });
  37 + }
  38 +}
src/app/login/login.service.ts
... ... @@ -0,0 +1,13 @@
  1 +import { Injectable } from '@angular/core';
  2 +import { HttpClient } from '@angular/common/http';
  3 +import { AppSetings } from '../../etc/AppSetings';
  4 +
  5 +@Injectable()
  6 +export class LoginService {
  7 +
  8 + constructor(private http: HttpClient) { }
  9 +
  10 + getLogin(json: object) {
  11 + return this.http.post(AppSetings.END_POINT + '/login', json);
  12 + };
  13 +}
src/etc/AppSetings.ts
... ... @@ -0,0 +1,3 @@
  1 +export class AppSetings {
  2 + public static END_POINT='http://localhost:6060/gateway-debo';
  3 +}