Commit ad214f9d4275bc0e682a95ca97b7a94e1bfc6fb2

Authored by Eric Fernandez
1 parent 3e5d641314
Exists in master

devuelvo comprobante a servicio

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/busqueda-comprobante/busqueda-comprobantes.service.ts
1 1 import { Injectable } from '@angular/core';
2   -import { HttpClient, HttpHeaders } from '@angular/common/http';
  2 +import { HttpClient } from '@angular/common/http';
3 3 import { AppSetings } from '../../etc/AppSetings';
4 4  
5 5 @Injectable()
6 6 export class BusquedaComprobantesService {
7 7  
8   - constructor(private http: HttpClient) {
9   - }
  8 + constructor(private http: HttpClient) { }
10 9  
11 10 getComprobantes() {
12 11 return this.http.get(AppSetings.END_POINT + '/comprobantes/' + localStorage.getItem('gln'));
src/app/comprobantes/comprobantes.component.html
... ... @@ -162,5 +162,5 @@
162 162 </table>
163 163 </div>
164 164 </form>
165   - <app-acciones (guardar)="guardarComprobante()"></app-acciones>
  165 + <app-acciones (guardar)="guardarComprobante()" [(saveLoading)]="saveLoading"></app-acciones>
166 166 </div>
src/app/comprobantes/comprobantes.component.ts
1 1 import { Component, OnInit} from '@angular/core';
2 2 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
3 3 import { BusquedaComprobanteComponent } from '../busqueda-comprobante/busqueda-comprobante.component';
  4 +import { ComprobanteService } from './comprobantes.service';
4 5  
5 6 @Component({
6 7 templateUrl: './comprobantes.component.html',
7   - styleUrls: ['./comprobantes.component.scss']
  8 + styleUrls: ['./comprobantes.component.scss'],
  9 + providers:[ ComprobanteService ]
8 10 })
9 11 export class ComprobantesComponent implements OnInit {
10 12  
11   - constructor(private modalService: NgbModal) { }
  13 + constructor(private modalService: NgbModal, public comprobanteService: ComprobanteService) { }
12 14  
13 15 ngOnInit() { }
14 16  
... ... @@ -20,6 +22,7 @@ export class ComprobantesComponent implements OnInit {
20 22 articulosFiltro = [];
21 23 paginaActiva = 1;
22 24 paginas = [];
  25 + saveLoading = false;
23 26  
24 27 fecha = new Date();
25 28  
... ... @@ -52,7 +55,16 @@ export class ComprobantesComponent implements OnInit {
52 55 }
53 56  
54 57 guardarComprobante(event: any) {
55   - 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 + });
56 68 }
57 69  
58 70 busquedaComprobantes() {
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.service.ts
1 1 import { Injectable } from '@angular/core';
2   -import { HttpClient, HttpHeaders } from '@angular/common/http';
  2 +import { HttpClient } from '@angular/common/http';
3 3 import { AppSetings } from '../../etc/AppSetings';
4 4  
5 5 @Injectable()