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

190 lines
5.2 KiB
TypeScript
Raw Normal View History

2022-06-24 15:26:15 +01:00
import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
import { ProcessesService } from 'src/app/services/processes.service';
2022-10-12 17:01:09 +01:00
import { Router } from '@angular/router';
2022-06-24 15:26:15 +01:00
import { ToastService } from 'src/app/services/toast.service';
import { ThemeService } from 'src/app/services/theme.service'
import { DespachoService } from 'src/app/Rules/despacho.service'
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 { customTask, fullTask } from 'src/app/models/dailyworktask.model';
2023-06-11 20:17:10 +01:00
import { RouteService } from 'src/app/services/route.service';
import { TaskService } from 'src/app/services/task.service'
2022-06-24 15:26:15 +01:00
@Component({
selector: 'app-diplomas-gerar-options',
templateUrl: './diplomas-gerar-options.page.html',
styleUrls: ['./diplomas-gerar-options.page.scss'],
})
export class DiplomasGerarOptionsPage implements OnInit {
task: customTask
fulltask: fullTask;
serialNumber: string;
constructor(
private processes: ProcessesService,
public popoverController: PopoverController,
private modalController: ModalController,
private toastService: ToastService,
public ThemeService: ThemeService,
private despachoService: DespachoService,
private navParams: NavParams,
private router: Router,
2023-06-11 20:17:10 +01:00
private RouteService: RouteService,
public TaskService: TaskService
2022-06-24 15:26:15 +01:00
) { }
ngOnInit() {
this.task = this.navParams.get('task')
this.fulltask = this.navParams.get('fulltask')
this.serialNumber = this.navParams.get('serialNumber')
}
async enviarDiploma({note = '', documents = [], serialnumber}) {
let classs;
if (window.innerWidth <= 800) {
classs = 'modal modal-desktop'
} else {
classs = 'add-note-modal-no-height'
}
const modal = await this.modalController.create({
component: AddNotePage,
componentProps: {
showAttachmentBtn: true,
2023-02-17 12:18:28 +01:00
actionName:false
2022-06-24 15:26:15 +01:00
},
cssClass: classs,
backdropDismiss: true
});
await modal.present();
modal.onDidDismiss().then(async (res) => {
if (res.data) {
const DocumentToSave = res.data.documents.map((e) => {
return {
ApplicationId: e.ApplicationType,
SourceId: e.Id,
}
});
let docs = {
ProcessInstanceID: "",
Attachments: DocumentToSave,
}
let body = {
"serialNumber": serialnumber,
"action": "Enviar diploma",
"ActionTypeId": 104,
"dataFields": {
"ReviewUserComment": res.data.note,
},
"AttachmentList" : docs,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise();
this.modalController.dismiss('sucess');
this.toastService._successMessage();
this.goBack()
} 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();
}
2022-06-24 15:26:15 +01:00
} finally {
loader.remove()
}
}
});
}
async sendExpedienteToPending() {
2022-07-15 12:01:14 +01:00
const loader = this.toastService.loading()
2022-06-24 15:26:15 +01:00
this.despachoService.sendExpedienteToPending(this.serialNumber).subscribe(res => {
this.goBack();
2023-02-03 14:37:29 +01:00
this.toastService._badRequest("Processo enviado para Pendentes")
2022-07-15 12:01:14 +01:00
loader.remove()
2022-06-24 15:26:15 +01:00
},
2023-02-03 14:37:29 +01:00
error => {
loader.remove()
if(error.status == 0) {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
this.toastService._badRequest("Processo não enviado para Pendentes")
}
});
2022-06-24 15:26:15 +01:00
}
async openBookMeetingModal() {
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,
},
cssClass: classs,
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
}
async openDelegarModal() {
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
});
await modal.present();
modal.onDidDismiss().then(res => {
if(res) {
const data = res.data;
if(data == 'close') {
this.goBack();
}
}
});
}
goBack() {
this.popoverController.dismiss();
2023-06-11 20:17:10 +01:00
this.RouteService.goBack();
this.TaskService.loadDespachos();
2022-06-24 15:26:15 +01:00
}
}