mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
259 lines
6.9 KiB
TypeScript
259 lines
6.9 KiB
TypeScript
import { Component, OnInit, ViewChild } from '@angular/core';
|
|
import { CalendarComponent } from 'ionic2-calendar';
|
|
|
|
import { customFullTask, customTask, DailyWorkTask } from '../../../models/dailyworktask.model';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { ModalController } from '@ionic/angular';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
|
|
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
import { DespachoPage } from 'src/app/pages/gabinete-digital/despachos/despacho/despacho.page';
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
|
import { NavigationStart, Router } from '@angular/router';
|
|
import { __awaiter } from 'tslib';
|
|
import { DespachosprStore } from 'src/app/store/despachospr-store.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 { SessionStore } from 'src/app/store/session.service';
|
|
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
|
|
import { environment } from 'src/environments/environment';
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
|
|
@Component({
|
|
selector: 'app-despachos-pr',
|
|
templateUrl: './despachos-pr.page.html',
|
|
styleUrls: ['./despachos-pr.page.scss'],
|
|
})
|
|
export class DespachosPrPage implements OnInit {
|
|
|
|
@ViewChild(CalendarComponent) myCal: CalendarComponent;
|
|
|
|
taskslist: DailyWorkTask[] = [];
|
|
despachoList: any[] = [];
|
|
deferimentoList: DailyWorkTask[] = [];
|
|
|
|
taskList: customTask[] = [];
|
|
|
|
taskType: string;
|
|
serialNumber: string;
|
|
totalDocs: any;
|
|
|
|
profile: string;
|
|
segment: string;
|
|
|
|
// @Output() openExpedientDetail:EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
loadedAttachments: any;
|
|
dicIndex = 0;
|
|
inicial = false
|
|
|
|
skeletonLoader = true
|
|
despachoprstore = DespachosprStore
|
|
|
|
|
|
customTaskPipe = new CustomTaskPipe()
|
|
SessionStore = SessionStore
|
|
environment = environment
|
|
|
|
constructor(
|
|
private processes: ProcessesService,
|
|
private modalController: ModalController,
|
|
private alertService: AlertService,
|
|
private authService: AuthService,
|
|
private router: Router,
|
|
private sqliteservice: SqliteService,
|
|
private backgroundservice: BackgroundService,
|
|
private sortService: SortService,
|
|
public ThemeService: ThemeService,
|
|
public TaskService: TaskService
|
|
) {
|
|
|
|
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 NavigationStart && event.url.startsWith(pathname)) {
|
|
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.LoadList()
|
|
} else {
|
|
this.LoadList()
|
|
}
|
|
}
|
|
});
|
|
|
|
this.backgroundservice.registerBackService('Online', () => {
|
|
this.LoadList()
|
|
});
|
|
}
|
|
|
|
segmentChanged(ev: any) {
|
|
|
|
this.LoadList();
|
|
}
|
|
|
|
goToDespachoPr(serialNumber: any) {
|
|
this.router.navigate(['/home/gabinete-digital/despachos-pr', serialNumber, 'gabinete-digital']);
|
|
}
|
|
|
|
notImplemented() {
|
|
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
|
}
|
|
|
|
openExpedientDetailPage(data) {
|
|
|
|
}
|
|
|
|
async LoadList() {
|
|
|
|
this.skeletonLoader = true
|
|
|
|
try {
|
|
|
|
let result = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
|
|
this.despachoList = [];
|
|
this.skeletonLoader = false;
|
|
|
|
|
|
let despachosPr;
|
|
let despachos = this.sortService.sortArrayByDate(result);
|
|
|
|
if(SessionStore.user.Profile != "PR") {
|
|
|
|
|
|
if(SessionStore.user.Profile != 'Consultant') {
|
|
despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
|
|
} else {
|
|
despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Gerar Diploma" || data.activityInstanceName == "Retificar Diploma");
|
|
}
|
|
|
|
} else if (SessionStore.user.Profile == "PR") {
|
|
despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Concluir Despacho");
|
|
}
|
|
|
|
|
|
despachosPr = despachosPr.filter(data => data.workflowInstanceDataFields.Status == "Active");
|
|
|
|
despachosPr.forEach((element, index) => {
|
|
|
|
let date = new Date(element.taskStartDate);
|
|
date.setMonth(date.getMonth() + 1);
|
|
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
|
|
|
let task = this.customTaskPipe.transform(element)
|
|
|
|
this.despachoList.push(task);
|
|
});
|
|
|
|
|
|
this.despachoList = this.sortService.sortDate(this.despachoList, 'CreateDate')
|
|
this.despachoprstore.reset(this.despachoList)
|
|
|
|
} catch(error) {
|
|
|
|
}
|
|
|
|
this.skeletonLoader = false
|
|
|
|
}
|
|
|
|
|
|
doRefresh(event) {
|
|
if (event) {
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000)
|
|
|
|
}
|
|
|
|
async viewExpedientDetail(serialNumber: any) {
|
|
|
|
|
|
let classs;
|
|
if (window.innerWidth <= 800) {
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop'
|
|
}
|
|
|
|
const modal = await this.modalController.create({
|
|
component: DespachoPage,
|
|
componentProps: {
|
|
enterAnimation: "",
|
|
serialNumber: serialNumber,
|
|
profile: this.profile,
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then((res) => {
|
|
|
|
this.LoadList();
|
|
});
|
|
}
|
|
|
|
|
|
async openBookMeetingModal(task: customFullTask) {
|
|
|
|
const doc = this.loadedAttachments[this.dicIndex];
|
|
|
|
task = {
|
|
serialNumber: doc.SourceId,
|
|
taskStartDate: doc.CreateDate,
|
|
isEvent: true,
|
|
workflowInstanceDataFields: {
|
|
FsId: doc.ApplicationId,
|
|
FolderID: null,
|
|
DocId: doc.SourceId,
|
|
Subject: doc.SourceName
|
|
},
|
|
}
|
|
|
|
let classs;
|
|
if (window.innerWidth <= 800) {
|
|
classs = 'book-meeting-modal modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: BookMeetingModalPage,
|
|
componentProps: {
|
|
task: task,
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss();
|
|
}
|
|
|
|
|
|
docIndex(index: number) {
|
|
this.dicIndex = index;
|
|
}
|
|
|
|
goBack() {
|
|
this.router.navigate(['/home/gabinete-digital']);
|
|
}
|
|
|
|
}
|