|
|
@@ -1,7 +1,6 @@
|
|
|
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
|
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
|
import {
|
|
|
- ActivateWorkflow,
|
|
|
ChangeWorkflowStatusRequest,
|
|
|
GetWorkflows,
|
|
|
ResponseDataGetWorkflows,
|
|
|
@@ -135,9 +134,13 @@ export class WorkflowManagementComponent implements OnInit, AfterViewInit {
|
|
|
console.log('Llamando getWorkflowById para ID:', idWorkflow);
|
|
|
const user: string = this.resourcesService.getUser();
|
|
|
const line: number = this.resourcesService.getLineNumber();
|
|
|
-
|
|
|
+
|
|
|
await lastValueFrom(
|
|
|
- this._processManagementService.getWorkflowById(idWorkflow.toString(), user, line)
|
|
|
+ this._processManagementService.getWorkflowById(
|
|
|
+ idWorkflow.toString(),
|
|
|
+ user,
|
|
|
+ line
|
|
|
+ )
|
|
|
).then(
|
|
|
(responseData: ResponseDataWorkflow) => {
|
|
|
if (!responseData.error) {
|
|
|
@@ -160,47 +163,6 @@ export class WorkflowManagementComponent implements OnInit, AfterViewInit {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public alertActivateWorkflow(idWorkflow: number) {
|
|
|
- this._dialog
|
|
|
- .open(AlertComponent, {
|
|
|
- disableClose: true,
|
|
|
- data: {
|
|
|
- title: `${this.interService.get('confirmacion')}`,
|
|
|
- description: `${this.interService.get(
|
|
|
- 'register_workflow_description_alert'
|
|
|
- )}`,
|
|
|
- icon: `warning`,
|
|
|
- },
|
|
|
- })
|
|
|
- .afterClosed()
|
|
|
- .subscribe(async (result) => {
|
|
|
- if (result) {
|
|
|
- await this.activateWorkflow(idWorkflow);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private async activateWorkflow(idWorkflow: number) {
|
|
|
- const ACTIVATE_WORKFLOW: ActivateWorkflow = {
|
|
|
- ID_WORKFLOW: idWorkflow,
|
|
|
- USUARIO: this.resourcesService.getUser(),
|
|
|
- NUMERO_LINEA: this.resourcesService.getLineNumber(),
|
|
|
- };
|
|
|
- await lastValueFrom(
|
|
|
- this._processManagementService.activateWorkflow(ACTIVATE_WORKFLOW)
|
|
|
- ).then(
|
|
|
- async (responseData: ResponseData) => {
|
|
|
- if (!responseData.error) {
|
|
|
- await this.getWorkflows();
|
|
|
- } else {
|
|
|
- this.resourcesService.openSnackBar(`${responseData.msg}`);
|
|
|
- }
|
|
|
- },
|
|
|
- (httpErrorResponse) =>
|
|
|
- this.resourcesService.checkErrors(httpErrorResponse)
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
public goForm(element: GetWorkflows) {
|
|
|
this._dialog
|
|
|
.open(FormWorkflowComponent, {
|
|
|
@@ -220,52 +182,6 @@ export class WorkflowManagementComponent implements OnInit, AfterViewInit {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public alertRestore() {
|
|
|
- let dialogRef = this._dialog.open(AlertComponent, {
|
|
|
- disableClose: true,
|
|
|
- data: {
|
|
|
- title: this.interService.get('confirmacion'),
|
|
|
- description: this.interService.get('reset_description_alert'),
|
|
|
- icon: 'warning',
|
|
|
- },
|
|
|
- });
|
|
|
-
|
|
|
- dialogRef.afterClosed().subscribe((res) => {
|
|
|
- if (res) {
|
|
|
- this._restoreWorkflows();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private async _restoreWorkflows() {
|
|
|
- try {
|
|
|
- this.isLoading = true;
|
|
|
-
|
|
|
- const requestRestoreWorkflows: RequestUserNumberLine =
|
|
|
- this.resourcesService.objectUserLine();
|
|
|
- let response = await lastValueFrom(
|
|
|
- this._processManagementService.restoreWorkflows(requestRestoreWorkflows)
|
|
|
- );
|
|
|
-
|
|
|
- if (response.error) {
|
|
|
- this.resourcesService.openSnackBar(response.msg);
|
|
|
- this.isLoading = false;
|
|
|
- } else {
|
|
|
- this.getWorkflows();
|
|
|
- }
|
|
|
- } 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.isLoading = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public changeWorkflowStatus(element: GetWorkflows) {
|
|
|
this._dialog
|
|
|
.open(ChangeStatusWorkflowComponent, {
|
|
|
@@ -278,12 +194,20 @@ export class WorkflowManagementComponent implements OnInit, AfterViewInit {
|
|
|
.afterClosed()
|
|
|
.subscribe(async (result) => {
|
|
|
if (result) {
|
|
|
- await this._changeStatus(element.ID_WORKFLOW, result.newStatus, result.comentario);
|
|
|
+ await this._changeStatus(
|
|
|
+ element.ID_WORKFLOW,
|
|
|
+ result.newStatus,
|
|
|
+ result.comentario
|
|
|
+ );
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private async _changeStatus(idWorkflow: number, newStatus: string, comentario: string) {
|
|
|
+ private async _changeStatus(
|
|
|
+ idWorkflow: number,
|
|
|
+ newStatus: string,
|
|
|
+ comentario: string
|
|
|
+ ) {
|
|
|
this.isLoading = true;
|
|
|
const changeStatusRequest: ChangeWorkflowStatusRequest = {
|
|
|
ID_WORKFLOW: idWorkflow,
|
|
|
@@ -292,7 +216,7 @@ export class WorkflowManagementComponent implements OnInit, AfterViewInit {
|
|
|
USUARIO: this.resourcesService.getUser(),
|
|
|
NUMERO_LINEA: this.resourcesService.getLineNumber(),
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
await lastValueFrom(
|
|
|
this._processManagementService.changeWorkflowStatus(changeStatusRequest)
|
|
|
).then(
|
|
|
@@ -318,7 +242,7 @@ export class WorkflowManagementComponent implements OnInit, AfterViewInit {
|
|
|
this._dialog.open(WorkflowHistoryComponent, {
|
|
|
disableClose: true,
|
|
|
width: '700px',
|
|
|
- data: { idWorkflow }
|
|
|
+ data: { idWorkflow },
|
|
|
});
|
|
|
}
|
|
|
}
|