Ver código fonte

Merge branch 'master' of http://209.50.56.224/ITTEC/SistemaIntegralRecursosHumanos

alanittec 3 anos atrás
pai
commit
ff5abff565

+ 14 - 14
vacaciones/src/app/components/mco/mcomdf/mcomdf.component.ts

@@ -20,7 +20,7 @@ import { USERInterface } from 'src/app/interfaces/user-interface';
 })
 export class MCOMDFComponent implements AfterViewInit {
 
-  usuario_session:USERInterface = JSON.parse(localStorage.getItem('TIMUSERENC')!);
+  usuario_session: USERInterface = JSON.parse(localStorage.getItem('TIMUSERENC')!);
   loading: Boolean = true;
   data_empty = false;
   displayedColumns: string[] = ['periodo', 'mes', 'dia', 'motivo', 'accion'];
@@ -75,7 +75,7 @@ export class MCOMDFComponent implements AfterViewInit {
         'Noviembre',
         'Diciembre',
       ];
-      
+
       return (
         data.ANIO.toString().includes(filter) ||
         nombreMes[data.MES - 1].toString().toLowerCase().includes(filter) ||
@@ -83,7 +83,7 @@ export class MCOMDFComponent implements AfterViewInit {
         data.MOTIVO.toString().toLowerCase().includes(filter)
       );
     };
-   
+
     this.obtener();
   }
 
