Просмотр исходного кода

Correcciones equipos de trabajo

Jose Brito 1 год назад
Родитель
Сommit
b9b1b2d2b7
17 измененных файлов с 702 добавлено и 324 удалено
  1. 2 0
      sistema-mantenimiento-front/src/app/app.module.ts
  2. 6 2
      sistema-mantenimiento-front/src/app/components/personal-management/employee/employee-form/employee-form.component.html
  3. 47 3
      sistema-mantenimiento-front/src/app/components/personal-management/employee/employee-form/employee-form.component.ts
  4. 3 2
      sistema-mantenimiento-front/src/app/components/personal-management/employee/employee.component.ts
  5. 46 70
      sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team-form/work-team-form.component.html
  6. 160 42
      sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team-form/work-team-form.component.ts
  7. 78 90
      sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team.component.html
  8. 56 17
      sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team.component.ts
  9. 85 85
      sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/active-orders.component.html
  10. 64 10
      sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/active-orders.component.ts
  11. 0 0
      sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.css
  12. 28 0
      sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.html
  13. 23 0
      sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.spec.ts
  14. 95 0
      sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.ts
  15. 2 2
      sistema-mantenimiento-front/src/app/interfaces/personal-managment/workteam.interface.ts
  16. 5 0
      sistema-mantenimiento-front/src/app/services/functions.service.ts
  17. 2 1
      sistema-mantenimiento-front/src/styles.css

+ 2 - 0
sistema-mantenimiento-front/src/app/app.module.ts

@@ -487,6 +487,7 @@ import { PriorityArticleComponent } from './components/acquisition-management/pr
 import { GraphicEquipmentSearchComponent } from './components/equipment-management/graphic-equipment-search/graphic-equipment-search.component';
 import { GroupPendingComponent } from './components/equipment-management/group-pending/group-pending.component';
 import { HourSelectorComponent } from './components/resources/hour-selector/hour-selector.component';
