This commit is contained in:
Peter Maquiran
2024-02-28 09:04:11 +01:00
parent d851aff6ef
commit a5f458de2e
111 changed files with 7528 additions and 942 deletions
@@ -0,0 +1,398 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { CreateProcessPage } from 'src/app/modals/create-process/create-process.page';
import { DarParecerPage } from 'src/app/modals/dar-parecer/dar-parecer.page';
import { DelegarPage } from 'src/app/modals/delegar/delegar.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';
import { ToastService } from 'src/app/services/toast.service';
import { PedidoService } from 'src/app/Rules/pedido.service';
import { PermissionService } from 'src/app/services/permission.service';
import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page';
import { ForwardPage } from 'src/app/modals/forward/forward.page';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
@Component({
selector: 'app-request-options',
templateUrl: './request-options.page.html',
styleUrls: ['./request-options.page.scss'],
})
export class RequestOptionsPage implements OnInit {
task:any;
fulltask: any;
profile:string;
serialNumber : string;
showEnviarPendentes = false;
taskActions = [];
constructor(
private popoverController: PopoverController,
private modalController: ModalController,
private navParams: NavParams,
private processes: ProcessesService,
private activatedRoute: ActivatedRoute,
private toastService: ToastService,
public p: PermissionService,
private pedidoService: PedidoService,
private httpErrorHandle: HttpErrorHandle
) {
this.task = this.navParams.get('task');
this.fulltask = this.navParams.get('fulltask');
this.serialNumber = this.navParams.get('serialNumber');
this.taskActions = this.navParams.get('actions');
this.activatedRoute.queryParams.subscribe(params => {
if(params["serialNumber"]) {
this.serialNumber = params["serialNumber"];
//
}
});
if(this.task.serialNumber) {
this.serialNumber = this.task.serialNumber
} else if (this.task.SerialNumber) {
this.serialNumber = this.task.SerialNumber
}
this.showEnviarPendentes = this.navParams.get('showEnviarPendentes');
if(!this.showEnviarPendentes) this.showEnviarPendentes = false
}
ngOnInit() {
this.profile = "mdgpr";
window.onresize = (event) => {
if( window.innerWidth >= 800){
this.popoverController.dismiss();
}
};
}
checkStringInArray(str) {
return this.taskActions.includes(str);
}
close() {
this.popoverController.dismiss('close')
}
cancel(){
this.popoverController.dismiss();
}
sendExpedienteToPending() {
const loader = this.toastService.loading()
this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{
this.httpErrorHandle.httpsSucessMessagge('Enviar para Pendentes')
this.close();
loader.remove()
}, (error)=> {
loader.remove()
this.httpErrorHandle.httpStatusHandle(error)
});
}
async openBookMeetingModal(task: any) {
this.popoverController.dismiss();
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 openNewGroupPage(){
this.modalController.dismiss()
const modal = await this.modalController.create({
component: NewGroupPage,
cssClass: 'modal modal-desktop',
componentProps: {
name: this.task.Folio,
task: this.task,
documents: this.fulltask.Documents,
},
});
modal.onDidDismiss().then( () => {
this.popoverController.dismiss('close');
}, (error) => {
console.log(error)
});
await modal.present();
}
async newGroup(){
this.modalController.dismiss()
const modal = await this.modalController.create({
component: NewGroupPage,
cssClass: 'modal modal-desktop',
componentProps: {
name: this.task.Folio,
},
});
await modal.present();
modal.onDidDismiss().then(
()=>{},
(error) => {
console.log(error)
})
}
async openExpedientActionsModal(taskAction: any, task: any) {
//this.modalController.dismiss();
let classs;
if( window.innerWidth <= 800) {
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
this.modalController.dismiss()
const modal = await this.modalController.create({
component: CreateProcessPage,
componentProps: {
taskAction: taskAction,
task: task,
profile: this.profile,
fulltask: this.fulltask
},
cssClass: classs,
});
modal.onDidDismiss().then(res=> {
if(res['data']=='openDiscart') {
} else {
this.popoverController.dismiss('close')
}
}, (error) => {
console.log(error)
});
await modal.present();
}
async repreciar(note:string, documents:any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Reapreciação",
"ActionTypeId": 100000009,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.close();
this.httpErrorHandle.httpsSucessMessagge('Solicitar Reapreciação')
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error);
}
finally {
loader.remove()
}
}
async openAddNoteModal(actionName:string) {
let classs;
if( window.innerWidth <= 800){
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop'
}
this.modalController.dismiss()
const modal = await this.modalController.create({
component: AddNotePage,
componentProps:{
showAttachmentBtn: true,
actionName:actionName
},
cssClass: classs,
backdropDismiss: true
});
modal.onDidDismiss().then(async (res) => {
const DocumentToSave = res.data.documents.map((e) => {
return {
ApplicationId: e.ApplicationType,
SourceId: e.Id,
}
});
let docs = {
ProcessInstanceID: "",
Attachments: DocumentToSave,
}
if(res.data) {
if(actionName == 'Solicitar Reapreciação') {
await this.repreciar(res.data.note, docs);
}
else if(actionName == 'Arquivar') {
await this.arquivar(res.data.note, docs);
this.popoverController.dismiss('close')
}
}
}, (error) => {
console.log(error)
});
await modal.present();
}
async arquivar(note:string, documents:any) {
const loader = this.toastService.loading()
try {
await this.pedidoService.arquivar({serialNumber: this.serialNumber,
documents,
note
}).toPromise()
this.httpErrorHandle.httpsSucessMessagge('Arquivar')
} catch (error) {
this.httpErrorHandle.httpStatusHandle(error)
} finally {
loader.remove()
}
}
async openDarParecer(task: any) {
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: DarParecerPage,
componentProps: {
serialNumber: this.task.SerialNumber,
ProcessInstanceID: this.task.ProcessInstanceID,
},
cssClass: classs,
backdropDismiss: false
});
modal.onDidDismiss().then( () => {
this.popoverController.dismiss('close');
}, (error) => {
console.log(error)
});
await modal.present();
}
async openForwardModal(tasK: any) {
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: ForwardPage,
componentProps: {
task: this.task,
},
cssClass: classs,
backdropDismiss: false
});
modal.onDidDismiss().then(() => {
this.popoverController.dismiss('close');
}, (error) => {
console.log(error)
});
await modal.present();
}
async openDelegarModal(task: any) {
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( async (res)=> {
if(res['data']=='close') {
this.popoverController.dismiss('close');
}
}, (error) => {
console.log(error)
})
await modal.present();
}
}