comprobantes.component.ts 1.72 KB
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-comprobantes',
  templateUrl: './comprobantes.component.html',
  styleUrls: ['./comprobantes.component.scss']
})
export class ComprobantesComponent implements OnInit {

  constructor() { }

  ngOnInit() {

    this.obtenerConsulta()
  }

  filter = '';
  comprobantes = [1, 2, 3];
  cabecera = {};
  cuerpo = [];
  articulosFiltro = [];
  pagina = 1;
  paginas = [];

  fecha = new Date();

  filtrar(event: any) {
    var filtro =  this.cuerpo.filter((param)=> {
      return (param.LI0).toLocaleUpperCase().includes((event.target.value).toLocaleUpperCase());
    });

    this.paginar(filtro, this.pagina);
    this.paginas.length = Math.round(filtro.length / 5);
  }

  paginar(filtro: any, pagina: any) {
    this.articulosFiltro = filtro.slice(
      filtro.length - 1 * pagina, filtro.length * this.pagina + 4);
  }

  obtenerConsulta() {

    setTimeout(() => {
      this.cabecera = {
        TIP: 'A',
        TCO: 'FT',
        SUC: 623,
        NCO: 53979,
        COD: 1,
        FEC: new Date(),
        NOM: 'POTIGIAN GOLOCINAS',
        CUI: '30-54775125-2'
      };
  
      this.cuerpo = [
        {
          LI0: 'Mantel Combo Bolso CocaCola',
          CAN: 5
        },
        {
          LI0: 'Papas',
          CAN: 5
        },
        {
          LI0: 'Peras',
          CAN: 5
        },
        {
          LI0: 'Cafe',
          CAN: 5
        },
        {
          LI0: 'Menta',
          CAN: 5
        },
        {
          LI0: 'Fernet',
          CAN: 5
        },
        {
          LI0: 'Birra',
          CAN: 5
        }
      ];
  
      this.articulosFiltro = this.cuerpo;

      this.paginar(this.articulosFiltro);
    }, 500);
  }

}