Prechádzať zdrojové kódy

Error en detalles y editar empleado, solucionado

MathewCordourier 2 rokov pred
rodič
commit
179b88feca

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

@@ -78,10 +78,9 @@ export class EmployeeFormComponent implements OnInit {
   ngOnInit(): void {
     this.idEmployee = this._activatedRoute.snapshot.paramMap.get('id')!;
     this.enable = this._activatedRoute.snapshot.paramMap.get('enable')!;
-    this.getUsers();
+    this.decript();
     this.getWorkteams();
     this.getSubcontratists();
-    this.decript();
     this.getCountries();
   }
 
@@ -105,6 +104,7 @@ export class EmployeeFormComponent implements OnInit {
 
   private async decript() {
     this.idEmployee = await this._encService.desencriptar(this.idEmployee);
+    await this.getUsers();
     if (this.idEmployee != "0") {
       this.getData();
     }
@@ -175,11 +175,12 @@ export class EmployeeFormComponent implements OnInit {
   }
 
   private async getUsers() {
-    await lastValueFrom(this._employeeService.getAvaibleUsers()).then(
-      (responseData: any) => {
-        this.users = responseData.response;
-      }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
-    );
+    console.log(this.idEmployee);
+      await lastValueFrom(this._employeeService.getAvaibleUsers(this.idEmployee)).then(
+        (responseData: any) => {
+          this.users = responseData.response;
+        }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
+      );
   }
 
   private async getWorkteams() {
@@ -239,16 +240,16 @@ export class EmployeeFormComponent implements OnInit {
       }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
     );
 
-      await lastValueFrom(this._employeeService.getLastDocumentsByEmployee(this.idEmployee)).then(
-        (responseData: any) => {
-          if (responseData.response.length > 0) {
-            responseData.response.forEach((document: any) => {
-              this.documentsEmployee.push(document);
-            });
-          }
-        }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
-      );
-    
+    await lastValueFrom(this._employeeService.getLastDocumentsByEmployee(this.idEmployee)).then(
+      (responseData: any) => {
+        if (responseData.response.length > 0) {
+          responseData.response.forEach((document: any) => {
+            this.documentsEmployee.push(document);
+          });
+        }
+      }, (error: HttpErrorResponse) => this._resourcesService.checkErrors(error)
+    );
+
 
   }
 
@@ -268,7 +269,7 @@ export class EmployeeFormComponent implements OnInit {
     this.formData.append('USER_ID', this.userId.value);
 
     if (this.officeDoc.length > 0) { this.formData.append('DOCUMENT_OFFICE', this.officeDoc[0]); }
-    this.officeDoc.length > 1 ? this.formData.append('DOCUMENT_OFFICE_UPDATE', this.officeDoc[1]) : this.formData.append('DOCUMENT_OFFICE_UPDATE', "0") 
+    this.officeDoc.length > 1 ? this.formData.append('DOCUMENT_OFFICE_UPDATE', this.officeDoc[1]) : this.formData.append('DOCUMENT_OFFICE_UPDATE', "0")
 
     if (this.authoDoc.length > 0) { this.formData.append('DOCUMENTS_AUTHO', this.authoDoc[0]); }
     this.authoDoc.length > 1 ? this.formData.append('DOCUMENTS_AUTHO_UPDATE', this.authoDoc[1]) : this.formData.append('DOCUMENTS_AUTHO_UPDATE', "0")
@@ -314,7 +315,7 @@ export class EmployeeFormComponent implements OnInit {
         update: this.nameUpdateDocument
       });
       this.authoDoc.push(file);
-      if(this.nameUpdateDocument != ""){
+      if (this.nameUpdateDocument != "") {
         this.authoDoc.push(this.nameUpdateDocument);
       }
     }
@@ -327,7 +328,7 @@ export class EmployeeFormComponent implements OnInit {
         update: this.nameUpdateDocument
       });
       this.authoDoc2.push(file);
-      if(this.nameUpdateDocument != ""){
+      if (this.nameUpdateDocument != "") {
         this.authoDoc2.push(this.nameUpdateDocument);
       }
     }
@@ -340,7 +341,7 @@ export class EmployeeFormComponent implements OnInit {
         update: this.nameUpdateDocument
       });
       this.officeDoc.push(file);
-      if(this.nameUpdateDocument != ""){
+      if (this.nameUpdateDocument != "") {
         this.officeDoc.push(this.nameUpdateDocument);
       }
     }
@@ -353,7 +354,7 @@ export class EmployeeFormComponent implements OnInit {
         update: this.nameUpdateDocument
       });
       this.certDoc.push(file);
-      if(this.nameUpdateDocument != ""){
+      if (this.nameUpdateDocument != "") {
         this.certDoc.push(this.nameUpdateDocument);
       }
     }
@@ -366,7 +367,7 @@ export class EmployeeFormComponent implements OnInit {
         update: this.nameUpdateDocument
       });
       this.certDoc2.push(file);
-      if(this.nameUpdateDocument != ""){
+      if (this.nameUpdateDocument != "") {
         this.certDoc2.push(this.nameUpdateDocument);
       }
     }

+ 3 - 2
sistema-mantenimiento-front/src/app/services/personal-management/employee.service.ts

@@ -17,8 +17,9 @@ export class EmployeeService {
     return this._httpRequestService.getQuery(`${this._url}/consult`).pipe(
       map((data: any) => data))
   }
-  public getAvaibleUsers() {
-    return this._httpRequestService.getQuery(`${this._url}/user-avaible`).pipe(
+
+  public getAvaibleUsers(employeeId: string) {
+    return this._httpRequestService.getQuery(`${this._url}/user-avaible/${employeeId}`).pipe(
       map((data: any) => data))
   }