mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
461 lines
14 KiB
TypeScript
461 lines
14 KiB
TypeScript
import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
import { ModalController } from '@ionic/angular';
|
|
import { EventListPage } from './event-list/event-list.page';
|
|
import { ExpedientePage } from './expediente/expediente.page';
|
|
import { ActivatedRoute, NavigationEnd, NavigationExtras, Router } from '@angular/router';
|
|
import { DespachosPage } from './despachos/despachos.page';
|
|
import { PedidosPage } from './pedidos/pedidos.page';
|
|
/* import { PendentesPage } from './pendentes/pendentes.page'; */
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
import { User } from 'src/app/models/user.model';
|
|
import { ExpedientsPage } from 'src/app/shared/gabinete-digital/expedients/expedients.page';
|
|
import { PendentesPage } from 'src/app/shared/gabinete-digital/pendentes/pendentes.page';
|
|
import { EventsToApprovePage } from 'src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page';
|
|
@Component({
|
|
selector: 'app-gabinete-digital',
|
|
templateUrl: './gabinete-digital.page.html',
|
|
styleUrls: ['./gabinete-digital.page.scss'],
|
|
})
|
|
|
|
export class GabineteDigitalPage implements OnInit {
|
|
|
|
segment:string;
|
|
showLoader: boolean;
|
|
public profile:string;
|
|
|
|
count_exp_dailywork=0;
|
|
count_exp_pr =0
|
|
count_desp_dailywork=0;
|
|
count_desp_pending=0;
|
|
count_par_dailywork=0;
|
|
count_par_pending=0;
|
|
count_def_dailywork=0;
|
|
count_def_pending=0;
|
|
count_exp_pp : string;
|
|
count_exp_pd : string;
|
|
count_dip_apr : string;
|
|
count_dip_as_pr =0
|
|
count_dip_pv=0;
|
|
count_dip_as = 0;
|
|
count_de_pr = 0;
|
|
count_ev_pr=0;
|
|
count_ev_md=0;
|
|
count_total_pending = 0;
|
|
count_desp_pr_active = 0;
|
|
|
|
selectedElement = "";
|
|
|
|
desktopComponent: any = {
|
|
showEventList: false,
|
|
showExpediente : false
|
|
}
|
|
|
|
showEventsToApprove = false;
|
|
showEmptyContainer = false;
|
|
showExpedients = false;
|
|
showExpedientesPr = false;
|
|
showPedidos = false;
|
|
showDespachos = false;
|
|
showDespachosPr = false;
|
|
showPendentes = false;
|
|
showDiplomas = false;
|
|
showDiplomasAssinar = false;
|
|
showExpedientDetail = false;
|
|
showSignedDiploma = false
|
|
emptyTextDescription = 'Sem opção selecionada';
|
|
|
|
serialNumber:string;
|
|
|
|
loggeduser: User;
|
|
mdgpr = "MDGPR";
|
|
pr = "PR";
|
|
|
|
hideRefreshBtn = true;
|
|
|
|
@ViewChild(ExpedientsPage) expedientesPage: ExpedientsPage;
|
|
@ViewChild(PendentesPage) pendentesListPage: PendentesPage;
|
|
@ViewChild(EventsToApprovePage) eventsToApprove: EventsToApprovePage;
|
|
|
|
constructor(
|
|
private processesbackend:ProcessesService,
|
|
private modalController: ModalController,
|
|
private alertService: AlertService,
|
|
private activatedRoute: ActivatedRoute,
|
|
private router: Router,
|
|
authService: AuthService
|
|
) {
|
|
|
|
this.loggeduser = authService.ValidatedUser;
|
|
|
|
window.onresize = (event) => {
|
|
// if not mobile remove all component
|
|
if( window.innerWidth <= 801){
|
|
this.modalController.dismiss();
|
|
}
|
|
};
|
|
this.checkRoutes();
|
|
|
|
}
|
|
|
|
closeAllDesktopComponent(){
|
|
this.desktopComponent = {
|
|
showEventList: false,
|
|
showExpediente: false
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
const pathname = window.location.pathname
|
|
|
|
this.router.events.forEach((event) => {
|
|
if(event instanceof NavigationEnd && event.url == pathname) {
|
|
this.checkRoutes();
|
|
this.LoadCounts();
|
|
// console.log('yes', pathname)
|
|
} else {
|
|
// console.log('not')
|
|
}
|
|
});
|
|
|
|
this.hideRefreshButton();
|
|
}
|
|
|
|
checkUser(){
|
|
switch(this.loggeduser.Profile){
|
|
case 'MDGPR':
|
|
this.showExpedients = true;
|
|
break;
|
|
case 'PR':
|
|
this.showExpedientesPr = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
hideRefreshButton(){
|
|
window.onresize = (event) => {
|
|
if( window.innerWidth < 801) {
|
|
this.hideRefreshBtn = false;
|
|
}
|
|
else{
|
|
this.hideRefreshBtn = true;
|
|
}
|
|
}
|
|
if(window.innerWidth < 801){
|
|
this.hideRefreshBtn = false;
|
|
}
|
|
}
|
|
|
|
checkRoutes(){
|
|
if(this.router.url == '/home/gabinete-digital?eventos=true'){
|
|
this.openEventsToApprovePage();
|
|
this.selectedElement='approval';
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?expedientes=true'){
|
|
this.openExpedientListPage();
|
|
if(this.loggeduser.Profile == 'MDGPR'){
|
|
this.selectedElement='Correspondence';
|
|
}
|
|
else{
|
|
this.selectedElement='Expediente Presidente'
|
|
}
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?pendentes=true'){
|
|
this.openPendentesPage('');
|
|
this.selectedElement='Pending';
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?despachos=true'){
|
|
this.openDespachosPage('');
|
|
this.selectedElement='Dispatches';
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?pedidos=true'){
|
|
this.openPedidosPage('parecer');
|
|
this.selectedElement='RequestsForOpinion';
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?expedientespr=true'){
|
|
this.openExpedientesPrPage();
|
|
this.selectedElement='Expediente Presidente'
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?despachospr=true'){
|
|
this.openDespachosPrPage('');
|
|
this.selectedElement='DispatchesPr'
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?diplomas=true'){
|
|
this.openDiplomasPage('validar');
|
|
this.selectedElement='DiplomasPorValidar';
|
|
}
|
|
else if(this.router.url == '/home/gabinete-digital?diplomasassinar=true'){
|
|
this. openDiplomasAssinarPage();
|
|
this.selectedElement='DiplomasAssinar';
|
|
}
|
|
else{
|
|
this.checkUser();
|
|
}
|
|
}
|
|
|
|
refreshExpedientes(){
|
|
this.expedientesPage.doRefresh();
|
|
//this.pendentesListPage.doRefresh();
|
|
//this.eventsToApprove.doRefresh();
|
|
}
|
|
|
|
closeAllDesktopComponents() {
|
|
this.showEmptyContainer = false;
|
|
this.showEventsToApprove = false;
|
|
this.showExpedients = false;
|
|
this.showPedidos = false;
|
|
this.showDespachos = false;
|
|
this.showDespachosPr = false;
|
|
this.showPendentes = false;
|
|
this.showDiplomas = false;
|
|
this.showDiplomasAssinar = false;
|
|
this.showExpedientesPr = false;
|
|
this.showExpedientDetail = false;
|
|
this.showSignedDiploma = false
|
|
}
|
|
|
|
async LoadCounts() {
|
|
this.showLoader = true;
|
|
|
|
let expedientes = await this.processesbackend.GetTasksList("Expediente", false).toPromise();
|
|
this.count_exp_dailywork = Object.keys(expedientes.filter(data => data.workflowInstanceDataFields.Status == "Active")).length;
|
|
|
|
let expedientes_pr = await this.processesbackend.GetTasksList("Expediente do Presidente", false).toPromise();
|
|
this.count_exp_pr = Object.keys(expedientes_pr.filter(data => data.workflowInstanceDataFields.Status == "Active")).length;
|
|
|
|
let despachos = await this.processesbackend.GetTasksList("Despacho", false).toPromise();
|
|
this.count_desp_dailywork = Object.keys(despachos).length;
|
|
|
|
let pareceres = await this.processesbackend.GetTasksList("Pedido de Parecer", false).toPromise();
|
|
let pareceresPr = await this.processesbackend.GetTasksList("Pedido de Parecer do Presidente", false).toPromise();
|
|
let allParecer = pareceres.concat(pareceresPr);
|
|
this.count_par_dailywork = Object.keys(allParecer).length;
|
|
|
|
let deferimentos = await this.processesbackend.GetTasksList("Pedido de Deferimento", false).toPromise();
|
|
this.count_def_dailywork = Object.keys(deferimentos).length;
|
|
|
|
let pendentes = despachos.concat(pareceres, deferimentos, expedientes).reverse().filter(data => data.workflowInstanceDataFields.Status == "Pending");
|
|
this.count_total_pending = Object.keys(pendentes).length;
|
|
|
|
let despachospr = await this.processesbackend.GetTasksList("Despacho do Presidente da República", false).toPromise();
|
|
let despachosPr;
|
|
switch (this.loggeduser.Profile) {
|
|
case 'MDGPR':
|
|
despachosPr = despachospr.filter(data => data.activityInstanceName == "Tarefa de Despacho");
|
|
this.count_de_pr = Object.keys(despachosPr).length;
|
|
break;
|
|
case 'PR':
|
|
despachosPr = despachospr.filter(data => data.activityInstanceName == "Concluir Despacho");
|
|
this.count_de_pr = Object.keys(despachosPr).length;
|
|
break;
|
|
}
|
|
|
|
let diplomasValidar = despachospr.filter(data => data.activityInstanceName == "Revisar Diploma");
|
|
this.count_dip_pv = Object.keys(diplomasValidar).length;
|
|
|
|
let diplomasAssinar = despachospr.filter(data => data.activityInstanceName == "Assinar Diploma");
|
|
this.count_dip_as = Object.keys(diplomasAssinar).length;
|
|
|
|
let diplomasAssinados = despachospr.filter(data => data.activityInstanceName == "Diploma Assinado");
|
|
this.count_dip_as_pr = Object.keys(diplomasAssinados).length;
|
|
|
|
this.processesbackend.GetToApprovedEvents('PR','true').subscribe(res=>{
|
|
this.count_ev_pr = res;
|
|
});
|
|
this.processesbackend.GetToApprovedEvents('MDGPR','true').subscribe(res=>{
|
|
this.count_ev_md = res;
|
|
});
|
|
|
|
this.showLoader = false;
|
|
|
|
this.count_exp_pp = "-";
|
|
this.count_exp_pd = "-";
|
|
this.count_dip_apr = "-";
|
|
|
|
}
|
|
|
|
doRefresh(event) {
|
|
console.log(event);
|
|
|
|
this.closeAllDesktopComponents();
|
|
/* switch(this.loggeduser.Profile){
|
|
case 'MDGPR':
|
|
this.selectedElement='Correspondence';
|
|
this.showExpedients = true;
|
|
this.expedientesPage.doRefresh();
|
|
break;
|
|
case 'PR':
|
|
this.selectedElement='ExpedientesPr';
|
|
this.showExpedientesPr = true;
|
|
break;
|
|
} */
|
|
this.LoadCounts();
|
|
//this.refreshExpedientes();
|
|
|
|
if(event){
|
|
setTimeout(() => {
|
|
event.target.complete();
|
|
}, 2000);
|
|
}
|
|
else{
|
|
console.log('null');
|
|
|
|
}
|
|
}
|
|
|
|
notImplemented(){
|
|
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
|
}
|
|
|
|
selectedElementF(element:string) {
|
|
if (window.innerWidth >= 801) {
|
|
return element == this.selectedElement
|
|
}
|
|
return false;
|
|
}
|
|
|
|
openEventsToApprovePage() {
|
|
this.closeAllDesktopComponents();
|
|
let navigationExtras: NavigationExtras = { queryParams: {"eventos": true,}};
|
|
if( window.innerWidth <= 801) {
|
|
//this.openEventsToApproveList(profile);
|
|
this.router.navigate(['/home/gabinete-digital/event-list']);
|
|
}
|
|
else {
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showEventsToApprove = true;
|
|
//this.eventsToApprove.doRefresh();
|
|
}
|
|
}
|
|
|
|
openExpedientListPage() {
|
|
this.closeAllDesktopComponents();
|
|
switch(this.loggeduser.Profile){
|
|
case 'MDGPR':
|
|
if( window.innerWidth <= 801) {
|
|
//this.openExpedientList();
|
|
this.router.navigate(['/home/gabinete-digital/expediente']);
|
|
}
|
|
else {
|
|
this.selectedElement='Correspondence'
|
|
let navigationExtras: NavigationExtras = { queryParams: {"expedientes": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showExpedients = true;
|
|
}
|
|
break;
|
|
case 'PR':
|
|
if( window.innerWidth <= 801) {
|
|
this.router.navigate(['/home/gabinete-digital/expedientes-pr']);
|
|
}
|
|
else {
|
|
this.selectedElement='ExpedientesPr'
|
|
let navigationExtras: NavigationExtras = { queryParams: {"expedientes": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showExpedientesPr = true;
|
|
}
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
openPedidosPage(segment:string) {
|
|
this.closeAllDesktopComponents();
|
|
if( window.innerWidth <= 801) {
|
|
|
|
let navigationExtras: NavigationExtras;
|
|
|
|
if (segment == 'deferimento') {
|
|
navigationExtras= { queryParams: {"deferimento": true,}};
|
|
} else if (segment == 'parecer') {
|
|
navigationExtras = { queryParams: {"parecer": true,}};
|
|
}
|
|
|
|
this.router.navigate(['/home/gabinete-digital/pedidos'], navigationExtras);
|
|
}
|
|
else{
|
|
this.segment = segment;
|
|
let navigationExtras: NavigationExtras = { queryParams: {"pedidos": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showPedidos = true;
|
|
}
|
|
}
|
|
|
|
openDespachosPage(segment?:string) {
|
|
this.closeAllDesktopComponents();
|
|
if( window.innerWidth <= 801){
|
|
this.router.navigate(['/home/gabinete-digital/despachos']);
|
|
}
|
|
else{
|
|
let navigationExtras: NavigationExtras = {queryParams: {"despachos": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showDespachos = true;
|
|
}
|
|
}
|
|
|
|
openDespachosPrPage(segment?:string) {
|
|
this.closeAllDesktopComponents();
|
|
if( window.innerWidth <= 801){
|
|
this.router.navigate(['/home/gabinete-digital/despachos-pr']);
|
|
}
|
|
else{
|
|
let navigationExtras: NavigationExtras = {queryParams: {"despachospr": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showDespachosPr = true;
|
|
}
|
|
}
|
|
|
|
openPendentesPage(segment?:string){
|
|
this.closeAllDesktopComponents();
|
|
if( window.innerWidth <= 801){
|
|
this.router.navigate(['/home/gabinete-digital/pendentes']);
|
|
}
|
|
else{
|
|
let navigationExtras: NavigationExtras = { queryParams: {"pendentes": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showPendentes = true;
|
|
}
|
|
}
|
|
|
|
openExpedientesPrPage(segment?:string){
|
|
this.closeAllDesktopComponents();
|
|
if( window.innerWidth <= 801) {
|
|
this.router.navigate(['/home/gabinete-digital/expedientes-pr']);
|
|
}
|
|
else {
|
|
this.selectedElement='ExpedientesPr'
|
|
let navigationExtras: NavigationExtras = { queryParams: {"expedientespr": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showExpedientesPr = true;
|
|
}
|
|
}
|
|
|
|
openDiplomasPage(segment:string) {
|
|
if( window.innerWidth <= 801){
|
|
this.router.navigate(['/home/gabinete-digital/diplomas']);
|
|
}
|
|
else{
|
|
this.closeAllDesktopComponents();
|
|
this.segment = segment;
|
|
let navigationExtras: NavigationExtras = { queryParams: {"diplomas": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showDiplomas = true;
|
|
}
|
|
}
|
|
|
|
openDiplomasAssinarPage() {
|
|
this.closeAllDesktopComponents();
|
|
if( window.innerWidth <= 801){
|
|
this.router.navigate(['/home/gabinete-digital/diplomas-assinar']);
|
|
}
|
|
else{
|
|
let navigationExtras: NavigationExtras = { queryParams: {"diplomasassinar": true,}};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
this.showDiplomasAssinar = true;
|
|
}
|
|
}
|
|
|
|
}
|