Forráskód Böngészése

modal de detalles de orden preventiva lista para su uso.

EmilianoOrtiz 2 hete
szülő
commit
3e5678a2bd

+ 4 - 1
src/app/components/preventive-maintenance/preventive-order-details/preventive-order-details.component.html

@@ -32,7 +32,10 @@
           <li><b>Sin medidas</b></li>
         }
       </ul>
-      <p class="mt-12"><b>Fecha de finalización: </b>{{ workOrder!.FECHA_FINAL || '-' }}</p>
+      <p class="mt-12"><b>Prioridad: </b><span style="font-weight: 500;" [style.color]="workOrder!.PRIORIDAD_OBJ?.color">
+        {{ workOrder!.PRIORIDAD_OBJ?.label || '-' }}
+      </span></p>
+      <p><b>Fecha de finalización: </b>{{ workOrder!.FECHA_FINAL || '-' }}</p>
       <p><b>Duración total: </b>{{ workOrder!.DURACION_TOTAL ? workOrder!.DURACION_TOTAL + 'h' : '-' }}</p>
       <p class="m-0"><b>Recursos requeridos:</b></p>
       <ul class="m-0">

+ 46 - 5
src/app/components/preventive-maintenance/preventive-order-details/preventive-order-details.component.ts

@@ -4,11 +4,13 @@ import { PreventiveMaintenanceService } from '../../../services/preventive-maint
 import { EncService } from '../../../services/enc.service';
 import { FunctionsService } from '../../../services/functions.service';
 import { ResourcesService } from '../../../services/resources.service';
+import { SystemAdminService } from '../../../services/system-admin.service';
 import { lastValueFrom } from 'rxjs';
 import {
   PreventiveVisitDetailsResponse,
   PreventiveVisitDetails,
 } from '../../../interfaces/preventive-maintenance.interface';
+import { PriorityInterface } from '../../system-admin/system-params/system-params.component';
 
 @Component({
   selector: 'app-preventive-order-details',
@@ -22,8 +24,7 @@ export class PreventiveOrderDetailsComponent implements OnInit {
   hasError: boolean;
   errorStr: string;
 
-
-
+  orderPriorities: PriorityInterface[];
   workOrder: PreventiveVisitDetails | null;
 
   constructor(
@@ -32,6 +33,7 @@ export class PreventiveOrderDetailsComponent implements OnInit {
     private _encService: EncService,
     private _functionsService: FunctionsService,
     private _resourcesService: ResourcesService,
+    private _sysAdminService: SystemAdminService,
 
   ) {
     this.idOrder = '';
@@ -39,13 +41,43 @@ export class PreventiveOrderDetailsComponent implements OnInit {
     this.hasError = false;
     this.errorStr = '';
 
-
-
+    this.orderPriorities = [];
     this.workOrder = null;
   }
 
   ngOnInit(): void {
-    this.getOrderDetails();
+    this.getOrderPriorities();
+  }
+
+  async getOrderPriorities() {
+    try {
+      let idUser = localStorage.getItem('idusuario')!;
+      let priorities = await lastValueFrom(this._sysAdminService.getOrderPriorities(idUser, 1));
+
+      this.hasError = priorities.error;
+      this.errorStr = priorities.msg;
+
+      if (this.hasError) {
+        this.isLoading = false;
+      } else {
+        let orderPriorities: PriorityInterface[] = [];
+        for (const priority of priorities.response.order_priorities as PriorityInterface[]) {
+          let valEnc = await this._encService.encrypt(priority.value);
+          
+          priority.label = `${priority.label} (${priority.value})`;
+          priority.value = valEnc;
+
+          orderPriorities.push(priority);
+        }
+
+        this.orderPriorities = orderPriorities;
+        this.getOrderDetails();
+      }
+    } catch (error: any) {
+      this.errorStr = error?.error?.msg || 'Ocurrió un error inesperado.';
+      this.hasError = true;
+      this.isLoading = false;
+    }
   }
 
   async getOrderDetails() {
@@ -99,6 +131,15 @@ export class PreventiveOrderDetailsComponent implements OnInit {
             )!;
         }
 
+        // Process priority
+        let priorityDec = await this._encService.decrypt(order.response.PRIORIDAD);
+        for (const priority of this.orderPriorities) {
+          let valDec = await this._encService.decrypt(priority.value);
+          if (valDec == priorityDec) {
+            order.response.PRIORIDAD_OBJ = priority;
+          }
+        }
+
         // Process resources - handle both formats
         if (order.response.RECURSOS_ARR) {
           // Already comes as array

+ 15 - 0
src/app/components/template/notification-dialog/notification-dialog.component.ts

@@ -17,6 +17,7 @@ import { GdelService } from '../../../services/gdel.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 { PreventiveOrderDetailsComponent } from '../../preventive-maintenance/preventive-order-details/preventive-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';
@@ -151,6 +152,11 @@ export class NotificationDialogComponent implements OnInit {
           paramsArr[3]
         );
         break;
+      case 'openPreventiveWorkOrderDetails':
+        this.openPreventiveWorkOrderDetails(paramsArr[0]);
+        break;
+      case 'validatePreventiveWorkOrder':
+        break;
       default:
         this._resourcesService.openSnackBar(
           'La función seleccionada no existe.'
@@ -255,6 +261,15 @@ export class NotificationDialogComponent implements OnInit {
     });
   }
 
+  openPreventiveWorkOrderDetails(idOrder: string) {
+    this._dialog.open(PreventiveOrderDetailsComponent, {
+      width: '480px',
+      data: {
+        idOrder: idOrder,
+      },
+    });
+  }
+
   private validateCorrectiveWorkOrder(idOrder: string) {
     let dialogRef = this._dialog.open(StaffSelectionComponent, {
       disableClose: true,

+ 1 - 0
src/app/interfaces/preventive-maintenance.interface.ts

@@ -29,6 +29,7 @@ export interface PreventiveVisitDetails {
   DOCUMENTOS_RELACIONADOS_ARR?: PreventiveDocumentInfo[];
   RECURSOS_ARR?: string[];
   PERSONAL_ARR?: any[];
+  PRIORIDAD_OBJ?: any;
   FECHA_INICIO?: string;
   FECHA_FINAL?: string;
   DURACION_TOTAL?: number;