mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
187 lines
6.9 KiB
TypeScript
187 lines
6.9 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { NavigationStart, Router } from '@angular/router';
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
|
|
import { DeplomasStore } from 'src/app/store/deplomas.service';
|
|
import { PendentesStore } from 'src/app/store/pendestes-store.service';
|
|
import { DespachoStore } from 'src/app/store/despacho-store.service';
|
|
import { TotalDocumentStore } from 'src/app/store/total-document.service';
|
|
import { DespachosprStore } from 'src/app/store/despachospr-store.service';
|
|
import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service';
|
|
import { PedidosStore } from 'src/app/store/pedidos-store.service';
|
|
import { SessionStore } from 'src/app/store/session.service';
|
|
|
|
|
|
@Component({
|
|
selector: 'app-all-processes',
|
|
templateUrl: './all-processes.page.html',
|
|
styleUrls: ['./all-processes.page.scss'],
|
|
})
|
|
export class AllProcessesPage implements OnInit {
|
|
|
|
skeletonLoader = false;
|
|
allProcessesList: any[] = [];
|
|
loggeduser: LoginUserRespose;
|
|
|
|
|
|
expedientegbstore = ExpedienteGdStore;
|
|
pendentesstore = PendentesStore;
|
|
despachoStore = DespachoStore;
|
|
eventoaprovacaostore = EventoAprovacaoStore;
|
|
pedidosstore = PedidosStore;
|
|
despachoprstore = DespachosprStore;
|
|
totalDocumentStore = TotalDocumentStore
|
|
deplomasStore = DeplomasStore
|
|
|
|
AllProcess = []
|
|
|
|
constructor(
|
|
private router: Router,
|
|
public ThemeService: ThemeService
|
|
) {
|
|
this.loggeduser = SessionStore.user;
|
|
|
|
window['all-process'] = () => {
|
|
if(window.location.href.includes('?processes=true')) {
|
|
this.updateAllProcess()
|
|
}
|
|
}
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.updateAllProcess()
|
|
|
|
this.router.events.forEach((event) => {
|
|
if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) {
|
|
if (window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.refreshing();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
doRefresh(event) {
|
|
if (event) {
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
setTimeout(() => {
|
|
this.updateAllProcess();
|
|
}, 1000);
|
|
}
|
|
|
|
refreshing() {
|
|
|
|
setTimeout(() => {
|
|
this.updateAllProcess();
|
|
}, 1000);
|
|
}
|
|
|
|
updateAllProcess = () => {
|
|
|
|
this.AllProcess = this.sortArrayISODate(this.despachoprstore.list.concat(this.deplomasStore.diplomasAssinadoList as any).concat(this.deplomasStore.diplomasParaAssinarList as any).concat(this.deplomasStore.DiplomaGerarList as any)
|
|
.concat(this.eventoaprovacaostore.contactList as any).concat(this.expedientegbstore.list as any).concat(this.despachoStore.list as any).concat(this.pedidosstore.listparecer as any).concat(this.pedidosstore.listdeferimento as any)
|
|
.concat(this.pendentesstore.list as any)).reverse()
|
|
}
|
|
|
|
get getAllProcessCount() {
|
|
return this.AllProcess.length
|
|
}
|
|
|
|
sortArrayISODate(myArray: any): any[] {
|
|
// return myArray.sort(function (a, b) {
|
|
// return (a.CreateDate || a.taskStartDate < b.CreateDate || b.taskStartDate) ? -1 : ((a.CreateDate || a.taskStartDate > b.CreateDate || b.taskStartDate) ? 1 : 0);
|
|
// });
|
|
|
|
return myArray.sort((a,b) => Date.parse(b.CreateDate || b.taskStartDate) - Date.parse(a.CreateDate || a.taskStartDate))
|
|
}
|
|
|
|
setFormatDate(start: any, end: any, allday: boolean) {
|
|
let customDate;
|
|
|
|
const totalSeconds = Math.floor((end - (start)) / 1000);;
|
|
const totalMinutes = Math.floor(totalSeconds / 60);
|
|
const totalHours = Math.floor(totalMinutes / 60);
|
|
const totalDays = Math.floor(totalHours / 24);
|
|
|
|
const hours = totalHours - (totalDays * 24);
|
|
const minutes = totalMinutes - (totalDays * 24 * 60) - (hours * 60);
|
|
const seconds = totalSeconds - (totalDays * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60);
|
|
|
|
|
|
if (totalDays == 0) {
|
|
if (allday) {
|
|
customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " (todo dia)";
|
|
|
|
return customDate;
|
|
}
|
|
else {
|
|
//customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+" ("+minutes+" mins)";
|
|
customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " | " + this.getCustomHours(end);
|
|
return customDate;
|
|
}
|
|
}
|
|
else {
|
|
customDate = this.getCustomDate(start) + "," + this.getCustomHours(start) +
|
|
" (termina:" + this.getCustomDate(end) + "," + this.getCustomHours(end) + ")";
|
|
return customDate;
|
|
}
|
|
}
|
|
|
|
getCustomDate(thedate: Date) {
|
|
return (thedate.getDay() + 1) + "/" +
|
|
(thedate.getMonth() + 1) + "/" +
|
|
thedate.getFullYear();
|
|
}
|
|
getCustomHours(thedate: Date) {
|
|
return thedate.getHours() + ":" +
|
|
thedate.getMinutes();
|
|
}
|
|
|
|
goToProcess(serialNumber: string, workflowName: string, activityName: string) {
|
|
|
|
|
|
if (workflowName == 'Despacho') {
|
|
if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') {
|
|
this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
|
|
}
|
|
}
|
|
else if (workflowName == 'Despacho do Presidente da República') {
|
|
if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') {
|
|
this.router.navigate(['/home/gabinete-digital/despachos-pr', serialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma') {
|
|
this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (activityName == 'Diploma Assinado') {
|
|
this.router.navigate(['/home/gabinete-digital/diplomas-assinar', serialNumber, 'gabinete-digital']);
|
|
} else {
|
|
throw('Bug!');
|
|
}
|
|
}
|
|
else if (workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') {
|
|
this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (workflowName == 'Expediente') {
|
|
this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (workflowName == 'Expediente' && this.loggeduser.Profile == 'PR') {
|
|
this.router.navigate(['/home/gabinete-digital/expedientes-pr', serialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (workflowName == "Pedido de Parecer do Presidente") {
|
|
this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (workflowName == 'Agenda Pessoal PR' || workflowName == 'Agenda Oficial PR' || workflowName == 'Agenda Oficial MDGPR' || workflowName == 'Agenda Pessoal MDGPR' || activityName == "Aprovar Evento" || workflowName == "Agendar Evento") {
|
|
this.router.navigate(['/home/gabinete-digital/event-list/approve-event', serialNumber, 'gabinete-digital']);
|
|
}
|
|
else {
|
|
throw(`${workflowName} && ${activityName} no route`)
|
|
}
|
|
}
|
|
|
|
}
|