2021-04-29 13:58:52 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-06-08 15:59:06 +01:00
|
|
|
import { AnimationController, ModalController, NavParams } from '@ionic/angular';
|
2021-04-29 13:58:52 +01:00
|
|
|
import { Despacho } from 'src/app/models/despacho.model';
|
|
|
|
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
|
|
|
|
import { Participant } from 'src/app/models/participant.model';
|
|
|
|
|
import { Folder } from 'src/app/models/folder.model';
|
|
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
|
|
|
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
|
|
|
|
|
import { ExpedienteDetailPage } from 'src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page';
|
2021-08-20 12:02:27 +01:00
|
|
|
import { SearchList } from 'src/app/models/search-document';
|
2021-05-07 14:22:54 +01:00
|
|
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
2021-08-27 15:21:15 +01:00
|
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
2021-06-15 15:28:03 +01:00
|
|
|
import { AttendeesPageModal } from 'src/app/pages/events/attendees/attendees.page';
|
2021-06-14 13:48:02 +01:00
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
2021-07-05 16:12:08 +01:00
|
|
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
2021-06-24 11:08:17 +01:00
|
|
|
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
|
|
|
|
|
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
|
2021-08-05 11:47:09 +01:00
|
|
|
import { PermissionService } from 'src/app/OtherService/permission.service';
|
|
|
|
|
import { DespachoService } from 'src/app/Rules/despacho.service';
|
2021-08-05 16:09:09 +01:00
|
|
|
import { PedidoService } from 'src/app/Rules/pedido.service'
|
2021-08-19 11:32:08 +01:00
|
|
|
import { fullTask } from 'src/app/models/dailyworktask.model';
|
2021-06-24 11:08:17 +01:00
|
|
|
|
|
|
|
|
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
|
|
|
|
|
parse: {
|
|
|
|
|
dateInput: "YYYY-MMMM-DD HH:mm"
|
|
|
|
|
},
|
|
|
|
|
display: {
|
|
|
|
|
dateInput: "DD MMM YYYY H:mm",
|
|
|
|
|
monthYearLabel: "MMM YYYY",
|
|
|
|
|
dateA11yLabel: "LL",
|
|
|
|
|
monthYearA11yLabel: "MMMM YYYY"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-create-process',
|
|
|
|
|
templateUrl: './create-process.page.html',
|
|
|
|
|
styleUrls: ['./create-process.page.scss'],
|
2021-06-24 11:08:17 +01:00
|
|
|
providers: [
|
|
|
|
|
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
|
|
|
|
|
]
|
2021-04-29 13:58:52 +01:00
|
|
|
})
|
|
|
|
|
export class CreateProcessPage implements OnInit {
|
|
|
|
|
modalTitle: string[] = [
|
|
|
|
|
'Efectuar Despacho',
|
|
|
|
|
'Solicitar Parecer',
|
|
|
|
|
'Solicitar Deferimento'
|
|
|
|
|
];
|
|
|
|
|
taskType:string;
|
|
|
|
|
task: any;
|
2021-08-19 11:32:08 +01:00
|
|
|
fulltask: fullTask;
|
2021-04-29 13:58:52 +01:00
|
|
|
|
|
|
|
|
taskParticipants: any = [];
|
|
|
|
|
taskParticipantsCc: any = [];
|
|
|
|
|
|
|
|
|
|
taskDate: Date;
|
|
|
|
|
taskDescription: string;
|
|
|
|
|
loadedAttachments:any;
|
|
|
|
|
subjectTypes:any;
|
2021-05-07 15:27:31 +01:00
|
|
|
selectedTypes: string[]=[];
|
2021-04-29 13:58:52 +01:00
|
|
|
|
|
|
|
|
postData: Despacho;
|
|
|
|
|
dispatchFolder: Folder;
|
|
|
|
|
participants: Participant[];
|
|
|
|
|
|
|
|
|
|
contacts= [];
|
|
|
|
|
// trigger hide and show for attendee component
|
|
|
|
|
showAttendees= false;
|
|
|
|
|
|
|
|
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
|
profile: string;
|
|
|
|
|
|
2021-07-05 16:12:08 +01:00
|
|
|
Form: FormGroup;
|
|
|
|
|
validateFrom = false
|
|
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
emptyTextDescription = "Sem intervenientes selecionados";
|
|
|
|
|
showEmptyContainer = true;
|
|
|
|
|
|
2021-08-20 12:02:27 +01:00
|
|
|
documents:SearchList[] = [];
|
2021-05-28 16:37:57 +01:00
|
|
|
|
2021-08-27 15:21:15 +01:00
|
|
|
loggeduser: LoginUserRespose;
|
2021-06-23 15:39:45 +01:00
|
|
|
|
2021-06-24 11:08:17 +01:00
|
|
|
toppings = new FormControl();
|
|
|
|
|
|
|
|
|
|
toppingList: string[] = ['Economia', 'Saúde', 'Educação', 'Finanças', 'Agricultura'];
|
2021-06-23 15:39:45 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
constructor(
|
|
|
|
|
private modalController: ModalController,
|
|
|
|
|
private processes:ProcessesService,
|
|
|
|
|
private navParams: NavParams,
|
2021-05-28 16:37:57 +01:00
|
|
|
private authService: AuthService,
|
|
|
|
|
private userAuth: AuthService,
|
2021-06-08 15:59:06 +01:00
|
|
|
private animationController: AnimationController,
|
2021-06-14 13:48:02 +01:00
|
|
|
private toastService: ToastService,
|
2021-08-05 11:47:09 +01:00
|
|
|
public p: PermissionService,
|
2021-08-05 16:09:09 +01:00
|
|
|
private despachoService: DespachoService,
|
|
|
|
|
private pedidoService: PedidoService
|
2021-05-28 16:37:57 +01:00
|
|
|
) {
|
|
|
|
|
this.loggeduser = userAuth.ValidatedUser;
|
2021-04-29 13:58:52 +01:00
|
|
|
this.task = this.navParams.get('task');
|
|
|
|
|
|
2021-08-19 17:42:34 +01:00
|
|
|
if (this.task.SerialNumber) {
|
|
|
|
|
this.task.serialNumber = this.task.SerialNumber
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
this.taskType = this.navParams.get('taskAction');
|
|
|
|
|
|
|
|
|
|
this.postData = new Despacho();
|
|
|
|
|
this.participants = this.participants = new Array();
|
2021-06-14 14:04:00 +01:00
|
|
|
//Initialize SubjectTypes Array with the value "Indefinido"
|
|
|
|
|
this.selectedTypes = ['99999850'];
|
|
|
|
|
|
2021-08-13 16:49:51 +01:00
|
|
|
let NumberPDPP;
|
|
|
|
|
|
|
|
|
|
if(this.fulltask) {
|
|
|
|
|
if(this.fulltask.workflowInstanceDataFields) {
|
|
|
|
|
NumberPDPP = this.fulltask.workflowInstanceDataFields.DispatchNumber
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-17 11:15:49 +01:00
|
|
|
let SourceId;
|
|
|
|
|
let SourceType;
|
|
|
|
|
let SourceSecFsId;
|
|
|
|
|
|
2021-08-19 11:32:08 +01:00
|
|
|
if(this.task.workflowInstanceDataFields.FolderID || this.task.FolderId || this.task.FolderID) {
|
2021-08-17 11:15:49 +01:00
|
|
|
SourceId = this.task.workflowInstanceDataFields.FolderID
|
|
|
|
|
SourceType = 'FOLDER'
|
|
|
|
|
SourceSecFsId = 361
|
2021-08-17 12:31:22 +01:00
|
|
|
} else {
|
2021-08-17 11:15:49 +01:00
|
|
|
SourceId = this.task.workflowInstanceDataFields.SourceID
|
|
|
|
|
SourceType = 'DOC'
|
|
|
|
|
SourceSecFsId = 8
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
this.dispatchFolder = {
|
|
|
|
|
Nad: 30,
|
|
|
|
|
Subject: '',
|
|
|
|
|
Message: '',
|
2021-08-17 11:15:49 +01:00
|
|
|
SourceSecFsId: SourceSecFsId, //361
|
|
|
|
|
SourceType: SourceType, //FOLDER
|
|
|
|
|
SourceId: SourceId,
|
2021-04-29 13:58:52 +01:00
|
|
|
DeadlineType: '',
|
2021-06-14 14:04:00 +01:00
|
|
|
SubjectTypes: this.selectedTypes,
|
2021-08-13 16:49:51 +01:00
|
|
|
NumberPDPP: this.task.workflowInstanceDataFields.DispatchNumber || NumberPDPP
|
2021-04-29 13:58:52 +01:00
|
|
|
};
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
this.postData.DispatchFolder = this.dispatchFolder;
|
|
|
|
|
this.postData.UsersSelected = this.participants;
|
|
|
|
|
/* By Default TypeDeadline should be 'Normal' */
|
|
|
|
|
this.postData.Priority = '99999861';
|
|
|
|
|
/* Initialize 'Subject' with the title of the expedient */
|
|
|
|
|
this.postData.DispatchFolder.Subject = this.task.workflowInstanceDataFields.Subject;
|
|
|
|
|
this.profile = this.navParams.get('profile');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async setAdding(type: "intervenient" | "CC"){
|
|
|
|
|
this.adding = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-06-21 12:46:19 +01:00
|
|
|
this.getSubjectType();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.selectedTypes = ['99999850'];
|
|
|
|
|
}, 500);
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-07-22 10:39:55 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
this.taskDate = new Date(this.task.taskStartDate);
|
2021-06-14 13:48:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSelectedTypesChanged(ev:any){
|
|
|
|
|
console.log(ev);
|
|
|
|
|
if(ev.length > 1){
|
|
|
|
|
console.log(ev.filter(data => data != '99999850'));
|
|
|
|
|
this.selectedTypes = ev.filter(data => data != '99999850');
|
|
|
|
|
}
|
|
|
|
|
if(ev.length == 0){
|
|
|
|
|
this.selectedTypes = ["99999850"];
|
|
|
|
|
}
|
2021-04-29 13:58:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-24 11:08:17 +01:00
|
|
|
close() {
|
2021-05-28 09:29:18 +01:00
|
|
|
//this.router.navigate(['/home/gabinete-digital/expediente']);
|
2021-04-29 13:58:52 +01:00
|
|
|
this.modalController.dismiss(null);
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
getSubjectType() {
|
|
|
|
|
this.processes.GetSubjectType().subscribe(res=>{
|
|
|
|
|
this.subjectTypes = res;
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-08-05 16:09:09 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
cancelTask() {
|
|
|
|
|
this.modalController.dismiss(null);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-05 16:12:08 +01:00
|
|
|
runValidation() {
|
|
|
|
|
this.validateFrom = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
injectValidation() {
|
|
|
|
|
|
|
|
|
|
this.Form = new FormGroup({
|
|
|
|
|
Subject: new FormControl(this.postData.DispatchFolder.Subject, [
|
|
|
|
|
Validators.required,
|
|
|
|
|
// Validators.minLength(4)
|
|
|
|
|
]),
|
|
|
|
|
Message: new FormControl(this.postData.DispatchFolder.Message, [
|
|
|
|
|
Validators.required,
|
|
|
|
|
]),
|
|
|
|
|
Priority: new FormControl(this.postData.Priority, [
|
|
|
|
|
Validators.required,
|
|
|
|
|
]),
|
2021-07-08 13:41:27 +01:00
|
|
|
participantes: new FormControl(this.taskParticipants, [
|
2021-07-08 13:57:08 +01:00
|
|
|
Validators.required
|
2021-07-05 16:12:08 +01:00
|
|
|
]),
|
2021-07-06 11:27:45 +01:00
|
|
|
selectedTypes: new FormControl(this.selectedTypes, [
|
|
|
|
|
Validators.required,
|
|
|
|
|
]),
|
2021-07-05 16:12:08 +01:00
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-07-05 16:12:08 +01:00
|
|
|
async saveTask() {
|
|
|
|
|
|
2021-08-05 11:47:09 +01:00
|
|
|
if(!this.p.userRole(['PR'])) {
|
|
|
|
|
this.injectValidation()
|
|
|
|
|
this.runValidation()
|
|
|
|
|
if(this.Form.invalid) return false
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-06-09 14:45:36 +01:00
|
|
|
if(this.postData.Priority=='99999861') {
|
2021-04-29 13:58:52 +01:00
|
|
|
this.dispatchFolder.DeadlineType = 'Normal';
|
|
|
|
|
}
|
2021-06-09 14:45:36 +01:00
|
|
|
else if(this.postData.Priority=='99999862') {
|
2021-04-29 13:58:52 +01:00
|
|
|
this.dispatchFolder.DeadlineType = 'Urgente';
|
|
|
|
|
}
|
2021-06-09 14:45:36 +01:00
|
|
|
else if(this.postData.Priority=='99999863') {
|
2021-04-29 13:58:52 +01:00
|
|
|
this.dispatchFolder.DeadlineType = 'Muito Urgente';
|
|
|
|
|
}
|
2021-06-09 14:45:36 +01:00
|
|
|
else if(this.postData.Priority=='99999864') {
|
2021-04-29 13:58:52 +01:00
|
|
|
this.dispatchFolder.DeadlineType = 'Urgentíssimo';
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
let attendees = this.taskParticipants.concat(this.taskParticipantsCc);
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
attendees = attendees.map(function(val) {
|
|
|
|
|
return {
|
|
|
|
|
UserEmail: val.EmailAddress,
|
|
|
|
|
UserType: val.IsRequired?"I": "CC"
|
|
|
|
|
};
|
2021-05-07 15:27:31 +01:00
|
|
|
});
|
2021-04-29 13:58:52 +01:00
|
|
|
|
2021-06-28 10:49:33 +01:00
|
|
|
|
2021-05-07 14:22:54 +01:00
|
|
|
const DocumentToSave = this.documents.map((e) => {
|
|
|
|
|
return {
|
|
|
|
|
ApplicationId: e.ApplicationType,
|
|
|
|
|
SourceId: e.Id
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-07 15:27:31 +01:00
|
|
|
this.dispatchFolder.SubjectTypes = this.selectedTypes;
|
2021-07-09 19:27:08 +01:00
|
|
|
const loader = this.toastService.loading()
|
|
|
|
|
|
2021-05-28 16:37:57 +01:00
|
|
|
switch (this.loggeduser.Profile) {
|
|
|
|
|
case 'MDGPR':
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-07-05 15:37:27 +01:00
|
|
|
switch (this.taskType) {
|
2021-08-05 11:47:09 +01:00
|
|
|
case '0': // Despacho
|
2021-07-05 15:37:27 +01:00
|
|
|
this.postData = {
|
|
|
|
|
DistributionType: "Paralelo",
|
|
|
|
|
CountryCode: 'AO',
|
|
|
|
|
Priority: this.postData.Priority,
|
|
|
|
|
UserEmail: this.loggeduser.Email,
|
|
|
|
|
UsersSelected: attendees,
|
|
|
|
|
DispatchFolder: this.dispatchFolder,
|
|
|
|
|
}
|
|
|
|
|
console.log('this.postData', this.postData, this.taskType);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await this.processes.postDespatcho(this.postData).toPromise();
|
2021-08-25 10:02:12 +01:00
|
|
|
await this.despachoService.EfectuarDespacho({serialnumber: this.task.serialNumber}).toPromise();
|
|
|
|
|
|
2021-08-16 16:46:57 +01:00
|
|
|
this.modalController.dismiss();
|
2021-07-05 15:37:27 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
this.toastService.badRequest('Processo não efectuado');
|
2021-08-26 13:48:29 +01:00
|
|
|
|
|
|
|
|
} finally {
|
2021-08-05 11:47:09 +01:00
|
|
|
loader.remove()
|
2021-07-05 15:37:27 +01:00
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-07-05 15:37:27 +01:00
|
|
|
break;
|
2021-08-05 16:09:09 +01:00
|
|
|
case '1': // pedido de Parecer
|
2021-07-05 15:37:27 +01:00
|
|
|
this.postData = {
|
|
|
|
|
DistributionType: "Paralelo",
|
|
|
|
|
CountryCode: 'AO',
|
|
|
|
|
Priority: this.postData.Priority,
|
|
|
|
|
UserEmail: this.loggeduser.Email,
|
|
|
|
|
UsersSelected: attendees,
|
|
|
|
|
DispatchFolder: this.dispatchFolder,
|
|
|
|
|
}
|
|
|
|
|
console.log(this.postData);
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-07-05 15:37:27 +01:00
|
|
|
try {
|
2021-08-16 16:46:57 +01:00
|
|
|
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();
|
|
|
|
|
} else {
|
|
|
|
|
await this.pedidoService.createParecer(this.postData).toPromise();
|
|
|
|
|
await this.pedidoService.taskCompleteParecer({serialNumber:this.task.serialNumber}).toPromise();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-05 16:09:09 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
this.toastService.successMessage('Pedido de Parecer enviado');
|
2021-07-14 08:39:27 +01:00
|
|
|
}
|
2021-07-05 15:37:27 +01:00
|
|
|
catch (error) {
|
|
|
|
|
this.toastService.badRequest('Processo não efectuado');
|
2021-08-05 16:09:09 +01:00
|
|
|
} finally {
|
2021-08-05 11:47:09 +01:00
|
|
|
loader.remove()
|
2021-07-05 15:37:27 +01:00
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-07-05 15:37:27 +01:00
|
|
|
break;
|
2021-08-05 16:09:09 +01:00
|
|
|
case '2': // Pedido de Deferimento
|
2021-07-05 15:37:27 +01:00
|
|
|
this.postData = {
|
|
|
|
|
DistributionType: "Paralelo",
|
|
|
|
|
CountryCode: 'AO',
|
|
|
|
|
Priority: this.postData.Priority,
|
|
|
|
|
UserEmail: this.loggeduser.Email,
|
|
|
|
|
UsersSelected: attendees,
|
|
|
|
|
DispatchFolder: this.dispatchFolder,
|
2021-05-28 16:37:57 +01:00
|
|
|
}
|
2021-07-05 15:37:27 +01:00
|
|
|
console.log(this.postData);
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-07-05 15:37:27 +01:00
|
|
|
try {
|
2021-08-05 16:09:09 +01:00
|
|
|
await this.pedidoService.createDeferimento(this.postData).toPromise();
|
|
|
|
|
await this.pedidoService.taskCompleteDeferimento({serialNumber:this.task.serialNumber}).toPromise();
|
2021-08-17 13:04:30 +01:00
|
|
|
|
2021-08-05 16:09:09 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
this.toastService.successMessage('Pedido de Deferimento criado');
|
2021-07-05 15:37:27 +01:00
|
|
|
}
|
|
|
|
|
catch (error) {
|
|
|
|
|
this.toastService.badRequest('Processo não efectuado');
|
2021-08-05 16:09:09 +01:00
|
|
|
}
|
|
|
|
|
finally {
|
2021-08-05 11:47:09 +01:00
|
|
|
loader.remove()
|
2021-07-05 15:37:27 +01:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-05-28 16:37:57 +01:00
|
|
|
break;
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-05-28 16:37:57 +01:00
|
|
|
case 'PR':
|
|
|
|
|
switch (this.taskType) {
|
2021-08-05 16:09:09 +01:00
|
|
|
case '0': // Despacho PR
|
2021-07-17 11:07:01 +01:00
|
|
|
this.postData = {
|
|
|
|
|
DistributionType: "Paralelo",
|
|
|
|
|
CountryCode: 'AO',
|
|
|
|
|
Priority: this.postData.Priority,
|
|
|
|
|
UserEmail: this.loggeduser.Email,
|
|
|
|
|
UsersSelected: attendees,
|
|
|
|
|
DispatchFolder: this.dispatchFolder,
|
|
|
|
|
}
|
|
|
|
|
console.log('this.postData', this.postData, this.taskType);
|
|
|
|
|
|
|
|
|
|
try {
|
2021-08-05 11:47:09 +01:00
|
|
|
await this.despachoService.createDespacho(this.postData).toPromise();
|
|
|
|
|
await this.despachoService.CompleteTask({serialNumber: this.task.serialNumber}).toPromise();
|
2021-08-16 16:46:57 +01:00
|
|
|
|
2021-08-05 11:47:09 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
this.toastService.successMessage('Despacho criado');
|
2021-07-17 11:07:01 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
this.toastService.badRequest('Processo não efectuado');
|
2021-08-05 11:47:09 +01:00
|
|
|
} finally {
|
|
|
|
|
loader.remove()
|
2021-07-17 11:07:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2021-08-05 16:09:09 +01:00
|
|
|
case '1': // Pedido de Parecer
|
2021-07-17 11:07:01 +01:00
|
|
|
this.postData = {
|
|
|
|
|
DistributionType: "Paralelo",
|
|
|
|
|
CountryCode: 'AO',
|
|
|
|
|
Priority: this.postData.Priority,
|
|
|
|
|
UserEmail: this.loggeduser.Email,
|
|
|
|
|
UsersSelected: attendees,
|
|
|
|
|
DispatchFolder: this.dispatchFolder,
|
|
|
|
|
}
|
|
|
|
|
console.log(this.postData);
|
|
|
|
|
|
|
|
|
|
try {
|
2021-08-16 16:46:57 +01:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
} else {
|
|
|
|
|
await this.pedidoService.createParecer(this.postData).toPromise();
|
|
|
|
|
await this.pedidoService.taskCompleteParecer({serialNumber:this.task.serialNumber}).toPromise();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-05 16:09:09 +01:00
|
|
|
this.modalController.dismiss();
|
2021-07-17 11:07:01 +01:00
|
|
|
this.toastService.successMessage('Pedido de Parecer criado');
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
|
|
|
|
this.toastService.badRequest('Processo não efectuado');
|
2021-08-05 16:09:09 +01:00
|
|
|
} finally {
|
|
|
|
|
loader.remove()
|
2021-07-17 11:07:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2021-08-05 16:09:09 +01:00
|
|
|
case '2': // Pedido de Deferimento
|
2021-05-28 16:37:57 +01:00
|
|
|
this.postData = {
|
|
|
|
|
DistributionType: "Paralelo",
|
|
|
|
|
CountryCode: 'AO',
|
|
|
|
|
Priority: this.postData.Priority,
|
2021-06-28 10:49:33 +01:00
|
|
|
UserEmail: this.loggeduser.Email,
|
2021-05-28 16:37:57 +01:00
|
|
|
UsersSelected: attendees,
|
|
|
|
|
DispatchFolder: this.dispatchFolder,
|
|
|
|
|
}
|
|
|
|
|
console.log(this.postData);
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-05-28 16:37:57 +01:00
|
|
|
try {
|
2021-08-05 16:09:09 +01:00
|
|
|
await this.pedidoService.createDeferimento(this.postData).toPromise();
|
|
|
|
|
await this.pedidoService.taskCompleteDeferimento({serialNumber:this.task.serialNumber}).toPromise();
|
2021-08-16 16:46:57 +01:00
|
|
|
|
2021-08-05 16:09:09 +01:00
|
|
|
this.modalController.dismiss();
|
2021-06-14 13:48:02 +01:00
|
|
|
this.toastService.successMessage('Pedido de Deferimento criado');
|
2021-07-13 17:39:23 +01:00
|
|
|
}
|
2021-06-14 13:48:02 +01:00
|
|
|
catch (error) {
|
|
|
|
|
this.toastService.badRequest('Processo não efectuado');
|
2021-08-05 16:09:09 +01:00
|
|
|
} finally {
|
|
|
|
|
loader.remove()
|
2021-05-28 16:37:57 +01:00
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-05-28 16:37:57 +01:00
|
|
|
break;
|
2021-05-25 13:38:46 +01:00
|
|
|
}
|
2021-05-28 16:37:57 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2021-05-25 13:38:46 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
}
|
2021-06-14 13:48:02 +01:00
|
|
|
|
2021-06-14 14:28:10 +01:00
|
|
|
|
2021-07-14 08:39:27 +01:00
|
|
|
async FinalizarDespacho(loader: HTMLDivElement, message?) {
|
2021-06-21 15:51:08 +01:00
|
|
|
|
2021-06-18 15:40:31 +01:00
|
|
|
let body;
|
|
|
|
|
|
2021-07-13 17:39:23 +01:00
|
|
|
if(this.task.activityInstanceName =='Tarefa de Despacho' ||
|
2021-06-21 15:22:48 +01:00
|
|
|
this.task.activityInstanceName =='Reexecutar Despacho') {
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-06-18 15:40:31 +01:00
|
|
|
body = {
|
2021-07-13 17:39:23 +01:00
|
|
|
"serialNumber": this.task.serialNumber,
|
2021-06-15 13:42:47 +01:00
|
|
|
"action": "Conhecimento",
|
|
|
|
|
"ActionTypeId": 104,
|
|
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": '',
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :null,
|
2021-07-13 17:39:23 +01:00
|
|
|
}
|
2021-06-15 13:42:47 +01:00
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
else if(this.task.activityInstanceName =='Concluir Despacho' ||
|
2021-08-17 14:47:57 +01:00
|
|
|
this.task.activityInstanceName == 'Concluir Parecer' ||
|
|
|
|
|
this.task.activityInstanceName =='Concluir Deferimento' ||
|
|
|
|
|
this.task.activityInstanceName =='Reapreciar Deferimento' ||
|
|
|
|
|
this.task.activityInstanceName == 'Tarefa de Deferimento'
|
2021-06-21 15:22:48 +01:00
|
|
|
) {
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-06-18 15:40:31 +01:00
|
|
|
body = {
|
2021-07-13 17:39:23 +01:00
|
|
|
"serialNumber": this.task.serialNumber,
|
2021-06-15 13:42:47 +01:00
|
|
|
"action": "Despacho",
|
|
|
|
|
"ActionTypeId": 94,
|
|
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": '',
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :null,
|
2021-07-13 17:39:23 +01:00
|
|
|
}
|
2021-08-17 13:04:30 +01:00
|
|
|
|
|
|
|
|
} else {
|
2021-08-18 15:42:36 +01:00
|
|
|
console.log('unexpected activityInstanceName', this.task)
|
2021-06-18 15:40:31 +01:00
|
|
|
}
|
2021-08-17 13:04:30 +01:00
|
|
|
|
2021-06-21 15:51:08 +01:00
|
|
|
console.log(body);
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-06-18 15:40:31 +01:00
|
|
|
try {
|
2021-06-15 13:42:47 +01:00
|
|
|
await this.processes.CompleteTask(body).toPromise();
|
2021-06-21 15:22:48 +01:00
|
|
|
this.toastService.successMessage(message);
|
2021-06-18 15:40:31 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
this.toastService.badRequest('Processo não efectuado');
|
2021-07-14 08:39:27 +01:00
|
|
|
} finally {
|
|
|
|
|
loader.remove()
|
2021-06-15 13:42:47 +01:00
|
|
|
}
|
2021-06-18 15:40:31 +01:00
|
|
|
|
2021-06-14 14:28:10 +01:00
|
|
|
}
|
2021-05-17 09:44:24 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
async addParticipants() {
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
this.adding = "intervenient";
|
|
|
|
|
this.contacts = this.taskParticipants;
|
|
|
|
|
|
2021-06-15 11:39:59 +01:00
|
|
|
if(window.innerWidth <=800) {
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
this.showAttendees=false;
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
2021-06-15 15:28:03 +01:00
|
|
|
component: AttendeesPageModal,
|
2021-06-15 11:39:59 +01:00
|
|
|
componentProps: {
|
|
|
|
|
adding: this.adding,
|
|
|
|
|
taskParticipants: this.taskParticipants,
|
|
|
|
|
taskParticipantsCc: this.taskParticipantsCc
|
2021-04-29 13:58:52 +01:00
|
|
|
},
|
2021-08-25 10:40:17 +01:00
|
|
|
cssClass: 'modal attendee modal-desktop',
|
2021-04-29 13:58:52 +01:00
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
2021-06-15 11:39:59 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
await modal.present();
|
2021-06-15 11:39:59 +01:00
|
|
|
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-06-15 11:39:59 +01:00
|
|
|
if(data) {
|
|
|
|
|
data = data['data'];
|
|
|
|
|
|
|
|
|
|
const newAttendees: EventPerson[] = data['taskParticipants'];
|
|
|
|
|
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
|
|
|
|
|
|
|
|
|
|
this.setIntervenient(newAttendees);
|
|
|
|
|
this.setIntervenientCC(newAttendeesCC);
|
2021-04-29 13:58:52 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.showAttendees=true
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
async addParticipantsCc() {
|
|
|
|
|
|
|
|
|
|
this.adding = "CC";
|
|
|
|
|
this.contacts = this.taskParticipantsCc;
|
|
|
|
|
|
|
|
|
|
if(window.innerWidth <=800){
|
|
|
|
|
this.showAttendees=false;
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
2021-06-15 15:28:03 +01:00
|
|
|
component: AttendeesPageModal,
|
2021-06-15 11:39:59 +01:00
|
|
|
componentProps: {
|
|
|
|
|
adding: this.adding,
|
|
|
|
|
taskParticipants: this.taskParticipants,
|
|
|
|
|
taskParticipantsCc: this.taskParticipantsCc
|
2021-04-29 13:58:52 +01:00
|
|
|
},
|
2021-06-15 11:39:59 +01:00
|
|
|
cssClass: 'attendee',
|
2021-04-29 13:58:52 +01:00
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
2021-06-15 11:39:59 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
await modal.present();
|
2021-06-15 11:39:59 +01:00
|
|
|
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-06-15 11:39:59 +01:00
|
|
|
if(data) {
|
|
|
|
|
data = data['data'];
|
|
|
|
|
|
|
|
|
|
const newAttendees: EventPerson[] = data['taskParticipants'];
|
|
|
|
|
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
|
|
|
|
|
|
|
|
|
|
this.setIntervenient(newAttendees);
|
|
|
|
|
this.setIntervenientCC(newAttendeesCC);
|
2021-04-29 13:58:52 +01:00
|
|
|
}
|
|
|
|
|
});
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
} else {
|
|
|
|
|
this.showAttendees=true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async distartExpedientModal() {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: DiscartExpedientModalPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
serialNumber: this.task.serialNumber,
|
|
|
|
|
folderId: this.task.workflowInstanceDataFields.FolderID,
|
|
|
|
|
action: 'complete',
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'discart-expedient-modal',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then(res=>{
|
|
|
|
|
if(res['data']=='close'){
|
|
|
|
|
console.log('Expedient Discard closed');
|
|
|
|
|
this.modalController.dismiss(res['data'])
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async setContact(data:EventPerson[]) {
|
|
|
|
|
|
|
|
|
|
if(this.adding == "intervenient"){
|
|
|
|
|
this.taskParticipants = data;
|
|
|
|
|
} else if (this.adding == "CC") {
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
this.taskParticipantsCc = data;
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 16:05:05 +01:00
|
|
|
dynamicSetIntervenient({taskParticipants, taskParticipantsCc}){
|
|
|
|
|
this.taskParticipants = taskParticipants;
|
|
|
|
|
this.taskParticipantsCc = taskParticipantsCc;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
async setIntervenient(data) {
|
|
|
|
|
this.taskParticipants = data;
|
|
|
|
|
}
|
2021-07-13 17:39:23 +01:00
|
|
|
|
2021-04-29 13:58:52 +01:00
|
|
|
async setIntervenientCC(data) {
|
|
|
|
|
this.taskParticipantsCc = data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async closeComponent() {
|
|
|
|
|
this.showAttendees = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async viewExpedientDetail() {
|
|
|
|
|
console.log(this.profile);
|
|
|
|
|
|
|
|
|
|
let classs;
|
|
|
|
|
if( window.innerWidth <= 800){
|
2021-05-07 16:57:53 +01:00
|
|
|
classs = 'modal modal-desktop'
|
2021-04-29 13:58:52 +01:00
|
|
|
} else {
|
|
|
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ExpedienteDetailPage,
|
|
|
|
|
componentProps:{
|
|
|
|
|
serialNumber: this.task.serialNumber,
|
|
|
|
|
profile: this.profile,
|
|
|
|
|
},
|
|
|
|
|
cssClass: classs,
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
|
/* console.log('!refresh list'); */
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 14:22:54 +01:00
|
|
|
removeAttachment(index: number){
|
|
|
|
|
|
|
|
|
|
this.documents = this.documents.filter( (e, i) => index != i);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async getDoc(){
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: SearchPage,
|
|
|
|
|
cssClass: 'modal-width-100-width-background modal',
|
|
|
|
|
componentProps: {
|
|
|
|
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
|
|
|
|
showSearchInput: true,
|
|
|
|
|
select: true
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
|
if(res){
|
|
|
|
|
const data = res.data;
|
|
|
|
|
this.documents.push(data.selected);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-29 13:58:52 +01:00
|
|
|
|
2021-07-13 17:39:23 +01:00
|
|
|
}
|