Procházet zdrojové kódy

request a search-notificaciones con respuesta, el formulario se modificó para adaptarse al request

EmilianoOrtiz před 4 týdny
rodič
revize
999d4e9718

+ 58 - 40
src/app/components/process-management/multicriteria-searches/multicriteria-searches.component.ts

@@ -1,6 +1,9 @@
 import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
 import { MatTableDataSource } from '@angular/material/table';
-import { FilterNotificate, FilterRequest } from '../../../interfaces/process-managementv/workflow-management.interface';
+import {
+  FilterNotificate,
+  FilterRequest,
+} from '../../../interfaces/process-managementv/workflow-management.interface';
 import { MatPaginator } from '@angular/material/paginator';
 import { MatSort } from '@angular/material/sort';
 import { ResourcesService } from '../../../services/resources.service';
@@ -12,10 +15,10 @@ import { SearchRequestComponent } from './search-request/search-request.componen
 import { SearchNotificateComponent } from './search-notificate/search-notificate.component';
 
 @Component({
-    selector: 'app-multicriteria-searches',
-    templateUrl: './multicriteria-searches.component.html',
-    styleUrl: './multicriteria-searches.component.css',
-    standalone: false
+  selector: 'app-multicriteria-searches',
+  templateUrl: './multicriteria-searches.component.html',
+  styleUrl: './multicriteria-searches.component.css',
+  standalone: false,
 })
 export class MulticriteriaSearchesComponent implements AfterViewInit {
   public isLoadingRequest: boolean;
@@ -26,7 +29,7 @@ export class MulticriteriaSearchesComponent implements AfterViewInit {
   public displayedColumnsRequest: Array<string>;
   @ViewChild('paginatorRequest') paginatorRequest!: MatPaginator;
   @ViewChild(MatSort) sortRequest!: MatSort;
-  
+
   public dataSourceNotificate: MatTableDataSource<any>;
   public displayedColumnsNotificate: Array<string>;
   @ViewChild('paginatorNotificate') paginatorNotificate!: MatPaginator;
@@ -37,7 +40,7 @@ export class MulticriteriaSearchesComponent implements AfterViewInit {
     public interService: InternationalizationService,
     private _dialog: MatDialog,
     private _encService: EncService,
-    private _router: Router,
+    private _router: Router
   ) {
     this.isLoadingRequest = false;
     this.isLoadingNotificate = false;
@@ -56,7 +59,7 @@ export class MulticriteriaSearchesComponent implements AfterViewInit {
       'FECHA_MODIFICA',
       'ACCIONES',
     ];
-    
+
     this.dataSourceNotificate = new MatTableDataSource<any>();
     this.displayedColumnsNotificate = [
       'ID_NOTIFICACION',
@@ -66,57 +69,72 @@ export class MulticriteriaSearchesComponent implements AfterViewInit {
       'ESTADO',
       'USUARIO_MODIFICA',
       'FECHA_MODIFICA',
-      'ACCIONES'
+      'ACCIONES',
     ];
   }
-  
+
   ngAfterViewInit(): void {
     this.dataSourceRequest.paginator = this.paginatorRequest;
     this.dataSourceRequest.sort = this.sortRequest;
-    
+
     this.dataSourceNotificate.paginator = this.paginatorNotificate;
     this.dataSourceNotificate.sort = this.sortNotificate;
   }
 
   public openSearchRequest() {
-    this._dialog.open(SearchRequestComponent, {
-      disableClose: true,
-      data: [],
-      width: '850px',
-      maxWidth: '850px',
-    }).afterClosed().subscribe((result: false | FilterRequest[]) => {
-      if (result !== false) {
-        this.isLoadingRequest = true;
-        this.dataSourceRequest.data = result;
-        this.isLoadingRequest = false;
-      }
-    });
+    this._dialog
+      .open(SearchRequestComponent, {
+        disableClose: true,
+        data: [],
+        width: '850px',
+        maxWidth: '850px',
+      })
+      .afterClosed()
+      .subscribe((result: false | FilterRequest[]) => {
+        if (result !== false) {
+          this.isLoadingRequest = true;
+          this.dataSourceRequest.data = result;
+          this.isLoadingRequest = false;
+        }
+      });
   }
 
   public async viewDetailsRequest(filterRequest: FilterRequest) {
     const ID_EXECUTE_TASK: string = filterRequest.ID_EJECUCION_TAREA.toString();
-    const ENC_EXECUTE_TASK: string = await this._encService.encrypt(ID_EXECUTE_TASK);
-    this._router.navigate([`/sam/GEPR/GFTR/BUMU/details-request/${ENC_EXECUTE_TASK}`])
+    const ENC_EXECUTE_TASK: string = await this._encService.encrypt(
+      ID_EXECUTE_TASK
+    );
+    this._router.navigate([
+      `/sam/GEPR/GFTR/BUMU/details-request/${ENC_EXECUTE_TASK}`,
+    ]);
   }
-  
+
   public openSearchNotificate() {
-    this._dialog.open(SearchNotificateComponent, {
-      disableClose: true,
-      data: [],
-      width: '500px',
-      maxWidth: '500px',
-    }).afterClosed().subscribe((result: false | FilterNotificate[]) => {
-      if (result) {
-        this.isLoadingNotificate = true;
-        this.dataSourceNotificate.data = result;
-        this.isLoadingNotificate = false;
-      }
-    });
+    this._dialog
+      .open(SearchNotificateComponent, {
+        disableClose: true,
+        data: [],
+        width: '500px',
+        maxWidth: '500px',
+      })
+      .afterClosed()
+      .subscribe((result: false | FilterNotificate[]) => {
+        if (result) {
+          console.log('Response from search notificaciones:', result);
+          this.isLoadingNotificate = true;
+          this.dataSourceNotificate.data = result;
+          this.isLoadingNotificate = false;
+        }
+      });
   }
 
   public async viewDetailsNotificate(filterNotificate: FilterNotificate) {
     const ID_NOTIFICATE: string = filterNotificate.ID_NOTIFICACION.toString();
-    const ENC_NOTIFICATE: string = await this._encService.encrypt(ID_NOTIFICATE);
-    this._router.navigate([`/sam/GEPR/GFTR/BUMU/details-notificate/${ENC_NOTIFICATE}`])
+    const ENC_NOTIFICATE: string = await this._encService.encrypt(
+      ID_NOTIFICATE
+    );
+    this._router.navigate([
+      `/sam/GEPR/GFTR/BUMU/details-notificate/${ENC_NOTIFICATE}`,
+    ]);
   }
 }

+ 11 - 31
src/app/components/process-management/multicriteria-searches/search-notificate/search-notificate.component.html

@@ -3,48 +3,28 @@
   <app-loading-card [isLoading]="isLoading" [txtLoading]="interService.get('cargando_informacion')"/>
   @if (!isLoading) {
     <form [formGroup]="formGroup" class="override_content_flex">
-      <div class="col-flex-12">
-        <mat-form-field appearance="outline" class="w-100">
-          <mat-label>{{ interService.get('numero_notificacion') }}</mat-label>
-          <input matInput type="number" formControlName="NUMERO_NOTIFICACION">
-          <mat-icon matSuffix>notifications</mat-icon>
-          @if (formGroup.controls['NUMERO_NOTIFICACION'].hasError('min')) {
-            <mat-error [title]="interService.get('el_campo')+' '+interService.get('numero_notificacion')+' '+interService.get('no_es_valido')">
-              {{ interService.get('el_campo') }} <b>{{ interService.get('numero_notificacion') }}</b> {{ interService.get('no_es_valido') }}
-            </mat-error>
-          }
-        </mat-form-field>
-      </div>
+
       <div class="col-flex-12">
         <mat-form-field appearance="outline" class="w-100">
           <mat-label>{{ interService.get('usuario_notificado') }}</mat-label>
-          <input type="text" matInput formControlName="USUARIO_NOTIFICADO" [matAutocomplete]="autoProcessWorkflow">
-          <mat-autocomplete autoActiveFirstOption #autoProcessWorkflow="matAutocomplete">
-            @for (user of filteredOptionsUser | async; track user) {
-              <mat-option [value]="user">{{ user }}</mat-option>
+          <mat-select formControlName="USUARIOS_NOTIFICADOS" multiple>
+            @for (user of arrUsers; track user.IDUSUARIO) {
+              <mat-option [value]="user.IDUSUARIO">
+                {{ user.NOMBRE }} {{ user.APEPAT }}{{ user.APEMAT ? ' ' + user.APEMAT : '' }} ({{ user.IDUSUARIO }})
+              </mat-option>
             }
-          </mat-autocomplete>
-          <mat-icon matSuffix>campaign</mat-icon>
-        </mat-form-field>
-      </div>
-      <div class="col-flex-12">
-        <mat-form-field appearance="outline" class="w-100">
-          <mat-label>{{ interService.get('tipo_notificacion') }}</mat-label>
-          <mat-select formControlName="TIPO_NOTIFICACION">
-            <mat-option value="V">De validación</mat-option>
-            <mat-option value="N">De notificación</mat-option>
           </mat-select>
-          <mat-icon matSuffix>circle_notifications</mat-icon>
+          <mat-icon matSuffix>campaign</mat-icon>
         </mat-form-field>
       </div>
+
       <div class="col-flex-12">
         <mat-form-field appearance="outline" class="w-100">
           <mat-label>{{ interService.get('estado_notifiación') }}</mat-label>
           <mat-select formControlName="ESTADO_NOTIFICACION">
-            <mat-option value="Notificado">Notificado</mat-option>
-            <mat-option value="En espera">En espera</mat-option>
-            <mat-option value="Aceptado">Aceptado</mat-option>
-            <mat-option value="Rechazado">Rechazado</mat-option>
+            @for (estado of estadosNotificacion; track estado) {
+              <mat-option [value]="estado">{{ estado }}</mat-option>
+            }
           </mat-select>
           <mat-icon matSuffix>rule</mat-icon>
         </mat-form-field>

+ 22 - 57
src/app/components/process-management/multicriteria-searches/search-notificate/search-notificate.component.ts

@@ -9,6 +9,7 @@ import { FilterNotificate, RequestNotificate, ResponseDataFilterNotificate } fro
 import { UsersProfilesService } from '../../../../services/users-profiles.service';
 import { ProcessManagementService } from '../../../../services/process-management/process-management.service';
 import { HttpErrorResponse } from '@angular/common/http';
+import { EncService } from '../../../../services/enc.service';
 
 @Component({
     selector: 'app-search-notificate',
@@ -21,8 +22,7 @@ export class SearchNotificateComponent implements OnInit {
   public isLoading: boolean;
 
   public arrUsers: UserResponse[];
-  public arrUsersStr: string[];
-  public filteredOptionsUser!: Observable<string[]>;
+  public estadosNotificacion = ['Leido', 'No leido'];
   
   constructor(
     public resourcesService: ResourcesService,
@@ -30,19 +30,17 @@ export class SearchNotificateComponent implements OnInit {
     private _dialogReg: MatDialogRef<false | FilterNotificate[]>,
     private _usersProfilesService: UsersProfilesService,
     private _processManagementService: ProcessManagementService,
+    private _encService: EncService,
   ) {
     this.formGroup = this._createFormGroup();
     this.isLoading = false;
 
     this.arrUsers = [];
-    this.arrUsersStr = [];
   }
 
   private _createFormGroup(): FormGroup {
     return new FormGroup({
-      NUMERO_NOTIFICACION: new FormControl(null, Validators.min(1)),
-      USUARIO_NOTIFICADO: new FormControl(null),
-      TIPO_NOTIFICACION: new FormControl(null),
+      USUARIOS_NOTIFICADOS: new FormControl([]),
       ESTADO_NOTIFICACION: new FormControl(null),
       FECHA_INICIO: new FormControl<Date | null>(null),
       FECHA_FINAL: new FormControl<Date | null>(null),
@@ -54,25 +52,21 @@ export class SearchNotificateComponent implements OnInit {
     await this._getUsers();
     this.isLoading = false;
 
-    this.filteredOptionsUser = this.formGroup.controls['USUARIO_NOTIFICADO'].valueChanges.pipe(
-      startWith(''),
-      map( value => {
-        value = value === null || value === undefined ? '' : value;
-        const filterValue = value.toLowerCase();
-        return this.arrUsersStr.filter(option => option.toLowerCase().includes(filterValue));
-      })
-    )
+
   }
 
   private async _getUsers() {
     const user: string = this.resourcesService.getUser();
     const line: number = this.resourcesService.getLineNumber();
     await lastValueFrom(this._usersProfilesService.getUsers(user, line)).then(
-      (responseData: UsersResponse) => {
+      async (responseData: UsersResponse) => {
         if (!responseData.error) {
+          for (let index = 0; index < responseData.response.length; index++) {
+            let element = responseData.response[index];
+            element.IDUSUARIO = await this._encService.decrypt(element.IDUSUARIO);
+            responseData.response[index] = element;
+          }
           this.arrUsers = responseData.response;
-          this.arrUsersStr = responseData.response.map((userResponse: UserResponse) => 
-            `${userResponse.NOMBRE} ${userResponse.APEPAT}${userResponse.APEMAT === null || userResponse.APEMAT === undefined || userResponse.APEMAT === '' ? '' : ` ${userResponse.APEMAT}` } (${userResponse.IDUSUARIO})`);
         } else {
           this.resourcesService.openSnackBar(`${responseData.msg}`);
         }
@@ -86,45 +80,18 @@ export class SearchNotificateComponent implements OnInit {
   }
 
   public async search() {
-    let numeroNotificacion = this.formGroup.controls['NUMERO_NOTIFICACION'].value;
-    if (numeroNotificacion !== null && numeroNotificacion !== undefined && numeroNotificacion !== '') {
-      numeroNotificacion = parseInt(numeroNotificacion);
-      if ( numeroNotificacion <= 0 ) {
-        this.resourcesService.openSnackBar(`Ocurrió un error con el formato del número de notificación.`);
-        return;
-      }
-      if (numeroNotificacion % 1 !== 0) {
-        this.resourcesService.openSnackBar(`El número de notificación debe ser un número entero.`);
-        return;
-      }
-    } else {
-      numeroNotificacion = null;
-    }
-
-    let usuarioNotificado = this.formGroup.controls['USUARIO_NOTIFICADO'].value;
-    if (usuarioNotificado !== null && usuarioNotificado !== undefined && usuarioNotificado !== '') {
-      usuarioNotificado = usuarioNotificado.toString().trim();
-      if ( !usuarioNotificado.includes('(') || !usuarioNotificado.includes(')') ) {
-        this.resourcesService.openSnackBar(`Debe elegir una opción de la lista desplegable en el campo del usuario notificado.`);
-        return;
-      }
-      usuarioNotificado = usuarioNotificado.split('(')[1].split(')')[0];
-    } else {
-      usuarioNotificado = null;
-    }
-
-    let tipoNotificacion = this.formGroup.controls['TIPO_NOTIFICACION'].value;
-    if (tipoNotificacion !== null && tipoNotificacion !== undefined && tipoNotificacion !== '') {
-      tipoNotificacion = tipoNotificacion.toString().trim();
+    let usuariosNotificados = this.formGroup.controls['USUARIOS_NOTIFICADOS'].value;
+    if (usuariosNotificados && usuariosNotificados.length > 0) {
+      usuariosNotificados = usuariosNotificados;
     } else {
-      tipoNotificacion = null;
+      usuariosNotificados = null;
     }
 
-    let estadoNotificacion = this.formGroup.controls['ESTADO_NOTIFICACION'].value;
-    if (estadoNotificacion !== null && estadoNotificacion !== undefined && estadoNotificacion !== '') {
-      estadoNotificacion = estadoNotificacion.toString().trim();
+    let estado = this.formGroup.controls['ESTADO_NOTIFICACION'].value;
+    if (estado !== null && estado !== undefined && estado !== '') {
+      estado = estado.toString().trim();
     } else {
-      estadoNotificacion = null;
+      estado = null;
     }
 
     let fechaInicio = this.formGroup.controls['FECHA_INICIO'].value;
@@ -154,12 +121,10 @@ export class SearchNotificateComponent implements OnInit {
     }
 
     const REQUEST_NOTIFICATE: RequestNotificate = {
-      'NUMERO_NOTIFICACION': numeroNotificacion,
-      'USUARIO_NOTIFICACION': usuarioNotificado,
-      'TIPO_NOTIFICACION': tipoNotificacion,
-      'ESTADO_NOTIFICACION': estadoNotificacion,
+      'USUARIOS_NOTIFICADOS': usuariosNotificados,
+      'ESTADO': estado,
       'FECHA_INICIO': fechaInicio,
-      'FECHA_FINAL': fechaFinal,
+      'FECHA_FIN': fechaFinal,
       'USUARIO': this.resourcesService.getUser(),
       'NUMERO_LINEA': this.resourcesService.getLineNumber(),
     }    

+ 4 - 6
src/app/interfaces/process-managementv/workflow-management.interface.ts

@@ -279,12 +279,10 @@ export interface DetailsRequest {
 }
 
 export interface RequestNotificate {
-  NUMERO_NOTIFICACION: number;
-  USUARIO_NOTIFICACION: string;
-  TIPO_NOTIFICACION: string;
-  ESTADO_NOTIFICACION: string;
-  FECHA_INICIO: string;
-  FECHA_FINAL: string;
+  USUARIOS_NOTIFICADOS: string[] | null;
+  ESTADO: string | null;
+  FECHA_INICIO: string | null;
+  FECHA_FIN: string | null;
   USUARIO: string;
   NUMERO_LINEA: number;
 }

+ 1 - 1
src/app/services/process-management/process-management.service.ts

@@ -235,7 +235,7 @@ export class ProcessManagementService {
     requestNotificate: RequestNotificate
   ): Observable<ResponseDataFilterNotificate> {
     return this._httpRequestService
-      .postQuery(`${this._url}/search-notificate`, requestNotificate)
+      .postQuery(`${this._url}/search-notificaciones`, requestNotificate)
       .pipe(map((data: any) => data));
   }
   public getDetailsNotificate(