mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
221 lines
6.6 KiB
TypeScript
221 lines
6.6 KiB
TypeScript
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
|
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
|
import { CalendarComponent } from 'ionic2-calendar';
|
|
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
|
|
import { customTask } from '../../../models/dailyworktask.model';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
import { PendentesStore } from 'src/app/store/pendestes-store.service';
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
|
|
|
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
|
import { Platform } from '@ionic/angular';
|
|
import { SortService } from 'src/app/services/functions/sort.service';
|
|
import { Storage } from '@ionic/storage';
|
|
import { SessionStore } from 'src/app/store/session.service';
|
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { RouteService } from 'src/app/services/route.service';
|
|
@Component({
|
|
selector: 'app-pendentes',
|
|
templateUrl: './pendentes.page.html',
|
|
styleUrls: ['./pendentes.page.scss'],
|
|
})
|
|
export class PendentesPage implements OnInit {
|
|
@ViewChild(CalendarComponent) myCal: CalendarComponent;
|
|
|
|
taskType: string;
|
|
serialNumber: string;
|
|
totalDocs: any;
|
|
showLoader: boolean;
|
|
loggeduser: LoginUserRespose;
|
|
|
|
@Input() profile: string;
|
|
segment: string;
|
|
skeletonLoader = true
|
|
pendentesstore = PendentesStore;
|
|
customTaskPipe = new CustomTaskPipe()
|
|
listToPresent = [];
|
|
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
|
|
|
|
showSearch = false
|
|
searchSubject = ''
|
|
list = []
|
|
ordinance: string = 'old'
|
|
headerName = "Pendentes"
|
|
|
|
constructor(
|
|
private processes: ProcessesService,
|
|
private alertService: AlertService,
|
|
private router: Router,
|
|
private backgroundservices: BackgroundService,
|
|
private sortService: SortService,
|
|
private storage: Storage,
|
|
private httpErroHandle: HttpErrorHandle,
|
|
public TaskService: TaskService,
|
|
public ThemeService: ThemeService,
|
|
private RouteService: RouteService,
|
|
) {
|
|
this.loggeduser = SessionStore.user;
|
|
this.profile = 'mdgpr';
|
|
}
|
|
|
|
ngOnInit() {
|
|
//Inicializar segment
|
|
this.segment = "despachos";
|
|
const location = window.location
|
|
const pathname = location.pathname + location.search
|
|
|
|
this.LoadList()
|
|
|
|
this.router.events.forEach((event) => {
|
|
if (event instanceof NavigationEnd && event.url.startsWith(pathname)) {
|
|
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.refreshing()
|
|
} else {
|
|
this.LoadList()
|
|
}
|
|
}
|
|
});
|
|
|
|
this.backgroundservices.registerBackService('Online', () => {
|
|
this.LoadList();
|
|
});
|
|
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
|
|
reorderList(orderBy: string) {
|
|
|
|
this.ordinance = orderBy;
|
|
|
|
this.dynamicSearch();
|
|
}
|
|
|
|
changeFilterName(filterName) {
|
|
this.filterName = filterName
|
|
}
|
|
|
|
|
|
async dynamicSearch() {
|
|
|
|
if(this.showSearch && this.searchSubject) {
|
|
|
|
const list = this.pendentesstore.list.filter((task) => {
|
|
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
|
subject = subject.toLowerCase();
|
|
return subject.includes(this.searchSubject.toLowerCase())
|
|
})
|
|
|
|
this.list = this.TaskService.reorderList(this.ordinance, list)
|
|
} else {
|
|
const list = this.pendentesstore.list
|
|
this.list = this.TaskService.reorderList(this.ordinance, list)
|
|
}
|
|
|
|
}
|
|
|
|
segmentChanged(ev: any) {
|
|
this.refreshing();
|
|
}
|
|
|
|
goBack() {
|
|
this.RouteService.goBack();
|
|
}
|
|
|
|
notImplemented() {
|
|
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
|
}
|
|
|
|
async LoadList() {
|
|
|
|
this.processes.GetPendingTasks(false).subscribe(async res => {
|
|
this.skeletonLoader = true;
|
|
|
|
let pendentes = await this.processes.GetPendingTasks(false).toPromise();
|
|
let pendentesList = [];
|
|
|
|
pendentes.forEach(element => {
|
|
let task: customTask = this.customTaskPipe.transform(element);
|
|
pendentesList.push(task);
|
|
});
|
|
|
|
pendentesList = removeDuplicate(pendentesList)
|
|
pendentesList = this.sortService.sortDate(pendentesList, 'CreateDate');
|
|
this.pendentesstore.reset(pendentesList);
|
|
this.listToPresent = pendentesList;
|
|
this.storage.set('pendente-list',pendentesList).then(() => {
|
|
|
|
})
|
|
this.skeletonLoader = false;
|
|
this.dynamicSearch()
|
|
|
|
}, (error) => {
|
|
if(error.status == 0) {
|
|
this.getFromDb();
|
|
} else {
|
|
this.httpErroHandle.httpStatusHandle(error)
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
getFromDb() {
|
|
|
|
}
|
|
|
|
async refreshing() {
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1500);
|
|
}
|
|
|
|
doRefresh(event) {
|
|
this.LoadList();
|
|
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
|
|
async viewTaskDetails({ SerialNumber, WorkflowName, activityInstanceName }: customTask) {
|
|
if (WorkflowName == 'Despacho') {
|
|
this.router.navigate(['/home/gabinete-digital/despachos', SerialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (WorkflowName == 'Despacho do Presidente da República') {
|
|
this.router.navigate(['/home/gabinete-digital/despachos', SerialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (WorkflowName == 'Pedido de Parecer' || WorkflowName == 'Pedido de Deferimento' || WorkflowName == 'Pedido de Parecer do Presidente') {
|
|
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 (activityInstanceName == "Tarefa de Parecer") {
|
|
this.router.navigate(['/home/gabinete-digital/pedidos', SerialNumber, 'gabinete-digital']);
|
|
}
|
|
else if (activityInstanceName == "Tarefa de Despacho") {
|
|
this.router.navigate(['/home/gabinete-digital/despachos', SerialNumber, 'gabinete-digital']);
|
|
}
|
|
else {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
toDateString(e) {
|
|
return new Date(e).toDateString()
|
|
}
|
|
|
|
}
|