mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
217 lines
6.0 KiB
TypeScript
217 lines
6.0 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
|
import { ModalController, NavParams, PopoverController } from '@ionic/angular';
|
|
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
|
|
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
|
|
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
@Component({
|
|
selector: 'app-opts-expediente',
|
|
templateUrl: './opts-expediente.page.html',
|
|
styleUrls: ['./opts-expediente.page.scss'],
|
|
})
|
|
export class OptsExpedientePage implements OnInit {
|
|
task:any;
|
|
fulltask: any;
|
|
profile:string;
|
|
caller:string;
|
|
|
|
showEnviarPendentes = false
|
|
|
|
constructor(
|
|
private popoverController: PopoverController,
|
|
private modalController: ModalController,
|
|
private navParams: NavParams,
|
|
private processes: ProcessesService,
|
|
private toastService: ToastService,
|
|
private router: Router,
|
|
private activatedRoute: ActivatedRoute,
|
|
) {
|
|
this.task = this.navParams.get('task');
|
|
this.fulltask = this.navParams.get('fulltask');
|
|
|
|
if(this.task.Status != 'Pending'){
|
|
this.showEnviarPendentes = true;
|
|
}
|
|
}
|
|
|
|
ngOnInit() {
|
|
window.onresize = (event) => {
|
|
if( window.innerWidth >= 800){
|
|
this.popoverController.dismiss();
|
|
}
|
|
};
|
|
}
|
|
|
|
close(){
|
|
if( window.innerWidth <= 1024){
|
|
this.popoverController.dismiss();
|
|
}
|
|
else{
|
|
this.modalController.dismiss();
|
|
}
|
|
}
|
|
|
|
goBack() {
|
|
if(this.task.Status == "Pending" && this.caller != 'events'){
|
|
if (window.innerWidth <= 800) {
|
|
this.router.navigate(['/home/gabinete-digital/pendentes']);
|
|
}
|
|
else {
|
|
let navigationExtras: NavigationExtras = {
|
|
queryParams: {
|
|
"pendentes": true,
|
|
}
|
|
}
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
}
|
|
}
|
|
else{
|
|
this.activatedRoute.paramMap.subscribe(params => {
|
|
switch (params["params"].caller) {
|
|
case 'events':
|
|
this.router.navigate(['/home',params["params"].caller]);
|
|
break;
|
|
|
|
case 'gabinete-digital':
|
|
let navigationExtras: NavigationExtras = {
|
|
queryParams: {
|
|
"expedientes": true,
|
|
}
|
|
}
|
|
if( window.innerWidth < 801) {
|
|
this.router.navigate(['/home/gabinete-digital/expediente']);
|
|
} else {
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
}
|
|
break;
|
|
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
sendExpedienteToPending() {
|
|
this.close();
|
|
this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{
|
|
this.goBack();
|
|
});
|
|
}
|
|
|
|
async openBookMeetingModal() {
|
|
this.close();
|
|
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 openExpedientActionsModal(taskAction: any, task: any) {
|
|
this.close();
|
|
let classs;
|
|
if( window.innerWidth <= 800){
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: ExpedientTaskModalPage,
|
|
componentProps: {
|
|
taskAction: taskAction,
|
|
task: task,
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then(res=>{
|
|
console.log(res['data']);
|
|
let body = res['data'];
|
|
if(res['data']){
|
|
console.log('open discart')
|
|
this.distartExpedientModal(body);
|
|
}
|
|
else{
|
|
console.log('Not open');
|
|
}
|
|
});
|
|
}
|
|
|
|
async distartExpedientModal(body:any){
|
|
const modal = await this.modalController.create({
|
|
component: DiscartExpedientModalPage,
|
|
componentProps: {
|
|
},
|
|
cssClass: 'discart-expedient-modal',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
modal.onDidDismiss().then( async (res)=>{
|
|
console.log(res['data']);
|
|
|
|
if(body == 'descartar'){
|
|
if(res['data']== 'Yes'){
|
|
let otherbody = {
|
|
"serialNumber": this.task.SerialNumber,
|
|
"action": "Passivo",
|
|
"ActionTypeId": 99999877,
|
|
"dataFields": {
|
|
"Note": "",
|
|
}
|
|
}
|
|
|
|
try {
|
|
await this.processes.CompleteTask(otherbody).toPromise()
|
|
this.toastService.successMessage('Processo descartado');
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest('Processo não descartado')
|
|
}
|
|
|
|
}
|
|
else if(res['data'] == 'No'){
|
|
//Do nothing
|
|
}
|
|
}
|
|
else{
|
|
if(res['data']== 'Yes'){
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise();
|
|
this.toastService.successMessage('Processo descartado');
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest('Processo não descartado')
|
|
}
|
|
this.goBack();
|
|
}
|
|
else if(res['data'] == 'No'){
|
|
console.log('Update');
|
|
try {
|
|
await this.processes.UpdateTaskStatus(this.task.FolderId).toPromise();
|
|
this.toastService.successMessage();
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest()
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|