Files
doneit-web/src/app/shared/popover/desktop/dk-diplomas-gerar-options/dk-diplomas-gerar-options.page.ts
T
Peter Maquiran a5f458de2e dix bugs
2024-02-28 09:04:11 +01:00

210 lines
5.4 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
import { ProcessesService } from 'src/app/services/processes.service';
import { Router } from '@angular/router';
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';
import { RouteService } from 'src/app/services/route.service';
import { TaskService } from 'src/app/services/task.service'
@Component({
selector: 'app-dk-diplomas-gerar-options',
templateUrl: './dk-diplomas-gerar-options.page.html',
styleUrls: ['./dk-diplomas-gerar-options.page.scss'],
})
export class DkDiplomasGerarOptionsPage 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,
private RouteService: RouteService,
public TaskService: TaskService
) { }
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'
}
this.modalController.dismiss()
const modal = await this.modalController.create({
component: AddNotePage,
componentProps: {
showAttachmentBtn: true,
actionName:false
},
cssClass: classs,
backdropDismiss: true
});
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) {
if(error.status == 0) {
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
} else {
this.toastService._badRequest();
}
} finally {
loader.remove()
}
}
}, (error) => {
console.log(error)
});
await modal.present();
}
async sendExpedienteToPending() {
const loader = this.toastService.loading()
this.despachoService.sendExpedienteToPending(this.serialNumber).subscribe(res => {
this.goBack();
this.toastService._badRequest("Processo enviado para Pendentes")
loader.remove()
},
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")
}
});
}
async openBookMeetingModal() {
let classs;
if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
this.modalController.dismiss()
const modal = await this.modalController.create({
component: BookMeetingModalPage,
componentProps: {
task: this.task,
fulltask:this.fulltask
},
cssClass: classs,
backdropDismiss: false
});
modal.onDidDismiss().then(
()=>{},
(error) => {
console.log(error)
}
)
await modal.present();
}
async openDelegarModal() {
let classs;
if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
this.modalController.dismiss()
const modal = await this.modalController.create({
component: DelegarPage,
componentProps: {
task: this.task,
},
cssClass: classs,
backdropDismiss: false
});
modal.onDidDismiss().then(res => {
if(res) {
const data = res.data;
if(data == 'close') {
this.goBack();
}
}
}, (error) => {
console.log(error)
});
await modal.present();
}
goBack() {
this.popoverController.dismiss();
this.RouteService.goBack();
this.TaskService.loadDespachos();
}
}