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

397 lines
10 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';
2022-04-26 16:14:55 +01:00
import { ModalController, NavParams, 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';
2021-08-19 11:32:08 +01:00
import { customTask, fullTask } from 'src/app/models/dailyworktask.model';
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-02-27 09:34:36 +01:00
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
2023-03-22 15:31:01 +01:00
import { environment } from 'src/environments/environment';
2023-08-14 16:25:57 +01:00
import { TaskService } from 'src/app/services/task.service'
2021-05-27 14:33:17 +01:00
@Component({
selector: 'app-despachos-options',
templateUrl: './despachos-options.page.html',
styleUrls: ['./despachos-options.page.scss'],
})
export class DespachosOptionsPage implements OnInit {
2021-08-19 11:32:08 +01:00
task: customTask
fulltask: fullTask;
serialNumber: 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
2022-10-12 17:01:09 +01:00
constructor(
2021-05-27 14:33:17 +01:00
private processes: ProcessesService,
private modalController: ModalController,
public popoverController: PopoverController,
2021-06-15 15:09:20 +01:00
private navParams: NavParams,
2021-07-07 08:39:54 +01:00
private toastService: ToastService,
2021-08-24 14:07:27 +01:00
public p: PermissionService,
2021-11-18 14:07:04 +01:00
public ThemeService: ThemeService,
2022-01-06 14:47:22 +01:00
private RouteService: RouteService,
2023-02-27 09:34:36 +01:00
private httpErrorHandle: HttpErrorHandle,
2023-08-14 16:25:57 +01:00
public TaskService: TaskService
2022-03-28 15:46:07 +01:00
) {
2021-06-14 14:16:16 +01:00
this.task = this.navParams.get('task')
this.fulltask = this.navParams.get('fulltask')
2024-03-02 12:56:54 +01:00
console.log('is delegated ',this.fulltask.isDelegated )
this.isDelegated = this.fulltask.isDelegated;
2021-08-19 11:32:08 +01:00
this.serialNumber = this.task.SerialNumber
2021-06-14 14:16:16 +01:00
}
2021-05-27 14:33:17 +01:00
ngOnInit() {
}
2021-07-01 12:36:37 +01:00
async openTaskProcessModal(taskAction: any, task: any) {
2023-06-10 16:44:19 +01:00
2021-05-27 14:33:17 +01:00
let classs;
if( window.innerWidth <= 800){
classs = 'modal modal-desktop'
2021-07-07 08:39:54 +01:00
} else {
2021-05-27 14:33:17 +01:00
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: CreateProcessPage,
componentProps: {
taskAction: taskAction,
task: task,
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-23 14:17:32 +01:00
modal.onDidDismiss().then( res => {
2023-06-10 16:44:19 +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();
2021-05-27 14:33:17 +01:00
}
2022-07-15 12:01:14 +01:00
sendExpedienteToPending() {
const loader = this.toastService.loading()
2021-07-01 11:08:04 +01:00
this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpsSucessMessagge('Enviar para Pendentes')
2022-07-15 12:01:14 +01:00
loader.remove()
2022-04-28 09:32:27 +01:00
2023-06-10 16:44:19 +01:00
this.goBack('back');
2023-02-02 12:01:18 +01:00
},(error)=>{
2022-07-15 12:01:14 +01:00
loader.remove()
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpStatusHandle(error)
2021-05-27 14:33:17 +01:00
});
}
2022-03-28 15:46:07 +01:00
2023-06-10 17:49:13 +01:00
async distartExpedientModal() {
2023-06-10 16:44:19 +01:00
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
2023-07-15 11:01:09 +01:00
2021-05-27 14:33:17 +01:00
modal.onDidDismiss().then(res=>{
if(res['data']=='close'){
2023-06-10 16:44:19 +01:00
this.goBack('back');
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-05-27 14:33:17 +01:00
}
async openBookMeetingModal(task: any) {
2023-06-10 16:44:19 +01:00
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-06-10 16:44:19 +01:00
modal.onDidDismiss().then(() => {
this.goBack('no');
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2023-06-10 16:44:19 +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) {
2023-06-10 16:44:19 +01:00
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
});
2021-11-18 15:30:11 +01:00
modal.onDidDismiss().then(res => {
if(res){
const data = res.data;
if(data == 'close') {
2023-06-10 16:44:19 +01:00
this.goBack('back');
2021-11-18 15:30:11 +01:00
}
}
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-07-01 16:15:40 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-05-27 14:33:17 +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()
2023-06-10 16:44:19 +01:00
this.goBack('back');
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
}
}
async openAddNoteModal(actionName:string) {
2021-08-19 11:32:08 +01:00
2023-06-10 16:44:19 +01:00
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 11:32:08 +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-05-27 14:33:17 +01:00
await modal.present();
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-06-15 11:39:59 +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-12-06 15:09:59 +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
}
2023-06-10 16:44:19 +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-12-06 15:09:59 +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-12-06 15:09:59 +01:00
else if(actionName == 'Concluido') {
2023-08-14 16:25:57 +01:00
this.concluir(res.data.note, docs);
2021-05-27 14:33:17 +01:00
}
2021-12-06 15:09:59 +01:00
else if(actionName == 'Reexecução') {
2021-07-16 19:32:13 +01:00
await this.reexecutar(res.data.note, docs);
2021-05-27 14:33:17 +01:00
}
2023-06-10 16:44:19 +01:00
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
});
2022-03-28 15:46:07 +01:00
}
2021-05-27 14:33:17 +01:00
2023-08-14 16:25:57 +01:00
async concluir(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Arquivo",
"ActionTypeId": 95,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList": documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.httpErrorHandle.httpsSucessMessagge('Concluir Despacho')
this.TaskService.loadDiplomas()
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
}
finally {
loader.remove()
}
}
2021-06-15 11:39:59 +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-11-09 15:37:59 +01:00
this.toastService._successMessage('Processo arquivado')
2023-06-10 16:44:19 +01:00
this.goBack('back');
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('Processo não arquivado')
}
2021-07-12 11:13:29 +01:00
} finally {
loader.remove()
2021-05-27 14:33:17 +01:00
}
2022-03-28 15:46:07 +01:00
2021-05-27 14:33:17 +01:00
}
2023-06-10 17:49:13 +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-06-10 16:44:19 +01:00
this.goBack('back');
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
}
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()
2021-11-09 15:37:59 +01:00
this.toastService._successMessage()
2023-06-10 16:44:19 +01:00
this.goBack('back');
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
}
}
2023-06-10 16:44:19 +01:00
goBack(params) {
2023-06-10 20:17:51 +01:00
this.popoverController.dismiss(params)
2021-05-27 14:33:17 +01:00
}
}