@@ -92,10 +92,11 @@ export class MCOMDFComponent implements AfterViewInit {
       if (res.status == 'Token is Expired') {
         this._iamService.logout();
         this.snackAlert('Sesión expirada. Vuelva a iniciar sesión');
-      }else if (!res.status && res.response.length > 0) {
+      } else if (!res.status && res.response.length > 0) {
         this.dataSource.data = res.response;
-      }else{
-        this.snackAlert( res.response.length > 0 ? res.msg : 'No hay datos para mostrar');
+
+      } else {
+        this.snackAlert(res.response.length > 0 ? res.msg : 'No hay datos para mostrar');
         this.data_empty = true;
         this.dataSource.data = [];
       }
@@ -121,12 +122,12 @@ export class MCOMDFComponent implements AfterViewInit {
       id_usuario_elimina: this._encService.desencriptar(this.usuario_session.IDUSUARIO),
     };
     this._mcomdfService.eliminar(dato_eliminar).subscribe(res => {
-      if(!res.error){
+      if (!res.error) {
         this.obtener();
         this.snackAlert('¡Eliminación Exitosa!');
-      }else{
+      } else {
         this.snackAlert(res.msg);
-      } 
+      }
     }, error => {
       if (!error.ok) {
         this.snackAlert('Ocurrió un error inesperado');
@@ -138,8 +139,8 @@ export class MCOMDFComponent implements AfterViewInit {
         this.snackAlert('Conexion lenta');
       }
     });
- 
-    
+
+
   }
 
   obtenerNombreMes(mes: any) {
@@ -153,9 +154,8 @@ export class MCOMDFComponent implements AfterViewInit {
   openDialog(item: any) {
     let dataAction = {
       titulo: 'Eliminar Día Feriado',
-      descripcion: `¿Está seguro de eliminar la fecha ${
-        item.DIA
-      }/${this.obtenerNombreMes(item.MES)}/${item.ANIO}?`,
+      descripcion: `¿Está seguro de eliminar la fecha ${item.DIA
+        }/${this.obtenerNombreMes(item.MES)}/${item.ANIO}?`,
     };
 
     const dialogRef = this.dialog.open(AlertaComponent, {

+ 1 - 1
vacaciones/src/app/components/mes/mesmav/mesmav.component.html

@@ -78,7 +78,7 @@
     <ng-container matColumnDef="fecha_fin">
       <th mat-header-cell *matHeaderCellDef>Fecha Fin</th>
       <td mat-cell *matCellDef="let element">
-        {{ formatoFecha(element.FECHAINICIO) }}
+        {{ formatoFecha(element.FECHAFIN) }}
       </td>
     </ng-container>
 

+ 17 - 17
vacaciones/src/app/components/mes/mesmav/mesmav.component.ts

@@ -11,6 +11,7 @@ import { MESMAVInterface } from 'src/app/interfaces/mes/mesmav/mesmav-interface'
 import { ENCService } from 'src/app/services/enc/enc.service';
 import { ActivatedRoute } from '@angular/router';
 import { IAMService } from 'src/app/services/iam/iam.service';
+import { lastValueFrom } from 'rxjs';
 
 @Component({
   selector: 'app-mesmav',
@@ -63,7 +64,7 @@ export class MESMAVComponent implements AfterViewInit {
           : params['solicitud_datos'].replace('data=', '');
     });
     console.log(this.solicitud_datos);
-    
+
     if (this.solicitud_datos != '') {
       let data_dec = this._encService.desencriptar(this.solicitud_datos);
       this.solicitud = JSON.parse(data_dec);
@@ -79,7 +80,7 @@ export class MESMAVComponent implements AfterViewInit {
     this.solicitudes.forEach((element: any) => {
       if (element.IDSOLICITUD == this.solicitud.id_solicitud) {
         console.log(this.solicitud);
-        
+
         if (this.solicitud.estatus == 'Rechazado') {
           this.openDialogForm('Rechazar vacaciones', element);
         }
@@ -98,7 +99,7 @@ export class MESMAVComponent implements AfterViewInit {
 
   obtener() {
     this.__mesmavService.consultar().subscribe((res: any) => {
-      
+
       if (res.status == 'Token is Expired') {
         this._iamService.logout();
         this.snackAlert('Sesión expirada. Vuelva a iniciar sesión');
@@ -108,7 +109,7 @@ export class MESMAVComponent implements AfterViewInit {
         this.cargarTabla(this.solicitudes);
       } else {
         this.solicitudes = [];
-        this.snackAlert( res.response.length > 0 ? res.msg : 'No hay datos para mostrar');
+        this.snackAlert(res.response.length > 0 ? res.msg : 'No hay datos para mostrar');
         this.data_empty = true;
       }
       this.isLoading = false;
@@ -150,7 +151,7 @@ export class MESMAVComponent implements AfterViewInit {
     this.paginator._intl.previousPageLabel = 'Anterior Página';
   }
 
-  aprobarSolicitud(solicitud: MESMAVInterface) {
+  async aprobarSolicitud(solicitud: MESMAVInterface) {
     //Se esta enviando un correo
     this.isSend = true;
     //Estructura de solicitud aceptada
@@ -163,9 +164,9 @@ export class MESMAVComponent implements AfterViewInit {
       rfc_empresa: this.__mesmavService.usuario_session.RFCEMPRESA,
     };
 
-    this.__mesmavService
-      .aprobarSolicitud(solicitud_aprobar)
-      .subscribe((res: any) => {
+    await lastValueFrom(this.__mesmavService
+      .aprobarSolicitud(solicitud_aprobar))
+      .then((res: any) => {
         if (!res.error) {
           this.isSend = false;
           this.removerSolicitudTabla(solicitud);
@@ -176,7 +177,6 @@ export class MESMAVComponent implements AfterViewInit {
             .afterDismissed()
             .subscribe(() => {
 
-              this.obtener();
               this.ngAfterViewInit();
               this.snackAlert('Se ha enviado un correo para informar al empleado');
             });
@@ -194,21 +194,23 @@ export class MESMAVComponent implements AfterViewInit {
           this.snackAlert('Conexion lenta');
         }
       });
+
+    this.obtener();
   }
 
-  rechazarSolicitud(solicitud: MESMAVInterface) {
+  async rechazarSolicitud(solicitud: MESMAVInterface) {
     //Se esta enviando un correo
     this.isSend = true;
     //Rechazamos solicitud
-    this.__mesmavService.rechazarSolicitud(solicitud).subscribe((res: any) => {
+    await lastValueFrom(this.__mesmavService.rechazarSolicitud(solicitud)).then((res: any) => {
       //alert("Espera")
-      
+
       if (!res.error) {
         this.isSend = false;
-        
+
         //this.removerSolicitudTabla(solicitud);
-        
-         this.obtener();
+
+        this.obtener();
         /* this.ngAfterViewInit(); */
 
         this._snackBar
@@ -219,8 +221,6 @@ export class MESMAVComponent implements AfterViewInit {
           .subscribe(() => {
             this.snackAlert('Se ha enviado un correo para informar a los administradores');
           });
-
-        
       } else {
         this.snackAlert(res.msg);
       }

+ 2 - 2
vacaciones/src/app/components/resources/dialogos/informacion-solicitud/informacion-solicitud.component.html

@@ -25,14 +25,14 @@
     <mat-divider></mat-divider>
     <div class="text-icon">
       <p class="text-dialog-info">
-        Fecha inicio: <b>{{ data.FECHAINICIO }}</b>
+        Fecha inicio: <b>{{ formatoFecha(data.FECHAINICIO) }}</b>
       </p>
       <mat-icon class="icon-margin">today</mat-icon>
     </div>
     <mat-divider></mat-divider>
     <div class="text-icon">
       <p class="text-dialog-info">
-        Fecha fin: <b>{{ data.FECHAFIN }}</b>
+        Fecha fin: <b>{{ formatoFecha(data.FECHAFIN) }}</b>
       </p>
       <mat-icon class="icon-margin">event_available</mat-icon>
     </div>

+ 5 - 0
vacaciones/src/app/components/resources/dialogos/informacion-solicitud/informacion-solicitud.component.ts

@@ -13,4 +13,9 @@ export class INFORMACIONSOLICITUDComponent implements OnInit {
   ngOnInit(): void {
   }
 
+  formatoFecha(fecha: string): string {   
+    let split = fecha.split('-');
+    return `${split[2]}-${split[1]}-${split[0]}`;
+  }
+
 }

+ 26 - 10
vacaciones/src/app/services/mes/mesmav/mesmav.service.ts

@@ -1,6 +1,7 @@
 import { HttpClient, HttpHeaders } from '@angular/common/http';
 import { Injectable } from '@angular/core';
 import { MatSnackBar } from '@angular/material/snack-bar';
+import { map } from 'rxjs';
 import { MESMAVInterface } from 'src/app/interfaces/mes/mesmav/mesmav-interface';
 import { ResponseData } from 'src/app/interfaces/response-data';
 import { USERInterface } from 'src/app/interfaces/user-interface';
@@ -41,21 +42,36 @@ export class MESMAVService {
     );
   }
 
-  rechazarSolicitud(solicitud: any) {
-    return this.http.post<ResponseData>(`${this._url}/autorizar`, solicitud, {
-      headers: this.header,
-    });
+  public rechazarSolicitud(solicitud: any) {
+    return this.postQuery("/autorizar", solicitud).pipe(map((data: any) => data))
   }
 
   aprobarSolicitud(solicitud: any) {
-    return this.http.post<ResponseData>(`${this._url}/autorizar`, solicitud, {
-      headers: this.header,
-    });
+    return this.postQuery("/autorizar", solicitud).pipe(map((data: any) => data))
   }
 
-  private formatoRFC(rfc: string){
-    let rfc_decoded =  window.atob(rfc);
+  private formatoRFC(rfc: string) {
+    let rfc_decoded = window.atob(rfc);
     let rfc_replace = rfc_decoded.replace("|", "/");
     return rfc_replace;
-  } 
+  }
+
+  private getQuery(query: string) {
+    const URL = `${this._url}${query}`;
+    return this.http.get(URL, {
+      headers: new HttpHeaders({
+        Authorization: 'Bearer ' + this.jwt
+      })
+    });
+  }
+
+  private postQuery(query: string, body: any) {
+    const URL = `${this._url}${query}`;
+    return this.http.post(URL, body, {
+      headers: new HttpHeaders({
+        Authorization: 'Bearer ' + this.jwt
+      })
+    });
+  }
+
 }