diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts index 0fa3e84c7..1239d592d 100644 --- a/src/app/modals/create-process/create-process.page.ts +++ b/src/app/modals/create-process/create-process.page.ts @@ -18,6 +18,7 @@ import { SearchDocument } from 'src/app/models/search-document'; import { SearchPage } from 'src/app/pages/search/search.page'; import { BadRequestComponent } from 'src/app/shared/popover/bad-request/bad-request.component'; import { SuccessMessageComponent } from 'src/app/shared/popover/success-message/success-message.component'; +import { User } from 'src/app/models/user.model'; @Component({ selector: 'app-create-process', @@ -58,6 +59,8 @@ export class CreateProcessPage implements OnInit { showEmptyContainer = true; documents:SearchDocument[] = []; + + loggeduser: User; constructor( private modalController: ModalController, @@ -66,7 +69,10 @@ export class CreateProcessPage implements OnInit { private attachmentsService: AttachmentsService, private navParams: NavParams, private alertController: AlertService, - private authService: AuthService) { + private authService: AuthService, + private userAuth: AuthService, + ) { + this.loggeduser = userAuth.ValidatedUser; this.user = environment.defaultuser +'@'+ environment.domain; this.task = this.navParams.get('task'); @@ -80,9 +86,9 @@ export class CreateProcessPage implements OnInit { Nad: 30, Subject: '', Message: '', - SourceSecFsId: this.task.workflowInstanceDataFields.FsId, //361 + SourceSecFsId: this.task.workflowInstanceDataFields.SourceSecFsID, //361 SourceType: 'DOC', //FOLDER - SourceId: this.task.workflowInstanceDataFields.DocIdD, //FolderId + SourceId: this.task.workflowInstanceDataFields.SourceID, //FolderId DeadlineType: '', SubjectTypes: ['99999844'], NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber, @@ -153,74 +159,145 @@ export class CreateProcessPage implements OnInit { }); this.dispatchFolder.SubjectTypes = this.selectedTypes; - - if(this.taskParticipants.length > 0) { - switch (this.taskType) { - case '0': - this.postData = { - DistributionType: "Paralelo", - CountryCode: 'AO', - Priority: this.postData.Priority, - UserEmail: this.user, - UsersSelected: attendees, - DispatchFolder: this.dispatchFolder, - } - console.log('this.postData', this.postData, this.taskType); - - try { - await this.processes.postDespatcho(this.postData).toPromise() - this.successMessage() - } catch (error) { - this.badRequest() - } - - break; - case '1': - this.postData = { - DistributionType: "Paralelo", - CountryCode: 'AO', - Priority: this.postData.Priority, - UserEmail: this.user, - UsersSelected: attendees, - DispatchFolder: this.dispatchFolder, - } - console.log(this.postData); - await this.processes.postParecer(this.postData).toPromise() - - try { - await this.processes.postParecer(this.postData).toPromise() - this.successMessage() - } catch (error) { - this.badRequest() - } - - break; - case '2': - this.postData = { - DistributionType: "Paralelo", - CountryCode: 'AO', - Priority: this.postData.Priority, - UserEmail: this.user, - UsersSelected: attendees, - DispatchFolder: this.dispatchFolder, - } - console.log(this.postData); + switch (this.loggeduser.Profile) { + case 'MDGPR': + if(this.taskParticipants.length > 0) { + switch (this.taskType) { + case '0': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.user, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + } + console.log('this.postData', this.postData, this.taskType); + + try { + await this.processes.postDespatcho(this.postData).toPromise() + this.successMessage() + } catch (error) { + this.badRequest() + } + + break; + case '1': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.user, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + } + console.log(this.postData); + await this.processes.postParecer(this.postData).toPromise() + + try { + await this.processes.postParecer(this.postData).toPromise() + this.successMessage() + } catch (error) { + this.badRequest() + } + + break; + case '2': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.user, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + } + console.log(this.postData); + + try { + await this.processes.postDeferimento(this.postData).toPromise() + this.successMessage() + } catch (error) { + this.badRequest() + } + + break; + } + this.executado(); + this.modalController.dismiss(); + } + else { + this.alertController.presentAlert("Lista de intervenientes vazia. Por favor, adicione 1 ou mais intervenientes."); + } - try { - await this.processes.postDeferimento(this.postData).toPromise() - this.successMessage() - } catch (error) { - this.badRequest() + break; + + case 'PR': + switch (this.taskType) { + case '0': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.user, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + } + console.log('this.postData', this.postData, this.taskType); + + try { + await this.processes.postDespatcho(this.postData).toPromise() + this.successMessage() + } catch (error) { + this.badRequest() + } + + break; + case '1': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.user, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + } + console.log(this.postData); + await this.processes.postParecer(this.postData).toPromise() + + try { + await this.processes.postParecer(this.postData).toPromise() + this.successMessage() + } catch (error) { + this.badRequest() + } + + break; + case '2': + this.postData = { + DistributionType: "Paralelo", + CountryCode: 'AO', + Priority: this.postData.Priority, + UserEmail: this.user, + UsersSelected: attendees, + DispatchFolder: this.dispatchFolder, + } + console.log(this.postData); + + try { + await this.processes.postDeferimento(this.postData).toPromise() + this.successMessage() + } catch (error) { + this.badRequest() + } + + break; } + this.executado(); + this.modalController.dismiss(); + break; + } - break; - } - this.executado(); - this.modalController.dismiss(); - } - else { - this.alertController.presentAlert("Lista de intervenientes vazia. Por favor, adicione 1 ou mais intervenientes."); - } + } async executado(){ diff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts index 89667fe56..c716002fe 100644 --- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts @@ -95,7 +95,7 @@ export class ExpedientTaskModalPage implements OnInit { Message: '', SourceSecFsId: this.task.workflowInstanceDataFields.FsId, //361 SourceType: 'DOC', //FOLDER - SourceId: this.task.workflowInstanceDataFields.DocId, //FolderId + SourceId: this.task.workflowInstanceDataFields.DocIdD, //FolderId DeadlineType: '', SubjectTypes: ['99999844'], NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber,