|
|
@@ -1,22 +1,33 @@
|
|
|
import { Component, Inject, OnInit } from '@angular/core';
|
|
|
-import { NotificationAction, NotificationDetailsResponse, NotificationsListItem } from '../../../interfaces/notification.interface';
|
|
|
-import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
|
|
|
+import {
|
|
|
+ NotificationAction,
|
|
|
+ NotificationDetailsResponse,
|
|
|
+ NotificationsListItem,
|
|
|
+} from '../../../interfaces/notification.interface';
|
|
|
+import {
|
|
|
+ MAT_DIALOG_DATA,
|
|
|
+ MatDialog,
|
|
|
+ MatDialogRef,
|
|
|
+} from '@angular/material/dialog';
|
|
|
import { EncService } from '../../../services/enc.service';
|
|
|
import { NotificationsService } from '../../../services/notifications.service';
|
|
|
import { ResourcesService } from '../../../services/resources.service';
|
|
|
import { CorrectiveMaintenanceService } from '../../../services/corrective-maintenance.service';
|
|
|
+import { ProcessManagementService } from '../../../services/process-management/process-management.service';
|
|
|
import { lastValueFrom } from 'rxjs';
|
|
|
import { CorrectiveOrderDetailsComponent } from '../../corrective-maintenance/operations-management/corrective-order-details/corrective-order-details.component';
|
|
|
import { AgreeOrderComponent } from './agree-order/agree-order.component';
|
|
|
import { SignatureViewComponent } from './signature-view/signature-view.component';
|
|
|
import { StaffSelectionComponent } from '../../corrective-maintenance/operations-management/staff-selection/staff-selection.component';
|
|
|
import { CommentsViewComponent } from './comments-view/comments-view.component';
|
|
|
+import { ValidateApplicationsModalComponent } from './validate-applications-modal/validate-applications-modal.component';
|
|
|
+import { ResponseDataValidateApplications } from '../../../interfaces/process-managementv/workflow-management.interface';
|
|
|
|
|
|
@Component({
|
|
|
- selector: 'app-notification-dialog',
|
|
|
- templateUrl: './notification-dialog.component.html',
|
|
|
- styleUrl: './notification-dialog.component.css',
|
|
|
- standalone: false
|
|
|
+ selector: 'app-notification-dialog',
|
|
|
+ templateUrl: './notification-dialog.component.html',
|
|
|
+ styleUrl: './notification-dialog.component.css',
|
|
|
+ standalone: false,
|
|
|
})
|
|
|
export class NotificationDialogComponent implements OnInit {
|
|
|
idNotification: string;
|
|
|
@@ -33,7 +44,8 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
private _dialog: MatDialog,
|
|
|
private _resourcesService: ResourcesService,
|
|
|
private _correctiveMaintenanceService: CorrectiveMaintenanceService,
|
|
|
- private _dialogRef: MatDialogRef<NotificationDialogComponent>,
|
|
|
+ private _processManagementService: ProcessManagementService,
|
|
|
+ private _dialogRef: MatDialogRef<NotificationDialogComponent>
|
|
|
) {
|
|
|
this.idNotification = '';
|
|
|
this.isLoading = true;
|
|
|
@@ -46,42 +58,50 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
this.init();
|
|
|
}
|
|
|
|
|
|
- async init(){
|
|
|
- this.idNotification = await this._encService.decrypt(this._data.idNotification);
|
|
|
+ async init() {
|
|
|
+ this.idNotification = await this._encService.decrypt(
|
|
|
+ this._data.idNotification
|
|
|
+ );
|
|
|
this.getNotification();
|
|
|
}
|
|
|
|
|
|
- async getNotification(){
|
|
|
- try{
|
|
|
+ async getNotification() {
|
|
|
+ try {
|
|
|
let idUser = localStorage.getItem('idusuario')!;
|
|
|
- let notification: NotificationDetailsResponse = await lastValueFrom(this._notificationsService.getNotification(
|
|
|
- this._data.idNotification,
|
|
|
- 'S',
|
|
|
- idUser,
|
|
|
- 1
|
|
|
- ));
|
|
|
+ let notification: NotificationDetailsResponse = await lastValueFrom(
|
|
|
+ this._notificationsService.getNotification(
|
|
|
+ this._data.idNotification,
|
|
|
+ 'S',
|
|
|
+ idUser,
|
|
|
+ 1
|
|
|
+ )
|
|
|
+ );
|
|
|
|
|
|
this.hasError = notification.error;
|
|
|
this.errorStr = notification.msg;
|
|
|
|
|
|
- if(!this.hasError){
|
|
|
- let notificationActionsArr: NotificationAction[] = JSON.parse(notification.response.ACCIONES);
|
|
|
-
|
|
|
+ if (!this.hasError) {
|
|
|
+ let notificationActionsArr: NotificationAction[] = JSON.parse(
|
|
|
+ notification.response.ACCIONES
|
|
|
+ );
|
|
|
+
|
|
|
notification.response.ACCIONES_ARR = notificationActionsArr;
|
|
|
if (notification.response.ID_ORDEN !== null) {
|
|
|
- notification.response.ID_ORDEN = await this._encService.decrypt(notification.response.ID_ORDEN);
|
|
|
+ notification.response.ID_ORDEN = await this._encService.decrypt(
|
|
|
+ notification.response.ID_ORDEN
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
this.notification = notification.response;
|
|
|
}
|
|
|
|
|
|
this.isLoading = false;
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
+ } catch (error: any) {
|
|
|
+ if (error.error == undefined) {
|
|
|
this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
+ } else if (error.error.msg == undefined) {
|
|
|
this.errorStr = 'Ocurrió un error inesperado.';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.errorStr = error.error.msg;
|
|
|
}
|
|
|
|
|
|
@@ -90,82 +110,156 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- executeNotificationAction(func: string, params: string){
|
|
|
+ executeNotificationAction(func: string, params: string) {
|
|
|
+ console.log(params);
|
|
|
+
|
|
|
let paramsArr = JSON.parse(params);
|
|
|
- switch(func){
|
|
|
- case "openCorrectiveWorkOrderDetails":
|
|
|
+ switch (func) {
|
|
|
+ case 'openCorrectiveWorkOrderDetails':
|
|
|
this.openCorrectiveWorkOrderDetails(paramsArr[0]);
|
|
|
- break;
|
|
|
- case "validateCorrectiveWorkOrder":
|
|
|
+ break;
|
|
|
+ case 'validateCorrectiveWorkOrder':
|
|
|
this.validateCorrectiveWorkOrder(paramsArr[0]);
|
|
|
- break;
|
|
|
- case "openModule":
|
|
|
+ break;
|
|
|
+ case 'openModule':
|
|
|
this._dialogRef.close(`go|${paramsArr[0]}`);
|
|
|
- break;
|
|
|
- case "attendCorrectiveWorkOrder":
|
|
|
+ break;
|
|
|
+ case 'attendCorrectiveWorkOrder':
|
|
|
this.attendCorrectiveWorkOrder(paramsArr[0]);
|
|
|
- break;
|
|
|
- case "reviewSignatureInCorrectiveWorkOrder":
|
|
|
+ break;
|
|
|
+ case 'reviewSignatureInCorrectiveWorkOrder':
|
|
|
this.reviewSignatureInCorrectiveWorkOrder(paramsArr[0], paramsArr[1]);
|
|
|
- break;
|
|
|
- case "reviewCommentsInCorrectiveWorkOrder":
|
|
|
+ break;
|
|
|
+ case 'reviewCommentsInCorrectiveWorkOrder':
|
|
|
this.reviewCommentsInCorrectiveWorkOrder(paramsArr[0], paramsArr[1]);
|
|
|
- break;
|
|
|
- case "revalidateCorrectiveWorkOrder":
|
|
|
+ break;
|
|
|
+ case 'revalidateCorrectiveWorkOrder':
|
|
|
this.revalidateCorrectiveWorkOrder(paramsArr[0]);
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ case 'getValidateApplications':
|
|
|
+ this.getValidateApplications(paramsArr[0], paramsArr[1]);
|
|
|
+ break;
|
|
|
+ case 'asignStateToApplication':
|
|
|
+ this.asignStateToApplication(
|
|
|
+ paramsArr[0],
|
|
|
+ paramsArr[1],
|
|
|
+ paramsArr[2],
|
|
|
+ paramsArr[3]
|
|
|
+ );
|
|
|
+ break;
|
|
|
default:
|
|
|
- this._resourcesService.openSnackBar('La función seleccionada no existe.');
|
|
|
- break;
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'La función seleccionada no existe.'
|
|
|
+ );
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//FUNCIONES POSIBLES PARA LAS NOTIFICACIONES
|
|
|
- openCorrectiveWorkOrderDetails(idOrder: string){
|
|
|
+ async getValidateApplications(user: string, line: number) {
|
|
|
+ if (!user || !line) {
|
|
|
+ this._resourcesService.openSnackBar('Parámetros inválidos.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const response: ResponseDataValidateApplications = await lastValueFrom(
|
|
|
+ this._processManagementService.getValidateApplications(
|
|
|
+ await this._encService.encrypt(user),
|
|
|
+ line
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ console.log(response);
|
|
|
+
|
|
|
+ if (!response.error) {
|
|
|
+ this._dialog.open(ValidateApplicationsModalComponent, {
|
|
|
+ width: '800px',
|
|
|
+ data: { applications: response.response },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this._resourcesService.openSnackBar(response.msg);
|
|
|
+ }
|
|
|
+ } catch (error: any) {
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ error?.error?.msg || 'Ocurrió un error inesperado.'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async asignStateToApplication(
|
|
|
+ user: string,
|
|
|
+ line: number,
|
|
|
+ idapplication: number,
|
|
|
+ state: string
|
|
|
+ ) {
|
|
|
+ if (!user || !line || !idapplication || !state) {
|
|
|
+ this._resourcesService.openSnackBar('Parámetros inválidos.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await lastValueFrom(
|
|
|
+ this._processManagementService.assignStateToApplication({
|
|
|
+ USUARIO: await this._encService.encrypt(user),
|
|
|
+ NUMERO_LINEA: line,
|
|
|
+ ID_APPLICATION: idapplication,
|
|
|
+ STATE: state,
|
|
|
+ })
|
|
|
+ );
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'Estado asignado correctamente a la solicitud.'
|
|
|
+ );
|
|
|
+ } catch (error: any) {
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ error?.error?.msg || 'Ocurrió un error inesperado.'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ openCorrectiveWorkOrderDetails(idOrder: string) {
|
|
|
this._dialog.open(CorrectiveOrderDetailsComponent, {
|
|
|
width: '480px',
|
|
|
data: {
|
|
|
idOrder: idOrder,
|
|
|
- }
|
|
|
- })
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- private validateCorrectiveWorkOrder(idOrder: string){
|
|
|
+ private validateCorrectiveWorkOrder(idOrder: string) {
|
|
|
let dialogRef = this._dialog.open(StaffSelectionComponent, {
|
|
|
disableClose: true,
|
|
|
width: '540px',
|
|
|
maxWidth: '540px',
|
|
|
data: {
|
|
|
idOrder: idOrder,
|
|
|
- }
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
- dialogRef.afterClosed().subscribe(res => {
|
|
|
- if(res != null && res != undefined && res != ''){
|
|
|
+ dialogRef.afterClosed().subscribe((res) => {
|
|
|
+ if (res != null && res != undefined && res != '') {
|
|
|
this.approveWorkOrder(idOrder, res);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private revalidateCorrectiveWorkOrder(idOrder: string){
|
|
|
+ private revalidateCorrectiveWorkOrder(idOrder: string) {
|
|
|
let dialogRef = this._dialog.open(StaffSelectionComponent, {
|
|
|
disableClose: true,
|
|
|
width: '540px',
|
|
|
maxWidth: '540px',
|
|
|
data: {
|
|
|
idOrder: idOrder,
|
|
|
- }
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
- dialogRef.afterClosed().subscribe(res => {
|
|
|
- if(res != null && res != undefined && res != ''){
|
|
|
+ dialogRef.afterClosed().subscribe((res) => {
|
|
|
+ if (res != null && res != undefined && res != '') {
|
|
|
this.updateApprovedWorkOrder(idOrder, res);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private async approveWorkOrder(idOrder: string, config: string){
|
|
|
- try{
|
|
|
+ private async approveWorkOrder(idOrder: string, config: string) {
|
|
|
+ try {
|
|
|
let idUser = localStorage.getItem('idusuario')!;
|
|
|
let formData = new FormData();
|
|
|
|
|
|
@@ -174,22 +268,30 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
formData.append('id_order', idOrder);
|
|
|
formData.append('config', config);
|
|
|
|
|
|
- await lastValueFrom(this._correctiveMaintenanceService.approveWorkOrder(formData));
|
|
|
- this._resourcesService.openSnackBar('La orden de trabajo se aprobó correctamente.');
|
|
|
+ await lastValueFrom(
|
|
|
+ this._correctiveMaintenanceService.approveWorkOrder(formData)
|
|
|
+ );
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'La orden de trabajo se aprobó correctamente.'
|
|
|
+ );
|
|
|
this._dialogRef.close();
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado (14).');
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado (15).');
|
|
|
- }else{
|
|
|
+ } catch (error: any) {
|
|
|
+ if (error.error == undefined) {
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'Ocurrió un error inesperado (14).'
|
|
|
+ );
|
|
|
+ } else if (error.error.msg == undefined) {
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'Ocurrió un error inesperado (15).'
|
|
|
+ );
|
|
|
+ } else {
|
|
|
this._resourcesService.openSnackBar(error.error.msg);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async updateApprovedWorkOrder(idOrder: string, config: string){
|
|
|
- try{
|
|
|
+ private async updateApprovedWorkOrder(idOrder: string, config: string) {
|
|
|
+ try {
|
|
|
let idUser = localStorage.getItem('idusuario')!;
|
|
|
let formData = new FormData();
|
|
|
|
|
|
@@ -198,39 +300,50 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
formData.append('id_order', idOrder);
|
|
|
formData.append('config', config);
|
|
|
|
|
|
- await lastValueFrom(this._correctiveMaintenanceService.updateApprovedWorkOrder(formData));
|
|
|
- this._resourcesService.openSnackBar('La orden de trabajo se actualizó correctamente.');
|
|
|
+ await lastValueFrom(
|
|
|
+ this._correctiveMaintenanceService.updateApprovedWorkOrder(formData)
|
|
|
+ );
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'La orden de trabajo se actualizó correctamente.'
|
|
|
+ );
|
|
|
this._dialogRef.close();
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado (14).');
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
- this._resourcesService.openSnackBar('Ocurrió un error inesperado (15).');
|
|
|
- }else{
|
|
|
+ } catch (error: any) {
|
|
|
+ if (error.error == undefined) {
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'Ocurrió un error inesperado (14).'
|
|
|
+ );
|
|
|
+ } else if (error.error.msg == undefined) {
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'Ocurrió un error inesperado (15).'
|
|
|
+ );
|
|
|
+ } else {
|
|
|
this._resourcesService.openSnackBar(error.error.msg);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- attendCorrectiveWorkOrder(idOrder: string){
|
|
|
+ attendCorrectiveWorkOrder(idOrder: string) {
|
|
|
let dialogRef = this._dialog.open(AgreeOrderComponent, {
|
|
|
disableClose: true,
|
|
|
- width: "560px",
|
|
|
- maxWidth: "560px",
|
|
|
+ width: '560px',
|
|
|
+ maxWidth: '560px',
|
|
|
data: {
|
|
|
idOrder: idOrder,
|
|
|
- }
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
- dialogRef.afterClosed().subscribe(res => {
|
|
|
- if(res != null && res != undefined && res != ''){
|
|
|
+ dialogRef.afterClosed().subscribe((res) => {
|
|
|
+ if (res != null && res != undefined && res != '') {
|
|
|
this.saveAttendanceCorrectiveOrder(idOrder, res);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- private async saveAttendanceCorrectiveOrder(idOrder: string, dataEnc: string){
|
|
|
- try{
|
|
|
+ private async saveAttendanceCorrectiveOrder(
|
|
|
+ idOrder: string,
|
|
|
+ dataEnc: string
|
|
|
+ ) {
|
|
|
+ try {
|
|
|
let idUser = localStorage.getItem('idusuario')!;
|
|
|
let dataDec = await this._encService.decrypt(dataEnc);
|
|
|
let dataArr = JSON.parse(dataDec);
|
|
|
@@ -242,39 +355,49 @@ export class NotificationDialogComponent implements OnInit {
|
|
|
formData.append('attendance', dataArr[0]);
|
|
|
formData.append('data', dataArr[1]);
|
|
|
|
|
|
- await lastValueFrom(this._correctiveMaintenanceService.setWorkOrderAttendance(formData));
|
|
|
- this._resourcesService.openSnackBar('La atención a la orden de trabajo se registró correctamente.');
|
|
|
+ await lastValueFrom(
|
|
|
+ this._correctiveMaintenanceService.setWorkOrderAttendance(formData)
|
|
|
+ );
|
|
|
+ this._resourcesService.openSnackBar(
|
|
|
+ 'La atención a la orden de trabajo se registró correctamente.'
|
|
|
+ );
|
|
|
this._dialogRef.close();
|
|
|
- }catch(error: any){
|
|
|
- if(error.error == undefined){
|
|
|
+ } catch (error: any) {
|
|
|
+ if (error.error == undefined) {
|
|
|
this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
+ } else if (error.error.msg == undefined) {
|
|
|
this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this._resourcesService.openSnackBar(error.error.msg);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private reviewSignatureInCorrectiveWorkOrder(idOrder: string, idUserAction: string){
|
|
|
+ private reviewSignatureInCorrectiveWorkOrder(
|
|
|
+ idOrder: string,
|
|
|
+ idUserAction: string
|
|
|
+ ) {
|
|
|
this._dialog.open(SignatureViewComponent, {
|
|
|
width: '420px',
|
|
|
maxWidth: '420px',
|
|
|
data: {
|
|
|
idOrder: idOrder,
|
|
|
idUserAction: idUserAction,
|
|
|
- }
|
|
|
+ },
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private reviewCommentsInCorrectiveWorkOrder(idOrder: string, idUserAction: string){
|
|
|
+ private reviewCommentsInCorrectiveWorkOrder(
|
|
|
+ idOrder: string,
|
|
|
+ idUserAction: string
|
|
|
+ ) {
|
|
|
this._dialog.open(CommentsViewComponent, {
|
|
|
width: '420px',
|
|
|
maxWidth: '420px',
|
|
|
data: {
|
|
|
idOrder: idOrder,
|
|
|
idUserAction: idUserAction,
|
|
|
- }
|
|
|
+ },
|
|
|
});
|
|
|
}
|
|
|
}
|