Selaa lähdekoodia

Mejora en documentos de empleado

MathewCordourier 2 vuotta sitten
vanhempi
commit
d3d447781f

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

@@ -231,12 +231,6 @@ export class EmployeeFormComponent implements OnInit {
 
         }
 
-        if (responseData.response.DOCUMENTS!.length > 0) {
-          responseData.response.DOCUMENTS!.forEach(async document => {
-            this.documentsEmployee.push(await this._encService.desencriptar(document));
-          });
-        }
-
         this.putDataOnForm(responseData.response);
         this.infoEmployee = {
           SAVED_BY_USER: this.userId.value,
@@ -244,6 +238,20 @@ export class EmployeeFormComponent implements OnInit {
         };
       }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
     );
+
+      await lastValueFrom(this._employeeService.getLastDocumentsByEmployee(this.idEmployee)).then(
+        (responseData: any) => {
+          console.log(responseData.response);
+          console.log("sad");
+          if (responseData.response.length > 0) {
+            responseData.response.forEach((document: any) => {
+              this.documentsEmployee.push(document);
+            });
+          }
+        }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
+      );
+    
+
   }
 
   private async putDataOnForm(employee: Employee) {

+ 5 - 0
sistema-mantenimiento-front/src/app/services/personal-management/employee.service.ts

@@ -27,6 +27,11 @@ export class EmployeeService {
       map((data: any) => data))
   }
 
+    public getLastDocumentsByEmployee(employeeId: string) {
+    return this._httpRequestService.getQuery(`${this._url}/last-documents/${employeeId}/1`).pipe(
+      map((data: any) => data))
+  }
+
   public getInterventionsByEmployee(employeeId: string) {
     return this._httpRequestService.getQuery(`${this._url}/orders/${employeeId}/1`).pipe(
       map((data: any) => data))