busqueda-comprobante.component.ts
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Component, OnInit} from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { BusquedaComprobantesService } from './busqueda-comprobantes.service';
@Component({
templateUrl: './busqueda-comprobante.component.html',
styleUrls: ['./busqueda-comprobante.component.scss'],
providers: [BusquedaComprobantesService]
})
export class BusquedaComprobanteComponent implements OnInit {
comprobantes: Array<Object> = [];
paginaActiva = 1;
paginas = [];
cantidadPorPagina = 10;
constructor(public activeModal: NgbActiveModal, public comprobanteService: BusquedaComprobantesService) { }
ngOnInit() {
this.comprobanteService.getComprobantes().subscribe((data: Array<Object>) => {
this.comprobantes = data;
this.paginar();
});
}
getPaginaFiltro() {
return this.comprobantes.slice((this.paginaActiva - 1) * this.cantidadPorPagina,
this.paginaActiva * this.cantidadPorPagina);
}
paginar() {
var cantPaginas = Math.ceil(this.comprobantes.length / this.cantidadPorPagina);
this.paginas = [];
for (let i = 0; i < cantPaginas; i++) {
this.paginas.push(i + 1);
}
}
rellenar(relleno: number, numero: number) {
if (numero.toString().length >= relleno) {
return numero;
}
let rellenar = '';
for (let i = 0; i < relleno - numero.toString().length; i++) {
rellenar += '0'
}
return rellenar + numero.toString();
}
close() {
this.activeModal.dismiss();
}
selectItem(comprobante: object) {
this.activeModal.close(comprobante);
}
}