mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
226 lines
6.1 KiB
TypeScript
226 lines
6.1 KiB
TypeScript
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
|
|
import { NavigationStart, Router } from '@angular/router';
|
|
import { CalendarComponent } from 'ionic2-calendar';
|
|
import { customTask } from '../../../models/dailyworktask.model';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { ModalController } from '@ionic/angular';
|
|
import { PedidoPage } from 'src/app/pages/gabinete-digital/pedidos/pedido/pedido.page';
|
|
import { PedidosStore } from 'src/app/store/pedidos-store.service';
|
|
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
|
|
import { SortService } from 'src/app/services/functions/sort.service';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
|
|
@Component({
|
|
selector: 'app-pedidos',
|
|
templateUrl: './pedidos.page.html',
|
|
styleUrls: ['./pedidos.page.scss'],
|
|
})
|
|
export class PedidosPage implements OnInit {
|
|
|
|
//profile:string;
|
|
|
|
@ViewChild(CalendarComponent) myCal: CalendarComponent;
|
|
|
|
parecerList:any[] = [];
|
|
fulltask:any;
|
|
|
|
parecerListResult:customTask[] = [];
|
|
deferimentoListResult:customTask[] = [];
|
|
|
|
deferimentoList:any[] = [];
|
|
taskType: string;
|
|
|
|
@Input() serialNumber:string;
|
|
|
|
@Input() profile:string;
|
|
@Input() segment:string;
|
|
@Output() openPedido:EventEmitter<any> = new EventEmitter<any>();
|
|
skeletonLoader = true
|
|
pedidosstore = PedidosStore;
|
|
customTaskPipe = new CustomTaskPipe()
|
|
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
|
|
|
|
showSearch = false
|
|
searchSubject = ''
|
|
listPedidosParecer = []
|
|
listPedidosDeferimento = []
|
|
hideSearchBtn: boolean = false;
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private processes:ProcessesService,
|
|
private modalController: ModalController,
|
|
private sortService: SortService,
|
|
public ThemeService: ThemeService,
|
|
public TaskService: TaskService,
|
|
) {
|
|
this.profile = 'mdgpr';
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
this.router.events.forEach((event) => {
|
|
if(event instanceof NavigationStart && '/home/gabinete-digital?parecer=true'.startsWith(event.url) ||
|
|
event instanceof NavigationStart && '/home/gabinete-digital?deferimento=true'.startsWith(event.url) ||
|
|
event instanceof NavigationStart && '/home/gabinete-digital?pedidos=true'.startsWith(event.url)
|
|
) {
|
|
|
|
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.LoadList()
|
|
} else {
|
|
this.LoadList()
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
|
|
this.dynamicSearch()
|
|
|
|
}
|
|
|
|
|
|
async dynamicSearch() {
|
|
|
|
if(this.showSearch && this.searchSubject) {
|
|
|
|
this.listPedidosParecer = this.pedidosstore.listparecer.filter((task) => {
|
|
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
|
subject = subject.toLowerCase();
|
|
return subject.includes(this.searchSubject.toLowerCase())
|
|
})
|
|
|
|
|
|
this.listPedidosDeferimento = this.pedidosstore.listdeferimento.filter((task) => {
|
|
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
|
subject = subject.toLowerCase();
|
|
return subject.includes(this.searchSubject.toLowerCase())
|
|
})
|
|
|
|
} else {
|
|
|
|
this.listPedidosParecer = this.pedidosstore.listparecer
|
|
this.listPedidosDeferimento = this.pedidosstore.listdeferimento
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
openSearch() {
|
|
this.dynamicSearch()
|
|
}
|
|
async closeSearch() {
|
|
this.searchSubject = ''
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
async basicSearch() {
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
|
|
|
|
segmentChanged(ev: any) {
|
|
this.LoadList();
|
|
}
|
|
|
|
async LoadList() {
|
|
|
|
this.skeletonLoader = true;
|
|
|
|
if(this.segment == 'parecer') {
|
|
this.taskType = "Pedido de Parecer";
|
|
|
|
let parecer = [];
|
|
let parecerPr = [];
|
|
|
|
try {
|
|
parecer = await this.processes.GetTasksList("Pedido de Parecer", false).toPromise();
|
|
parecerPr = await this.processes.GetTasksList("Pedido de Parecer do Presidente", false).toPromise();
|
|
this.skeletonLoader = false
|
|
} catch (error) {
|
|
this.skeletonLoader = false
|
|
}
|
|
|
|
|
|
let allParecer = parecer.concat(parecerPr).reverse();
|
|
|
|
this.parecerList = new Array();
|
|
|
|
allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active").forEach(element => {
|
|
|
|
let task: customTask = this.customTaskPipe.transform(element);
|
|
this.parecerList.push(task);
|
|
|
|
});
|
|
|
|
this.pedidosstore.resetparecer(this.sortService.sortDate(this.parecerList, 'CreateDate'));
|
|
|
|
this.dynamicSearch()
|
|
|
|
}
|
|
else if(this.segment == 'deferimento') {
|
|
this.taskType = "Pedido de Deferimento";
|
|
this.processes.GetTasksList("Pedido de Deferimento", false).subscribe(result => {
|
|
|
|
this.skeletonLoader = false
|
|
|
|
this.deferimentoList = new Array();
|
|
let res = result.reverse().filter(data => data.workflowInstanceDataFields.Status == "Active")
|
|
|
|
res.forEach(element => {
|
|
let task: customTask = this.customTaskPipe.transform(element);
|
|
this.deferimentoList.push(task);
|
|
});
|
|
|
|
|
|
this.pedidosstore.resetdeferimento(this.sortService.sortDate(this.deferimentoList, 'CreateDate'));
|
|
this.dynamicSearch()
|
|
|
|
},() => {
|
|
this.skeletonLoader = false
|
|
});
|
|
}
|
|
this.skeletonLoader = false
|
|
}
|
|
|
|
doRefresh(event) {
|
|
if (event) {
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000);
|
|
}
|
|
|
|
goToPedido(serialNumber:any) {
|
|
this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']);
|
|
}
|
|
|
|
async viewPedidoDetail(serialNumber:any) {
|
|
|
|
const modal = await this.modalController.create({
|
|
component: PedidoPage,
|
|
componentProps:{
|
|
enterAnimation: "",
|
|
serialNumber: serialNumber,
|
|
profile: this.profile,
|
|
},
|
|
cssClass: 'modal modal-desktop',
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then((res)=>{
|
|
|
|
this.LoadList();
|
|
});
|
|
}
|
|
|
|
|
|
}
|