This commit is contained in:
tiago.kayaya
2021-05-28 16:37:57 +01:00
parent 4face84ff4
commit bbb2af8cda
2 changed files with 146 additions and 69 deletions
@@ -18,6 +18,7 @@ import { SearchDocument } from 'src/app/models/search-document';
import { SearchPage } from 'src/app/pages/search/search.page'; import { SearchPage } from 'src/app/pages/search/search.page';
import { BadRequestComponent } from 'src/app/shared/popover/bad-request/bad-request.component'; 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 { SuccessMessageComponent } from 'src/app/shared/popover/success-message/success-message.component';
import { User } from 'src/app/models/user.model';
@Component({ @Component({
selector: 'app-create-process', selector: 'app-create-process',
@@ -58,6 +59,8 @@ export class CreateProcessPage implements OnInit {
showEmptyContainer = true; showEmptyContainer = true;
documents:SearchDocument[] = []; documents:SearchDocument[] = [];
loggeduser: User;
constructor( constructor(
private modalController: ModalController, private modalController: ModalController,
@@ -66,7 +69,10 @@ export class CreateProcessPage implements OnInit {
private attachmentsService: AttachmentsService, private attachmentsService: AttachmentsService,
private navParams: NavParams, private navParams: NavParams,
private alertController: AlertService, private alertController: AlertService,
private authService: AuthService) { private authService: AuthService,
private userAuth: AuthService,
) {
this.loggeduser = userAuth.ValidatedUser;
this.user = environment.defaultuser +'@'+ environment.domain; this.user = environment.defaultuser +'@'+ environment.domain;
this.task = this.navParams.get('task'); this.task = this.navParams.get('task');
@@ -80,9 +86,9 @@ export class CreateProcessPage implements OnInit {
Nad: 30, Nad: 30,
Subject: '', Subject: '',
Message: '', Message: '',
SourceSecFsId: this.task.workflowInstanceDataFields.FsId, //361 SourceSecFsId: this.task.workflowInstanceDataFields.SourceSecFsID, //361
SourceType: 'DOC', //FOLDER SourceType: 'DOC', //FOLDER
SourceId: this.task.workflowInstanceDataFields.DocIdD, //FolderId SourceId: this.task.workflowInstanceDataFields.SourceID, //FolderId
DeadlineType: '', DeadlineType: '',
SubjectTypes: ['99999844'], SubjectTypes: ['99999844'],
NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber, NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber,
@@ -153,74 +159,145 @@ export class CreateProcessPage implements OnInit {
}); });
this.dispatchFolder.SubjectTypes = this.selectedTypes; this.dispatchFolder.SubjectTypes = this.selectedTypes;
switch (this.loggeduser.Profile) {
if(this.taskParticipants.length > 0) { case 'MDGPR':
switch (this.taskType) { if(this.taskParticipants.length > 0) {
case '0': switch (this.taskType) {
this.postData = { case '0':
DistributionType: "Paralelo", this.postData = {
CountryCode: 'AO', DistributionType: "Paralelo",
Priority: this.postData.Priority, CountryCode: 'AO',
UserEmail: this.user, Priority: this.postData.Priority,
UsersSelected: attendees, UserEmail: this.user,
DispatchFolder: this.dispatchFolder, UsersSelected: attendees,
} DispatchFolder: this.dispatchFolder,
console.log('this.postData', this.postData, this.taskType); }
console.log('this.postData', this.postData, this.taskType);
try {
await this.processes.postDespatcho(this.postData).toPromise() try {
this.successMessage() await this.processes.postDespatcho(this.postData).toPromise()
} catch (error) { this.successMessage()
this.badRequest() } catch (error) {
} this.badRequest()
}
break;
case '1': break;
this.postData = { case '1':
DistributionType: "Paralelo", this.postData = {
CountryCode: 'AO', DistributionType: "Paralelo",
Priority: this.postData.Priority, CountryCode: 'AO',
UserEmail: this.user, Priority: this.postData.Priority,
UsersSelected: attendees, UserEmail: this.user,
DispatchFolder: this.dispatchFolder, UsersSelected: attendees,
} DispatchFolder: this.dispatchFolder,
console.log(this.postData); }
await this.processes.postParecer(this.postData).toPromise() console.log(this.postData);
await this.processes.postParecer(this.postData).toPromise()
try {
await this.processes.postParecer(this.postData).toPromise() try {
this.successMessage() await this.processes.postParecer(this.postData).toPromise()
} catch (error) { this.successMessage()
this.badRequest() } catch (error) {
} this.badRequest()
}
break;
case '2': break;
this.postData = { case '2':
DistributionType: "Paralelo", this.postData = {
CountryCode: 'AO', DistributionType: "Paralelo",
Priority: this.postData.Priority, CountryCode: 'AO',
UserEmail: this.user, Priority: this.postData.Priority,
UsersSelected: attendees, UserEmail: this.user,
DispatchFolder: this.dispatchFolder, UsersSelected: attendees,
} DispatchFolder: this.dispatchFolder,
console.log(this.postData); }
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 { break;
await this.processes.postDeferimento(this.postData).toPromise()
this.successMessage() case 'PR':
} catch (error) { switch (this.taskType) {
this.badRequest() 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(){ async executado(){
@@ -95,7 +95,7 @@ export class ExpedientTaskModalPage implements OnInit {
Message: '', Message: '',
SourceSecFsId: this.task.workflowInstanceDataFields.FsId, //361 SourceSecFsId: this.task.workflowInstanceDataFields.FsId, //361
SourceType: 'DOC', //FOLDER SourceType: 'DOC', //FOLDER
SourceId: this.task.workflowInstanceDataFields.DocId, //FolderId SourceId: this.task.workflowInstanceDataFields.DocIdD, //FolderId
DeadlineType: '', DeadlineType: '',
SubjectTypes: ['99999844'], SubjectTypes: ['99999844'],
NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber, NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber,