|
|
@@ -29,6 +29,8 @@ import {
|
|
|
MatCalendarCellCssClasses,
|
|
|
} from '@angular/material/datepicker';
|
|
|
|
|
|
+
|
|
|
+
|
|
|
import { AlertaComponent } from '../../resources/dialogos/alerta/alerta.component';
|
|
|
import { USERInterface } from 'src/app/interfaces/user-interface';
|
|
|
import { ENCService } from 'src/app/services/enc/enc.service';
|
|
|
@@ -64,6 +66,7 @@ export class MESMSVComponent implements OnInit {
|
|
|
status: false,
|
|
|
};
|
|
|
loading = false;
|
|
|
+ contadorCellDate: number = 0;
|
|
|
|
|
|
minDate = new Date(
|
|
|
new Date().getFullYear(),
|
|
|
@@ -80,6 +83,7 @@ export class MESMSVComponent implements OnInit {
|
|
|
public perfil: number = 0;
|
|
|
public otros_usuarios_arr: Array<any> = [];
|
|
|
public enable = true;
|
|
|
+ public enableAux = true;
|
|
|
|
|
|
diasFeriados: any[] = [];
|
|
|
myControl: FormControl = new FormControl();
|
|
|
@@ -169,8 +173,9 @@ export class MESMSVComponent implements OnInit {
|
|
|
this.myControl.reset();
|
|
|
}
|
|
|
|
|
|
- public cambioEmpleado() {
|
|
|
+ public async cambioEmpleado() {
|
|
|
this.enable = true;
|
|
|
+ this.enableAux = true;
|
|
|
this.fecha_inicio?.reset();
|
|
|
this.fecha_fin?.reset();
|
|
|
|
|
|
@@ -198,6 +203,40 @@ export class MESMSVComponent implements OnInit {
|
|
|
this.disabledFechas = true;
|
|
|
this.dias_vacacionales?.disable();
|
|
|
}
|
|
|
+
|
|
|
+ let idpolitica:any = [];
|
|
|
+
|
|
|
+ if (this.otro_usuario?.value) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let campo_empleado2: string = this.myControl.value;
|
|
|
+ let id_empleado3 = campo_empleado2.split(' - ')[0];
|
|
|
+ let filtro:Array<any> = this.otros_usuarios_arr.filter(
|
|
|
+ (element) => element.IDUSUARIO === id_empleado3
|
|
|
+ );
|
|
|
+ idpolitica = filtro[0].POLITICA;
|
|
|
+ }else{
|
|
|
+ idpolitica = this._encService.desencriptar(this.usuario_session.POLITICA);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ await lastValueFrom(this._mcompvService.obtenerPoliticaUsuario(idpolitica)).then(
|
|
|
+ (data:any) => {
|
|
|
+ if (!data.error) {
|
|
|
+ this.politica = data.response.DIASDESCANSO;
|
|
|
+ this.getDaysPolitician(JSON.parse(data.response.DIASDESCANSO));
|
|
|
+ }
|
|
|
+ }, (error: HttpErrorResponse) => {
|
|
|
+ if (!error.ok)
|
|
|
+ this._validationService.openSnackBar('Ocurrió un error inesperado');
|
|
|
+ if (error.error.msg != undefined)
|
|
|
+ this._validationService.openSnackBar(error.error.msg);
|
|
|
+ if (error.status == 408)
|
|
|
+ this._validationService.openSnackBar('Conexion lenta');
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
public async cambioUsuario() {
|
|
|
@@ -262,33 +301,36 @@ export class MESMSVComponent implements OnInit {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- dateClass: MatCalendarCellClassFunction<Date> = (cellDate, view) => {
|
|
|
+ dateClass: MatCalendarCellClassFunction<Date> = async (cellDate, view) => {
|
|
|
if (this.enable) {
|
|
|
+ this.getDaysPolitician(JSON.parse(this.politica));
|
|
|
this.cambioUsuario();
|
|
|
this.enable = false;
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
let dateToString = cellDate?.toString();
|
|
|
cellDate = new Date(dateToString!);
|
|
|
|
|
|
- if (view === 'month') return this.filterDays(cellDate);
|
|
|
+ if (view === 'month')
|
|
|
+ return this.filterDays(cellDate);
|
|
|
+
|
|
|
return '';
|
|
|
};
|
|
|
|
|
|
async filterDays(cellDate: any) {
|
|
|
- const sleep = (ms: number) =>
|
|
|
- new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
+
|
|
|
const collection = document.getElementsByClassName(
|
|
|
'mat-calendar-body-cell-content'
|
|
|
) as HTMLCollectionOf<HTMLElement>;
|
|
|
|
|
|
- await sleep(400);
|
|
|
-
|
|
|
+
|
|
|
let dateToString = cellDate?.toString();
|
|
|
let lastPosition = this.dates_disable[this.dates_disable.length - 1];
|
|
|
cellDate = new Date(dateToString!);
|
|
|
-
|
|
|
- for (let index = 0; index < this.dates_disable.length; index++) {
|
|
|
+
|
|
|
+ let index = 0;
|
|
|
+ for await (let item of this.dates_disable) {
|
|
|
if (
|
|
|
cellDate.getDate() == this.dates_disable[index].getDate() &&
|
|
|
cellDate.getMonth() == this.dates_disable[index].getMonth() &&
|
|
|
@@ -314,6 +356,8 @@ export class MESMSVComponent implements OnInit {
|
|
|
return 'weekendsDays';
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ index++;
|
|
|
}
|
|
|
|
|
|
return '';
|
|
|
@@ -595,7 +639,8 @@ export class MESMSVComponent implements OnInit {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- getDaysPolitician(convert: any) {
|
|
|
+ async getDaysPolitician(convert: any) {
|
|
|
+
|
|
|
this.days_week_disable = [];
|
|
|
if (convert.Do == 'Si') this.days_week_disable.push(0);
|
|
|
if (convert.Lu == 'Si') this.days_week_disable.push(1);
|
|
|
@@ -604,6 +649,8 @@ export class MESMSVComponent implements OnInit {
|
|
|
if (convert.Ju == 'Si') this.days_week_disable.push(4);
|
|
|
if (convert.Vi == 'Si') this.days_week_disable.push(5);
|
|
|
if (convert.Sa == 'Si') this.days_week_disable.push(6);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
get numero_empleado() {
|