Files
doneit-web/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.ts
T

434 lines
11 KiB
TypeScript
Raw Normal View History

2021-05-27 14:33:17 +01:00
import { Component, OnInit } from '@angular/core';
import { ProcessesService } from 'src/app/services/processes.service';
2021-08-19 18:18:20 +01:00
import { ActivatedRoute, Router } from '@angular/router';
2021-08-19 12:52:26 +01:00
import { ModalController, PopoverController } from '@ionic/angular';
2021-05-27 14:33:17 +01:00
import { CreateProcessPage } from 'src/app/modals/create-process/create-process.page';
import { DelegarPage } from 'src/app/modals/delegar/delegar.page';
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
2021-06-15 15:09:20 +01:00
import { ToastService } from 'src/app/services/toast.service';
2022-03-28 15:46:07 +01:00
import { PermissionService } from 'src/app/services/permission.service';
2021-10-25 15:31:43 +01:00
import { ThemeService } from 'src/app/services/theme.service'
2022-01-06 14:47:22 +01:00
import { RouteService } from 'src/app/services/route.service';
2023-03-22 15:31:01 +01:00
import { environment } from 'src/environments/environment';
2023-05-29 15:19:13 +01:00
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { TaskService } from 'src/app/services/task.service'
2021-05-27 14:33:17 +01:00
@Component({
selector: 'app-despachos-pr-options',
templateUrl: './despachos-pr-options.page.html',
styleUrls: ['./despachos-pr-options.page.scss'],
})
export class DespachosPrOptionsPage implements OnInit {
task: any;
fulltask: any;
2021-08-19 17:42:34 +01:00
serialNumber: string;
2021-05-27 14:33:17 +01:00
profile: string
2023-03-22 15:31:01 +01:00
environment = environment
2024-03-02 12:56:54 +01:00
isDelegated: boolean;
2021-05-27 14:33:17 +01:00
constructor(private activateRoute: ActivatedRoute,
private processes: ProcessesService,
private router: Router,
private modalController: ModalController,
public popoverController: PopoverController,
2021-06-08 15:59:06 +01:00
private activatedRoute: ActivatedRoute,
2021-08-17 16:06:01 +01:00
private toastService: ToastService,
2022-01-06 14:47:22 +01:00
private RouteService: RouteService,
2021-08-18 16:35:23 +01:00
public p: PermissionService,
2021-11-18 14:07:04 +01:00
public ThemeService: ThemeService,
2023-05-29 15:19:13 +01:00
public TaskService: TaskService,
private httpErroHandle: HttpErrorHandle,
2021-08-18 16:35:23 +01:00
) { }
2021-05-27 14:33:17 +01:00
ngOnInit() {
2024-03-02 12:56:54 +01:00
console.log('is delegated', this.fulltask.isDelegated)
this.isDelegated = this.fulltask.isDelegated;
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
this.profile = "mdgpr";
this.activatedRoute.queryParams.subscribe(params => {
if(params["serialNumber"]) {
2021-08-19 17:42:34 +01:00
this.serialNumber = params["serialNumber"];
2022-04-28 09:32:27 +01:00
2021-05-27 14:33:17 +01:00
}
});
2021-08-19 17:42:34 +01:00
if(this.task.serialNumber) {
this.serialNumber = this.task.serialNumber
} else if(this.task.SerialNumber) {
this.serialNumber = this.task.SerialNumber
}
2021-05-27 14:33:17 +01:00
}
close () {
this.goBack()
}
async openExpedientActionsModal(taskAction: any, task: any) {
2021-06-22 16:18:14 +01:00
this.popoverController.dismiss();
2021-05-27 14:33:17 +01:00
let classs;
if( window.innerWidth <= 800){
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: CreateProcessPage,
componentProps: {
taskAction: taskAction,
task: task,
profile: this.profile,
2021-08-13 16:39:28 +01:00
fulltask: this.fulltask
2021-05-27 14:33:17 +01:00
},
cssClass: classs,
});
2023-07-15 11:01:09 +01:00
2021-08-18 12:05:27 +01:00
modal.onDidDismiss().then( (res)=> {
2022-04-28 09:32:27 +01:00
2021-08-18 12:05:27 +01:00
if(res['data']=='openDiscart') {
2022-04-28 09:32:27 +01:00
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
this.distartExpedientModal();
2021-08-19 18:29:25 +01:00
} else {
this.goBack()
2021-05-27 14:33:17 +01:00
}
2021-08-17 16:06:01 +01:00
this.popoverController.dismiss('close')
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-05-27 14:33:17 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-05-27 14:33:17 +01:00
}
2021-08-17 16:06:01 +01:00
sendExpedienteToPending() {
2022-07-15 12:01:14 +01:00
const loader = this.toastService.loading()
2021-08-19 17:42:34 +01:00
this.processes.SetTaskToPending(this.serialNumber).subscribe(res=>{
2022-04-28 09:32:27 +01:00
2023-05-29 15:19:13 +01:00
this.httpErroHandle.httpsSucessMessagge('Enviar para Pendentes')
2021-08-23 14:08:58 +01:00
this.popoverController.dismiss('close')
2022-07-15 12:01:14 +01:00
loader.remove()
2023-02-02 12:01:18 +01:00
},(error)=>{
2022-07-15 12:01:14 +01:00
loader.remove()
2023-02-02 12:01:18 +01:00
if(error.status == 0) {
2023-02-02 18:22:31 +01:00
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
2023-02-02 12:01:18 +01:00
} else {
this.toastService._badRequest('Processo não encontrado')
}
2021-05-27 14:33:17 +01:00
});
}
2022-03-28 15:46:07 +01:00
2021-08-18 12:05:27 +01:00
async distartExpedientModal() {
2021-06-22 16:18:14 +01:00
this.popoverController.dismiss();
2022-04-28 09:32:27 +01:00
2021-05-27 14:33:17 +01:00
const modal = await this.modalController.create({
component: DiscartExpedientModalPage,
componentProps: {
serialNumber: this.fulltask.serialNumber,
folderId: this.fulltask.workflowInstanceDataFields.FolderID,
action: 'complete',
},
cssClass: 'discart-expedient-modal',
backdropDismiss: false
});
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
modal.onDidDismiss().then(res=>{
if(res['data']=='close'){
this.close();
2022-04-28 09:32:27 +01:00
/*
2021-05-27 14:33:17 +01:00
this.close();
this.openMenu(); */
}
2021-08-17 16:06:01 +01:00
this.popoverController.dismiss('close')
2022-03-28 15:46:07 +01:00
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-05-27 14:33:17 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-05-27 14:33:17 +01:00
}
async openBookMeetingModal(task: any) {
2021-06-22 16:18:14 +01:00
this.popoverController.dismiss();
2021-05-27 14:33:17 +01:00
let classs;
if( window.innerWidth <= 800){
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: BookMeetingModalPage,
componentProps: {
task: this.task,
2023-08-30 19:59:39 +01:00
fulltask:this.fulltask
2021-05-27 14:33:17 +01:00
},
cssClass: classs,
backdropDismiss: false
});
2023-07-15 11:01:09 +01:00
2023-07-14 10:19:33 +01:00
modal.onDidDismiss().then(
()=> {},
(error) => {
console.log(error)
}
)
2021-08-19 18:29:25 +01:00
2023-07-15 11:01:09 +01:00
await modal.present();
2021-05-27 14:33:17 +01:00
}
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
async openDelegarModal(task: any) {
2021-06-22 16:18:14 +01:00
this.popoverController.dismiss();
2021-05-27 14:33:17 +01:00
let classs;
if( window.innerWidth <= 800){
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: DelegarPage,
componentProps: {
task: this.task,
},
cssClass: classs,
backdropDismiss: false
});
2023-07-15 11:01:09 +01:00
2021-11-18 15:30:11 +01:00
modal.onDidDismiss().then(res => {
2023-07-14 10:19:33 +01:00
if(res) {
2021-11-18 15:30:11 +01:00
const data = res.data;
if(data == 'close') {
this.goBack();
}
}
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-11-18 15:30:11 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-05-27 14:33:17 +01:00
}
2021-08-18 12:05:27 +01:00
async generateDiploma(note:string, documents:any) {
2022-03-28 15:46:07 +01:00
let body = {
"serialNumber": this.serialNumber,
2021-05-27 14:33:17 +01:00
"action": "Reencaminhar",
"ActionTypeId": 99999839,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
2021-07-12 11:13:29 +01:00
const loader = this.toastService.loading()
2021-05-27 14:33:17 +01:00
try {
2021-05-28 15:45:41 +01:00
await this.processes.CompleteTask(body).toPromise()
2021-11-09 15:37:59 +01:00
this.toastService._successMessage()
2021-05-27 14:33:17 +01:00
this.close();
} catch (error) {
2023-02-02 12:01:18 +01:00
if(error.status == 0) {
2023-02-02 18:22:31 +01:00
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
2023-02-02 12:01:18 +01:00
} else {
this.toastService._badRequest()
}
2021-07-12 11:13:29 +01:00
} finally {
loader.remove()
2021-05-27 14:33:17 +01:00
}
}
async openAddNoteModal(actionName:string) {
2021-06-22 16:18:14 +01:00
this.popoverController.dismiss();
2021-05-27 14:33:17 +01:00
let classs;
if( window.innerWidth <= 800){
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop'
}
const modal = await this.modalController.create({
component: AddNotePage,
2021-08-19 16:19:29 +01:00
componentProps: {
2023-02-17 12:18:28 +01:00
showAttachmentBtn: true,
actionName:actionName
2021-05-27 14:33:17 +01:00
},
cssClass: classs,
backdropDismiss: true
});
2022-03-28 15:46:07 +01:00
2021-07-16 19:32:13 +01:00
modal.onDidDismiss().then(async (res) => {
2022-04-28 09:32:27 +01:00
2021-05-27 14:33:17 +01:00
if(res.data){
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
const DocumentToSave = res.data.documents.map((e) => {
return {
ApplicationId: e.ApplicationType,
SourceId: e.Id,
}
});
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
let docs = {
ProcessInstanceID: "",
Attachments: DocumentToSave,
}
2021-08-20 12:02:27 +01:00
if(actionName == 'Executado') {
2021-07-16 19:32:13 +01:00
await this.executado(res.data.note, docs);
2021-05-27 14:33:17 +01:00
}
2021-08-20 12:02:27 +01:00
else if(actionName == 'Arquivar') {
2021-07-16 19:32:13 +01:00
await this.arquivar(res.data.note, docs);
2021-05-27 14:33:17 +01:00
}
2021-08-20 12:02:27 +01:00
else if(actionName == 'Gerar Diploma') {
2021-07-16 19:32:13 +01:00
await this.generateDiploma(res.data.note, docs);
2021-05-27 14:33:17 +01:00
}
2021-08-20 12:02:27 +01:00
else if(actionName == 'Reexecução') {
2021-07-16 19:32:13 +01:00
await this.reexecutar(res.data.note, docs);
2022-03-28 15:46:07 +01:00
}
2021-08-20 12:02:27 +01:00
else if(actionName == 'Concluido') {
2021-08-19 18:56:08 +01:00
await this.concluir(res.data.note, docs);
2021-05-27 14:33:17 +01:00
}
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
this.goBack();
}
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-05-27 14:33:17 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2022-03-28 15:46:07 +01:00
}
2021-05-27 14:33:17 +01:00
2021-08-19 18:56:08 +01:00
async concluir(note:string, documents:any){
let body = {
"serialNumber": this.serialNumber,
2023-08-14 16:25:57 +01:00
"action": "Arquivo",
"ActionTypeId": 95,
2021-08-19 18:56:08 +01:00
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
2023-06-10 14:17:41 +01:00
this.httpErroHandle.httpsSucessMessagge('Concluir Despacho')
2021-08-19 18:56:08 +01:00
this.close();
} catch (error) {
2023-02-02 12:01:18 +01:00
if(error.status == 0) {
2023-02-02 18:22:31 +01:00
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
2023-02-02 12:01:18 +01:00
} else {
this.toastService._badRequest()
}
2021-08-19 18:56:08 +01:00
}
finally {
loader.remove()
}
}
2021-05-27 14:33:17 +01:00
async arquivar(note:string, documents:any){
2022-03-28 15:46:07 +01:00
let body = {
"serialNumber": this.serialNumber,
2021-05-27 14:33:17 +01:00
"action": "Arquivo",
"ActionTypeId": 95,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
2021-07-12 11:13:29 +01:00
const loader = this.toastService.loading()
2021-05-27 14:33:17 +01:00
try {
2021-05-28 15:45:41 +01:00
await this.processes.CompleteTask(body).toPromise()
2021-06-15 15:09:20 +01:00
this.toastService.successMessage('Processo arquivado')
2021-05-27 14:33:17 +01:00
this.close();
} catch (error) {
2021-06-15 15:09:20 +01:00
this.toastService.badRequest('Processo não arquivado')
2021-07-12 11:13:29 +01:00
} finally {
loader.remove()
2021-05-27 14:33:17 +01:00
}
}
async executado(note:string, documents:any){
2022-03-28 15:46:07 +01:00
let body = {
"serialNumber": this.serialNumber,
2021-05-27 14:33:17 +01:00
"action": "Conhecimento",
"ActionTypeId": 104,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
2021-07-12 11:13:29 +01:00
const loader = this.toastService.loading()
2021-05-27 14:33:17 +01:00
try {
2021-05-28 15:45:41 +01:00
await this.processes.CompleteTask(body).toPromise()
2023-05-29 15:19:13 +01:00
this.httpErroHandle.httpsSucessMessagge('Executado')
2021-05-27 14:33:17 +01:00
this.close();
2021-06-15 15:09:20 +01:00
this.toastService.successMessage()
2021-05-27 14:33:17 +01:00
} catch(error) {
2021-06-15 15:09:20 +01:00
this.toastService.badRequest()
2021-07-12 11:13:29 +01:00
} finally {
loader.remove()
2021-05-27 14:33:17 +01:00
}
2021-07-12 11:13:29 +01:00
2021-05-27 14:33:17 +01:00
}
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
async reexecutar(note:string, documents:any){
2022-03-28 15:46:07 +01:00
let body = {
"serialNumber": this.serialNumber,
"action": "Reexecução",
2021-05-27 14:33:17 +01:00
"ActionTypeId": 100000010,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
2021-07-12 11:13:29 +01:00
const loader = this.toastService.loading()
2021-05-27 14:33:17 +01:00
try {
2021-05-28 15:45:41 +01:00
await this.processes.CompleteTask(body).toPromise()
2023-05-29 15:19:13 +01:00
this.httpErroHandle.httpsSucessMessagge('Reexecução')
2021-06-15 15:09:20 +01:00
this.toastService.successMessage()
2021-05-27 14:33:17 +01:00
this.close();
} catch (error) {
2021-06-15 15:09:20 +01:00
this.toastService.badRequest()
2021-07-12 11:13:29 +01:00
} finally {
loader.remove()
2021-05-27 14:33:17 +01:00
}
}
goBack() {
2022-01-06 14:47:22 +01:00
this.RouteService.goBack();
2023-06-11 20:17:10 +01:00
this.TaskService.loadDiplomas()
2021-05-27 14:33:17 +01:00
}
2021-08-19 12:52:26 +01:00
cancle() {
this.popoverController.dismiss()
}
2021-05-27 14:33:17 +01:00
}