|
|
@@ -398,9 +398,9 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
let resCont = 0;
|
|
|
|
|
|
//PENDIENTE INCLUIR STOCK
|
|
|
- this.orderFormGroup.controls['toolsControl'].setValue(['SH']);
|
|
|
+ /*this.orderFormGroup.controls['toolsControl'].setValue(['SH']);
|
|
|
this.orderFormGroup.controls['sparePartsControl'].setValue(['SH']);
|
|
|
- this.toolsChange(['SH'], ['SH']);
|
|
|
+ this.toolsChange(['SH'], ['SH']);*/
|
|
|
|
|
|
if(order.response.DOCUMENTOS != null){
|
|
|
let attached = JSON.parse(order.response.DOCUMENTOS!);
|
|
|
@@ -456,7 +456,7 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
this.getActivatorsByType(activatorTypeInd, activator);
|
|
|
}
|
|
|
|
|
|
- this.getEmployees();
|
|
|
+ this._getToolsAndSpare();
|
|
|
}
|
|
|
}catch(error: any){
|
|
|
if(error.error == undefined){
|
|
|
@@ -472,156 +472,6 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async getEmployees(){
|
|
|
- try{
|
|
|
- let idUser = localStorage.getItem('idusuario')!;
|
|
|
- let employees: EmployeesListResponse = await lastValueFrom(this._employeeService.getConsultOfEmployees(idUser, 1));
|
|
|
-
|
|
|
- this.hasError = employees.error;
|
|
|
- this.errorStr = employees.msg;
|
|
|
-
|
|
|
- if(this.hasError){
|
|
|
- this.isLoading = false;
|
|
|
- }else{
|
|
|
- let employeesSelected: string[] = [];
|
|
|
- if(this.workOrder != null){
|
|
|
- let staffArr = JSON.parse(this.workOrder.OPERARIOS);
|
|
|
- let employeesFilt = staffArr.filter((item: any) => item.TYPE == 'EM');
|
|
|
- for(const employee of employeesFilt){
|
|
|
- let idDec = await this._encService.decrypt(employee.ID);
|
|
|
- employeesSelected.push(idDec);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let staffVal = this.orderFormGroup.controls['staffControl'].value;
|
|
|
- for(const employee of employees.response){
|
|
|
- let idEmployeeDec = await this._encService.decrypt(employee.ID_EMPLOYEE);
|
|
|
- if(employeesSelected.includes(idEmployeeDec)){
|
|
|
- staffVal.push(`${employee.ID_EMPLOYEE}-EM`);
|
|
|
- }
|
|
|
-
|
|
|
- employee.NAME = `${employee.NAME} (${idEmployeeDec})`;
|
|
|
- if(employee.STATUS == 'Activo'){
|
|
|
- this.employees.push(employee);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.orderFormGroup.controls['staffControl'].setValue(staffVal);
|
|
|
- this.getSubcontratists();
|
|
|
- }
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else{
|
|
|
- this._resourcesService.openSnackBar(error.error.msg);
|
|
|
- }
|
|
|
-
|
|
|
- this.hasError = true;
|
|
|
- this.isLoading = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- async getSubcontratists(){
|
|
|
- try{
|
|
|
- let idUser = localStorage.getItem('idusuario')!;
|
|
|
- let subcontratists: SubcontratistsResponse = await lastValueFrom(this._subcontratistService.getConsultOfSubcontratists(idUser, 1));
|
|
|
-
|
|
|
- this.hasError = subcontratists.error;
|
|
|
- this.errorStr = subcontratists.msg;
|
|
|
-
|
|
|
- if(this.hasError){
|
|
|
- this.isLoading = false;
|
|
|
- }else{
|
|
|
- let subcontratistsSelected: string[] = [];
|
|
|
- if(this.workOrder != null){
|
|
|
- let staffArr = JSON.parse(this.workOrder.OPERARIOS);
|
|
|
- let subcontratistsFilt = staffArr.filter((item: any) => item.TYPE == 'SU');
|
|
|
- for(const subcontratist of subcontratistsFilt){
|
|
|
- let idDec = await this._encService.decrypt(subcontratist.ID);
|
|
|
- subcontratistsSelected.push(idDec);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let staffVal = this.orderFormGroup.controls['staffControl'].value;
|
|
|
- for(const subcontratist of subcontratists.response){
|
|
|
- let idSubcontratistDec = await this._encService.decrypt(subcontratist.ID_SUBCONTRATIST);
|
|
|
- if(subcontratistsSelected.includes(idSubcontratistDec)){
|
|
|
- staffVal.push(`${subcontratist.ID_SUBCONTRATIST}-SU`);
|
|
|
- }
|
|
|
-
|
|
|
- subcontratist.NAME = `${subcontratist.NAME} (${idSubcontratistDec})`;
|
|
|
- if(subcontratist.STATUS == 'Activo'){
|
|
|
- this.subcontratists.push(subcontratist);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.orderFormGroup.controls['staffControl'].setValue(staffVal);
|
|
|
- this.getWorkTeams();
|
|
|
- }
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else{
|
|
|
- this._resourcesService.openSnackBar(error.error.msg);
|
|
|
- }
|
|
|
-
|
|
|
- this.hasError = true;
|
|
|
- this.isLoading = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- async getWorkTeams(){
|
|
|
- try{
|
|
|
- let idUser = localStorage.getItem('idusuario')!;
|
|
|
- let workTeams = await lastValueFrom(this._workTeamsService.getConsultOfWorkteams(idUser, 1));
|
|
|
-
|
|
|
- this.hasError = workTeams.error;
|
|
|
- this.errorStr = workTeams.msg;
|
|
|
-
|
|
|
- if(this.hasError){
|
|
|
- this.isLoading = false;
|
|
|
- }else{
|
|
|
- let workTeamsSelected: number[] = [];
|
|
|
- if(this.workOrder != null){
|
|
|
- let staffArr = JSON.parse(this.workOrder.OPERARIOS);
|
|
|
- let workTeamsFilt = staffArr.filter((item: any) => item.TYPE == 'EQ');
|
|
|
- for(const workTeam of workTeamsFilt){
|
|
|
- let idDec = await this._encService.decrypt(workTeam.ID);
|
|
|
- workTeamsSelected.push(parseInt(idDec));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let staffVal = this.orderFormGroup.controls['staffControl'].value;
|
|
|
- for(const workTeam of workTeams.response){
|
|
|
- let idWorkTeamDec = await this._encService.decrypt(workTeam.WORKTEAM_ID);
|
|
|
-
|
|
|
- workTeam.NAME = `${workTeam.NAME} (${idWorkTeamDec})`;
|
|
|
- if(workTeam.STATUS == 'Activo'){
|
|
|
- this.workTeams.push(workTeam);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.orderFormGroup.controls['staffControl'].setValue(staffVal);
|
|
|
- this.getSpecialties();
|
|
|
- }
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else{
|
|
|
- this._resourcesService.openSnackBar(error.error.msg);
|
|
|
- }
|
|
|
-
|
|
|
- this.hasError = true;
|
|
|
- this.isLoading = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
async getSpecialties(){
|
|
|
try{
|
|
|
let idUser = localStorage.getItem('idusuario')!;
|
|
|
@@ -631,6 +481,15 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
this.errorStr = specialties.msg;
|
|
|
|
|
|
if(!this.hasError){
|
|
|
+ let specialtiesSelected: string[] = [];
|
|
|
+ if(this.workOrder != null){
|
|
|
+ let staffArr: any[] = JSON.parse(this.workOrder.OPERARIOS);
|
|
|
+ for(const item of staffArr){
|
|
|
+ let idDec = await this._encService.decrypt(item.ID);
|
|
|
+ specialtiesSelected.push(idDec);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let specialtiesArr: SpecialtiesListItem[] = [];
|
|
|
for(const specialty of specialties.response){
|
|
|
let codeDec = await this._encService.decrypt(specialty.CODIGO_ESPECIALIDAD);
|
|
|
@@ -638,6 +497,11 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
|
|
|
if(specialty.ESTADO == 'Activo'){
|
|
|
specialtiesArr.push(specialty);
|
|
|
+
|
|
|
+ let specialtiesVal = this.orderFormGroup.controls['staffControl'].value;
|
|
|
+ if(specialtiesSelected.includes(codeDec)){
|
|
|
+ specialtiesVal.push(specialty.CODIGO_ESPECIALIDAD);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -662,6 +526,34 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
|
|
|
initTables(){
|
|
|
setTimeout(() => {
|
|
|
+ let equipment = this.orderFormGroup.controls['equipmentControl'].value;
|
|
|
+ if(equipment != null && equipment != undefined && equipment != ''){
|
|
|
+ this.changeEquipmentTable(equipment);
|
|
|
+ }
|
|
|
+
|
|
|
+ let specialties = this.orderFormGroup.controls['staffControl'].value;
|
|
|
+ this.updateSpecialty(specialties);
|
|
|
+ setTimeout(async () => {
|
|
|
+ if(this.workOrder != null){
|
|
|
+ let specialtiesArr = JSON.parse(this.workOrder.OPERARIOS);
|
|
|
+ for(const specialty of specialtiesArr){
|
|
|
+ specialty.ID = await this._encService.decrypt(specialty.ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ for(const item of specialties){
|
|
|
+ let input = this._document.getElementById(`cant-req-${item}`) as HTMLInputElement;
|
|
|
+ let itemDec = await this._encService.decrypt(item);
|
|
|
+ let specialtyFilt = specialtiesArr.filter((item1: any) => item1.ID == itemDec);
|
|
|
+
|
|
|
+ if(specialtyFilt.length > 0){
|
|
|
+ input.value = specialtyFilt[0].CANT;
|
|
|
+ }else{
|
|
|
+ input.value = '1';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+
|
|
|
let toolsKeys = Object.keys(this.toolsConf);
|
|
|
toolsKeys.forEach(key => {
|
|
|
if(key != 'SH'){
|
|
|
@@ -1630,12 +1522,16 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
|
|
|
addStep(type: string, id: string | null){
|
|
|
let ins = this.instructions.filter(item => item.ID == id);
|
|
|
+ let startDate = this.orderFormGroup.controls['startDateControl'].value;
|
|
|
+ let endDate = this.orderFormGroup.controls['endDateControl'].value;
|
|
|
|
|
|
let dialogRef = this._dialog.open(NewInstructionComponent, {
|
|
|
width: '560px',
|
|
|
data: {
|
|
|
action: type,
|
|
|
instruction: ins.length > 0 ? ins[0] : null,
|
|
|
+ startDate: startDate,
|
|
|
+ endDate: endDate,
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -1962,12 +1858,25 @@ export class NewWorkOrderComponent implements OnInit {
|
|
|
await lastValueFrom(this._inventoryManagementService.getToolsAndSpare(USER, LINE)).then(
|
|
|
(responseData: ResponseDataGetToolsAndSpare) => {
|
|
|
if (!responseData.error) {
|
|
|
- this.tools = responseData.response.HERRAMIENTAS
|
|
|
- this.spareParts = responseData.response.REFACCIONES
|
|
|
+ this.tools = responseData.response.HERRAMIENTAS;
|
|
|
+ this.spareParts = responseData.response.REFACCIONES;
|
|
|
+
|
|
|
+ this.getSpecialties();
|
|
|
} else {
|
|
|
this._resourcesService.openSnackBar(`${responseData.msg}`);
|
|
|
}
|
|
|
- }, (httpErrorResponse: HttpErrorResponse) => this._resourcesService.checkErrors(httpErrorResponse)
|
|
|
+ }, (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;
|
|
|
+ }
|
|
|
)
|
|
|
}
|
|
|
|