|
|
@@ -84,9 +84,6 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
let personalData: string = '';
|
|
|
let historialEstatus: string = '';
|
|
|
|
|
|
- console.log('🔍 Staff Selection - Order Type:', this.orderType);
|
|
|
- console.log('🔍 Staff Selection - Order ID:', this._data.idOrder);
|
|
|
-
|
|
|
// Fetch order details based on orderType
|
|
|
if (this.orderType === 'Correctivo') {
|
|
|
let order: CorrectiveWorkOrderDetailsResponse = await lastValueFrom(
|
|
|
@@ -97,20 +94,17 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
)
|
|
|
);
|
|
|
|
|
|
- console.log('✅ Corrective Order Response:', order);
|
|
|
-
|
|
|
this.hasError = order.error;
|
|
|
this.errorStr = order.msg;
|
|
|
|
|
|
if (this.hasError) {
|
|
|
- console.error('❌ Error getting corrective order:', this.errorStr);
|
|
|
+ this._resourcesService.openSnackBar(this.errorStr);
|
|
|
this.isLoading = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
personalData = order.response.PERSONAL;
|
|
|
historialEstatus = order.response.HISTORIAL_ESTATUS;
|
|
|
- console.log('📋 PERSONAL data (raw):', personalData);
|
|
|
} else {
|
|
|
// Preventive maintenance
|
|
|
let order: PreventiveVisitDetailsResponse = await lastValueFrom(
|
|
|
@@ -121,13 +115,11 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
)
|
|
|
);
|
|
|
|
|
|
- console.log('✅ Preventive Order Response:', order);
|
|
|
-
|
|
|
this.hasError = order.error;
|
|
|
this.errorStr = order.msg;
|
|
|
|
|
|
if (this.hasError) {
|
|
|
- console.error('❌ Error getting preventive order:', this.errorStr);
|
|
|
+ this._resourcesService.openSnackBar(this.errorStr);
|
|
|
this.isLoading = false;
|
|
|
return;
|
|
|
}
|
|
|
@@ -136,7 +128,6 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
// Preventive visits might not have HISTORIAL_ESTATUS in the same format
|
|
|
// We'll handle this case by using an empty string
|
|
|
historialEstatus = '';
|
|
|
- console.log('📋 PERSONAL data (raw):', personalData);
|
|
|
}
|
|
|
|
|
|
// Process excluded users from status history (only for corrective orders)
|
|
|
@@ -160,14 +151,9 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
// Process staff requirements (same for both types)
|
|
|
if (personalData) {
|
|
|
let staffArr = JSON.parse(personalData);
|
|
|
- console.log('👥 Staff Array (parsed):', staffArr);
|
|
|
|
|
|
for (const specialty of staffArr) {
|
|
|
let idDec = await this._encService.decrypt(specialty.ID);
|
|
|
- console.log(`🔓 Specialty ID decrypted: ${specialty.ID} -> ${idDec}`);
|
|
|
- console.log(
|
|
|
- `📛 Specialty Name: ${specialty.NAME}, Cantidad: ${specialty.CANT}`
|
|
|
- );
|
|
|
|
|
|
this.staffSpecialtiesMap.set(idDec, specialty.NAME);
|
|
|
|
|
|
@@ -177,7 +163,6 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
: this.staffOperariesMap.get(idDec)!;
|
|
|
for (let i = 0; i < specialty.CANT; i++) {
|
|
|
let index = `${idDec}${i}Control`;
|
|
|
- console.log(`➕ Adding form control: ${index}`);
|
|
|
this.formGroup.addControl(
|
|
|
index,
|
|
|
new FormControl('', Validators.required)
|
|
|
@@ -188,24 +173,14 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
|
|
|
this.staffOperariesMap.set(idDec, operaries);
|
|
|
}
|
|
|
-
|
|
|
- console.log('🗺️ staffSpecialtiesMap:', this.staffSpecialtiesMap);
|
|
|
- console.log('🗺️ staffOperariesMap:', this.staffOperariesMap);
|
|
|
- } else {
|
|
|
- console.warn('⚠️ No PERSONAL data found in response');
|
|
|
}
|
|
|
|
|
|
this.getEmployees();
|
|
|
} 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.errorStr = error?.error?.msg || 'Ocurrió un error inesperado.';
|
|
|
this.hasError = true;
|
|
|
this.isLoading = false;
|
|
|
+ this._resourcesService.openSnackBar(this.errorStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -216,20 +191,15 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
this._employeeService.getConsultOfEmployees(idUser, 1)
|
|
|
);
|
|
|
|
|
|
- console.log('👷 Employees Response:', employees);
|
|
|
-
|
|
|
this.hasError = employees.error;
|
|
|
this.errorStr = employees.msg;
|
|
|
|
|
|
if (this.hasError) {
|
|
|
- console.error('❌ Error getting employees:', this.errorStr);
|
|
|
+ this._resourcesService.openSnackBar(this.errorStr);
|
|
|
this.isLoading = false;
|
|
|
} else {
|
|
|
let employeesArr: EmployeesListItem[] = [];
|
|
|
let subcontratistsEmployees: EmployeesListItem[] = [];
|
|
|
- console.log(
|
|
|
- `📊 Total employees received: ${employees.response.length}`
|
|
|
- );
|
|
|
|
|
|
for (const employee of employees.response) {
|
|
|
let idEmployee = await this._encService.decrypt(employee.ID_EMPLOYEE);
|
|
|
@@ -270,20 +240,13 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
this.employees = employeesArr;
|
|
|
- console.log(`✅ Internal employees filtered: ${employeesArr.length}`);
|
|
|
- console.log(
|
|
|
- `🏢 Subcontractor employees to process: ${subcontratistsEmployees.length}`
|
|
|
- );
|
|
|
this.getSubcontratists(subcontratistsEmployees);
|
|
|
}
|
|
|
} 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.errorStr = error?.error?.msg || 'Ocurrió un error inesperado.';
|
|
|
+ this.hasError = true;
|
|
|
+ this.isLoading = false;
|
|
|
+ this._resourcesService.openSnackBar(this.errorStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -348,26 +311,14 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
this.subcontratists = subcontratistEmployeesArr;
|
|
|
- console.log(
|
|
|
- `✅ Final subcontractor employees: ${subcontratistEmployeesArr.length}`
|
|
|
- );
|
|
|
}
|
|
|
|
|
|
- console.log('🎯 Final data loaded:');
|
|
|
- console.log(' - Employees:', this.employees.length);
|
|
|
- console.log(' - Subcontratists:', this.subcontratists.length);
|
|
|
- console.log(' - Specialties Map:', this.staffSpecialtiesMap);
|
|
|
- console.log(' - Operaries Map:', this.staffOperariesMap);
|
|
|
-
|
|
|
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.errorStr = error?.error?.msg || 'Ocurrió un error inesperado.';
|
|
|
+ this.hasError = true;
|
|
|
+ this.isLoading = false;
|
|
|
+ this._resourcesService.openSnackBar(this.errorStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -420,7 +371,6 @@ export class StaffSelectionComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
let configStr = JSON.stringify(config);
|
|
|
- console.log('Staff Selection Request:', configStr);
|
|
|
this._dialogRef.close(configStr);
|
|
|
}
|
|
|
}
|