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

389 lines
9.8 KiB
TypeScript
Raw Normal View History

2021-05-27 14:33:17 +01:00
import { Component, OnInit } from '@angular/core';
2022-04-26 16:14:55 +01:00
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
2021-05-27 14:33:17 +01:00
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 { ProcessesService } from 'src/app/services/processes.service';
2021-06-15 15:09:20 +01:00
import { ToastService } from 'src/app/services/toast.service';
2022-01-06 14:47:22 +01:00
import { RouteService } from 'src/app/services/route.service';
2022-04-01 15:12:18 +01:00
import { PermissionService } from 'src/app/services/permission.service';
2023-02-27 22:16:15 +01:00
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
import { CreateProcessPage } from 'src/app/modals/create-process/create-process.page';
import { AttachmentList } from 'src/app/models/Excludetask';
import { DespachoService } from 'src/app/Rules/despacho.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
2023-06-11 20:17:10 +01:00
import { TaskService } from 'src/app/services/task.service'
2021-05-27 14:33:17 +01:00
@Component({
selector: 'app-deploma-options',
templateUrl: './deploma-options.page.html',
styleUrls: ['./deploma-options.page.scss'],
})
2023-07-14 18:57:07 +01:00
export class DiplomaOptionsPage implements OnInit {
2021-05-27 14:33:17 +01:00
2021-08-13 11:57:12 +01:00
serialNumber: string;
2021-05-27 14:33:17 +01:00
profile: string;
task: any
fulltask: any
2023-07-21 10:12:55 +01:00
DraftIds = ""
DraftNames= ""
2021-05-27 14:33:17 +01:00
2022-04-01 15:12:18 +01:00
constructor(
public popoverController: PopoverController,
2021-05-27 14:33:17 +01:00
private modalController: ModalController,
2021-06-08 15:59:06 +01:00
private processes: ProcessesService,
2021-07-06 13:21:51 +01:00
private navParams: NavParams,
2021-06-28 15:49:59 +01:00
private toastService: ToastService,
2022-04-01 15:12:18 +01:00
private RouteService: RouteService,
2023-02-27 22:16:15 +01:00
public p: PermissionService,
private despachoService: DespachoService,
2023-06-11 20:17:10 +01:00
private httpErroHandle: HttpErrorHandle,
public TaskService: TaskService) {
2021-08-13 11:57:12 +01:00
this.serialNumber = this.navParams.get('serialNumber');
2021-08-11 10:52:31 +01:00
this.task = this.navParams.get('task');
this.fulltask = this.navParams.get('fulltask');
2023-07-21 10:12:55 +01:00
this.DraftIds = this.navParams.get("DraftIds");
this.DraftNames = this.navParams.get("DraftNames");
console.log('this.task', this.task)
2021-05-27 14:33:17 +01:00
}
ngOnInit() {
2023-05-26 14:23:37 +01:00
2021-05-27 14:33:17 +01:00
}
2021-08-11 10:52:31 +01:00
async openAddNoteModal(actionName:string) {
2023-07-15 11:01:09 +01:00
// this.popoverController.dismiss();
2021-05-27 14:33:17 +01:00
let classs;
2021-08-13 11:57:12 +01:00
if( window.innerWidth <= 800) {
2021-05-27 14:33:17 +01:00
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop'
}
const modal = await this.modalController.create({
component: AddNotePage,
componentProps:{
2023-02-17 12:18:28 +01:00
actionName:actionName
2021-05-27 14:33:17 +01:00
},
cssClass: classs,
backdropDismiss: true
});
2021-07-27 09:33:00 +01:00
2021-07-16 19:32:13 +01:00
modal.onDidDismiss().then(async (res) => {
2023-07-21 10:48:26 +01:00
if(res.data) {
2021-05-27 14:33:17 +01:00
2021-07-27 09:33:00 +01:00
2021-05-27 14:33:17 +01:00
const DocumentToSave = res.data.documents.map((e) => {
return {
ApplicationId: e.ApplicationType,
SourceId: e.Id,
}
});
2021-07-27 09:33:00 +01:00
2021-05-27 14:33:17 +01:00
let docs = {
ProcessInstanceID: "",
Attachments: DocumentToSave,
}
2021-08-11 17:05:37 +01:00
if(actionName == 'Solicitar assinatura') {
2021-07-16 19:32:13 +01:00
await this.askSignature(res.data.note, docs);
2021-05-27 14:33:17 +01:00
this.goBack();
2021-08-11 17:05:37 +01:00
} else if(actionName == 'Solicitar alteração') {
2021-07-16 19:32:13 +01:00
await this.askToChange(res.data.note, docs);
2021-05-27 14:33:17 +01:00
this.goBack();
2021-08-11 17:05:37 +01:00
} else if (actionName == 'Assinar Diploma') {
await this.sign(res.data.note, docs);
this.goBack();
2021-08-13 11:57:12 +01:00
} else if(actionName == 'Concluir diploma'){
await this.finish(res.data.note, docs);
this.goBack();
2023-02-27 22:16:15 +01:00
} else if (actionName == 'Arquivo') {
await this.arquivar(res.data.note, docs);
this.goBack();
2023-07-20 16:54:58 +01:00
} else if (actionName =='AssinarNew') {
2023-07-21 17:17:28 +01:00
await this.AssinarNew(res.data.note, docs)
2021-05-27 14:33:17 +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-08-11 10:52:31 +01:00
}
2021-05-27 14:33:17 +01:00
2021-08-11 10:52:31 +01:00
async askToChange(note:string, documents:any){
2021-07-27 09:33:00 +01:00
let body = {
2021-08-13 11:57:12 +01:00
"serialNumber": this.serialNumber,
2021-05-27 14:33:17 +01:00
"action": "Retificar",
"ActionTypeId": 99999841,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
2021-07-12 11:13:29 +01:00
const loader = this.toastService.loading()
2021-07-27 09:33:00 +01:00
2021-05-27 14:33:17 +01:00
try {
2021-05-28 15:45:41 +01:00
await this.processes.CompleteTask(body).toPromise()
2021-05-27 14:33:17 +01:00
this.close();
2021-11-09 15:37:59 +01:00
this.toastService._successMessage()
2021-05-27 14:33:17 +01:00
} 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
}
2021-07-12 11:13:29 +01:00
2021-05-27 14:33:17 +01:00
}
async openBookMeetingModal(task: any) {
2021-06-22 11:43:09 +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
});
await modal.present();
2023-07-14 10:19:33 +01:00
modal.onDidDismiss().then(
()=> {},
(error) => {
console.log(error)
}
)
2021-05-27 14:33:17 +01:00
}
2022-04-01 15:12:18 +01:00
2021-06-08 15:59:06 +01:00
async askSignature(note:string, documents:any) {
2021-07-27 09:33:00 +01:00
let body = {
2021-08-13 11:57:12 +01:00
"serialNumber": this.serialNumber,
2021-05-27 14:33:17 +01:00
"action": "Aprovar",
"ActionTypeId": 99999840,
"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-05-27 14:33:17 +01:00
this.close();
2021-11-09 15:37:59 +01:00
this.toastService._successMessage()
2021-05-27 14:33:17 +01:00
} 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
}
2021-07-27 09:33:00 +01:00
2022-04-01 15:12:18 +01:00
}
2021-05-27 14:33:17 +01:00
2021-08-11 17:05:37 +01:00
async sign(note:string, documents:any) {
let body = {
2021-08-13 11:57:12 +01:00
"serialNumber": this.serialNumber,
2021-08-11 17:05:37 +01:00
"action": "Assinado",
"ActionTypeId": 99999842,
2023-07-24 13:52:48 +01:00
"FolderId": this.task.FolderID,
2021-08-11 17:05:37 +01:00
"dataFields": {
"ReviewUserComment": note,
2023-07-20 16:54:58 +01:00
"InstanceIDNew": this.task.InstanceID,
2023-07-24 13:52:48 +01:00
"DraftIds": "",
2023-07-20 16:54:58 +01:00
},
"AttachmentList" : {
2023-07-24 13:52:48 +01:00
"ProcessInstanceID": this.task.InstanceID,
"DraftIds": null,
"Attachments": []
2021-08-11 17:05:37 +01:00
},
}
try {
await this.processes.CompleteTask(body).toPromise()
2023-07-21 17:28:15 +01:00
this.httpErroHandle.httpsSucessMessagge('Assinado')
2021-08-11 17:05:37 +01:00
} 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()
}
2023-07-23 21:24:34 +01:00
} finally {}
2021-08-11 17:05:37 +01:00
}
2023-07-21 17:17:28 +01:00
async AssinarNew(note, doc) {
2023-07-20 16:54:58 +01:00
let body = {
"InstanceId": this.task.InstanceID,
"FolderId": this.task.FolderID,
2023-07-21 10:12:55 +01:00
"DraftIds": this.DraftIds,
"OriginalFileName": this.DraftNames
2023-07-20 16:54:58 +01:00
}
const loader = this.toastService.loading()
try {
await this.processes.presidentialActionsSignature(body).toPromise()
2023-07-21 17:17:28 +01:00
await this.sign(note, doc)
2023-07-20 16:54:58 +01:00
this.TaskService.loadDiplomas()
2023-07-23 21:24:34 +01:00
this.goBack();
2023-07-20 16:54:58 +01:00
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
}
finally {
loader.remove()
}
}
2021-08-11 17:05:37 +01:00
2021-08-13 11:57:12 +01:00
async finish(note:string, documents:any){
let body = {
"serialNumber": this.serialNumber,
"action": "Concluir",
"ActionTypeId": 95,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise();
2021-11-09 15:37:59 +01:00
this.toastService._successMessage('Processo concluído')
2021-08-13 11:57:12 +01:00
} 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 {
2021-11-09 15:37:59 +01:00
this.toastService._badRequest()
2023-02-02 12:01:18 +01:00
}
2021-08-13 11:57:12 +01:00
}
finally {
loader.remove()
}
}
2023-02-27 22:16:15 +01:00
async arquivar(note: string, documents: AttachmentList) {
const loader = this.toastService.loading()
try {
await this.despachoService.arquivar(note, documents, this.serialNumber).toPromise()
this.httpErroHandle.httpsSucessMessagge('Arquivar')
this.close();
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
}
finally {
loader.remove()
}
}
async openExpedientActionsModal(taskAction: any, task: any) {
let classs;
if (window.innerWidth <= 800) {
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
2023-05-26 14:23:37 +01:00
2023-02-27 22:16:15 +01:00
const modal = await this.modalController.create({
component: CreateProcessPage,
componentProps: {
taskAction: taskAction,
task: task,
profile: this.profile,
fulltask: this.fulltask
},
cssClass: classs,
});
modal.onDidDismiss().then(async (res) => {
if (res['data'] == 'openDiscart') {
await this.distartExpedientModal();
}
this.goBack();
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2023-07-15 11:01:09 +01:00
}).catch(e => {
console.log(e)
})
await modal.present();
2023-02-27 22:16:15 +01:00
}
async distartExpedientModal() {
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
});
modal.onDidDismiss().then(res => {
if (res['data'] == 'close') {
this.close();
/*
this.close();
this.openMenu(); */
}
2023-07-15 11:01:09 +01:00
}, (error) => {
console.log(error)
}).catch(e => {
console.log(e)
})
await modal.present();
2023-02-27 22:16:15 +01:00
}
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-07-27 09:33:00 +01:00
2021-08-11 10:52:31 +01:00
close() {
2021-06-22 11:43:09 +01:00
this.popoverController.dismiss();
}
2021-05-27 14:33:17 +01:00
}