From 64fb8f42a11abbb41256efb800ea4d0468d5c4e5 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Mon, 6 Sep 2021 12:14:21 +0100 Subject: [PATCH] save --- src/app/Rules/despacho.service.ts | 89 +++++++++++++------ .../create-process/create-process.page.ts | 27 +++--- 2 files changed, 74 insertions(+), 42 deletions(-) diff --git a/src/app/Rules/despacho.service.ts b/src/app/Rules/despacho.service.ts index d6356b8a2..2ff5130c4 100644 --- a/src/app/Rules/despacho.service.ts +++ b/src/app/Rules/despacho.service.ts @@ -32,7 +32,7 @@ export class DespachoService { public p: PermissionService, public LoaderService: LoaderService ) { } - + arquivar(note:string, documents:AttachmentList, serialnumber) { let body = { @@ -44,10 +44,10 @@ export class DespachoService { }, "AttachmentList" :documents, } - + return this.processes.CompleteTask(body) } - + // reencaminhar(note:string, documents:any, serialnumber) { // let body = { @@ -61,9 +61,9 @@ export class DespachoService { // } // return this.processes.CompleteTask(body) // } - + executado(note:string, documents:any , serialnumber) { - + let body = { "serialNumber": serialnumber, "action": "Conhecimento", @@ -77,30 +77,61 @@ export class DespachoService { return this.processes.CompleteTask(body) } - solicitarParecer({note ='', documents = [], serialnumber}) { - let body = { - "serialNumber": serialnumber, - "action": "Conhecimento", - "ActionTypeId": 92, - "dataFields": { - "ReviewUserComment": note, - }, - "AttachmentList" :documents, + solicitarParecer({note ='', documents = [], serialnumber, activityInstanceName}) { + let body; + if(activityInstanceName == 'Concluir Despacho' || activityInstanceName == 'Concluir Parecer' || activityInstanceName == 'Concluir Deferimento'){ + body = { + "serialNumber": serialnumber, + "action": "Parecer", + "ActionTypeId": 92, + "dataFields": { + "ReviewUserComment": note, + }, + "AttachmentList" :documents, + } + + } + else{ + body = { + "serialNumber": serialnumber, + "action": "Conhecimento", + "ActionTypeId": 92, + "dataFields": { + "ReviewUserComment": note, + }, + "AttachmentList" :documents, + } + } return this.processes.CompleteTask(body) } - EfectuarDespacho({note = '', documents = [], serialnumber}) { - let body = { - "serialNumber": serialnumber, - "action": "Conhecimento", - "ActionTypeId": 94, - "dataFields": { - "ReviewUserComment": note, - }, - "AttachmentList" :documents, + EfectuarDespacho({note = '', documents = [], serialnumber, activityInstanceName}) { + let body; + if(activityInstanceName == 'Concluir Despacho' || activityInstanceName == 'Concluir Parecer' || activityInstanceName == 'Concluir Deferimento'){ + body = { + "serialNumber": serialnumber, + "action": "Despacho", + "ActionTypeId": 94, + "dataFields": { + "ReviewUserComment": note, + }, + "AttachmentList" :documents, + } } + else{ + body = { + "serialNumber": serialnumber, + "action": "Conhecimento", + "ActionTypeId": 94, + "dataFields": { + "ReviewUserComment": note, + }, + "AttachmentList" :documents, + } + } + console.log(body); return this.processes.CompleteTask(body) } @@ -191,13 +222,13 @@ export class DespachoService { async getList({updateStore = false}): Promise | null { - + if (this.LoaderService.loading) { return this.despachoStore.list } this.LoaderService.push({}) - + let result: fullTaskList[] = [] let despachoList: customTask[] = []; @@ -205,18 +236,18 @@ export class DespachoService { result = await this.processes.GetTasksList("Despacho", false).toPromise(); result = result.filter((data:fullTaskList) => data.workflowInstanceDataFields.Status == "Active") result.forEach((element, index) => { - + let task: customTask = this.customTaskPipe.transform(element); despachoList.push(task); - + }); - + despachoList = this.sortArrayISODate(despachoList).reverse(); if(updateStore) { this.despachoStore.reset(despachoList); } - + } catch (error) { } finally { diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts index 2b27f0440..ddb43255c 100644 --- a/src/app/modals/create-process/create-process.page.ts +++ b/src/app/modals/create-process/create-process.page.ts @@ -120,7 +120,7 @@ export class CreateProcessPage implements OnInit { NumberPDPP = this.fulltask.workflowInstanceDataFields.DispatchNumber } } - + let SourceId; let SourceType; let SourceSecFsId; @@ -230,7 +230,7 @@ export class CreateProcessPage implements OnInit { this.runValidation() if(this.Form.invalid) return false } - + if(this.postData.Priority=='99999861') { this.dispatchFolder.DeadlineType = 'Normal'; @@ -279,15 +279,16 @@ export class CreateProcessPage implements OnInit { DispatchFolder: this.dispatchFolder, } console.log('this.postData', this.postData, this.taskType); + console.log(this.task.activityInstanceName); try { await this.processes.postDespatcho(this.postData).toPromise(); - await this.despachoService.EfectuarDespacho({serialnumber: this.task.serialNumber}).toPromise(); - + await this.despachoService.EfectuarDespacho({serialnumber: this.task.serialNumber, activityInstanceName: this.task.activityInstanceName}).toPromise(); + this.modalController.dismiss(); } catch (error) { this.toastService.badRequest('Processo não efectuado'); - + } finally { loader.remove() } @@ -307,12 +308,12 @@ export class CreateProcessPage implements OnInit { try { if(this.task.activityInstanceName == 'Tarefa de Despacho' || this.task.activityInstanceName == 'Reexecutar Despacho') { await this.despachoService.createParecer(this.postData).toPromise(); - await this.despachoService.solicitarParecer({ serialnumber: this.task.serialNumber}).toPromise(); + await this.despachoService.solicitarParecer({ serialnumber: this.task.serialNumber, activityInstanceName: this.task.activityInstanceName}).toPromise(); } else { await this.pedidoService.createParecer(this.postData).toPromise(); await this.pedidoService.taskCompleteParecer({serialNumber:this.task.serialNumber}).toPromise(); } - + this.modalController.dismiss(); this.toastService.successMessage('Pedido de Parecer enviado'); } @@ -340,7 +341,7 @@ export class CreateProcessPage implements OnInit { this.modalController.dismiss(); this.toastService.successMessage('Pedido de Deferimento criado'); - } + } catch (error) { this.toastService.badRequest('Processo não efectuado'); } @@ -368,7 +369,7 @@ export class CreateProcessPage implements OnInit { try { await this.despachoService.createDespacho(this.postData).toPromise(); await this.despachoService.CompleteTask({serialNumber: this.task.serialNumber}).toPromise(); - + this.modalController.dismiss(); this.toastService.successMessage('Despacho criado'); } catch (error) { @@ -393,7 +394,7 @@ export class CreateProcessPage implements OnInit { if(this.task.activityInstanceName == 'Tarefa de Despacho' || this.task.activityInstanceName == 'Reexecutar Despacho') { await this.despachoService.createParecer(this.postData).toPromise(); - await this.despachoService.solicitarParecer({ serialnumber: this.task.serialNumber}).toPromise(); + await this.despachoService.solicitarParecer({ serialnumber: this.task.serialNumber, activityInstanceName: this.task.activityInstanceName}).toPromise(); } else { await this.pedidoService.createParecer(this.postData).toPromise(); await this.pedidoService.taskCompleteParecer({serialNumber:this.task.serialNumber}).toPromise(); @@ -442,7 +443,7 @@ export class CreateProcessPage implements OnInit { async FinalizarDespacho(loader: HTMLDivElement, message?) { - + let body; if(this.task.activityInstanceName =='Tarefa de Despacho' || @@ -461,7 +462,7 @@ export class CreateProcessPage implements OnInit { else if(this.task.activityInstanceName =='Concluir Despacho' || this.task.activityInstanceName == 'Concluir Parecer' || this.task.activityInstanceName =='Concluir Deferimento' || - this.task.activityInstanceName =='Reapreciar Deferimento' || + this.task.activityInstanceName =='Reapreciar Deferimento' || this.task.activityInstanceName == 'Tarefa de Deferimento' ) { @@ -478,7 +479,7 @@ export class CreateProcessPage implements OnInit { } else { console.log('unexpected activityInstanceName', this.task) } - + console.log(body); try {