mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
271 lines
8.2 KiB
TypeScript
271 lines
8.2 KiB
TypeScript
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
|
|
import { ActivatedRoute, NavigationStart, Router } from '@angular/router';
|
|
import { CalendarComponent } from 'ionic2-calendar';
|
|
import { customTask, DailyWorkTask } from '../../../models/dailyworktask.model';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { Platform } from '@ionic/angular';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
import { PedidosStore } from 'src/app/store/pedidos-store.service';
|
|
import { ModalService } from 'src/app/services/modal.service';
|
|
|
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
|
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'
|
|
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
|
|
import { RouteService } from 'src/app/services/route.service';
|
|
|
|
|
|
@Component({
|
|
selector: 'app-pedidos',
|
|
templateUrl: './pedidos.page.html',
|
|
styleUrls: ['./pedidos.page.scss'],
|
|
})
|
|
export class PedidosPage implements OnInit {
|
|
|
|
@ViewChild(CalendarComponent) myCal: CalendarComponent;
|
|
|
|
taskslist: DailyWorkTask[] = [];
|
|
parecerList: any[] = [];
|
|
listToPresentparecerList: any[] = [];
|
|
listToPresentdeferimentoList: any[] = [];
|
|
fulltask: any;
|
|
|
|
parecerListResult: customTask[] = [];
|
|
deferimentoListResult: customTask[] = [];
|
|
|
|
deferimentoList: any[] = [];
|
|
taskType: string;
|
|
serialNumber: string;
|
|
skeletonLoader = true
|
|
pedidosstorage = PedidosStore;
|
|
customTaskPipe = new CustomTaskPipe()
|
|
|
|
segment: string;
|
|
@Output() openExpedientDetail: EventEmitter<any> = new EventEmitter<any>();
|
|
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
|
|
|
|
showSearch = false
|
|
searchSubject = ''
|
|
list = []
|
|
ordinance: string = 'old'
|
|
listPedidosParecer = []
|
|
listPedidosDeferimento = []
|
|
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private processes: ProcessesService,
|
|
private alertService: AlertService,
|
|
private activatedRoute: ActivatedRoute,
|
|
private modalService: ModalService,
|
|
private sqliteservice: SqliteService,
|
|
private sortService: SortService,
|
|
private backgroundservice: BackgroundService,
|
|
private platform: Platform,
|
|
public ThemeService: ThemeService,
|
|
public TaskService: TaskService,
|
|
private RouteService: RouteService,
|
|
) {
|
|
this.segment = 'parecer';
|
|
|
|
this.activatedRoute.queryParams.subscribe(params => {
|
|
if (params['deferimento'] == 'true') {
|
|
this.segment = 'deferimento';
|
|
} else if (params['parecer'] == 'true') {
|
|
this.segment = 'parecer';
|
|
}
|
|
});
|
|
|
|
const modal = this.modalService.BookMeetingModalPage({ task: '' }, {})
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
this.LoadList()
|
|
|
|
this.router.events.forEach((event) => {
|
|
if (event instanceof NavigationStart && '/home/gabinete-digital/pedidos?parecer=true'.startsWith(event.url) ||
|
|
event instanceof NavigationStart && '/home/gabinete-digital/pedidos?deferimento=true'.startsWith(event.url)
|
|
) {
|
|
|
|
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.refreshing()
|
|
} else {
|
|
this.LoadList()
|
|
}
|
|
}
|
|
});
|
|
|
|
this.backgroundservice.registerBackService('Online', () => {
|
|
this.getFromDb();
|
|
});
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
|
|
reorderList(orderBy: string) {
|
|
|
|
this.ordinance = orderBy;
|
|
|
|
this.dynamicSearch();
|
|
}
|
|
|
|
async dynamicSearch() {
|
|
|
|
if(this.showSearch && this.searchSubject) {
|
|
|
|
const listPedidosParecer = this.pedidosstorage.listparecer.filter((task) => {
|
|
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
|
subject = subject.toLowerCase();
|
|
return subject.includes(this.searchSubject.toLowerCase())
|
|
})
|
|
|
|
this.listPedidosParecer = this.TaskService.reorderList(this.ordinance, listPedidosParecer)
|
|
|
|
const listPedidosDeferimento = this.pedidosstorage.listdeferimento.filter((task) => {
|
|
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
|
subject = subject.toLowerCase();
|
|
return subject.includes(this.searchSubject.toLowerCase())
|
|
})
|
|
|
|
this.listPedidosDeferimento = this.TaskService.reorderList(this.ordinance, listPedidosDeferimento)
|
|
|
|
} else {
|
|
|
|
this.listPedidosParecer = this.TaskService.reorderList(this.ordinance, this.pedidosstorage.listparecer)
|
|
this.listPedidosDeferimento = this.TaskService.reorderList(this.ordinance, this.pedidosstorage.listdeferimento)
|
|
}
|
|
|
|
}
|
|
|
|
goBack() {
|
|
this.RouteService.goBack();
|
|
}
|
|
|
|
|
|
goToPedido(serialNumber: any) {
|
|
this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']);
|
|
}
|
|
|
|
notImplemented() {
|
|
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
|
}
|
|
|
|
openExpedientDetailPage(data) {
|
|
|
|
this.openExpedientDetail.emit(data);
|
|
}
|
|
|
|
async LoadList() {
|
|
|
|
//Retirar esta chamada posteriormente - Eudes
|
|
this.processes.GetTasksList("Pedido de Parecer", false).subscribe(async res => {
|
|
|
|
this.skeletonLoader = true
|
|
|
|
if (this.segment == 'parecer') {
|
|
this.taskType = "Pedido de Parecer";
|
|
|
|
let parecer = await this.processes.GetTasksList("Pedido de Parecer", false).toPromise();
|
|
let parecerPr = await this.processes.GetTasksList("Pedido de Parecer do Presidente", false).toPromise();
|
|
|
|
|
|
|
|
this.skeletonLoader = false
|
|
|
|
let allParecer = parecer.concat(parecerPr).reverse().filter(data => data.workflowInstanceDataFields.Status == "Active")
|
|
|
|
this.parecerList = [];
|
|
|
|
allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active").forEach(element => {
|
|
|
|
let date = new Date(element.taskStartDate);
|
|
const dateMonth = date.getMonth() + 1;
|
|
let month = date.getMonth() + 1;
|
|
let taskDate = date.getFullYear() + "-" + month + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
|
|
|
let task = this.customTaskPipe.transform(element);
|
|
this.parecerList.push(task);
|
|
});
|
|
// this.addPedidoToDb(this.parecerList);
|
|
|
|
this.listToPresentparecerList = this.sortService.sortDate(this.parecerList, 'CreateDate')
|
|
this.pedidosstorage.resetparecer(this.listToPresentparecerList);
|
|
|
|
}
|
|
else if (this.segment == 'deferimento') {
|
|
this.taskType = "Pedido de Deferimento";
|
|
this.processes.GetTasksList("Pedido de Deferimento", false).subscribe(result => {
|
|
|
|
this.skeletonLoader = false
|
|
|
|
|
|
|
|
this.deferimentoList = [];
|
|
|
|
let res = result.filter(data => data.workflowInstanceDataFields.Status == "Active")
|
|
res = res.reverse()
|
|
|
|
res.forEach(element => {
|
|
let date = new Date(element.taskStartDate);
|
|
//date.setMonth(date.getMonth() + 1);
|
|
let month = date.getMonth() + 1;
|
|
let taskDate = date.getFullYear() + "-" + month + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
|
|
|
let task = this.customTaskPipe.transform(element);
|
|
|
|
if (element.workflowInstanceDataFields.Status == "Active") {
|
|
this.deferimentoList.push(task);
|
|
}
|
|
});
|
|
this.listToPresentdeferimentoList = this.sortService.sortDate(this.deferimentoList, 'CreateDate')
|
|
this.pedidosstorage.resetdeferimento(this.listToPresentdeferimentoList);
|
|
});
|
|
|
|
}
|
|
|
|
this.dynamicSearch();
|
|
|
|
|
|
}, (error) => {
|
|
this.getFromDb()
|
|
})
|
|
|
|
}
|
|
|
|
// addPedidoToDb(pedido) {
|
|
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
// } else {
|
|
// this.sqliteservice.addProcess(pedido);
|
|
// }
|
|
// }
|
|
|
|
getFromDb() {
|
|
|
|
|
|
}
|
|
|
|
segmentChanged(ev: any) {
|
|
this.LoadList();
|
|
}
|
|
|
|
refreshing() {
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1500);
|
|
}
|
|
|
|
doRefresh(event) {
|
|
this.LoadList();
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
|
|
}
|