Commit a361ae9bc10a15961a9ad5ebc77965da47183862
1 parent
bf509b731c
Exists in
master
and in
1 other branch
paginación ok
Showing
2 changed files
with
35 additions
and
22 deletions
Show diff stats
src/app/comprobantes/comprobantes.component.html
1 | <div class="row panel-informativo"> | 1 | <div class="row panel-informativo"> |
2 | <div class="col-12"> | 2 | <div class="col-12"> |
3 | <div class="row titulares"> | 3 | <div class="row titulares"> |
4 | <div class="col-12 col-sm numero-pedido text-center text-md-left border border-white align-middle ng-binding ng-scope"> | 4 | <div class="col-12 col-sm numero-pedido text-center text-md-left border border-white align-middle ng-binding ng-scope"> |
5 | Recepción | 5 | Recepción |
6 | <button | 6 | <button |
7 | class="btn btn-xs btn-outline-light float-right" | 7 | class="btn btn-xs btn-outline-light float-right" |
8 | type="button" | 8 | type="button" |
9 | ng-click="$ctrl.busqueda()" | 9 | ng-click="$ctrl.busqueda()" |
10 | ng-if="$ctrl.busqueda" | 10 | ng-if="$ctrl.busqueda" |
11 | title="Buscar" | 11 | title="Buscar" |
12 | > | 12 | > |
13 | <i class="fa fa-search"></i> | 13 | <i class="fa fa-search"></i> |
14 | </button> | 14 | </button> |
15 | </div> | 15 | </div> |
16 | <div class="col-7 col-sm border border-white align-middle"> | 16 | <div class="col-7 col-sm border border-white align-middle"> |
17 | Fecha: | 17 | Fecha: |
18 | <span | 18 | <span |
19 | ng-click="datepickerAbierto = true" | 19 | ng-click="datepickerAbierto = true" |
20 | > {{ fecha | date: 'dd/MM/yyyy' }}</span> | 20 | > {{ fecha | date: 'dd/MM/yyyy' }}</span> |
21 | </div> | 21 | </div> |
22 | <div class="col-5 col-sm border border-white border-right-0 align-middle"> | 22 | <div class="col-5 col-sm border border-white border-right-0 align-middle"> |
23 | Hora: | 23 | Hora: |
24 | <span | 24 | <span |
25 | ng-click="datepickerAbierto = true" | 25 | ng-click="datepickerAbierto = true" |
26 | > {{ fecha | date: 'shortTime'}}</span> | 26 | > {{ fecha | date: 'shortTime'}}</span> |
27 | </div> | 27 | </div> |
28 | </div> | 28 | </div> |
29 | </div> | 29 | </div> |
30 | </div> | 30 | </div> |
31 | 31 | ||
32 | <form> | 32 | <form> |
33 | <div class="row border"> | 33 | <div class="row border"> |
34 | <div class="col-6 col-sm-3 d-flex"> | 34 | <div class="col-6 col-sm-3 d-flex"> |
35 | <strong>Letra Factura: </strong> | 35 | <strong>Letra Factura: </strong> |
36 | <label>{{cabecera.TIP}}</label> | 36 | <label>{{cabecera.TIP}}</label> |
37 | </div> | 37 | </div> |
38 | <div class="col-6 col-sm-3 d-flex"> | 38 | <div class="col-6 col-sm-3 d-flex"> |
39 | <strong>Tipo Factura: </strong> | 39 | <strong>Tipo Factura: </strong> |
40 | <label>{{cabecera.TCO}}</label> | 40 | <label>{{cabecera.TCO}}</label> |
41 | </div> | 41 | </div> |
42 | <div class="col-6 col-sm-3 d-flex"> | 42 | <div class="col-6 col-sm-3 d-flex"> |
43 | <strong>Sucursal: </strong> | 43 | <strong>Sucursal: </strong> |
44 | <label>{{cabecera.SUC}}</label> | 44 | <label>{{cabecera.SUC}}</label> |
45 | </div> | 45 | </div> |
46 | <div class="col-6 col-sm-3 d-flex"> | 46 | <div class="col-6 col-sm-3 d-flex"> |
47 | <strong>Número: </strong> | 47 | <strong>Número: </strong> |
48 | <label>{{cabecera.NCO}}</label> | 48 | <label>{{cabecera.NCO}}</label> |
49 | </div> | 49 | </div> |
50 | <div class="col-6 col-sm-3 d-flex"> | 50 | <div class="col-6 col-sm-3 d-flex"> |
51 | <strong>Cuit: </strong> | 51 | <strong>Cuit: </strong> |
52 | <label>{{cabecera.CUI}}</label> | 52 | <label>{{cabecera.CUI}}</label> |
53 | </div> | 53 | </div> |
54 | <div class="col-12 col-sm-3 d-flex"> | 54 | <div class="col-12 col-sm-3 d-flex"> |
55 | <strong>Nombre: </strong> | 55 | <strong>Nombre: </strong> |
56 | <label>{{cabecera.NOM}}</label> | 56 | <label>{{cabecera.NOM}}</label> |
57 | </div> | 57 | </div> |
58 | </div> | 58 | </div> |
59 | <div class="row"> | 59 | <div class="row"> |
60 | <input | 60 | <input |
61 | type="text" | 61 | type="text" |
62 | class="form-control-sm col-12" | 62 | class="form-control-sm col-12" |
63 | placeholder="Busque producto por nombre, codigo" | 63 | placeholder="Busque producto por nombre, codigo" |
64 | (keyup)="filtrar($event)"/> | 64 | (keyup)="filtrar($event)"/> |
65 | </div> | 65 | </div> |
66 | <div class="row"> | 66 | <div class="row"> |
67 | <table class="table table-dark"> | 67 | <table class="table table-dark"> |
68 | <thead> | 68 | <thead> |
69 | <tr> | 69 | <tr> |
70 | <th>Rechazar</th> | 70 | <th>Rechazar</th> |
71 | <th>Producto</th> | 71 | <th>Producto</th> |
72 | <th>Cantidad</th> | 72 | <th>Cantidad</th> |
73 | <th>Aceptar</th> | 73 | <th>Aceptar</th> |
74 | </tr> | 74 | </tr> |
75 | </thead> | 75 | </thead> |
76 | <tbody> | 76 | <tbody> |
77 | <tr *ngFor="let articulo of articulosFiltro" [ngClass]="{'bg-success': articulo.done}"> | 77 | <tr *ngFor="let articulo of getPaginaFiltro()" [ngClass]="{'bg-success': articulo.done}"> |
78 | <th><button type="button" class="" (click)="articulo.input = true"> | 78 | <th><button type="button" class="" (click)="articulo.input = true"> |
79 | <i class="fa fa-window-close"></i> | 79 | <i class="fa fa-window-close"></i> |
80 | </button></th> | 80 | </button></th> |
81 | <th>{{articulo.LI0}}</th> | 81 | <th>{{articulo.LI0}}</th> |
82 | <th *ngIf="!articulo.input">{{articulo.CAN}}</th> | 82 | <th *ngIf="!articulo.input">{{articulo.CAN}}/{{articulo.CAN}}</th> |
83 | <th *ngIf="articulo.input"> | 83 | <th *ngIf="articulo.input"> |
84 | <input class="form-control-sm col-12"/> | 84 | <input class="form-control-sm col-12"/> |
85 | </th> | 85 | </th> |
86 | <th><button type="button" class="" (click)="articulo.done = true"> | 86 | <th> |
87 | <i class="fa fa-check"></i> | 87 | <button type="button" class="" (click)="articulo.done = true"> |
88 | </button></th> | 88 | <i class="fa fa-check"></i> |
89 | </button> | ||
90 | </th> | ||
89 | </tr> | 91 | </tr> |
90 | </tbody> | 92 | </tbody> |
91 | <tfoot> | 93 | <tfoot> |
92 | <nav *ngIf="articulosFiltro.length > 0" class="mr-auto"> | 94 | <nav *ngIf="articulosFiltro.length > 0" class="mr-auto"> |
93 | <ul class="pagination pagination-sm justify-content mb-0"> | 95 | <ul class="pagination pagination-sm justify-content mb-0"> |
94 | <li class="page-item" [ngClass]="{'disabled': pagina == 1}"> | 96 | <li class="page-item" [ngClass]="{'disabled': paginaActiva == 1}"> |
95 | <a class="page-link" href="javascript:void();" (click)="paginar(articulosFiltro); pagina - 1"> | 97 | <a class="page-link" href="javascript:void();" (click)="paginaActiva = paginaActiva - 1"> |
96 | <span aria-hidden="true">«</span> | 98 | <span aria-hidden="true">«</span> |
97 | <span class="sr-only">Anterior</span> | 99 | <span class="sr-only">Anterior</span> |
98 | </a> | 100 | </a> |
99 | </li> | 101 | </li> |
100 | <li | 102 | <li |
101 | class="page-item" | 103 | class="page-item" |
102 | *ngFor="let pagina of paginas; index as i" | 104 | *ngFor="let pagina of paginas; index as i" |
103 | [ngClass]="{'active': pagina == currentPage}" | 105 | [ngClass]="{'active': pagina == paginaActiva}" |
104 | > | 106 | > |
105 | <a | 107 | <a |
106 | class="page-link" | 108 | class="page-link" |
107 | href="javascript:void();" | 109 | href="javascript:void();" |
108 | (click)="selectPage(pagina)" | 110 | (click)="paginaActiva = pagina" |
109 | >{{pagina}}</a> | 111 | >{{pagina}}</a> |
110 | </li> | 112 | </li> |
111 | <li class="page-item" [ngClass]="{'disabled': currentPage == lastPage}"> | 113 | <li class="page-item" [ngClass]="{'disabled': paginaActiva == paginas.length}"> |
112 | <a class="page-link" href="javascript:void();" (click)="paginar(articulosFiltro); pagina + 1"> | 114 | <a class="page-link" href="javascript:void();" (click)="paginaActiva = paginaActiva + 1"> |
113 | <span aria-hidden="true">»</span> | 115 | <span aria-hidden="true">»</span> |
114 | <span class="sr-only">Siguiente</span> | 116 | <span class="sr-only">Siguiente</span> |
115 | </a> | 117 | </a> |
116 | </li> | 118 | </li> |
117 | </ul> | 119 | </ul> |
118 | </nav> | 120 | </nav> |
119 | </tfoot> | 121 | </tfoot> |
120 | </table> | 122 | </table> |
121 | </div> | 123 | </div> |
122 | </form> | 124 | </form> |
123 | 125 |
src/app/comprobantes/comprobantes.component.ts
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | 2 | ||
3 | @Component({ | 3 | @Component({ |
4 | selector: 'app-comprobantes', | 4 | selector: 'app-comprobantes', |
5 | templateUrl: './comprobantes.component.html', | 5 | templateUrl: './comprobantes.component.html', |
6 | styleUrls: ['./comprobantes.component.scss'] | 6 | styleUrls: ['./comprobantes.component.scss'] |
7 | }) | 7 | }) |
8 | export class ComprobantesComponent implements OnInit { | 8 | export class ComprobantesComponent implements OnInit { |
9 | 9 | ||
10 | constructor() { } | 10 | constructor() { } |
11 | 11 | ||
12 | ngOnInit() { | 12 | ngOnInit() { |
13 | 13 | ||
14 | this.obtenerConsulta() | 14 | this.obtenerConsulta(); |
15 | } | 15 | } |
16 | 16 | ||
17 | filter = ''; | 17 | filter = ''; |
18 | comprobantes = [1, 2, 3]; | 18 | comprobantes = [1, 2, 3]; |
19 | cabecera = {}; | 19 | cabecera = {}; |
20 | cuerpo = []; | 20 | cuerpo = []; |
21 | articulosFiltro = []; | 21 | articulosFiltro = []; |
22 | pagina = 1; | 22 | paginaActiva = 1; |
23 | paginas = []; | 23 | paginas = []; |
24 | 24 | ||
25 | fecha = new Date(); | 25 | fecha = new Date(); |
26 | 26 | ||
27 | filtrar(event: any) { | 27 | filtrar(event: any) { |
28 | var filtro = this.cuerpo.filter((param)=> { | 28 | this.articulosFiltro = this.cuerpo.filter((param)=> { |
29 | return (param.LI0).toLocaleUpperCase().includes((event.target.value).toLocaleUpperCase()); | 29 | return (param.LI0).toLocaleUpperCase().includes( |
30 | (event.target.value).toLocaleUpperCase()) || | ||
31 | param.codigoBarras == event.target.value; | ||
30 | }); | 32 | }); |
31 | 33 | ||
32 | this.paginar(filtro, this.pagina); | 34 | this.paginar(); |
33 | this.paginas.length = Math.round(filtro.length / 5); | ||
34 | } | 35 | } |
35 | 36 | ||
36 | paginar(filtro: any, pagina: any) { | 37 | paginar() { |
37 | this.articulosFiltro = filtro.slice( | 38 | |
38 | filtro.length - 1 * pagina, filtro.length * this.pagina + 4); | 39 | var cantPaginas = Math.round(this.articulosFiltro.length / 5) + 1; |
40 | this.paginas = []; | ||
41 | for (let i = 0; i < cantPaginas; i++) { | ||
42 | this.paginas.push(i + 1); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | getPaginaFiltro() { | ||
47 | return this.articulosFiltro.slice( | ||
48 | (this.paginaActiva - 1) * 5 , this.paginaActiva * 5); | ||
39 | } | 49 | } |
40 | 50 | ||
41 | obtenerConsulta() { | 51 | obtenerConsulta() { |
42 | 52 | ||
43 | setTimeout(() => { | 53 | setTimeout(() => { |
44 | this.cabecera = { | 54 | this.cabecera = { |
45 | TIP: 'A', | 55 | TIP: 'A', |
46 | TCO: 'FT', | 56 | TCO: 'FT', |
47 | SUC: 623, | 57 | SUC: 623, |
48 | NCO: 53979, | 58 | NCO: 53979, |
49 | COD: 1, | 59 | COD: 1, |
50 | FEC: new Date(), | 60 | FEC: new Date(), |
51 | NOM: 'POTIGIAN GOLOCINAS', | 61 | NOM: 'POTIGIAN GOLOCINAS', |
52 | CUI: '30-54775125-2' | 62 | CUI: '30-54775125-2' |
53 | }; | 63 | }; |
54 | 64 | ||
55 | this.cuerpo = [ | 65 | this.cuerpo = [ |
56 | { | 66 | { |
57 | LI0: 'Mantel Combo Bolso CocaCola', | 67 | LI0: 'Mantel Combo Bolso CocaCola', |
58 | CAN: 5 | 68 | CAN: 5, |
69 | codigoBarras: '7790667006462' | ||
59 | }, | 70 | }, |
60 | { | 71 | { |
61 | LI0: 'Papas', | 72 | LI0: 'Papas', |
62 | CAN: 5 | 73 | CAN: 5 |
63 | }, | 74 | }, |
64 | { | 75 | { |
65 | LI0: 'Peras', | 76 | LI0: 'Peras', |
66 | CAN: 5 | 77 | CAN: 5 |
67 | }, | 78 | }, |
68 | { | 79 | { |
69 | LI0: 'Cafe', | 80 | LI0: 'Cafe', |
70 | CAN: 5 | 81 | CAN: 5 |
71 | }, | 82 | }, |
72 | { | 83 | { |
73 | LI0: 'Menta', | 84 | LI0: 'Menta', |
74 | CAN: 5 | 85 | CAN: 5 |
75 | }, | 86 | }, |
76 | { | 87 | { |
77 | LI0: 'Fernet', | 88 | LI0: 'Fernet', |
78 | CAN: 5 | 89 | CAN: 5 |
79 | }, | 90 | }, |
80 | { | 91 | { |
81 | LI0: 'Birra', | 92 | LI0: 'Birra', |
82 | CAN: 5 | 93 | CAN: 5 |
83 | } | 94 | } |
84 | ]; | 95 | ]; |
85 | 96 | ||
86 | this.articulosFiltro = this.cuerpo; | 97 | this.articulosFiltro = this.cuerpo; |
87 | 98 | ||
88 | this.paginar(this.articulosFiltro); | 99 | this.paginar(); |
89 | }, 500); | 100 | }, 500); |
90 | } | 101 | } |
91 | 102 | ||
92 | } | 103 | } |