+import { OrderExecutionConfigComponent } from './components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component';
 
 
 @NgModule({
@@ -858,6 +859,7 @@ import { HourSelectorComponent } from './components/resources/hour-selector/hour
     GraphicEquipmentSearchComponent,
     GroupPendingComponent,
     HourSelectorComponent,
+    OrderExecutionConfigComponent,
   ],
   imports: [
     MatMomentDateModule,

+ 6 - 2
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee-form/employee-form.component.html

@@ -77,8 +77,12 @@
                 </div>
                 <div class="form-cell pt-8" [ngClass]="{ fw_33: screenSize > 920, fw_50: screenSize <= 920 && screenSize > 690, fw_100: screenSize <= 690 }">
                   <mat-form-field appearance="outline">
-                    <mat-label>Especialidad</mat-label>
-                    <input matInput formControlName="speciality">
+                    <mat-label>Especialidades y/u oficios</mat-label>
+                    <mat-select formControlName="speciality" multiple>
+                      <mat-option *ngFor="let specialty of specialties" [value]="specialty.CODIGO_ESPECIALIDAD">
+                        {{ specialty.NOMBRE_ESPECIALIDAD }}
+                      </mat-option>
+                    </mat-select>
                     @if (formGroup.controls['speciality'].hasError('required')) {
                       <mat-error>Este campo es obligatorio.</mat-error>
                     }

+ 47 - 3
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee-form/employee-form.component.ts

@@ -27,6 +27,8 @@ import { TempFileInfo } from 'src/app/interfaces/temp-file-info.interface';
 import { apiTemp, availableFiles } from 'src/environments/environment.prod';
 import { GdelService } from 'src/app/services/document-management/gdel.service';
 import { HttpClient, HttpErrorResponse } from '@angular/common/http';
+import { InterventionService } from 'src/app/services/personal-management/intervention.service';
+import { SpecialtiesListItem, SpecialtiesListResponse } from 'src/app/interfaces/specialties.interface';
 
 @Component({
   selector: 'app-employee-form',
@@ -104,6 +106,7 @@ export class EmployeeFormComponent implements OnInit {
   fileTypes: Map<string, string>;
   screenSize: number;
   employee: EmployeeInfo | null;
+  specialties: SpecialtiesListItem[];
 
   public arrEmployee: Array<EmployeesListItem>;
   public employeeStr: Array<string>;
@@ -123,6 +126,7 @@ export class EmployeeFormComponent implements OnInit {
     private _functionsService: FunctionsService,
     private _gdelService: GdelService,
     private _httpClient: HttpClient,
+    private _interventionService: InterventionService,
   ) {
     this.action = "";
     this.idEmployee = this._activatedRoute.snapshot.paramMap.get('id')!;
@@ -180,6 +184,7 @@ export class EmployeeFormComponent implements OnInit {
     this.fileTypes = new Map();
     this.screenSize = window.innerWidth;
     this.employee = null;
+    this.specialties = [];
 
     this.arrEmployee = [];
     this.employeeStr = [];
@@ -1478,7 +1483,9 @@ export class EmployeeFormComponent implements OnInit {
       this.hasError = countries.error;
       this.errorStr = countries.msg;
 
-      if(!this.hasError){
+      if(this.hasError){
+        this.isLoading = false;
+      }else{
         let mex = countries.response.filter(item => item.COUNTRY_ID == 'MEX');
         this.countries.push(mex[0]);
         this.countriesStr.push(`${mex[0].NAME} (${mex[0].COUNTRY_ID})`);
@@ -1523,9 +1530,9 @@ export class EmployeeFormComponent implements OnInit {
             this.formGroup.controls['contactLada'].setValue(`${ladaObj.LADA!}-${ladaObj.NOMECLARUTA_ISO2!}`);
           }
         }
+
+        this.getSpecialties();
       }
-      
-      this.isLoading = false;
     }catch(error: any){
       if(error.error == undefined){
         this._resourcesService.openSnackBar("Ocurrió un error inesperado.");
@@ -1537,6 +1544,43 @@ export class EmployeeFormComponent implements OnInit {
     }
   }
 
+  async getSpecialties(){
+    try{
+      let idUser = localStorage.getItem('idusuario')!;
+      let specialties: SpecialtiesListResponse = await lastValueFrom(this._interventionService.getSpecialties(idUser, 1));
+
+      this.hasError = specialties.error;
+      this.errorStr = specialties.msg;
+
+      if(!this.hasError){
+        let specialtiesArr: SpecialtiesListItem[] = [];
+        for(const specialty  of specialties.response){
+          let codeDec = await this._encService.decrypt(specialty.CODIGO_ESPECIALIDAD);
+          specialty.NOMBRE_ESPECIALIDAD = `${codeDec} - ${specialty.NOMBRE_ESPECIALIDAD}`;
+
+          if(specialty.ESTADO == 'Activo'){
+            specialtiesArr.push(specialty);
+          }
+        }
+
+        this.specialties = specialtiesArr;
+      }
+
+      this.isLoading = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
+  }
+
   private async fileExists(url: string){
     try{
       let res: any = await lastValueFrom(this._httpClient.get(url).pipe());

+ 3 - 2
sistema-mantenimiento-front/src/app/components/personal-management/employee/employee.component.ts

@@ -199,6 +199,7 @@ export class EmployeeComponent implements OnInit {
           let idEmployeeDec = await this._encService.decrypt(employee.ID_EMPLOYEE);
 
           if(employee.TEAM_ID != null){
+            console.log(employee.TEAM_ID);
             let idTeamDec = await this._encService.decrypt(employee.TEAM_ID);
             employee.TEAM_NAME = `${employee.TEAM_NAME} (${idTeamDec})`;
           }
@@ -215,9 +216,9 @@ export class EmployeeComponent implements OnInit {
       this.isLoading = false;
     }catch(error: any){
       if(error.error == undefined){
-        this.errorStr = 'Ocurrió un error inesperado.';
+        this.errorStr = 'Ocurrió un error inesperado (1).';
       }else if(error.error.msg == undefined){
-        this.errorStr = 'Ocurrió un error inesperado.';
+        this.errorStr = 'Ocurrió un error inesperado (2).';
       }else{
         this.errorStr = error.error.msg;
       }

+ 46 - 70
sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team-form/work-team-form.component.html

@@ -1,73 +1,49 @@
-
-@switch (dialogData.action) {
-  @case ('REG') {
-    <h2 mat-dialog-title>Registrar equipo de trabajo</h2> 
-  }
-  @case ('UPD') {
-    <h2 mat-dialog-title>Modificación equipo de trabajo</h2>
-  }
-  @case ('DET') {
-    <h2 mat-dialog-title>Detalles equipo de trabajo</h2>
-  }
-  @default {
-    <h2 mat-dialog-title>...</h2>
-  }
-}
-
-<mat-dialog-content>
-
-
-  @if (!isLoading) {
-    <form [formGroup]="formGroup" class="override_content_flex">
-
-      <div class="col-flex-12">
-        <mat-form-field appearance="outline" class="w-100">
-          <mat-label>Nombre del equipo</mat-label>
-          <input formControlName="name" matInput placeholder="Ingrese el nombre del equipo de trabajo" maxlength="100" [readonly]="enable == '1' ? false : true">
-          @if (formGroup.controls['name'].hasError('required')) {
-            <mat-error title="El campo Nombre del Equipo es obligatorio">El campo <b>Nombre del Equipo</b> es obligatorio</mat-error>
-          }
-        </mat-form-field>
+<h1 mat-dialog-title class="prevent-select">{{ title }}</h1>
+<div mat-dialog-content class="prevent-select">
+  <div class="content-container animated fadeIn">
+    <div class="is-loading animated fadeIn fast" *ngIf="isLoading">
+      <mat-spinner align="center"></mat-spinner>
+      <h3>Cargando datos ...</h3>
+    </div>
+    <div class="has-error animated fadeIn" *ngIf="!isLoading && hasError">
+      <mat-icon class="red_primary_font">error</mat-icon>
+      <h2>{{ errorStr }}</h2>
+    </div>
+    <div class="execution-info-container animated fadeIn" *ngIf="!isLoading && !hasError" [formGroup]="formGroup">
+      <mat-form-field appearance="outline" class="w-100 mt-8">
+        <mat-label>Nombre del equipo</mat-label>
+        <input formControlName="name" matInput placeholder="Ingrese el nombre del equipo de trabajo" 
+        (input)="formGroup.controls['name'].markAsTouched()">
+        @if (formGroup.controls['name'].hasError('maxlength')) {
+          <mat-error>La longitud máxima del campo <b>Nombre del Equipo</b> es de 75 caracteres</mat-error>
+        }
+        @if (formGroup.controls['name'].hasError('required')) {
+          <mat-error>El campo <b>Nombre del Equipo</b> es obligatorio</mat-error>
+        }
+      </mat-form-field>
+      <mat-form-field appearance="outline" class="w-100 mt-8">
+        <mat-label>Especialidades y/u oficios</mat-label>
+        <mat-select formControlName="speciality" multiple>
+          <mat-option *ngFor="let specialty of specialties" [value]="specialty.CODIGO_ESPECIALIDAD">
+            {{ specialty.NOMBRE_ESPECIALIDAD }}
+          </mat-option>
+        </mat-select>
+        @if (formGroup.controls['speciality'].hasError('required')) {
+          <mat-error>El campo <b>Especialidad</b> es obligatorio</mat-error>
+        }
+      </mat-form-field>
+      <div *ngIf="action == 'DET'" class="w-100">
+        <h3 style="font-weight: 500;">Miembros del equipo:</h3>
+        <ul>
+          <li *ngFor="let member of members;">{{ member.NAME }}</li>
+        </ul>
       </div>
-      <div class="col-flex-12">
-        <mat-form-field appearance="outline" class="w-100">
-          <mat-label>Especialidad</mat-label>
-          <input formControlName="speciality" matInput placeholder="Ingrese el nombre de la especialidad" maxlength="100" [readonly]="enable == '1' ? false : true">
-          @if (formGroup.controls['speciality'].hasError('required')) {
-            <mat-error title="El campo Especialidad es obligatorio">El campo <b>Especialidad</b> es obligatorio</mat-error>
-          }
-        </mat-form-field>
-      </div>
-      
-      @if (enable === '0') {
-        <div>
-          <b class="black_font" style="letter-spacing: .03em;">Miembros del equipo</b>
-          <mat-list>
-            @for (member of members; track member) {
-              <mat-list-item>
-                <span matListItemTitle>- {{ member.NAME }} ({{ member.IDEMPLEADO }}) ({{ member.IDUSUARIO }})</span>
-              </mat-list-item>
-            } @empty {
-              <span>No hay miembros actualmente.</span>
-            }
-          </mat-list>
-        </div>
-      }
-    </form>
-  } @else {
-    <app-loading-card [isLoading]="isLoading" txtLoading="Cargando la información del formulario" />
-  }
-
-
-</mat-dialog-content>
-<mat-dialog-actions align="end">
+    </div>
+  </div>
+</div>
+<div mat-dialog-actions align="end">
   <button mat-button mat-dialog-close>Cerrar</button>
-  <button 
-    *ngIf="dialogData.action != 'DET'" 
-    mat-button 
-    class="override_no_shadow"
-    (click)="this.alert(dialogData.action)" 
-    [disabled]="formGroup.invalid">
-    {{ dialogData.action == "REG" ? "Registrar" : "Guardar" }}
+  <button *ngIf="action != 'DET'" mat-button (click)="alert(action)" [disabled]="formGroup.invalid">
+    {{ action == "REG" ? "Registrar" : "Guardar" }}
   </button>
-</mat-dialog-actions>
+</div>

+ 160 - 42
sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team-form/work-team-form.component.ts

@@ -6,7 +6,9 @@ import { lastValueFrom } from 'rxjs';
 import { AlertComponent } from 'src/app/components/resources/dialogs/alert/alert.component';
 import { ResponseDataWorkteam, DialogModule, Workteam } from 'src/app/interfaces/personal-managment/workteam.interface';
 import { ResponseData } from 'src/app/interfaces/response-data';
+import { SpecialtiesListItem, SpecialtiesListResponse } from 'src/app/interfaces/specialties.interface';
 import { EncService } from 'src/app/services/enc/enc.service';
+import { InterventionService } from 'src/app/services/personal-management/intervention.service';
 import { WorkTeamService } from 'src/app/services/personal-management/work-team.service';
 import { ResourcesService } from 'src/app/services/resources/resources.service';
 
@@ -16,44 +18,147 @@ import { ResourcesService } from 'src/app/services/resources/resources.service';
   styleUrls: ['./work-team-form.component.css']
 })
 export class WorkTeamFormComponent implements OnInit {
+  action: string;
+  title: string;
+  isLoading: boolean;
+  hasError: boolean;
+  errorStr: string;
+  specialties: SpecialtiesListItem[];
+  workTeam: any | null;
 
-
-  public isLoading: boolean;
   public formGroup: FormGroup;
   public idWorkteam: string;
   public enable: string;
   public members: any[];
 
   constructor(
+    @Inject(MAT_DIALOG_DATA) private _dialogData: DialogModule,
     private _resourcesService: ResourcesService,
     private _dialog: MatDialog,
     private _workteamService: WorkTeamService,
-    private dialogRef: MatDialogRef<WorkTeamFormComponent>,
+    private _dialogRef: MatDialogRef<WorkTeamFormComponent>,
     private _encService: EncService,
-    @Inject(MAT_DIALOG_DATA) public dialogData: DialogModule
+    private _interventionService: InterventionService,
   ) {
-    this.isLoading = false;
+    this.action = "";
+    this.title = "";
+    this.isLoading = true;
+    this.hasError = false;
+    this.errorStr = '';
+    this.specialties = [];
+    this.workTeam = null;
+
     this.idWorkteam = "";
     this.enable = "";
     this.members = [];
     this.formGroup = this.createFormGroup();
   }
 
-  async ngOnInit() {
-    this.isLoading = true;
+  ngOnInit() {
+    this.action = this._dialogData.action;
+    if(this.action == 'REG'){
+      this.title = "Registrar equipo de trabajo";
+      this.getSpecialties();
+    }else{
+      this.title = this.action == 'UPD' ? "Modificación equipo de trabajo" : "Detalles equipo de trabajo";
+      this.init();
+    }
+    
+    /*this.isLoading = true;
     if (this.dialogData.action != "REG") {
       this.idWorkteam = this.dialogData.dataElement.WORKTEAM_ID;
       await this._getData();
       await this._getMembers();
     }
     this.enable = this.dialogData.action == "DET" ? "0" : "1";
-    this.isLoading = false;
+    this.isLoading = false;*/
+  }
+
+  async init(){
+    try{
+      this.workTeam = this._dialogData.dataElement;
+      this.idWorkteam = this.workTeam.WORKTEAM_ID;
+      this.formGroup.controls['name'].setValue(this.workTeam.NAME);
+
+      if(this.action == 'DET'){
+        this._getMembers();
+      }else{
+        this.getSpecialties();
+      }
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
+  }
+
+  async getSpecialties(){
+    try{
+      let idUser = localStorage.getItem('idusuario')!;
+      let specialties: SpecialtiesListResponse = await lastValueFrom(this._interventionService.getSpecialties(idUser, 1));
+
+      this.hasError = specialties.error;
+      this.errorStr = specialties.msg;
+
+      if(!this.hasError){
+        let selectedSpecialties: string[] = [];
+        if(this.workTeam != null){
+          for(const specialtyCode of this.workTeam.SPECIALTY_ARR){
+            let codeDec = await this._encService.decrypt(specialtyCode);
+            let codeArr = codeDec.split(' - ');
+            selectedSpecialties.push(codeArr[0]);
+          }
+        }
+
+        let specialtiesArr: SpecialtiesListItem[] = [];
+        for(const specialty of specialties.response){
+          let codeDec = await this._encService.decrypt(specialty.CODIGO_ESPECIALIDAD);
+          specialty.NOMBRE_ESPECIALIDAD = `${codeDec} - ${specialty.NOMBRE_ESPECIALIDAD}`;
+
+          if(specialty.ESTADO == 'Activo'){
+            specialtiesArr.push(specialty);
+            if(selectedSpecialties.includes(codeDec)){
+              let specialtiesVal = this.formGroup.controls['speciality'].value;
+              specialtiesVal.push(specialty.CODIGO_ESPECIALIDAD);
+
+              this.formGroup.controls['speciality'].setValue(specialtiesVal);
+            }
+          }
+        }
+
+        this.specialties = specialtiesArr;
+        if(this.action == 'UPD' || this.action == 'REG'){
+          this.formGroup.controls['name'].enable();
+          this.formGroup.controls['speciality'].enable();
+        }
+      }
+
+      this.isLoading = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
   }
 
   private createFormGroup() {
     return new FormGroup({
-      name: new FormControl('', Validators.required),
-      speciality: new FormControl('', Validators.required),
+      name: new FormControl({value: '', disabled: true}, [Validators.required, Validators.maxLength(75)]),
+      speciality: new FormControl({value: [], disabled: true}, Validators.required),
     })
   }
 
@@ -92,8 +197,8 @@ export class WorkTeamFormComponent implements OnInit {
     await lastValueFrom(this._workteamService.storeWorkteam( WORKTEAM )).then(
       (responseData: ResponseData) => {
         if (!responseData.error) {
-          this._resourcesService.openSnackBar("Creación Exitosa!");
-          this.dialogRef.close(true);
+          this._resourcesService.openSnackBar("¡Creación Exitosa!");
+          this._dialogRef.close(true);
         } else {
           this._resourcesService.openSnackBar(`${responseData.msg}`);
         }
@@ -108,7 +213,7 @@ export class WorkTeamFormComponent implements OnInit {
       (responseData: ResponseData) => {
         if (!responseData.error) {
           this._resourcesService.openSnackBar("Actualización Exitosa!");
-          this.dialogRef.close(true);
+          this._dialogRef.close(true);
         } else {
           this._resourcesService.openSnackBar(`${responseData.msg}`);
         }
@@ -117,43 +222,56 @@ export class WorkTeamFormComponent implements OnInit {
   }
 
   private async workteamObject(idWorkteamEnc: string | undefined): Promise<Workteam> {
+    let formValue = this.formGroup.getRawValue();
+    
     return {
       WORKTEAM_ID: idWorkteamEnc,
-      NAME: this.formGroup.controls['name'].value == null ? null : this.formGroup.controls['name'].value.trim(),
-      SPECIALITY: this.formGroup.controls['speciality'].value == null ? null : this.formGroup.controls['speciality'].value.trim(),
+      NAME: formValue.name,
+      SPECIALITY: JSON.stringify(formValue.speciality),
       id_user: localStorage.getItem('idusuario')!,
       linea: 1,
     }
   }
 
-  private async _getData() {
-    let idWorkteamEnc = await this._encService.encrypt(`${this.idWorkteam}`);
-    const USER = this._resourcesService.getUser();
-    const LINE: number = this._resourcesService.getLineNumber();
-    await lastValueFrom(this._workteamService.getWorkteamById( idWorkteamEnc, USER, LINE )).then(
-      (responseData: ResponseDataWorkteam) => {
-        if (!responseData.error) {
-          this.formGroup.controls['name'].setValue(responseData.response.NAME);
-          this.formGroup.controls['speciality'].setValue(responseData.response.SPECIALITY);
-        } else {
-          this._resourcesService.openSnackBar(`${responseData.msg}`);
-        }
-      }, (httpErrorResponse: HttpErrorResponse) => this._resourcesService.checkErrors(httpErrorResponse)
-    );
-  }
-
   private async _getMembers(){
-    let idWorkteamEnc = await this._encService.encrypt(`${this.idWorkteam}`);
-    const USER = this._resourcesService.getUser();
-    const LINE: number = this._resourcesService.getLineNumber();
-    await lastValueFrom(this._workteamService.getMembersOfWorkteamById( idWorkteamEnc, USER, LINE )).then(
-      (responseData: any) => {
-        if (!responseData.error) {
-          this.members = responseData.response;          
-        } else {
-          this._resourcesService.openSnackBar(`${responseData.msg}`);
+    try{
+      let idUser = localStorage.getItem('idusuario')!;
+      let idWorkteamEnc = await this._encService.encrypt(this.idWorkteam);
+      let members = await lastValueFrom(this._workteamService.getMembersOfWorkteamById(
+        idWorkteamEnc,
+        idUser,
+        1
+      ));
+
+      this.hasError = members.error;
+      this.errorStr = members.msg;
+
+      if(this.hasError){
+        this.isLoading = false;
+      }else{
+        let membersArr: any[] = [];
+        for(const member of members.response){
+          let idEmp = await this._encService.decrypt(member.IDEMPLEADO);
+          let idUsr = await this._encService.decrypt(member.IDUSUARIO);
+
+          member.NAME = `${member.NAME} (${idEmp}) (${idUsr})`,
+          membersArr.push(member);
         }
-      }, (httpErrorResponse: HttpErrorResponse) => this._resourcesService.checkErrors(httpErrorResponse)
-    );
+
+        this.members = membersArr;
+        this.getSpecialties();
+      }
+    }catch(error: any){
+      if(error.error){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
   }
 }

+ 78 - 90
sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team.component.html

@@ -1,101 +1,89 @@
 <main class="main-container animated fadeIn">
+  <app-btn-navigate navigate="/sam/GPRS" nameButton="Gestión de personal, recursos y subcontratistas"/>
 
-    <app-btn-navigate navigate="/sam/GPRS" nameButton="Gestión de personal, recursos y subcontratistas"/>
+  <mat-card class="override-card override-elevation-z8">
+    <section class="override-section">
+      <nav class="override-nav">
+        <mat-card-title class="mat-card-title centre">Lista de equipos de trabajo</mat-card-title>
+        <div class="override-actions">
+          <app-search-card [dataSource]="dataSource" [disabled]="isLoading || isLoadingForm" (dataValue)="dataSource = $event"/>
+          <div class="override-buttons">
+            <app-btn-resize class="ml-8" (click)="openDialog('REG')" [disabled]="isLoading || isLoadingForm" backgroundColor="primary"
+            textColor="white_font"  nameButton="Nuevo" icon="add"/>
+            <button mat-mini-fab matTooltip="Actualizar datos" class="cyan_dark_background white_font override_no_shadow ml-8" (click)="getWorkteams()">
+              <mat-icon>refresh</mat-icon>
+            </button>
+          </div>
+        </div>
+      </nav>
 
-    <mat-card class="override-card override-elevation-z8">
-        <section class="override-section">
-            <nav class="override-nav">
-                <mat-card-title class="mat-card-title centre">Lista de equipos de trabajo</mat-card-title>
-                <div class="override-actions">
-                    <app-search-card
-                        [dataSource]="dataSource"
-                        [disabled]="isLoading || isLoadingForm"
-                        (dataValue)="dataSource = $event"
-                    />
-                    <div class="override-buttons">
+      <div class="is-loading animated fadeIn fast" *ngIf="isLoading">
+        <mat-spinner align="center"></mat-spinner>
+        <h3>Cargando datos ...</h3>
+      </div>
 
-                        <app-btn-resize
-                            class="ml-8"
-                            (click)="openDialog('REG')"
-                            [disabled]="isLoading || isLoadingForm"
-                            backgroundColor="primary"
-                            textColor="white_font"
-                            nameButton="Nuevo"
-                            icon="add" />
+      <div class="has-error animated fadeIn fast" *ngIf="!isLoading && hasError">
+        <mat-icon  class="red_primary_font">error</mat-icon>
+        <h3>{{ errorStr }}</h3>
+      </div>
 
-                        <button 
-                            mat-mini-fab 
-                            matTooltip="Actualizar datos" 
-                            class="cyan_dark_background white_font override_no_shadow ml-8"
-                            (click)="getWorkteams()">
-                            <mat-icon>refresh</mat-icon>
-                        </button>
-                    </div>
-                </div>
-            </nav>
+      <div class="override-table" [ngClass]="{ hidden: isLoading || hasError }">
+        <table mat-table [dataSource]="dataSource" matSort class="animated fadeIn" 
+        [style.display]="!isLoading && !hasError ? 'revert' : 'none'">
+          <ng-container matColumnDef="WORKTEAM_ID">
+            <th mat-header-cell *matHeaderCellDef mat-sort-header>No. Equipo</th>
+            <td mat-cell *matCellDef="let element">{{ element.WORKTEAM_ID }}</td>
+          </ng-container>
 
-            <app-loading-card [isLoading]="isLoading" txtLoading="Cargando información de los equipos de trabajo" />
+          <ng-container matColumnDef="NAME">
+            <th mat-header-cell *matHeaderCellDef mat-sort-header>Nombre</th>
+            <td mat-cell *matCellDef="let element">{{ element.NAME }}</td>
+          </ng-container>
 
-            <div class="override-table">
-                <table mat-table [dataSource]="dataSource" matSort [style.display]="isLoading ? 'none' : 'revert'" class="animated fadeIn">
-                    <ng-container matColumnDef="WORKTEAM_ID">
-                        <th mat-header-cell *matHeaderCellDef mat-sort-header>No. Equipo</th>
-                        <td mat-cell *matCellDef="let element">{{ element.WORKTEAM_ID }}</td>
-                    </ng-container>
-                    <ng-container matColumnDef="NAME">
-                        <th mat-header-cell *matHeaderCellDef mat-sort-header>Nombre</th>
-                        <td mat-cell *matCellDef="let element">{{ element.NAME }}</td>
-                    </ng-container>
-                    <ng-container matColumnDef="SPECIALITY">
-                        <th mat-header-cell *matHeaderCellDef mat-sort-header>Especialidad</th>
-                        <td mat-cell *matCellDef="let element">{{ element.SPECIALITY }}</td>
-                    </ng-container>
-                    <ng-container matColumnDef="STATUS">
-                        <th mat-header-cell *matHeaderCellDef mat-sort-header>Estado</th>
-                        <td mat-cell *matCellDef="let element">
-                            <mat-chip [class]="resourcesService.setChipList(element.STATUS)" selected> {{ element.STATUS }} </mat-chip>
-                        </td>
-                    </ng-container>
+          <ng-container matColumnDef="SPECIALITY">
+            <th mat-header-cell *matHeaderCellDef mat-sort-header>Especialidades y/u oficios</th>
+            <td mat-cell *matCellDef="let element">{{ element.SPECIALITY }}</td>
+          </ng-container>
 
-                    <ng-container matColumnDef="ACCIONES">
-                        <th mat-header-cell *matHeaderCellDef>Acciones</th>
-                        <td mat-cell *matCellDef="let element">
-                            <button 
-                                mat-mini-fab 
-                                color="primary" 
-                                [disabled]="isLoadingForm || element.STATUS === 'Eliminado'" 
-                                [matMenuTriggerFor]="menu"
-                                #menuTrigger 
-                                class="override_no_shadow">
-                                <mat-icon>more_vert</mat-icon>
-                            </button>
-                            <mat-menu #menu="matMenu">
-                                <button mat-menu-item (click)="openDialog('DET', element)">
-                                    <mat-icon>info</mat-icon> Detalles
-                                </button>
-                                <button mat-menu-item (click)="openDialog('UPD', element)">
-                                    <mat-icon>edit</mat-icon> Editar
-                                </button>
-                                <button mat-menu-item (click)="openDialog('DEL', element)">
-                                    <mat-icon>delete</mat-icon> Eliminar
-                                </button>
-                            </mat-menu>
-                        </td>
-                    </ng-container>
+          <ng-container matColumnDef="STATUS">
+            <th mat-header-cell *matHeaderCellDef mat-sort-header>Estado</th>
+            <td mat-cell *matCellDef="let element">
+              <mat-chip [class]="resourcesService.setChipList(element.STATUS)" selected> {{ element.STATUS }} </mat-chip>
+            </td>
+          </ng-container>
 
-                    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
-                    <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
-                    <tr class="mat-row" *matNoDataRow>
-                        <td class="mat-cell p-20 align-center" colspan="12">
-                            <object data="assets/img/empty_data.svg" width="300"></object>
-                            <h2>Sin datos</h2>
-                        </td>
-                    </tr>
-                </table>
-            </div>
-        </section>
-        <mat-paginator [pageSizeOptions]="[10, 50, 100]"
-            class="override-paginator"></mat-paginator>
-    </mat-card>
+          <ng-container matColumnDef="ACCIONES">
+            <th mat-header-cell *matHeaderCellDef>Acciones</th>
+            <td mat-cell *matCellDef="let element">
+              <button mat-mini-fab color="primary" [disabled]="isLoadingForm || element.STATUS === 'Eliminado'" [matMenuTriggerFor]="menu"
+              #menuTrigger class="override_no_shadow">
+                <mat-icon>more_vert</mat-icon>
+              </button>
+              <mat-menu #menu="matMenu">
+                <button mat-menu-item (click)="openDialog('DET', element)">
+                  <mat-icon>info</mat-icon> Detalles
+                </button>
+                <button mat-menu-item (click)="openDialog('UPD', element)">
+                  <mat-icon>edit</mat-icon> Editar
+                </button>
+                <button mat-menu-item (click)="openDialog('DEL', element)">
+                  <mat-icon>delete</mat-icon> Eliminar
+                </button>
+              </mat-menu>
+            </td>
+          </ng-container>
 
+          <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+          <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
+          <tr class="mat-row" *matNoDataRow>
+            <td class="mat-cell p-20 align-center" colspan="12">
+              <object data="assets/img/empty_data.svg" width="300"></object>
+              <h2>Sin datos</h2>
+            </td>
+          </tr>
+        </table>
+      </div>
+    </section>
+    <mat-paginator [pageSizeOptions]="[10, 50, 100]" class="override-paginator"></mat-paginator>
+  </mat-card>
 </main>

+ 56 - 17
sistema-mantenimiento-front/src/app/components/personal-management/work-team/work-team.component.ts

@@ -20,10 +20,11 @@ import { ResponseData } from 'src/app/interfaces/response-data';
   styleUrls: ['./work-team.component.css']
 })
 export class WorkTeamComponent implements OnInit {
-
-  public isLoading: boolean;
+  isLoading: boolean;
+  hasError: boolean;
+  errorStr: string;
+  
   public isLoadingForm: boolean;
-
   public dataSource: MatTableDataSource<GetWorkteams>;
   public displayedColumns: Array<string>;
 
@@ -36,8 +37,11 @@ export class WorkTeamComponent implements OnInit {
     private _dialog: MatDialog,
     private _encService: EncService
   ) {
-    this.dataSource = new MatTableDataSource<GetWorkteams>();
     this.isLoading = true;
+    this.hasError = false;
+    this.errorStr = '';
+
+    this.dataSource = new MatTableDataSource<GetWorkteams>();
     this.isLoadingForm = false;
     this.displayedColumns = [ 'WORKTEAM_ID', 'NAME', 'SPECIALITY', 'STATUS', 'ACCIONES' ];
   }
@@ -52,19 +56,54 @@ export class WorkTeamComponent implements OnInit {
   }
 
   public async getWorkteams() {
-    this.isLoading = true;
-    const USER = this.resourcesService.getUser();
-    const LINE: number = this.resourcesService.getLineNumber();
-    await lastValueFrom(this._workteamService.getConsultOfWorkteams(USER, LINE)).then(
-      (responseData: ResponseDataGetWorkteams) => {
-        if (!responseData.error) {
-          this.dataSource.data = responseData.response;
-        } else {
-          this.resourcesService.openSnackBar(`${responseData.msg}`)
+    try{
+      this.isLoading = true;
+      this.hasError = false;
+      this.errorStr = '';
+
+      let idUser = localStorage.getItem('idusuario')!;
+      let workTeams: ResponseDataGetWorkteams = await lastValueFrom(this._workteamService.getConsultOfWorkteams(idUser, 1));
+
+      this.hasError = workTeams.error;
+      this.errorStr = workTeams.msg;
+
+      if(!this.hasError){
+        let workTeamsArr: GetWorkteams[] = [];
+        for(const team of workTeams.response){
+          team.WORKTEAM_ID = await this._encService.decrypt(team.WORKTEAM_ID);
+          
+          let specialtiesArr: string[] = JSON.parse(team.SPECIALITY);
+          let specialtiesStr = "";
+          for(const specialtyCode of specialtiesArr){
+            let specialtyDec = await this._encService.decrypt(specialtyCode);
+            specialtiesStr += `${specialtyDec}, `;
+          }
+
+          specialtiesStr = specialtiesStr.substring(0, specialtiesStr.length - 2);
+          team.SPECIALITY = specialtiesStr;
+          team.SPECIALTY_ARR = specialtiesArr;
+          
+          workTeamsArr.push(team);
         }
-      }, (httpErrorResponse: HttpErrorResponse) => this.resourcesService.checkErrors(httpErrorResponse)
-    );
-    this.isLoading = false;
+
+        this.dataSource = new MatTableDataSource(workTeamsArr);
+        this.dataSource.paginator = this.paginator;
+        this.dataSource.sort = this.sort;
+      }
+
+      this.isLoading = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        this.errorStr = error.error.msg;
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
   }
 
   
@@ -100,7 +139,7 @@ export class WorkTeamComponent implements OnInit {
     }
   }
 
-  private async deleteWorkteam(workteamId: number) {
+  private async deleteWorkteam(workteamId: string) {
     let idWorkteamEnc = await this._encService.encrypt(`${workteamId}`);
     const USER: string = this.resourcesService.getUser();
     const LINE: number = this.resourcesService.getLineNumber();

+ 85 - 85
sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/active-orders.component.html

@@ -24,22 +24,100 @@
         </button>
       </div>
     </div>
-    <mat-button-toggle-group value="ORTTRA" (valueChange)="screenChange($event)">
-      <mat-button-toggle value="ORTTRA">
-        <span *ngIf="!floatToolbar">Órdenes de trabajo activas</span>
-        <mat-icon *ngIf="floatToolbar" matTooltip="Órdenes de trabajo activas">receipt_long</mat-icon>
-      </mat-button-toggle>
+    <mat-button-toggle-group value="CALEJE" (valueChange)="screenChange($event)">
       <mat-button-toggle value="CALEJE">
         <span *ngIf="!floatToolbar">Calendario de ejecuciones</span>
         <mat-icon *ngIf="floatToolbar" matTooltip="Calendario de ejecuciones">calendar_month</mat-icon>
       </mat-button-toggle>
+      <mat-button-toggle value="ORTTRA">
+        <span *ngIf="!floatToolbar">Órdenes de trabajo activas</span>
+        <mat-icon *ngIf="floatToolbar" matTooltip="Órdenes de trabajo activas">receipt_long</mat-icon>
+      </mat-button-toggle>
     </mat-button-toggle-group>
   </div>
+  <div class="animated fadeIn" [ngClass]="{ hidden: displayedScreen != 'CALEJE', executions_calendar_flex_container: !floatToolbar, 
+  executions_calendar_relative_container: floatToolbar }">
+    <div class="calendar-toolpanel" [ngClass]="{ calendar_toolpanel_float: floatToolbar, calendar_toolpanel_float_closed: !showToolbar, 
+    calendar_toolpanel_float_opening: showingToolbar, calendar_toolpanel_float_opened: showToolbar, calendar_toolpanel_float_hidding: hiddingToolbar }">
+      <mat-calendar [(selected)]="selected" (selectedChange)="changeDisplayedMonth('calendar')"></mat-calendar>
+      <h3>Tipo de activador</h3>
+      <section class="checkbox-group-section">
+        <span>
+          <mat-checkbox class="checkbox-margin" [checked]="allActivatorsChecked" color="primary" [indeterminate]="someActivatorsChecked()" 
+          (change)="setAllActivators($event.checked)">
+            Todos
+          </mat-checkbox>
+        </span>
+        <span>
+          <ul>
+            <li *ngFor="let activator of activators.subactivators">
+              <mat-checkbox [(ngModel)]="activator.checked" (ngModelChange)="updateAllActivatorsChecked()" color="secondary">
+                {{ activator.name }}
+              </mat-checkbox>
+            </li>
+          </ul>
+        </span>
+      </section>
+      <h3>Estado de la ejecución</h3>
+      <section class="checkbox-group-section">
+        <span>
+          <mat-checkbox class="checkbox-margin" [checked]="allStatesChecked" color="primary" [indeterminate]="someStatesChecked()" 
+          (change)="setAllStates($event.checked)">
+            Todos
+          </mat-checkbox>
+        </span>
+        <span>
+          <ul>
+            <li *ngFor="let state of states.subactivators">
+              <mat-checkbox [(ngModel)]="state.checked" (ngModelChange)="updateAllStatesChecked()" [id]="'c_box_' + state.value" 
+              (click)="updateSyncColor(state.value)">
+                {{ state.name }}
+              </mat-checkbox>
+            </li>
+          </ul>
+        </span>
+      </section>
+    </div>
+    <div class="calendar-content-container animated fadeIn" *ngIf="!gettingEvents">
+      <div class="calendar-day-names">
+        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Domingo</h3>
+        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Lunes</h3>
+        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Martes</h3>
+        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Miércoles</h3>
+        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Jueves</h3>
+        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Viernes</h3>
+        <h3 class="calendar_cell_border_bottom">Sábado</h3>
+      </div>
+      <div class="calendar-days-table">
+        <div class="calendar-days-row" *ngFor="let row of monthDays;let i = index" [ngClass]="{ calendar_cell_border_bottom: i < monthDays.length - 1 }">
+          <div class="calendar-day-cell" *ngFor="let day of monthDays[i];let j = index" [ngClass]="{ calendar_cell_border_right: j < monthDays[i].length - 1, 
+          selected_day: isSelected(i, j)}">
+            <div class="calendar-day-label">
+              <div class="month_day" [ngClass]="{ gray_light_font: !day.isActualMonth, actual_day: day.isActualDay }">{{ day.day }}</div>
+            </div>
+            <div class="calendar-day-events-container">
+              <div *ngFor="let event of getDayEvents(i, j)">
+                <div class="calendar-event" [style.background]="event.EVENTCOLOR" (click)="openExecution(event.IDORDEN, i, j)" 
+                *ngIf="event.SEEMORE == null || event.SEEMORE == undefined">
+                  <div class="mr-4"><div [ngClass]="{ amber_primary_background: event.REGEST == 'Programada', red_primary_background: event.REGEST == 'Cancelacion', 
+                  blue_primary_background: event.REGEST == 'Ejecucion', green_primary_background: event.REGEST == 'Finalizado' }"></div></div>Orden #{{ event.IDORDEN }}
+                </div>
+                <div *ngIf="event.SEEMORE == true" class="see-all-events" (click)="openAllEvents(i, j)">
+                  Ver mas...
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <mat-progress-bar mode="indeterminate" *ngIf="gettingEvents" class="animated fadeIn" style="width: calc(100% - 320px);"></mat-progress-bar>
+  </div>
   <div class="active-orders-table-container animated fadeIn" [ngClass]="{ hidden: displayedScreen != 'ORTTRA' }">
     <mat-card class="override-card override-elevation-z8">
       <section class="override-section">
         <nav class="override-nav">
-          <mat-card-title class="mat-card-title centre">Órdenes de trabajo activas</mat-card-title>
+          <mat-card-title class="mat-card-title centre">Seguimiento de ejecuciones</mat-card-title>
           <div class="override-actions">
             <mat-form-field appearance="outline" class="w-300p mr-8 ml-16">
               <mat-label>Buscador</mat-label>
@@ -120,7 +198,7 @@
             <ng-container matColumnDef="ACCIONES">
               <th mat-header-cell *matHeaderCellDef>Acciones</th>
               <td mat-cell *matCellDef="let row">
-                <button mat-mini-fab color="primary" class="no_shadow" [matTooltip]="actionTooltip" (click)="activateWorkOrder(row.IDORDEN, false, null)">
+                <button mat-mini-fab color="primary" class="no_shadow" [matTooltip]="actionTooltip">
                   <mat-icon>{{ actionIcon }}</mat-icon>
                 </button>
               </td>
@@ -141,82 +219,4 @@
       <mat-paginator [pageSizeOptions]="[10, 50, 100]" class="override-paginator"></mat-paginator>
     </mat-card>
   </div>
-  <div class="animated fadeIn" [ngClass]="{ hidden: displayedScreen != 'CALEJE', executions_calendar_flex_container: !floatToolbar, 
-  executions_calendar_relative_container: floatToolbar }">
-    <div class="calendar-toolpanel" [ngClass]="{ calendar_toolpanel_float: floatToolbar, calendar_toolpanel_float_closed: !showToolbar, 
-    calendar_toolpanel_float_opening: showingToolbar, calendar_toolpanel_float_opened: showToolbar, calendar_toolpanel_float_hidding: hiddingToolbar }">
-      <mat-calendar [(selected)]="selected" (selectedChange)="changeDisplayedMonth('calendar')"></mat-calendar>
-      <h3>Tipo de activador</h3>
-      <section class="checkbox-group-section">
-        <span>
-          <mat-checkbox class="checkbox-margin" [checked]="allActivatorsChecked" color="primary" [indeterminate]="someActivatorsChecked()" 
-          (change)="setAllActivators($event.checked)">
-            Todos
-          </mat-checkbox>
-        </span>
-        <span>
-          <ul>
-            <li *ngFor="let activator of activators.subactivators">
-              <mat-checkbox [(ngModel)]="activator.checked" (ngModelChange)="updateAllActivatorsChecked()" color="secondary">
-                {{ activator.name }}
-              </mat-checkbox>
-            </li>
-          </ul>
-        </span>
-      </section>
-      <h3>Estado de la ejecución</h3>
-      <section class="checkbox-group-section">
-        <span>
-          <mat-checkbox class="checkbox-margin" [checked]="allStatesChecked" color="primary" [indeterminate]="someStatesChecked()" 
-          (change)="setAllStates($event.checked)">
-            Todos
-          </mat-checkbox>
-        </span>
-        <span>
-          <ul>
-            <li *ngFor="let state of states.subactivators">
-              <mat-checkbox [(ngModel)]="state.checked" (ngModelChange)="updateAllStatesChecked()" [id]="'c_box_' + state.value" 
-              (click)="updateSyncColor(state.value)">
-                {{ state.name }}
-              </mat-checkbox>
-            </li>
-          </ul>
-        </span>
-      </section>
-    </div>
-    <div class="calendar-content-container animated fadeIn" *ngIf="!gettingEvents">
-      <div class="calendar-day-names">
-        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Domingo</h3>
-        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Lunes</h3>
-        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Martes</h3>
-        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Miércoles</h3>
-        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Jueves</h3>
-        <h3 class="calendar_cell_border_right calendar_cell_border_bottom">Viernes</h3>
-        <h3 class="calendar_cell_border_bottom">Sábado</h3>
-      </div>
-      <div class="calendar-days-table">
-        <div class="calendar-days-row" *ngFor="let row of monthDays;let i = index" [ngClass]="{ calendar_cell_border_bottom: i < monthDays.length - 1 }">
-          <div class="calendar-day-cell" *ngFor="let day of monthDays[i];let j = index" [ngClass]="{ calendar_cell_border_right: j < monthDays[i].length - 1, 
-          selected_day: isSelected(i, j)}">
-            <div class="calendar-day-label">
-              <div class="month_day" [ngClass]="{ gray_light_font: !day.isActualMonth, actual_day: day.isActualDay }">{{ day.day }}</div>
-            </div>
-            <div class="calendar-day-events-container">
-              <div *ngFor="let event of getDayEvents(i, j)">
-                <div class="calendar-event" [style.background]="event.EVENTCOLOR" (click)="openExecution(event.IDORDEN, i, j)" 
-                *ngIf="event.SEEMORE == null || event.SEEMORE == undefined">
-                  <div class="mr-4"><div [ngClass]="{ amber_primary_background: event.REGEST == 'Programada', red_primary_background: event.REGEST == 'Cancelacion', 
-                  blue_primary_background: event.REGEST == 'Ejecucion', green_primary_background: event.REGEST == 'Finalizado' }"></div></div>Orden #{{ event.IDORDEN }}
-                </div>
-                <div *ngIf="event.SEEMORE == true" class="see-all-events" (click)="openAllEvents(i, j)">
-                  Ver mas...
-                </div>
-              </div>
-            </div>
-          </div>
-        </div>
-      </div>
-    </div>
-    <mat-progress-bar mode="indeterminate" *ngIf="gettingEvents" class="animated fadeIn" style="width: calc(100% - 320px);"></mat-progress-bar>
-  </div>
 </div>

+ 64 - 10
sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/active-orders.component.ts

@@ -17,6 +17,7 @@ import { NewVisitComponent } from './new-visit/new-visit.component';
 import { Router } from '@angular/router';
 import { PriorityInterface } from '../../system-admin/system-params/system-params.component';
 import { SystemAdminService } from 'src/app/services/system-admin.service';
+import { OrderExecutionConfigComponent } from './order-execution-config/order-execution-config.component';
 
 interface ActivatorType{
   name: string;
@@ -116,7 +117,7 @@ export class ActiveOrdersComponent implements OnInit {
     this.errorStr = '';
     this.actionTooltip = '';
     this.actionIcon = '';
-    this.displayedScreen = "ORTTRA";
+    this.displayedScreen = "CALEJE";
     this.selected = new Date();
     this.displayedMonth = 0;
     this.displayedYear = 0;
@@ -178,7 +179,13 @@ export class ActiveOrdersComponent implements OnInit {
       }else if(error.error.msg == undefined){
         this.errorStr = 'Ocurrió un error inesperado.';
       }else{
-        this.errorStr = error.error.msg;
+        let msgArr = error.error.msg.split(':');
+        if(msgArr[0] == 'ERR_GLB_USU003'){
+          this.getOrderPriorities();
+          return;
+        }else{
+          this.errorStr = error.error.msg;
+        }
       }
 
       this.hasError = true;
@@ -232,7 +239,13 @@ export class ActiveOrdersComponent implements OnInit {
       }else if(error.error.msg == undefined){
         this.errorStr = 'Ocurrió un error inesperado.';
       }else{
-        this.errorStr = error.error.msg;
+        let msgArr = error.error.msg.split(':');
+        if(msgArr[0] == 'ERR_GLB_USU003'){
+          this.getActiveWorkOrders();
+          return;
+        }else{
+          this.errorStr = error.error.msg;
+        }
       }
 
       this.hasError = true;
@@ -482,7 +495,22 @@ export class ActiveOrdersComponent implements OnInit {
     });
   }
 
-  async activateWorkOrder(idOrder: number, isCalendar: boolean, date: string | null){
+  openOrderExecutionConfig(idOrder: number, isCalendar: boolean, date: string | null){
+    let dialogRef = this._dialog.open(OrderExecutionConfigComponent, {
+      disableClose: true,
+      width: '640px',
+      data: {
+        idOrder: idOrder,
+        date: date,
+      }
+    });
+
+    dialogRef.afterClosed().subscribe(res => {
+      console.log(res);
+    });
+  }
+
+  private async activateWorkOrder(idOrder: number, isCalendar: boolean, date: string | null){
     try{
       let idUser = localStorage.getItem('idusuario');
       let now = new Date();
@@ -508,7 +536,12 @@ export class ActiveOrdersComponent implements OnInit {
       }else if(error.error.msg == undefined){
         this.openSnackBar('Ocurrió un error inespedado.');
       }else{
-        this.openSnackBar(error.error.msg);
+        let msgArr = error.error.msg.split(':');
+        if(msgArr[0] == 'ERR_GLB_USU003'){
+          this.activateWorkOrder(idOrder, isCalendar, date);
+        }else{
+          this.openSnackBar(error.error.msg);
+        }
       }
     }
   }
@@ -557,7 +590,18 @@ export class ActiveOrdersComponent implements OnInit {
       }else if(error.error.msg == undefined){
         this.openSnackBar('Ocurrió un error inesperado.');
       }else{
-        this.openSnackBar(error.error.msg);
+        if(error.error == undefined){
+          this.openSnackBar('Ocurrió un error inespedado.');
+        }else if(error.error.msg == undefined){
+          this.openSnackBar('Ocurrió un error inespedado.');
+        }else{
+          let msgArr = error.error.msg.split(':');
+          if(msgArr[0] == 'ERR_GLB_USU003'){
+            this.getPreventiveCalendar();
+          }else{
+            this.openSnackBar(error.error.msg);
+          }
+        }
       }
 
       this.gettingEvents = false;
@@ -629,7 +673,7 @@ export class ActiveOrdersComponent implements OnInit {
         let startHour = order.FECHAINICIO.split(' ')[1];
         
         if(resArr[1] == 'execute'){
-          this.activateWorkOrder(idOrder, true, `${dateStr} ${startHour}`);
+          this.openOrderExecutionConfig(idOrder, true, `${dateStr} ${startHour}`);
         }else if(resArr[1] == 'end'){
           this.endExecution(idOrder, dateStr, resArr[3], resArr[2]);
         }else if(resArr[1] == 'cancel'){
@@ -662,7 +706,7 @@ export class ActiveOrdersComponent implements OnInit {
       if(res != '' && res != undefined && res != null){
         let resArr = res.split('|');
         if(res == 'execute'){
-          this.activateWorkOrder(idOrder, true, `${dateStr} ${startHour}`)
+          this.openOrderExecutionConfig(idOrder, true, `${dateStr} ${startHour}`)
         }else if(resArr[0] == 'end'){
           this.endExecution(idOrder, dateStr, resArr[2], resArr[1]);
         }else if(resArr[0] == 'cancel'){
@@ -693,7 +737,12 @@ export class ActiveOrdersComponent implements OnInit {
       }else if(error.error.msg == undefined){
         this.openSnackBar('Ocurrió un error inesperado.');
       }else{
-        this.openSnackBar(error.error.msg);
+        let msgArr = error.error.msg.split(':');
+        if(msgArr[0] == 'ERR_GLB_USU003'){
+          this.cancelOrderExecution(idOrder, date, observations);
+        }else{
+          this.openSnackBar(error.error.msg);
+        }
       }
     }
   }
@@ -720,7 +769,12 @@ export class ActiveOrdersComponent implements OnInit {
       }else if(error.error.msg == undefined){
         this.openSnackBar('Ocurrió un error inesperado.');
       }else{
-        this.openSnackBar(error.error.msg );
+        let msgArr = error.error.msg.split(':');
+        if(msgArr[0] == 'ERR_GLB_USU003'){
+          this.endExecution(idOrder, date, idReg, observations);
+        }else{
+          this.openSnackBar(error.error.msg);
+        }
       }
     }
   }

+ 0 - 0
sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.css


+ 28 - 0
sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.html

@@ -0,0 +1,28 @@
+<h1 mat-dialog-title class="prevent-select">Orden #{{ idOrder }}. Ejecución del {{ humanDate }}</h1>
+<div mat-dialog-content class="prevent-select">
+  <div class="content-container animated fadeIn">
+    <div class="is-loading animated fadeIn fast" *ngIf="isLoading">
+      <mat-spinner align="center"></mat-spinner>
+      <h3>Cargando datos ...</h3>
+    </div>
+    <div class="has-error animated fadeIn" *ngIf="!isLoading && hasError">
+      <mat-icon class="red_primary_font">error</mat-icon>
+      <h2>{{ errorStr }}</h2>
+    </div>
+    <div class="execution-info-container animated fadeIn" *ngIf="!isLoading && !hasError">
+      @for(specialty of specialtiesConf; track specialty){
+        <h3 class="mb-8">{{ specialty.NAME }}</h3>
+        <mat-form-field class="w-100" appearance="outline" *ngFor="let item of [].constructor(specialty.CANT); let i = index">
+          <mat-label>Empleado o subcontratista #{{ i + 1 }}</mat-label>
+          <mat-select>
+            <mat-option>PRUEBA</mat-option>
+          </mat-select>
+        </mat-form-field>
+      }
+    </div>
+  </div>
+</div>
+<div mat-dialog-actions align="end">
+  <button mat-button mat-dialog-close>Cancelar</button>
+  <button mat-button>Iniciar ejecución</button>
+</div>

+ 23 - 0
sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.spec.ts

@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { OrderExecutionConfigComponent } from './order-execution-config.component';
+
+describe('OrderExecutionConfigComponent', () => {
+  let component: OrderExecutionConfigComponent;
+  let fixture: ComponentFixture<OrderExecutionConfigComponent>;
+
+  beforeEach(async () => {
+    await TestBed.configureTestingModule({
+      imports: [OrderExecutionConfigComponent]
+    })
+    .compileComponents();
+    
+    fixture = TestBed.createComponent(OrderExecutionConfigComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 95 - 0
sistema-mantenimiento-front/src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.ts

@@ -0,0 +1,95 @@
+import { Component, Inject, OnInit } from '@angular/core';
+import { MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { lastValueFrom } from 'rxjs';
+import { PreventiveWorkOrderResponse } from 'src/app/interfaces/preventive-work-order.interface';
+import { EncService } from 'src/app/services/enc/enc.service';
+import { FunctionsService } from 'src/app/services/functions.service';
+import { EmployeeService } from 'src/app/services/personal-management/employee.service';
+import { PreventiveMaintenanceService } from 'src/app/services/preventive-maintenance.service';
+
+@Component({
+  selector: 'app-order-execution-config',
+  templateUrl: './order-execution-config.component.html',
+  styleUrl: './order-execution-config.component.css'
+})
+export class OrderExecutionConfigComponent implements OnInit {
+  isLoading: boolean;
+  hasError: boolean;
+  errorStr: string;
+  idOrder: number;
+  humanDate: string;
+  specialtiesConf: any[];
+
+  constructor(
+    @Inject(MAT_DIALOG_DATA) private _data: any,
+    private _functionsService: FunctionsService,
+    private _preventiveMaintenanceService: PreventiveMaintenanceService,
+    private _encService: EncService,
+    private _employeeService: EmployeeService,
+  ) {
+    this.isLoading = true;
+    this.hasError = false;
+    this.errorStr = '';
+    this.idOrder = 0;
+    this.humanDate = '';
+    this.specialtiesConf = [];
+  }
+
+  ngOnInit(): void {
+    this.idOrder = this._data.idOrder;
+    this.humanDate = this._functionsService.buildHumanDateWithDay(this._data.date);
+    
+    this.getPreventiveOrder();
+  }
+
+  async getPreventiveOrder(){
+    try{
+      let idUser = localStorage.getItem('idusuario')!;
+      let idOrderEnc = await this._encService.encrypt(`${this.idOrder}`);
+      let order: PreventiveWorkOrderResponse = await lastValueFrom(this._preventiveMaintenanceService.getWorkOrder(idOrderEnc, idUser, 1));
+
+      this.hasError = order.error;
+      this.errorStr = order.msg;
+
+      if(!this.hasError){
+        let specialtiesArr = JSON.parse(order.response.OPERARIOS);
+        for(const specialty of specialtiesArr){
+          let idSpecialty = await this._encService.decrypt(specialty.ID);
+          specialty.NAME = `${idSpecialty} - ${specialty.NAME}`;
+        }
+
+        this.specialtiesConf = specialtiesArr;
+        console.log(specialtiesArr);
+      }
+
+      this.isLoading = false;
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else if(error.error.msg == undefined){
+        this.errorStr = 'Ocurrió un error inesperado.';
+      }else{
+        let msgArr = error.error.msg.split(':');
+        if(msgArr[0] == 'ERR_GLB_USU003'){
+          this.getPreventiveOrder();
+          return;
+        }else{
+          this.errorStr = error.error.msg;
+        }
+      }
+
+      this.hasError = true;
+      this.isLoading = false;
+    }
+  }
+
+  async getEmployees(){
+    try{
+
+    }catch(error: any){
+      if(error.error == undefined){
+        this.errorStr = 'Ocurrió un error'
+      }
+    }
+  }
+}

+ 2 - 2
sistema-mantenimiento-front/src/app/interfaces/personal-managment/workteam.interface.ts

@@ -34,9 +34,9 @@ export interface UpdatedStatusWorkteam {
   }
   
   export interface GetWorkteams {
-  
-    WORKTEAM_ID: number,
+    WORKTEAM_ID: string,
     NAME: string;
     SPECIALITY: string;
+    SPECIALTY_ARR?: string[];
     STATUS: string;
   }

+ 5 - 0
sistema-mantenimiento-front/src/app/services/functions.service.ts

@@ -90,6 +90,11 @@ export class FunctionsService {
     return `${dateArr[0]} de ${this.MONTHS[monthInd]} del ${dateArr[2]}`;
   }
 
+  buildHumanDateWithDay(date: string): string{
+    let dateObj = new Date(date);
+    return `${this.DAYS[dateObj.getDay()]} ${dateObj.getDate()} de ${this.MONTHS[dateObj.getMonth()]} del ${dateObj.getFullYear()}`;
+  }
+
   buildName(no: string, ap: string, am: string | null | undefined): string{
     let name = `${no} ${ap}`;
     if(am != "" && am != undefined && am != null){

+ 2 - 1
sistema-mantenimiento-front/src/styles.css

@@ -2343,14 +2343,15 @@ mat-toolbar-row,
 }
 
 .active-orders-table-container{
-  flex-grow: 100;
   width: 100%;
+  height: calc(100% - 83px);
   background-color: white;
 }
 
 .active-orders-table-container mat-card{
   width: 75%;
   margin: 0 auto;
+  height: calc(100vh - 214px) !important;
 }
 
 .active-orders-table-content-container{