|
|
@@ -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);
|
|
|
}
|