merge with branchBug

This commit is contained in:
Eudes Inácio
2021-09-29 17:10:18 +01:00
24 changed files with 1329 additions and 735 deletions
+1 -1
View File
@@ -90,7 +90,7 @@
</div> </div>
<div class="content overflow-y-auto flex-grow-1 height-100"> <div class="content overflow-y-auto flex-grow-1 height-100">
<ion-list> <ion-list>
<ion-item class="item-hover cursor-pointer" lines="none" *ngFor = "let task of expedienteGdStore.list" <ion-item class="item-hover cursor-pointer" lines="none" *ngFor = "let task of listToPresentexpediente"
(click)="goToExpediente(task.SerialNumber)"> (click)="goToExpediente(task.SerialNumber)">
<div class="item-exp d-flex"> <div class="item-exp d-flex">
<div class="schedule-date"> <div class="schedule-date">
+50 -44
View File
@@ -67,9 +67,8 @@ export class EventsPage implements OnInit {
toDayEventStorage = ToDayEventStorage toDayEventStorage = ToDayEventStorage
expedienteGdStore = ExpedienteGdStore expedienteGdStore = ExpedienteGdStore
listToPresent = [];
pdfSrc = "https://www.tabularium.pt/file-upload/FSovLiyEa8Hqy2iDA/TK-Justificativo.pdf"; listToPresentexpediente =[]
listToPresent
expedienteTaskPipe = new ExpedienteTaskPipe() expedienteTaskPipe = new ExpedienteTaskPipe()
@@ -120,18 +119,6 @@ export class EventsPage implements OnInit {
this.segment = "Combinada"; this.segment = "Combinada";
this.profile = "mdgpr"; this.profile = "mdgpr";
this.showGreeting();
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(()=>{
this.LoadList();
}, 1500)
}
});
this.hideSearch();
this.getEventsFromLocalDb(); this.getEventsFromLocalDb();
//this.checkScreenOrientation(); //this.checkScreenOrientation();
@@ -199,17 +186,16 @@ export class EventsPage implements OnInit {
const list = mdOficialEvents.concat(mdPessoalEvents); const list = mdOficialEvents.concat(mdPessoalEvents);
console.log("getAllMdOficialPessoalEvents", list) console.log("getAllMdOficialPessoalEvents", list)
this.SqliteAddEvent(list); this.SqliteAddEvent(list);
this.listToPresent = this.toDayEventStorage.eventsList this.listToPresent = list
this.toDayEventStorage.reset(list)
if (this.toDayEventStorage.eventsList.length > 0) { if (list.length > 0) {
this.currentEvent = this.toDayEventStorage.eventsList[0].Subject; this.currentEvent = list[0].Subject;
this.currentHoursMinutes = this.toDayEventStorage.eventsList[0].StartDate; this.currentHoursMinutes = list[0].StartDate;
} }
this.totalEvent = this.toDayEventStorage.eventsList.length; this.totalEvent = list.length;
this.showLoader = false; this.showLoader = false;
} }
@@ -221,15 +207,14 @@ export class EventsPage implements OnInit {
const list = prOficialEvents.concat(prPessoalEvents); const list = prOficialEvents.concat(prPessoalEvents);
console.log("getAllPrOficialPessoalEvents", list) console.log("getAllPrOficialPessoalEvents", list)
this.SqliteAddEvent(list); this.SqliteAddEvent(list);
this.toDayEventStorage.reset(list)
if (this.toDayEventStorage.eventsList.length > 0) { if (list.length > 0) {
this.currentEvent = this.toDayEventStorage.eventsList[0].Subject; this.currentEvent = list[0].Subject;
this.currentHoursMinutes = this.toDayEventStorage.eventsList[0].StartDate; this.currentHoursMinutes = list[0].StartDate;
} }
this.listToPresent = this.toDayEventStorage.eventsList; this.listToPresent = list;
this.totalEvent = this.toDayEventStorage.eventsList.length; this.totalEvent = list.length;
this.showLoader = false; this.showLoader = false;
} }
@@ -329,7 +314,7 @@ export class EventsPage implements OnInit {
Body: "" Body: ""
} }
if(!event.Organizer){ if (!event.Organizer) {
this.sqliteservice.addEvent(data); this.sqliteservice.addEvent(data);
console.log("Events page add event sqllite") console.log("Events page add event sqllite")
} }
@@ -339,32 +324,50 @@ export class EventsPage implements OnInit {
getEventsFromLocalDb() { getEventsFromLocalDb() {
synchro.registerCallback('Online', () => { if (synchro.connected === true) {
this.showGreeting();
this.router.events.forEach((event) => { this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') { if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents(); this.RefreshEvents();
setTimeout(() => {
this.LoadList(); this.LoadList();
}, 1500)
} }
}); });
console.log('Onlineee') this.hideSearch();
} else {
}) this.sqliteservice.getAllEvents().then((event:any[]) => {
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.sqliteservice.getAllEvents().then((event) => {
this.listToPresent = event this.listToPresent = event
this.totalEvent = this.listToPresent.length this.totalEvent = this.listToPresent.length
this.currentEvent = this.listToPresent[0].Subject this.currentEvent = this.listToPresent[0].Subject
this.currentHoursMinutes = this.listToPresent[0].StartDate this.currentHoursMinutes = this.listToPresent[0].StartDate
console.log("All events from local,", event) console.log("All events from local,", event)
}) })
console.log('Offlineee')
this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
var expedientlist = [];
process.forEach((element) => {
let task = {
CreateDate: element.taskStartDate,
DocumentsQty: element.totalDocuments,
Senders: JSON.parse(element.workflowInstanceDataFields).Sender,
SerialNumber: element.serialNumber,
Status: JSON.parse(element.workflowInstanceDataFields).Status,
Subject: JSON.parse(element.workflowInstanceDataFields).Subject,
WorkflowName: element.workflowDisplayName,
activityInstanceName: element.activityInstanceName,
taskStartDate: element.taskStartDate,
}
expedientlist.push(task);
}) })
const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
}) })
} }
}
@@ -421,10 +424,13 @@ export class EventsPage implements OnInit {
LoadList() { LoadList() {
this.processes.GetTaskListExpediente(false).subscribe(result => { this.processes.GetTaskListExpediente(false).subscribe(result => {
console.log("Expediente", result); console.log("Expediente", result);
this.sqliteservice.addProcess(result)
const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e)) const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e))
this.expedienteGdStore.reset(ExpedienteTask) console.log("Expediente 2", ExpedienteTask);
this.listToPresentexpediente = ExpedienteTask;
}); });
} }
@@ -447,9 +453,9 @@ export class EventsPage implements OnInit {
} }
} }
viewExpedientListPage(){ viewExpedientListPage() {
if(this.loggeduser.Profile == 'MDGPR'){ if (this.loggeduser.Profile == 'MDGPR') {
if( window.innerWidth < 701){ if (window.innerWidth < 701) {
this.router.navigate(['/home/gabinete-digital/expediente']); this.router.navigate(['/home/gabinete-digital/expediente']);
} }
else { else {
@@ -457,8 +463,8 @@ export class EventsPage implements OnInit {
this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.router.navigate(['/home/gabinete-digital'], navigationExtras);
} }
} }
else if(this.loggeduser.Profile == 'PR'){ else if (this.loggeduser.Profile == 'PR') {
if( window.innerWidth < 701){ if (window.innerWidth < 701) {
this.router.navigate(['/home/gabinete-digital/expedientes-pr']); this.router.navigate(['/home/gabinete-digital/expedientes-pr']);
} }
else { else {
@@ -19,6 +19,9 @@ import { ToastService } from 'src/app/services/toast.service';
import { Location } from '@angular/common' import { Location } from '@angular/common'
import { DespachoService } from 'src/app/Rules/despacho.service'; import { DespachoService } from 'src/app/Rules/despacho.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
@Component({ @Component({
selector: 'app-despacho-pr', selector: 'app-despacho-pr',
templateUrl: './despacho-pr.page.html', templateUrl: './despacho-pr.page.html',
@@ -28,7 +31,7 @@ export class DespachoPrPage implements OnInit {
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
customDate:any; customDate: any;
task: any; task: any;
fulltask: any; fulltask: any;
@@ -51,13 +54,14 @@ export class DespachoPrPage implements OnInit {
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private toastService: ToastService, private toastService: ToastService,
private location: Location, private location: Location,
private despachoService: DespachoService private despachoService: DespachoService,
private sqliteservice: SqliteService
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if(params["params"].SerialNumber) { if (params["params"].SerialNumber) {
this.serialNumber = params["params"].SerialNumber; this.serialNumber = params["params"].SerialNumber;
} }
if(params["params"].caller) { if (params["params"].caller) {
this.caller = params["params"].caller; this.caller = params["params"].caller;
} }
}); });
@@ -68,17 +72,7 @@ export class DespachoPrPage implements OnInit {
ngOnInit() { ngOnInit() {
this.profile = "mdgpr"; this.profile = "mdgpr";
console.log(this.serialNumber); console.log(this.serialNumber);
this.getFromDB();
this.activateRoute.paramMap.subscribe(paramMap => {
if (!paramMap.has('SerialNumber')) {
return;
}
/* this.serialNumber = paramMap.get('SerialNumber'); */
this.LoadTaskDetail(this.serialNumber);
// this.LoadRelatedEvents(this.serialNumber);
});
this.LoadTaskDetail(this.serialNumber);
// this.LoadRelatedEvents(this.serialNumber);
} }
close() { close() {
@@ -91,12 +85,12 @@ export class DespachoPrPage implements OnInit {
async LoadTaskDetail(serial: string) { async LoadTaskDetail(serial: string) {
this.processes.GetTask(serial).subscribe((res:fullTask) => { this.processes.GetTask(serial).subscribe((res: fullTask) => {
this.task = { this.task = {
"SerialNumber": res.serialNumber, "SerialNumber": res.serialNumber,
"Folio": res.workflowInstanceDataFields.Subject, "Folio": res.workflowInstanceDataFields.Subject,
"Senders": res.originator.email, "Senders": res.originator.email,
"CreateDate": momentG(new Date(res.taskStartDate),'yyyy-MM-dd HH:mm:ss'), "CreateDate": momentG(new Date(res.taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": res.workflowInstanceDataFields.ViewerRequest, "DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
"Remetente": res.workflowInstanceDataFields.Sender, "Remetente": res.workflowInstanceDataFields.Sender,
"Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note, "Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note,
@@ -111,32 +105,36 @@ export class DespachoPrPage implements OnInit {
console.log(this.task); console.log(this.task);
console.log('GetTask', res); console.log('GetTask', res);
this.sqliteservice.updateProcess(res)
let thedate = new Date(this.task.CreateDate); let thedate = new Date(this.task.CreateDate);
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]); this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users=>{ this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users => {
this.intervenientes = users.filter(user=>{ this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users)).then(() => {
console.log('internen despacho pr ')
})
this.intervenientes = users.filter(user => {
return user.Type == 'I'; return user.Type == 'I';
}); });
this.cc = users.filter(user=>{ this.cc = users.filter(user => {
return user.Type == 'CC'; return user.Type == 'CC';
}) || [] }) || []
if(!this.cc) { if (!this.cc) {
this.cc = [] this.cc = []
} }
}); });
}, (error)=>{ }, (error) => {
try { try {
this.goBack() this.goBack()
} catch (e) { } catch (e) {
window.history.back(); window.history.back();
} finally { } finally {
if(error.status == 0) { if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else { } else {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
@@ -145,11 +143,76 @@ export class DespachoPrPage implements OnInit {
}); });
} }
viewDocument(docId:string){ getFromDB() {
this.processes.GetDocumentUrl(docId, '361').subscribe(res=>{ if (synchro.connected === true) {
this.activateRoute.paramMap.subscribe(paramMap => {
if (!paramMap.has('SerialNumber')) {
return;
}
/* this.serialNumber = paramMap.get('SerialNumber'); */
this.LoadTaskDetail(this.serialNumber);
// this.LoadRelatedEvents(this.serialNumber);
});
this.LoadTaskDetail(this.serialNumber);
// this.LoadRelatedEvents(this.serialNumber);
} else {
this.sqliteservice.getProcessById(this.serialNumber).then((process: any[]) => {
console.log('OFFLINE', process)
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
"Senders": JSON.parse(process[0].originator).email,
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage || JSON.parse(process[0].workflowInstanceDataFields).Note,
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
"FsId": '361',
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DispatchDocId,
"WorkflowName": process[0].workflowDisplayName,
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
"activityInstanceName": process[0].activityInstanceName,
}
console.log("OFFLINE TASK", this.task)
let fulltak = {
Documents: JSON.parse(process[0].Documents),
actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL,
originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName
}
this.fulltask = fulltak;
console.log(this.task);
let thedate = new Date(this.task.CreateDate);
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'I';
});
this.cc = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'CC';
});
})
}
}
viewDocument(docId: string) {
this.processes.GetDocumentUrl(docId, '361').subscribe(res => {
console.log(res); console.log(res);
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); const url: string = res.replace("webTRIX.Viewer", "webTRIX.Viewer.Branch1");
const browser = this.iab.create(url,"_blank"); const browser = this.iab.create(url, "_blank");
browser.show(); browser.show();
}); });
} }
@@ -159,7 +222,7 @@ export class DespachoPrPage implements OnInit {
this.modalController.dismiss(); this.modalController.dismiss();
} }
async executado(note:string, documents:any) { async executado(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Conhecimento", "action": "Conhecimento",
@@ -167,7 +230,7 @@ export class DespachoPrPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -176,7 +239,7 @@ export class DespachoPrPage implements OnInit {
await this.processes.CompleteTask(body).toPromise() await this.processes.CompleteTask(body).toPromise()
this.close(); this.close();
this.toastService.successMessage() this.toastService.successMessage()
} catch(error) { } catch (error) {
this.toastService.badRequest() this.toastService.badRequest()
} }
finally { finally {
@@ -185,7 +248,7 @@ export class DespachoPrPage implements OnInit {
} }
async arquivar(note:string, documents:any){ async arquivar(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Arquivo", "action": "Arquivo",
@@ -193,7 +256,7 @@ export class DespachoPrPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -212,7 +275,7 @@ export class DespachoPrPage implements OnInit {
} }
async generateDiploma(note:string, documents:any){ async generateDiploma(note: string, documents: any) {
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -234,7 +297,7 @@ export class DespachoPrPage implements OnInit {
} }
async concluir(note:string, documents:any){ async concluir(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Executado", "action": "Executado",
@@ -242,7 +305,7 @@ export class DespachoPrPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -261,7 +324,7 @@ export class DespachoPrPage implements OnInit {
} }
async reexecutar(note:string, documents:any) { async reexecutar(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Reexecutar", "action": "Reexecutar",
@@ -269,7 +332,7 @@ export class DespachoPrPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -291,27 +354,27 @@ export class DespachoPrPage implements OnInit {
return new Date(e).toDateString() return new Date(e).toDateString()
} }
sendExpedienteToPending(){ sendExpedienteToPending() {
this.processes.SetTaskToPending(this.serialNumber).subscribe(res=>{ this.processes.SetTaskToPending(this.serialNumber).subscribe(res => {
this.popoverController.dismiss('close') this.popoverController.dismiss('close')
this.toastService.successMessage('Processo enviado para pendentes') this.toastService.successMessage('Processo enviado para pendentes')
this.goBack() this.goBack()
},()=>{ }, () => {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
}); });
} }
async openAddNoteModal(actionName:string) { async openAddNoteModal(actionName: string) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'add-note-modal-no-height' classs = 'add-note-modal-no-height'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: AddNotePage, component: AddNotePage,
componentProps:{ componentProps: {
showAttachmentBtn: true, showAttachmentBtn: true,
}, },
cssClass: classs, cssClass: classs,
@@ -320,9 +383,9 @@ export class DespachoPrPage implements OnInit {
await modal.present(); await modal.present();
modal.onDidDismiss().then( async (res) => { modal.onDidDismiss().then(async (res) => {
console.log(res); console.log(res);
if(res.data) { if (res.data) {
const DocumentToSave = res.data.documents.map((e) => { const DocumentToSave = res.data.documents.map((e) => {
return { return {
@@ -336,19 +399,19 @@ export class DespachoPrPage implements OnInit {
Attachments: DocumentToSave, Attachments: DocumentToSave,
} }
if(actionName == 'Executado'){ if (actionName == 'Executado') {
await this.executado(res.data.note, docs); await this.executado(res.data.note, docs);
} }
else if(actionName == 'Arquivar'){ else if (actionName == 'Arquivar') {
await this.arquivar(res.data.note, docs); await this.arquivar(res.data.note, docs);
} }
else if(actionName == 'Gerar Diploma'){ else if (actionName == 'Gerar Diploma') {
await this.generateDiploma(res.data.note, docs); await this.generateDiploma(res.data.note, docs);
} }
else if(actionName == 'Concluido'){ else if (actionName == 'Concluido') {
await this.concluir(res.data.note, docs); await this.concluir(res.data.note, docs);
} }
else if(actionName == 'Reexecução'){ else if (actionName == 'Reexecução') {
await this.reexecutar(res.data.note, docs); await this.reexecutar(res.data.note, docs);
} }
this.goBack(); this.goBack();
@@ -359,7 +422,7 @@ export class DespachoPrPage implements OnInit {
async openExpedientActionsModal(taskAction: any, task: any) { async openExpedientActionsModal(taskAction: any, task: any) {
//this.modalController.dismiss(); //this.modalController.dismiss();
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -375,9 +438,9 @@ export class DespachoPrPage implements OnInit {
cssClass: classs, cssClass: classs,
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
console.log(res['data']); console.log(res['data']);
if(res['data']=='openDiscart'){ if (res['data'] == 'openDiscart') {
console.log('open discart'); console.log('open discart');
this.distartExpedientModal(); this.distartExpedientModal();
} }
@@ -387,7 +450,7 @@ export class DespachoPrPage implements OnInit {
}); });
} }
async distartExpedientModal2(task: any){ async distartExpedientModal2(task: any) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: DiscartExpedientModalPage, component: DiscartExpedientModalPage,
componentProps: { componentProps: {
@@ -405,7 +468,7 @@ export class DespachoPrPage implements OnInit {
async openBookMeetingModal(task: any) { async openBookMeetingModal(task: any) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -424,7 +487,7 @@ export class DespachoPrPage implements OnInit {
async openDelegarModal(task: any) { async openDelegarModal(task: any) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -441,7 +504,7 @@ export class DespachoPrPage implements OnInit {
modal.onDidDismiss(); modal.onDidDismiss();
} }
async distartExpedientModal(){ async distartExpedientModal() {
console.log(this.fulltask); console.log(this.fulltask);
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: DiscartExpedientModalPage, component: DiscartExpedientModalPage,
@@ -455,8 +518,8 @@ export class DespachoPrPage implements OnInit {
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
if(res['data']=='close'){ if (res['data'] == 'close') {
this.close(); this.close();
/* console.log('2Expedient Discard closed2'); /* console.log('2Expedient Discard closed2');
this.close(); this.close();
@@ -472,7 +535,7 @@ export class DespachoPrPage implements OnInit {
componentProps: { componentProps: {
task: this.task, task: this.task,
fulltask: this.fulltask, fulltask: this.fulltask,
taskAction:taskAction, taskAction: taskAction,
showEnviarPendentes: false showEnviarPendentes: false
}, },
translucent: true translucent: true
@@ -480,9 +543,9 @@ export class DespachoPrPage implements OnInit {
await popover.present(); await popover.present();
popover.onDidDismiss().then(( res =>{ popover.onDidDismiss().then((res => {
if( res['data'] == 'close') { if (res['data'] == 'close') {
this.goBack() this.goBack()
} }
@@ -33,7 +33,7 @@
<ion-list> <ion-list>
<div <div
class="expediente ion-no-padding ion-no-margin cursor-pointer" class="expediente ion-no-padding ion-no-margin cursor-pointer"
*ngFor = "let task of despachoprstore.list; let i = index" *ngFor = "let task of listToPresent; let i = index"
(click)="goToDespachoPr(task.SerialNumber)" (click)="goToDespachoPr(task.SerialNumber)"
> >
<!-- [routerLink]="['/home/gabinete-digital/expediente',task.SerialNumber]" --> <!-- [routerLink]="['/home/gabinete-digital/expediente',task.SerialNumber]" -->
@@ -67,13 +67,13 @@
</div> </div>
<div <div
*ngIf="!skeletonLoader && despachoprstore.list.length == 0" *ngIf="!skeletonLoader && listToPresent.length == 0"
class="empty-list d-flex height-100 align-center justify-content-center" class="empty-list d-flex height-100 align-center justify-content-center"
> >
<span>Lista vazia</span> <span>Lista vazia</span>
</div> </div>
<div *ngIf="skeletonLoader && despachoprstore.list.length == 0"> <div *ngIf="skeletonLoader && listToPresent.length == 0">
<ion-list> <ion-list>
<ion-item> <ion-item>
<ion-thumbnail slot="end"> <ion-thumbnail slot="end">
@@ -17,6 +17,9 @@ import { NavigationEnd, NavigationExtras, NavigationStart, Router } from '@angul
import { __awaiter } from 'tslib'; import { __awaiter } from 'tslib';
import { DespachosprStore } from 'src/app/store/despachospr-store.service'; import { DespachosprStore } from 'src/app/store/despachospr-store.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
@Component({ @Component({
selector: 'app-despachos-pr', selector: 'app-despachos-pr',
templateUrl: './despachos-pr.page.html', templateUrl: './despachos-pr.page.html',
@@ -26,35 +29,37 @@ export class DespachosPrPage implements OnInit {
@ViewChild(CalendarComponent) myCal: CalendarComponent; @ViewChild(CalendarComponent) myCal: CalendarComponent;
taskslist:DailyWorkTask[] = []; taskslist: DailyWorkTask[] = [];
despachoList:any[] = []; despachoList: any[] = [];
deferimentoList:DailyWorkTask[] = []; deferimentoList: DailyWorkTask[] = [];
taskList: customTask[] = []; taskList: customTask[] = [];
taskType: string; taskType: string;
serialNumber:string; serialNumber: string;
totalDocs:any; totalDocs: any;
profile:string; profile: string;
segment:string; segment: string;
// @Output() openExpedientDetail:EventEmitter<any> = new EventEmitter<any>(); // @Output() openExpedientDetail:EventEmitter<any> = new EventEmitter<any>();
loadedAttachments:any; loadedAttachments: any;
dicIndex = 0; dicIndex = 0;
inicial = false inicial = false
loggeduser: LoginUserRespose; loggeduser: LoginUserRespose;
skeletonLoader = true skeletonLoader = true
despachoprstore = DespachosprStore despachoprstore = DespachosprStore
listToPresent = [];
constructor ( constructor(
private processes:ProcessesService, private processes: ProcessesService,
private modalController: ModalController, private modalController: ModalController,
private alertService: AlertService, private alertService: AlertService,
private authService: AuthService, private authService: AuthService,
private router: Router, private router: Router,
private sqliteservice: SqliteService
) { ) {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
@@ -65,22 +70,7 @@ export class DespachosPrPage implements OnInit {
ngOnInit() { ngOnInit() {
//Inicializar segment //Inicializar segment
this.segment = "despachos"; this.segment = "despachos";
this.getFromDB();
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.doRefresh()
} else {
this.LoadList()
}
}
});
} }
segmentChanged(ev: any) { segmentChanged(ev: any) {
@@ -88,15 +78,15 @@ export class DespachosPrPage implements OnInit {
this.LoadList(); this.LoadList();
} }
goToDespachoPr(serialNumber:any){ goToDespachoPr(serialNumber: any) {
this.router.navigate(['/home/gabinete-digital/despachos-pr',serialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/despachos-pr', serialNumber, 'gabinete-digital']);
} }
notImplemented(){ notImplemented() {
this.alertService.presentAlert('Funcionalidade em desenvolvimento'); this.alertService.presentAlert('Funcionalidade em desenvolvimento');
} }
openExpedientDetailPage(data){ openExpedientDetailPage(data) {
console.log(data); console.log(data);
} }
@@ -124,11 +114,11 @@ export class DespachosPrPage implements OnInit {
console.log(despachosPr); console.log(despachosPr);
despachosPr = despachosPr.filter(data => data.workflowInstanceDataFields.Status == "Active"); despachosPr = despachosPr.filter(data => data.workflowInstanceDataFields.Status == "Active");
despachosPr.forEach( (element, index) => { despachosPr.forEach((element, index) => {
let date = new Date(element.taskStartDate); let date = new Date(element.taskStartDate);
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
let task = { let task = {
"SerialNumber": element.serialNumber, "SerialNumber": element.serialNumber,
@@ -146,29 +136,93 @@ export class DespachosPrPage implements OnInit {
this.despachoList.push(task); this.despachoList.push(task);
console.log(this.despachoList); console.log(this.despachoList);
}); });
this.despachoprstore.reset(this.despachoList); this.listToPresent = this.despachoList
} }
getFromDB() {
if (synchro.connected === true) {
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.doRefresh()
} else {
this.LoadList()
}
}
});
} else {
this.sqliteservice.getAllProcess().then((all) => {
console.log('DESPACHO PR ALL', all)
})
this.sqliteservice.getprocessByworkflow('Despacho do Presidente da República').then(async (process: any[]) => {
console.log('DESPACHO PR', process)
let despachosPr;
switch (this.loggeduser.Profile) {
case 'MDGPR':
despachosPr = await process.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
break;
case 'PR':
console.log(process);
despachosPr = await process.reverse().filter(data => data.activityInstanceName == "Concluir Despacho");
break;
}
despachosPr = despachosPr.filter(data => JSON.parse(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 = {
"SerialNumber": element.serialNumber,
"Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
"Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
}
this.despachoList.push(task);
console.log(this.despachoList);
});
this.listToPresent = this.despachoList;
})
}
}
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
return myArray.sort(function(a, b) { return myArray.sort(function (a, b) {
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0); return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
}); });
} }
doRefresh() { doRefresh() {
setTimeout(()=>{ setTimeout(() => {
this.LoadList(); this.LoadList();
}, 1000) }, 1000)
} }
async viewExpedientDetail(serialNumber:any) { async viewExpedientDetail(serialNumber: any) {
console.log(this.profile); console.log(this.profile);
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
@@ -176,7 +230,7 @@ export class DespachosPrPage implements OnInit {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: DespachoPage, component: DespachoPage,
componentProps:{ componentProps: {
enterAnimation: "", enterAnimation: "",
serialNumber: serialNumber, serialNumber: serialNumber,
profile: this.profile, profile: this.profile,
@@ -184,7 +238,7 @@ export class DespachosPrPage implements OnInit {
cssClass: classs, cssClass: classs,
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then((res)=>{ modal.onDidDismiss().then((res) => {
console.log('refresh list'); console.log('refresh list');
this.LoadList(); this.LoadList();
}); });
@@ -193,7 +247,7 @@ export class DespachosPrPage implements OnInit {
async openBookMeetingModal(task: customFullTask) { async openBookMeetingModal(task: customFullTask) {
const doc = this.loadedAttachments[ this.dicIndex]; const doc = this.loadedAttachments[this.dicIndex];
task = { task = {
serialNumber: doc.SourceId, serialNumber: doc.SourceId,
@@ -208,7 +262,7 @@ export class DespachosPrPage implements OnInit {
} }
let classs; let classs;
if( window.innerWidth <= 800) { if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -33,8 +33,8 @@
<h5 *ngIf="intervenientes">Intervenientes</h5> <h5 *ngIf="intervenientes">Intervenientes</h5>
<ion-item class="ion-no-margin ion-no-padding"> <ion-item class="ion-no-margin ion-no-padding">
<ion-label> <ion-label>
<div *ngFor="let interveniente of intervenientes"> <div *ngFor="let task of intervenientes">
<p>{{interveniente.Name}}</p> <p>{{task.Name}}</p>
</div> </div>
</ion-label> </ion-label>
</ion-item> </ion-item>
@@ -18,6 +18,10 @@ import { fullTask } from 'src/app/models/dailyworktask.model';
import { AttachmentList } from 'src/app/models/Excludetask'; import { AttachmentList } from 'src/app/models/Excludetask';
import { PermissionService } from 'src/app/OtherService/permission.service'; import { PermissionService } from 'src/app/OtherService/permission.service';
import { synchro } from 'src/app/services/socket/synchro.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { Platform } from '@ionic/angular';
@Component({ @Component({
selector: 'app-despacho', selector: 'app-despacho',
templateUrl: './despacho.page.html', templateUrl: './despacho.page.html',
@@ -27,20 +31,22 @@ export class DespachoPage implements OnInit {
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
customDate:any; customDate: any;
// task: customTask; // task: customTask;
task; task;
attachments:any; attachments: any;
fulltask: any; fulltask: any;
eventsList: Event[] = []; eventsList: Event[] = [];
serialnumber: string; serialnumber: string;
caller:string; caller: string;
profile: string; profile: string;
intervenientes: any; intervenientes: any;
cc: any = []; cc: any = [];
synch = synchro;
constructor(private activateRoute: ActivatedRoute, constructor(private activateRoute: ActivatedRoute,
private processes: ProcessesService, private processes: ProcessesService,
private iab: InAppBrowser, private iab: InAppBrowser,
@@ -51,13 +57,17 @@ export class DespachoPage implements OnInit {
private toastService: ToastService, private toastService: ToastService,
private despachoService: DespachoService, private despachoService: DespachoService,
private location: Location, private location: Location,
public p: PermissionService) { public p: PermissionService,
private sqliteservice: SqliteService,
private platform: Platform
) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if(params["params"].SerialNumber) { if (params["params"].SerialNumber) {
this.serialnumber = params["params"].SerialNumber; this.serialnumber = params["params"].SerialNumber;
} }
if(params["params"].caller) { if (params["params"].caller) {
this.caller = params["params"].caller; this.caller = params["params"].caller;
} }
}); });
@@ -70,8 +80,8 @@ export class DespachoPage implements OnInit {
return; return;
} }
}); });
this.getFromDb()
this.LoadTaskDetail(this.serialnumber)
} }
close() { close() {
@@ -111,12 +121,13 @@ export class DespachoPage implements OnInit {
} }
async LoadTaskDetail(serial: string) { async LoadTaskDetail(serial: string) {
this.processes.GetTask(serial).subscribe( (res: fullTask) => { this.processes.GetTask(serial).subscribe((res: fullTask) => {
console.log('despacho detail', res)
this.task = { this.task = {
"SerialNumber": res.serialNumber, "SerialNumber": res.serialNumber,
"Folio": res.workflowInstanceDataFields.Subject, "Folio": res.workflowInstanceDataFields.Subject,
"Senders": res.originator.email, "Senders": res.originator.email,
"CreateDate": momentG(new Date(res.taskStartDate),'yyyy-MM-dd HH:mm:ss'), "CreateDate": momentG(new Date(res.taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": res.workflowInstanceDataFields.ViewerRequest, "DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
"Remetente": res.workflowInstanceDataFields.Sender, "Remetente": res.workflowInstanceDataFields.Sender,
"Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note, "Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note,
@@ -129,27 +140,33 @@ export class DespachoPage implements OnInit {
"activityInstanceName": res.activityInstanceName, "activityInstanceName": res.activityInstanceName,
"Status": res.workflowInstanceDataFields.Status, "Status": res.workflowInstanceDataFields.Status,
} }
this.sqliteservice.updateProcess(res);
this.fulltask = res; this.fulltask = res;
let thedate = new Date(this.task.CreateDate); let thedate = new Date(this.task.CreateDate);
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]); this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
this.processes.GetTaskParticipants(this.task.FolderID).subscribe(users=>{ this.processes.GetTaskParticipants(this.task.FolderID).subscribe(users => {
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users))
console.log('interveniers online', users)
this.intervenientes = users.filter(user=>{ this.intervenientes = users.filter(user => {
console.log('interveniers online 2', users)
return user.Type == 'I'; return user.Type == 'I';
}); });
this.cc = users.filter(user=>{ this.cc = users.filter(user => {
console.log('interveniers online 3', users)
return user.Type == 'CC'; return user.Type == 'CC';
}); });
}); });
}, (error)=>{ }, (error) => {
try { try {
this.goBack() this.goBack()
} catch (e) { } catch (e) {
this.location.back(); this.location.back();
} finally { } finally {
if(error.status == 0) { if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else { } else {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
@@ -158,10 +175,84 @@ export class DespachoPage implements OnInit {
}); });
} }
viewDocument(docId:string) { getFromDb() {
this.processes.GetDocumentUrl(docId, '361').subscribe(res=>{ if (synchro.connected === true) {
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); this.LoadTaskDetail(this.serialnumber)
const browser = this.iab.create('https://equilibrium.dyndns.info/FileShare/pdfjs/web/viewer.html?file=https://equilibrium.dyndns.info/FileShare/merged_fastview.pdf', "_blank", 'location=yes,x=0,y=200,width=437,height=650,fullscreen=no'); }
if (synchro.connected === false) {
this.platform.ready().then(() => {
this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var intervine = JSON.parse(process[0].interveners)
var origina
if (process[0].originator === "undefined") {
origina = ""
} else {
origina = JSON.parse(process[0].originator)
}
console.log('sqlite', process)
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": workflow.Subject,
"Senders": origina.email || process[0].originator,
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": workflow.ViewerRequest,
"Remetente": workflow.Sender,
"Note": workflow.TaskMessage || workflow.Note,
"FolderId": workflow.FolderID,
"FsId": workflow.FsId,
"DocId": workflow.DocID,
"DocumentsQty": process[0].DocumentsQty,
"WorkflowName": process[0].workflowDisplayName,
"DeadlineType": workflow.DeadlineType,
"activityInstanceName": process[0].activityInstanceName,
"Status": workflow.Status,
}
let thedate = new Date(this.task.CreateDate);
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
let fulltak = {
Documents: JSON.parse(process[0].Documents),
actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL,
originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName
}
this.fulltask = fulltak;
console.log('interveniers offline', intervine)
this.intervenientes = intervine.filter(user => {
console.log('interveniers offline 2', user)
return user.Type == 'I';
});
this.cc = intervine.filter(user => {
console.log('interveniers offline 3', user)
return user.Type == 'CC';
});
})
})
}
}
viewDocument(docId: string) {
this.processes.GetDocumentUrl(docId, '361').subscribe(res => {
const url: string = res.replace("webTRIX.Viewer", "webTRIX.Viewer.Branch1");
const browser = this.iab.create(url, "_blank");
browser.show(); browser.show();
}); });
} }
@@ -171,7 +262,7 @@ export class DespachoPage implements OnInit {
this.modalController.dismiss(); this.modalController.dismiss();
} }
async executado(note:string, documents:any) { async executado(note: string, documents: any) {
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -179,7 +270,7 @@ export class DespachoPage implements OnInit {
await this.despachoService.executado(note, documents, this.serialnumber).toPromise(); await this.despachoService.executado(note, documents, this.serialnumber).toPromise();
this.toastService.successMessage('Processo criado') this.toastService.successMessage('Processo criado')
this.close(); this.close();
} catch(error) { } catch (error) {
this.toastService.badRequest("Processo não criado") this.toastService.badRequest("Processo não criado")
} }
finally { finally {
@@ -187,12 +278,12 @@ export class DespachoPage implements OnInit {
} }
} }
async arquivar(note:string, documents: AttachmentList) { async arquivar(note: string, documents: AttachmentList) {
const loader = this.toastService.loading() const loader = this.toastService.loading()
try { try {
await this.despachoService.arquivar(note, documents,this.serialnumber).toPromise() await this.despachoService.arquivar(note, documents, this.serialnumber).toPromise()
this.toastService.successMessage('Processo descartado') this.toastService.successMessage('Processo descartado')
this.close(); this.close();
} catch (error) { } catch (error) {
@@ -204,7 +295,7 @@ export class DespachoPage implements OnInit {
} }
async reexecute(note:string, documents:any) { async reexecute(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialnumber, "serialNumber": this.serialnumber,
"action": "Reexecução", "action": "Reexecução",
@@ -212,7 +303,7 @@ export class DespachoPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -237,7 +328,7 @@ export class DespachoPage implements OnInit {
async sendExpedienteToPending() { async sendExpedienteToPending() {
this.despachoService.sendExpedienteToPending(this.serialnumber).subscribe(res=>{ this.despachoService.sendExpedienteToPending(this.serialnumber).subscribe(res => {
this.goBack(); this.goBack();
this.toastService.successMessage() this.toastService.successMessage()
}, },
@@ -247,16 +338,16 @@ export class DespachoPage implements OnInit {
} }
async openAddNoteModal(actionName:string) { async openAddNoteModal(actionName: string) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'add-note-modal-no-height' classs = 'add-note-modal-no-height'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: AddNotePage, component: AddNotePage,
componentProps:{ componentProps: {
showAttachmentBtn: true, showAttachmentBtn: true,
}, },
cssClass: classs, cssClass: classs,
@@ -265,8 +356,8 @@ export class DespachoPage implements OnInit {
await modal.present(); await modal.present();
modal.onDidDismiss().then( async (res) => { modal.onDidDismiss().then(async (res) => {
if(res.data){ if (res.data) {
const DocumentToSave = res.data.documents.map((e) => { const DocumentToSave = res.data.documents.map((e) => {
return { return {
@@ -280,16 +371,16 @@ export class DespachoPage implements OnInit {
Attachments: DocumentToSave, Attachments: DocumentToSave,
} }
if(actionName == 'Executado'){ if (actionName == 'Executado') {
await this.executado(res.data.note, docs); await this.executado(res.data.note, docs);
this.goBack(); this.goBack();
} }
else if(actionName == 'Arquivar'){ else if (actionName == 'Arquivar') {
await this.arquivar(res.data.note, docs); await this.arquivar(res.data.note, docs);
this.goBack(); this.goBack();
} }
else if(actionName == 'Reexecução'){ else if (actionName == 'Reexecução') {
await this.reexecute(res.data.note, docs); await this.reexecute(res.data.note, docs);
this.goBack(); this.goBack();
} }
@@ -300,7 +391,7 @@ export class DespachoPage implements OnInit {
async openExpedientActionsModal(taskAction: any, task: any) { async openExpedientActionsModal(taskAction: any, task: any) {
let classs; let classs;
if( window.innerWidth <= 800) { if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -316,10 +407,10 @@ export class DespachoPage implements OnInit {
cssClass: classs, cssClass: classs,
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then( async (res)=>{ modal.onDidDismiss().then(async (res) => {
console.log(res['data']); console.log(res['data']);
if(res['data']=='openDiscart'){ if (res['data'] == 'openDiscart') {
await this.distartExpedientModal(); await this.distartExpedientModal();
} }
@@ -329,7 +420,7 @@ export class DespachoPage implements OnInit {
async openBookMeetingModal(task: any) { async openBookMeetingModal(task: any) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -348,7 +439,7 @@ export class DespachoPage implements OnInit {
async openDelegarModal(task: any) { async openDelegarModal(task: any) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -362,7 +453,7 @@ export class DespachoPage implements OnInit {
backdropDismiss: false backdropDismiss: false
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
this.goBack(); this.goBack();
}); });
} }
@@ -381,8 +472,8 @@ export class DespachoPage implements OnInit {
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
if(res['data']=='close'){ if (res['data'] == 'close') {
this.close(); this.close();
/* console.log('2Expedient Discard closed2'); /* console.log('2Expedient Discard closed2');
this.close(); this.close();
@@ -33,7 +33,7 @@
<ion-list> <ion-list>
<div <div
class="expediente ion-no-padding ion-no-margin cursor-pointer" class="expediente ion-no-padding ion-no-margin cursor-pointer"
*ngFor = "let task of despachoStore.list; let i = index" *ngFor = "let task of listToPresent; let i = index"
(click)="GoToDespacho(task.SerialNumber)" (click)="GoToDespacho(task.SerialNumber)"
> >
<!-- [routerLink]="['/home/gabinete-digital/expediente',task.SerialNumber]" --> <!-- [routerLink]="['/home/gabinete-digital/expediente',task.SerialNumber]" -->
@@ -68,13 +68,13 @@
</div> </div>
<div <div
*ngIf="!skeletonLoader && despachoStore.list.length == 0" *ngIf="!skeletonLoader && listToPresent.length == 0"
class="empty-list d-flex height-100 align-center justify-content-center" class="empty-list d-flex height-100 align-center justify-content-center"
> >
<span>Lista vazia</span> <span>Lista vazia</span>
</div> </div>
<div *ngIf="skeletonLoader && despachoStore.list.length == 0"> <div *ngIf="skeletonLoader && listToPresent.length == 0">
<ion-list> <ion-list>
<ion-item> <ion-item>
@@ -3,6 +3,11 @@ import { NavigationStart, Router } from '@angular/router';
import { DespachoService } from 'src/app/Rules/despacho.service'; import { DespachoService } from 'src/app/Rules/despacho.service';
import { DespachoStore } from 'src/app/store/despacho-store.service'; import { DespachoStore } from 'src/app/store/despacho-store.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
import { Platform } from '@ionic/angular';
import { isThisHour } from 'date-fns';
@Component({ @Component({
selector: 'app-despachos', selector: 'app-despachos',
templateUrl: './despachos.page.html', templateUrl: './despachos.page.html',
@@ -12,31 +17,21 @@ import { DespachoStore } from 'src/app/store/despacho-store.service';
export class DespachosPage implements OnInit { export class DespachosPage implements OnInit {
despachoStore = DespachoStore; despachoStore = DespachoStore;
synch = synchro;
listToPresent = [];
constructor ( constructor(
private router: Router, private router: Router,
private despachoRule: DespachoService private despachoRule: DespachoService,
private sqliteservice: SqliteService,
private platform: Platform
) { ) {
} }
ngOnInit() { ngOnInit() {
const location = window.location this.getFromDb()
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.refreshing()
} else {
this.LoadList()
}
}
});
} }
async refreshing() { async refreshing() {
@@ -51,7 +46,60 @@ export class DespachosPage implements OnInit {
async LoadList() { async LoadList() {
await this.despachoRule.getList({updateStore: true}) await this.despachoRule.getList({ updateStore: true }).then((pre) => {
this.listToPresent = pre;
console.log('despachooo', pre)
})
}
getFromDb() {
if (synchro.connected === true) {
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.refreshing()
} else {
this.LoadList()
}
}
});
}
if (synchro.connected === false) {
this.platform.ready().then(() => {
this.sqliteservice.getDespachosProcess('Tarefa de Despacho').then((process: any[]) => {
var listtopresent = [];
process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
let task = {
"CreateDate": element.taskStartDate,
"DocId": workflow.DispatchDocID,
"DocumentURL": undefined,
"DocumentsQty": element.totalDocuments,
"FolderID": workflow.FolderID,
"Folio": workflow.Subject,
"Remetente": undefined,
"Senders": workflow.Sender,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"WorkflowName": element.workflowDisplayName
}
listtopresent.push(task);
});
this.listToPresent = listtopresent;
})
})
}
} }
get skeletonLoader(): boolean { get skeletonLoader(): boolean {
@@ -66,9 +114,8 @@ export class DespachosPage implements OnInit {
}, 2000); }, 2000);
} }
async GoToDespacho(serialNumber:any) { async GoToDespacho(serialNumber: any) {
console.log('Despachos serial',serialNumber) this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
this.router.navigate(['/home/gabinete-digital/despachos',serialNumber,'gabinete-digital']);
} }
@@ -12,6 +12,9 @@ import { DeplomaOptionsPage } from 'src/app/shared/popover/deploma-options/deplo
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
@Component({ @Component({
selector: 'app-diploma', selector: 'app-diploma',
templateUrl: './diploma.page.html', templateUrl: './diploma.page.html',
@@ -42,6 +45,7 @@ export class DiplomaPage implements OnInit {
private animationController: AnimationController, private animationController: AnimationController,
private toastService: ToastService, private toastService: ToastService,
private location: Location, private location: Location,
private sqliteservice: SqliteService
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]); // console.log(params["params"]);
@@ -59,7 +63,7 @@ export class DiplomaPage implements OnInit {
ngOnInit() { ngOnInit() {
this.profile = "mdgpr"; this.profile = "mdgpr";
this.LoadTaskDetail(this.serialNumber); this.getFromDb();
} }
goBack() { goBack() {
@@ -125,11 +129,15 @@ export class DiplomaPage implements OnInit {
"activityInstanceName": res.activityInstanceName, "activityInstanceName": res.activityInstanceName,
} }
this.fulltask = res; this.fulltask = res;
this.sqliteservice.updateProcess(res)
let thedate = new Date(this.task.CreateDate); let thedate = new Date(this.task.CreateDate);
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]); this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]);
this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users=>{ this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users=>{
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users)).then(() => {
console.log('internen diploma ')
})
this.intervenientes = users.filter(user=>{ this.intervenientes = users.filter(user=>{
return user.Type == 'I'; return user.Type == 'I';
}); });
@@ -155,6 +163,62 @@ export class DiplomaPage implements OnInit {
} }
getFromDb() {
if(synchro.connected === true) {
this.LoadTaskDetail(this.serialNumber);
} else {
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
"Senders": JSON.parse(process[0].originator).email,
"CreateDate": momentG(new Date(process[0].taskStartDate),'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage || JSON.parse(process[0].workflowInstanceDataFields).Note,
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
"FsId": '361',
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DispatchDocId,
"WorkflowName": process[0].workflowDisplayName,
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
"activityInstanceName": process[0].activityInstanceName,
}
let fulltak = {
Documents: JSON.parse(process[0].Documents),
actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL,
originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName
}
this.fulltask = fulltak
let thedate = new Date(this.task.CreateDate);
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]);
this.intervenientes = JSON.parse(process[0].interveners).filter(user=>{
return user.Type == 'I';
});
this.cc = JSON.parse(process[0].interveners).filter(user=>{
return user.Type == 'CC';
});
this.attachments = JSON.parse(process[0].Documents)
})
}
}
viewDocument(docId:string){ viewDocument(docId:string){
this.processes.GetDocumentUrl(docId, '361').subscribe(res=>{ this.processes.GetDocumentUrl(docId, '361').subscribe(res=>{
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
@@ -3,34 +3,38 @@ import { ActivatedRoute, NavigationEnd, NavigationError, NavigationExtras, Navig
import { DailyWorkTask } from '../../../models/dailyworktask.model'; import { DailyWorkTask } from '../../../models/dailyworktask.model';
import { ProcessesService } from 'src/app/services/processes.service'; import { ProcessesService } from 'src/app/services/processes.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
@Component({ @Component({
selector: 'app-diplomas', selector: 'app-diplomas',
templateUrl: './diplomas.page.html', templateUrl: './diplomas.page.html',
styleUrls: ['./diplomas.page.scss'], styleUrls: ['./diplomas.page.scss'],
}) })
export class DiplomasPage implements OnInit, OnDestroy { export class DiplomasPage implements OnInit, OnDestroy {
list:DailyWorkTask[] = []; list: DailyWorkTask[] = [];
diplomasList:DailyWorkTask[] = []; diplomasList: DailyWorkTask[] = [];
diplomasAssinadoList:DailyWorkTask[] = []; diplomasAssinadoList: DailyWorkTask[] = [];
showLoader: boolean; showLoader: boolean;
totalDocs:any; totalDocs: any;
serialNumber:string; serialNumber: string;
segment:string; segment: string;
skeletonLoader = true skeletonLoader = true
constructor( constructor(
private processes:ProcessesService, private processes: ProcessesService,
private router: Router, private router: Router,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private sqliteservice: SqliteService
) { ) {
this.diplomasList = []; this.diplomasList = [];
//Inicializar segment //Inicializar segment
this.segment = 'validar'; this.segment = 'validar';
this.activatedRoute.queryParams.subscribe(params => { this.activatedRoute.queryParams.subscribe(params => {
if(params['validar'] == 'true') { if (params['validar'] == 'true') {
this.segment = 'validar'; this.segment = 'validar';
} else if (params['assinados'] == 'true') { } else if (params['assinados'] == 'true') {
this.segment = 'assinados'; this.segment = 'assinados';
@@ -43,27 +47,14 @@ export class DiplomasPage implements OnInit, OnDestroy {
//this.segment = 'validar'; //this.segment = 'validar';
this.activatedRoute.queryParams.subscribe(params => { this.activatedRoute.queryParams.subscribe(params => {
if(params['segment'] == 'validar') { if (params['segment'] == 'validar') {
this.segment = 'validar'; this.segment = 'validar';
} else if (params['segment'] == 'assinados') { } else if (params['segment'] == 'assinados') {
this.segment = 'assinados'; this.segment = 'assinados';
} }
}); });
const location = window.location this.getFromDb()
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.refreshing()
} else {
this.LoadList()
}
}
});
} }
@@ -141,7 +132,7 @@ export class DiplomasPage implements OnInit, OnDestroy {
}); });
} */ } */
async getTotalDocs(DocId:any) { async getTotalDocs(DocId: any) {
let res = await this.processes.GetDocumentDetails(DocId, '361').toPromise(); let res = await this.processes.GetDocumentDetails(DocId, '361').toPromise();
console.log(res.DocumentsTotal); console.log(res.DocumentsTotal);
return res.DocumentsTotal; return res.DocumentsTotal;
@@ -155,7 +146,7 @@ export class DiplomasPage implements OnInit, OnDestroy {
this.LoadList(); this.LoadList();
} }
goToDiploma(serialNumber:any) { goToDiploma(serialNumber: any) {
this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']);
} }
@@ -192,11 +183,54 @@ export class DiplomasPage implements OnInit, OnDestroy {
} }
getFromDb() {
if (synchro.connected === true) {
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.refreshing()
} else {
this.LoadList()
}
}
});
} else {
this.sqliteservice.getprocessByworkflow("Despacho do Presidente da República").then((process: any[]) => {
let diplomasValidar = process.filter(data => data.activityInstanceName == "Revisar Diploma");
let diplomasList = [];
diplomasValidar.forEach(async element => {
let task = this.pipeTaskOffline(element)
diplomasList.push(task);
});
this.diplomasList = this.sortArrayISODate(diplomasList.reverse());
let diplomasAssinados = process.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
let diplomasAssinadoList = []
diplomasAssinados.forEach(async element => {
let task = this.pipeTaskOffline(element)
diplomasAssinadoList.push(task);
});
console.log('diplomasAssinados', diplomasAssinados)
this.diplomasAssinadoList = this.sortArrayISODate(diplomasAssinadoList).reverse();
})
}
}
pipeTask(element) { pipeTask(element) {
let date = new Date(element.taskStartDate); let date = new Date(element.taskStartDate);
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
return { return {
"SerialNumber": element.serialNumber, "SerialNumber": element.serialNumber,
"Folio": element.workflowInstanceDataFields.Subject, "Folio": element.workflowInstanceDataFields.Subject,
@@ -212,8 +246,28 @@ export class DiplomasPage implements OnInit, OnDestroy {
} }
} }
pipeTaskOffline(element) {
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();
return {
"SerialNumber": element.serialNumber,
"Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
"Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
"Status": JSON.parse(element.workflowInstanceDataFields).Status,
}
}
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
return myArray.sort(function(a, b) { return myArray.sort(function (a, b) {
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0); return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
}); });
} }
@@ -79,8 +79,7 @@ export class ApproveEventPage implements OnInit {
console.log(this.serialNumber); console.log(this.serialNumber);
console.log(this.caller); console.log(this.caller);
this.getProcessFromDB(); this.getProcessFromDB();
console.log("Aprove enet")
//this.getTask();
} }
goBack() { goBack() {
@@ -106,6 +105,10 @@ export class ApproveEventPage implements OnInit {
getProcessFromDB() { getProcessFromDB() {
if (synchro.connected === true) {
this.getTask();
}
synchro.registerCallback('Offline', () => { synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => { this.platform.ready().then(() => {
@@ -46,13 +46,24 @@ export class EventListPage implements OnInit {
) { } ) { }
ngOnInit() { ngOnInit() {
this.segment = 'MDGPR'; this.segment = 'MDGPR';
const location = window.location
const pathname = location.pathname + location.search
this.getEventToAproveFromDB(); this.getEventToAproveFromDB();
window.onresize = (event) => {
// if not mobile remove all component
if( window.innerWidth <= 800){
this.modalController.dismiss();
}
};
}
getEventToAproveFromDB() {
if( synchro.connected === true) {
const location = window.location
const pathname = location.pathname + location.search
this.LoadToApproveEvents() this.LoadToApproveEvents()
@@ -65,18 +76,7 @@ export class EventListPage implements OnInit {
} }
} }
}); });
window.onresize = (event) => {
// if not mobile remove all component
if( window.innerWidth <= 800){
this.modalController.dismiss();
} }
};
}
getEventToAproveFromDB() {
synchro.registerCallback('Offline', () => { synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => { this.platform.ready().then(() => {
@@ -37,18 +37,18 @@ export class ExpedienteDetailPage implements OnInit {
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
customDate:any; customDate: any;
task: expedienteTask; task: expedienteTask;
fulltask: any; fulltask: any;
eventsList: Event[]; eventsList: Event[];
serialNumber: string; serialNumber: string;
caller:string; caller: string;
profile: string; profile: string;
intervenientes: any; intervenientes: any;
cc: any = []; cc: any = [];
documents:SearchList[] = []; documents: SearchList[] = [];
attachments:any; attachments: any;
hideSendToPendentes = true hideSendToPendentes = true
searchDocumentPipe = new SearchDocumentPipe() searchDocumentPipe = new SearchDocumentPipe()
@@ -75,10 +75,10 @@ export class ExpedienteDetailPage implements OnInit {
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if(params["params"].SerialNumber) { if (params["params"].SerialNumber) {
this.serialNumber = params["params"].SerialNumber; this.serialNumber = params["params"].SerialNumber;
} }
if(params["params"].caller) { if (params["params"].caller) {
this.caller = params["params"].caller; this.caller = params["params"].caller;
} }
}); });
@@ -86,9 +86,6 @@ export class ExpedienteDetailPage implements OnInit {
ngOnInit() { ngOnInit() {
this.getFromDB(); this.getFromDB();
if(this.onlinecheck) {
this.LoadTaskDetail(this.serialNumber);
}
} }
@@ -102,9 +99,9 @@ export class ExpedienteDetailPage implements OnInit {
getFromDB() { getFromDB() {
synchro.registerCallback('Online', () => { if(synchro.connected === true) {
this.onlinecheck = true; this.LoadTaskDetail(this.serialNumber);
}) }
synchro.registerCallback('Offline', () => { synchro.registerCallback('Offline', () => {
@@ -114,13 +111,18 @@ export class ExpedienteDetailPage implements OnInit {
console.log("expedient ditail", process) console.log("expedient ditail", process)
var workflow = JSON.parse(process[0].workflowInstanceDataFields); var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var origina = JSON.parse(process[0].originator) var origina
if (process[0].originator === "undefined") {
origina = ""
} else {
origina = JSON.parse(process[0].originator)
}
this.task = { this.task = {
"SerialNumber": process[0].serialNumber, "SerialNumber": process[0].serialNumber,
"Folio": workflow.Subject, "Folio": workflow.Subject,
"Senders": origina.email, "Senders": origina.email || process[0].originator,
"CreateDate": momentG(new Date(process[0].taskStartDate),'yyyy-MM-dd HH:mm:ss'), "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": workflow.ViewerRequest, "DocumentURL": workflow.ViewerRequest,
"Remetente": workflow.Sender, "Remetente": workflow.Sender,
"Note": workflow.TaskMessage || workflow.Note, "Note": workflow.TaskMessage || workflow.Note,
@@ -140,15 +142,15 @@ export class ExpedienteDetailPage implements OnInit {
} }
async approve(note:string, documents:any) { async approve(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Aprovar", "action": "Aprovar",
"ActionTypeId": 100000004 , "ActionTypeId": 100000004,
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
console.log(body); console.log(body);
@@ -159,7 +161,7 @@ export class ExpedienteDetailPage implements OnInit {
await this.processes.CompleteTask(body).toPromise(); await this.processes.CompleteTask(body).toPromise();
this.close(); this.close();
this.toastService.successMessage('Processo aprovado') this.toastService.successMessage('Processo aprovado')
} catch(error) { } catch (error) {
this.toastService.badRequest('Processo não aprovado') this.toastService.badRequest('Processo não aprovado')
} finally { } finally {
loader.remove() loader.remove()
@@ -167,7 +169,7 @@ export class ExpedienteDetailPage implements OnInit {
} }
async sendToReview(note:string, documents:any) { async sendToReview(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Retificar", "action": "Retificar",
@@ -175,7 +177,7 @@ export class ExpedienteDetailPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -184,7 +186,7 @@ export class ExpedienteDetailPage implements OnInit {
await this.processes.CompleteTask(body).toPromise() await this.processes.CompleteTask(body).toPromise()
this.close(); this.close();
this.toastService.successMessage() this.toastService.successMessage()
} catch(error) { } catch (error) {
this.toastService.badRequest() this.toastService.badRequest()
} finally { } finally {
loader.remove() loader.remove()
@@ -192,16 +194,16 @@ export class ExpedienteDetailPage implements OnInit {
} }
async openAddNoteModal(actionName:string) { async openAddNoteModal(actionName: string) {
let classs; let classs;
if( window.innerWidth < 701) { if (window.innerWidth < 701) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'add-note-modal' classs = 'add-note-modal'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: AddNotePage, component: AddNotePage,
componentProps:{ componentProps: {
showAttachmentBtn: false, showAttachmentBtn: false,
}, },
cssClass: classs, cssClass: classs,
@@ -212,7 +214,7 @@ export class ExpedienteDetailPage implements OnInit {
modal.onDidDismiss().then(res => { modal.onDidDismiss().then(res => {
console.log(res); console.log(res);
if(res.data){ if (res.data) {
const DocumentToSave = res.data.documents.map((e) => { const DocumentToSave = res.data.documents.map((e) => {
return { return {
ApplicationId: e.ApplicationType, ApplicationId: e.ApplicationType,
@@ -225,10 +227,10 @@ export class ExpedienteDetailPage implements OnInit {
Attachments: DocumentToSave, Attachments: DocumentToSave,
} }
if(actionName == 'Aprovar'){ if (actionName == 'Aprovar') {
this.approve(res.data.note, docs); this.approve(res.data.note, docs);
} }
else if(actionName == 'Revisão'){ else if (actionName == 'Revisão') {
this.sendToReview(res.data.note, docs); this.sendToReview(res.data.note, docs);
} }
this.goBack(); this.goBack();
@@ -278,12 +280,12 @@ export class ExpedienteDetailPage implements OnInit {
} }
sendExpedienteToPending() { sendExpedienteToPending() {
this.processes.SetTaskToPending(this.serialNumber).subscribe(res=>{ this.processes.SetTaskToPending(this.serialNumber).subscribe(res => {
console.log(res); console.log(res);
this.toastService.successMessage('Processo enviado para pendentes') this.toastService.successMessage('Processo enviado para pendentes')
this.goBack(); this.goBack();
}, },
(error)=>{ (error) => {
this.toastService.badRequest('Processo não enviado para pendentes') this.toastService.badRequest('Processo não enviado para pendentes')
}); });
} }
@@ -297,7 +299,7 @@ export class ExpedienteDetailPage implements OnInit {
"SerialNumber": res.serialNumber, "SerialNumber": res.serialNumber,
"Folio": res.workflowInstanceDataFields.Subject, "Folio": res.workflowInstanceDataFields.Subject,
"Senders": res.originator.email, "Senders": res.originator.email,
"CreateDate": momentG(new Date(res.taskStartDate),'yyyy-MM-dd HH:mm:ss'), "CreateDate": momentG(new Date(res.taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": res.workflowInstanceDataFields.ViewerRequest, "DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
"Remetente": res.workflowInstanceDataFields.Sender, "Remetente": res.workflowInstanceDataFields.Sender,
"Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note, "Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note,
@@ -315,14 +317,14 @@ export class ExpedienteDetailPage implements OnInit {
this.sqliteservice.updateProcess(res) this.sqliteservice.updateProcess(res)
let thedate = new Date(this.task.CreateDate); let thedate = new Date(this.task.CreateDate);
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]); this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users=>{ this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users => {
this.intervenientes = users.filter(user=>{ this.intervenientes = users.filter(user => {
return user.Type == 'I'; return user.Type == 'I';
}); });
this.cc = users.filter(user=>{ this.cc = users.filter(user => {
return user.Type == 'CC'; return user.Type == 'CC';
}); });
}) })
@@ -330,14 +332,14 @@ export class ExpedienteDetailPage implements OnInit {
console.log('this.task', this.task.InstanceID) console.log('this.task', this.task.InstanceID)
console.log('this.task.DocumentURL', this.task.DocumentURL) console.log('this.task.DocumentURL', this.task.DocumentURL)
}, (error)=>{ }, (error) => {
try { try {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
this.goBack() this.goBack()
} catch (e) { } catch (e) {
window.history.back(); window.history.back();
} finally { } finally {
if(error.status == 0) { if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else { } else {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
@@ -353,15 +355,15 @@ export class ExpedienteDetailPage implements OnInit {
} }
viewDocument(DocId:string) { viewDocument(DocId: string) {
this.expedienteService.viewDocument({ApplicationId:'361', DocId}) this.expedienteService.viewDocument({ ApplicationId: '361', DocId })
} }
getAttachments(serialNumber) { getAttachments(serialNumber) {
console.log(serialNumber); console.log(serialNumber);
this.attachmentsService.getAttachmentsBySerial(serialNumber).subscribe(res=>{ this.attachmentsService.getAttachmentsBySerial(serialNumber).subscribe(res => {
this.attachments = res; this.attachments = res;
console.log('res', res); console.log('res', res);
}); });
@@ -382,8 +384,8 @@ export class ExpedienteDetailPage implements OnInit {
} }
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then( async (res)=> { modal.onDidDismiss().then(async (res) => {
if(res){ if (res) {
const data = res.data; const data = res.data;
this.documents.push(data.selected); this.documents.push(data.selected);
this.documents.forEach((element: any) => { this.documents.forEach((element: any) => {
@@ -402,11 +404,11 @@ export class ExpedienteDetailPage implements OnInit {
const loader = this.toastService.loading() const loader = this.toastService.loading()
this.attachmentsService.AddAttachment(body).subscribe((res)=> { this.attachmentsService.AddAttachment(body).subscribe((res) => {
this.toastService.successMessage() this.toastService.successMessage()
}, ()=> { }, () => {
this.toastService.badRequest() this.toastService.badRequest()
}, ()=> { }, () => {
loader.remove() loader.remove()
}); });
@@ -418,7 +420,7 @@ export class ExpedienteDetailPage implements OnInit {
async openExpedientActionsModal(taskAction: any, task: any) { async openExpedientActionsModal(taskAction: any, task: any) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -433,9 +435,9 @@ export class ExpedienteDetailPage implements OnInit {
cssClass: classs, cssClass: classs,
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then( async(res)=>{ modal.onDidDismiss().then(async (res) => {
let body = res['data']; let body = res['data'];
if(res['data']) { if (res['data']) {
const loader = this.toastService.loading() const loader = this.toastService.loading()
try { try {
await this.processes.CompleteTask(body).toPromise(); await this.processes.CompleteTask(body).toPromise();
@@ -446,13 +448,13 @@ export class ExpedienteDetailPage implements OnInit {
loader.remove() loader.remove()
} }
} }
else{ else {
this.close(); this.close();
} }
}); });
} }
async distartExpedientModal(body:any) { async distartExpedientModal(body: any) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: DiscartExpedientModalPage, component: DiscartExpedientModalPage,
componentProps: { componentProps: {
@@ -462,16 +464,16 @@ export class ExpedienteDetailPage implements OnInit {
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then( async (res)=>{ modal.onDidDismiss().then(async (res) => {
console.log(res['data']); console.log(res['data']);
if(body == 'descartar') { if (body == 'descartar') {
if(res['data']== 'Yes') { if (res['data'] == 'Yes') {
const loader = this.toastService.loading() const loader = this.toastService.loading()
try { try {
await this.expedienteService.discard({SerialNumber: this.task.SerialNumber}).toPromise() await this.expedienteService.discard({ SerialNumber: this.task.SerialNumber }).toPromise()
this.toastService.successMessage('Processo descartado'); this.toastService.successMessage('Processo descartado');
this.goBack(); this.goBack();
} catch (error) { } catch (error) {
@@ -481,12 +483,12 @@ export class ExpedienteDetailPage implements OnInit {
} }
} }
else if(res['data'] == 'No'){ else if (res['data'] == 'No') {
//Do nothing //Do nothing
} }
} }
else{ else {
if(res['data']== 'Yes') { if (res['data'] == 'Yes') {
const loader = this.toastService.loading() const loader = this.toastService.loading()
try { try {
@@ -500,7 +502,7 @@ export class ExpedienteDetailPage implements OnInit {
} }
} }
else if(res['data'] == 'No') { else if (res['data'] == 'No') {
console.log('Update'); console.log('Update');
const loader = this.toastService.loading() const loader = this.toastService.loading()
try { try {
@@ -521,7 +523,7 @@ export class ExpedienteDetailPage implements OnInit {
console.log(task); console.log(task);
let classs; let classs;
if( window.innerWidth < 701){ if (window.innerWidth < 701) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -535,12 +537,12 @@ export class ExpedienteDetailPage implements OnInit {
backdropDismiss: false backdropDismiss: false
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
this.goBack(); this.goBack();
}); });
} }
goToEvent(eventId:any) { goToEvent(eventId: any) {
this.router.navigate(['/home/events', eventId, 'expediente']); this.router.navigate(['/home/events', eventId, 'expediente']);
} }
@@ -570,7 +572,7 @@ export class ExpedienteDetailPage implements OnInit {
componentProps: { componentProps: {
task: this.task, task: this.task,
fulltask: this.fulltask, fulltask: this.fulltask,
taskAction:taskAction, taskAction: taskAction,
}, },
translucent: true translucent: true
}); });
@@ -39,12 +39,10 @@ export class ExpedientePage implements OnInit {
ngOnInit() { ngOnInit() {
const location = window.location
const pathname = location.pathname + location.search
this.getEventsFromLocalDb(); this.getEventsFromLocalDb();
console.log("segrsgre") console.log("segrsgre")
<<<<<<< HEAD
this.LoadList() this.LoadList()
@@ -58,6 +56,8 @@ export class ExpedientePage implements OnInit {
} }
}); });
=======
>>>>>>> branchBug
} }
async LoadList() { async LoadList() {
@@ -74,6 +74,7 @@ export class ExpedientePage implements OnInit {
let task = this.expedienteTaskPipe.transform(element) let task = this.expedienteTaskPipe.transform(element)
this.taskslist.push(task); this.taskslist.push(task);
this.sqliteservice.addProcess(task);
}); });
this.listToPresent = this.taskslist this.listToPresent = this.taskslist
@@ -136,17 +137,25 @@ export class ExpedientePage implements OnInit {
getEventsFromLocalDb() { getEventsFromLocalDb() {
synchro.registerCallback('Online', () => { if (synchro.connected === true) {
this.onlinecheck = true; const location = window.location
}) const pathname = location.pathname + location.search
this.LoadList()
this.router.events.forEach((event) => {
synchro.registerCallback('Offline', () => { if (event instanceof NavigationStart && event.url.startsWith(pathname)) {
this.platform.ready().then(() => { if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.onlinecheck = false; this.refreshing()
} else {
this.LoadList()
}
}
});
} else {
this.taskslist = new Array(); this.taskslist = new Array();
this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => { this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => {
console.log("All expedientes from local,", expediente)
expediente.forEach((element) => { expediente.forEach((element) => {
@@ -168,12 +177,9 @@ export class ExpedientePage implements OnInit {
}); });
this.listToPresent = this.taskslist this.listToPresent = this.taskslist
console.log("All expedientes from local,", expediente)
})
console.log('Offlineee')
})
}) })
} }
}
} }
@@ -176,33 +176,9 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
this.segmentVista = "boxview" this.segmentVista = "boxview"
} }
const pathname = window.location.pathname
this.getAllProcessFromDB() this.getAllProcessFromDB()
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == pathname) {
this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.checkRoutes();
this.LoadCounts();
}
})
}
});
this.hideRefreshButton();
this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.loadAllProcesses();
}
})
} }
async loadAllProcesses() { async loadAllProcesses() {
@@ -247,7 +223,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
this.allProcessesList = removeDuplicate(this.allProcessesList) this.allProcessesList = removeDuplicate(this.allProcessesList)
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
this.totalDocumentStore.resetCount(this.allProcessesList.length)
}); });
@@ -283,14 +259,31 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
getAllProcessFromDB() { getAllProcessFromDB() {
synchro.registerCallback('Online', () => { if (synchro.connected === true ) {
this.platform.ready().then(() => { const pathname = window.location.pathname
this.loadAllProcesses(); this.router.events.forEach((event) => {
}) if (event instanceof NavigationEnd && event.url == pathname) {
})
synchro.registerCallback('Offline', () => { this.waitForDomService.selector({
this.platform.ready().then(() => { selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.checkRoutes();
this.LoadCounts();
}
})
}
});
this.hideRefreshButton();
this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.loadAllProcesses();
}
})
} else {
this.hideRefreshButton();
this.sqliteservice.getAllProcess().then((allprocess: any[]) => { this.sqliteservice.getAllProcess().then((allprocess: any[]) => {
allprocess.forEach(element => { allprocess.forEach(element => {
@@ -299,7 +292,6 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields); var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields);
console.log("WORKFLOW all process", workflowInstanceDataFields)
let task = { let task = {
"SerialNumber": element.serialNumber, "SerialNumber": element.serialNumber,
@@ -322,14 +314,10 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
this.allProcessesList = removeDuplicate(this.allProcessesList) this.allProcessesList = removeDuplicate(this.allProcessesList)
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
this.totalDocumentStore.resetCount(this.allProcessesList.length)
}); });
console.log("All process from db ", allprocess) console.log("All process from db ", allprocess)
}) })
}) }
console.log('Offlineee')
})
} }
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
@@ -547,7 +535,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
let allPreocesses_ = await this.processesbackend.GetTasksList("", false).toPromise(); let allPreocesses_ = await this.processesbackend.GetTasksList("", false).toPromise();
let count_all_processes = Object.keys(allPreocesses_).length; let count_all_processes = Object.keys(allPreocesses_).length;
this.totalDocumentStore.resetCount(count_all_processes)
let expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise(); let expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise();
expedientes = expedientes.filter(data => data.workflowInstanceDataFields.Status == "Active") expedientes = expedientes.filter(data => data.workflowInstanceDataFields.Status == "Active")
@@ -20,6 +20,9 @@ import { PermissionService } from 'src/app/OtherService/permission.service';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { PedidoService } from 'src/app/Rules/pedido.service'; import { PedidoService } from 'src/app/Rules/pedido.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
@Component({ @Component({
selector: 'app-pedido', selector: 'app-pedido',
@@ -30,10 +33,10 @@ export class PedidoPage implements OnInit {
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
customDate:any; customDate: any;
task: any; task: any;
attachments:any; attachments: any;
fulltask: any; fulltask: any;
eventsList: Event[]; eventsList: Event[];
serialnumber: string; serialnumber: string;
@@ -55,17 +58,18 @@ export class PedidoPage implements OnInit {
private toastService: ToastService, private toastService: ToastService,
public p: PermissionService, public p: PermissionService,
private location: Location, private location: Location,
private pedidoService: PedidoService private pedidoService: PedidoService,
private sqliteservice: SqliteService,
) { ) {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]); // console.log(params["params"]);
if(params["params"].SerialNumber) { if (params["params"].SerialNumber) {
this.serialnumber = params["params"].SerialNumber; this.serialnumber = params["params"].SerialNumber;
} }
if(params["params"].caller) { if (params["params"].caller) {
this.caller = params["params"].caller; this.caller = params["params"].caller;
} }
@@ -73,13 +77,13 @@ export class PedidoPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.LoadTaskDetail(this.serialnumber); this.getfromDb()
} }
close() { close() {
this.modalController.dismiss(); this.modalController.dismiss();
} }
notImplemented(){ notImplemented() {
this.alertService.presentAlert('Funcionalidade em desenvolvimento'); this.alertService.presentAlert('Funcionalidade em desenvolvimento');
} }
@@ -91,12 +95,13 @@ export class PedidoPage implements OnInit {
this.processes.GetTask(this.serialnumber).subscribe(res => { this.processes.GetTask(this.serialnumber).subscribe(res => {
this.fulltask = res this.fulltask = res
console.log('FULLTAK ONLINe', this.fulltask);
if(res.workflowDisplayName == 'Pedido de Parecer' || res.workflowDisplayName == 'Pedido de Parecer do Presidente'){ if (res.workflowDisplayName == 'Pedido de Parecer' || res.workflowDisplayName == 'Pedido de Parecer do Presidente') {
let date = new Date(res.taskStartDate); let date = new Date(res.taskStartDate);
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
this.task = { this.task = {
"SerialNumber": res.serialNumber, "SerialNumber": res.serialNumber,
@@ -116,12 +121,13 @@ export class PedidoPage implements OnInit {
"Status": res.workflowInstanceDataFields.Status, "Status": res.workflowInstanceDataFields.Status,
} }
console.log(this.task); console.log(this.task);
this.sqliteservice.updateProcess(res);
} }
else if(res.workflowDisplayName == 'Pedido de Deferimento'){ else if (res.workflowDisplayName == 'Pedido de Deferimento') {
let date = new Date(res.taskStartDate); let date = new Date(res.taskStartDate);
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
this.task = { this.task = {
"SerialNumber": res.serialNumber, "SerialNumber": res.serialNumber,
@@ -140,28 +146,32 @@ export class PedidoPage implements OnInit {
"activityInstanceName": res.activityInstanceName, "activityInstanceName": res.activityInstanceName,
"Status": res.workflowInstanceDataFields.Status, "Status": res.workflowInstanceDataFields.Status,
} }
this.sqliteservice.updateProcess(res);
} }
let thedate = new Date(res.taskStartDate); let thedate = new Date(res.taskStartDate);
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]); this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
this.processes.GetTaskParticipants(res.workflowInstanceDataFields.FolderID).subscribe(users=>{ this.processes.GetTaskParticipants(res.workflowInstanceDataFields.FolderID).subscribe(users => {
this.intervenientes = users.filter(user=>{ this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users)).then(() =>{
console.log('Pedido ')
})
this.intervenientes = users.filter(user => {
return user.Type == 'I'; return user.Type == 'I';
}); });
this.cc = users.filter(user=>{ this.cc = users.filter(user => {
return user.Type == 'CC'; return user.Type == 'CC';
}); });
}); });
this.getDocumentDetails(res.workflowInstanceDataFields.FolderID, '361'); this.getDocumentDetails(res.workflowInstanceDataFields.FolderID, '361');
}, (error)=>{ }, (error) => {
try { try {
this.goBack() this.goBack()
this.close() this.close()
} catch (e) { } catch (e) {
window.history.back(); window.history.back();
} finally { } finally {
if(error.status == 0) { if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else { } else {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
@@ -171,17 +181,111 @@ export class PedidoPage implements OnInit {
}); });
} }
getDocumentDetails(forlderId:string, applicationId:string){ getfromDb() {
this.processes.GetDocumentDetails(forlderId,applicationId).subscribe(res=>{ if (synchro.connected === true) {
this.LoadTaskDetail(this.serialnumber);
}
if (synchro.connected === false) {
this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
console.log('PROCESS BY ID', process,this.serialnumber )
let fulltak = {
Documents: JSON.parse(process[0].Documents),
actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL,
originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName
}
this.fulltask = fulltak;
console.log('FULLTAK OFFLINE', this.fulltask);
if (process[0].workflowDisplayName == 'Pedido de Parecer' || process[0].workflowDisplayName == 'Pedido de Parecer do Presidente') {
let date = new Date(process[0].taskStartDate);
date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
"FsId": '361',
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
"WorkflowName": process[0].workflowDisplayName,
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
"activityInstanceName": process[0].activityInstanceName,
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
}
this.attachments = JSON.parse(process[0].Documents);
} else if (process[0].workflowDisplayName == 'Pedido de Deferimento') {
let date = new Date(process[0].taskStartDate);
date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
"FsId": '361',
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
"WorkflowName": process[0].workflowDisplayName,
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
"activityInstanceName": process[0].activityInstanceName,
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
}
this.attachments = JSON.parse(process[0].Documents);
}
let thedate = new Date(process[0].taskStartDate);
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'I';
});
this.cc = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'CC';
});
this.getDocumentDetails(JSON.parse(process[0].workflowInstanceDataFields).FolderID, '361');
})
}
}
getDocumentDetails(forlderId: string, applicationId: string) {
this.processes.GetDocumentDetails(forlderId, applicationId).subscribe(res => {
this.attachments = res.Documents; this.attachments = res.Documents;
// console.log(res['Documents']); console.log('Attachment',this.attachments);
}) })
} }
viewDocument(docId:string) { viewDocument(docId: string) {
this.processes.GetDocumentUrl(docId, '361').subscribe(res=>{ this.processes.GetDocumentUrl(docId, '361').subscribe(res => {
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); const url: string = res.replace("webTRIX.Viewer", "webTRIX.Viewer.Branch1");
const browser = this.iab.create(url,"_blank"); const browser = this.iab.create(url, "_blank");
browser.show(); browser.show();
}); });
} }
@@ -199,16 +303,16 @@ export class PedidoPage implements OnInit {
task: this.task, task: this.task,
serialNumber: this.task.SerialNumber, serialNumber: this.task.SerialNumber,
fulltask: this.fulltask, fulltask: this.fulltask,
taskAction:taskAction, taskAction: taskAction,
showEnviarPendentes: false showEnviarPendentes: false
}, },
translucent: true translucent: true
}); });
await popover.present(); await popover.present();
popover.onDidDismiss().then(( res =>{ popover.onDidDismiss().then((res => {
if( res['data'] == 'close') { if (res['data'] == 'close') {
this.goBack() this.goBack()
} }
@@ -217,7 +321,7 @@ export class PedidoPage implements OnInit {
})) }))
} }
async repreciar(note:string, documents:any) { async repreciar(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialnumber, "serialNumber": this.serialnumber,
"action": "Reapreciação", "action": "Reapreciação",
@@ -225,7 +329,7 @@ export class PedidoPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -242,12 +346,13 @@ export class PedidoPage implements OnInit {
} }
} }
async arquivar(note:string, documents:any) { async arquivar(note: string, documents: any) {
const loader = this.toastService.loading() const loader = this.toastService.loading()
try { try {
await this.pedidoService.arquivar({serialNumber: this.serialnumber, await this.pedidoService.arquivar({
serialNumber: this.serialnumber,
documents, documents,
note note
}).toPromise() }).toPromise()
@@ -262,7 +367,7 @@ export class PedidoPage implements OnInit {
} }
async assignar(note:string, documents:any) { async assignar(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialnumber, "serialNumber": this.serialnumber,
"action": "Reencaminhar", "action": "Reencaminhar",
@@ -270,7 +375,7 @@ export class PedidoPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -288,9 +393,9 @@ export class PedidoPage implements OnInit {
} }
sendExpedienteToPending() { sendExpedienteToPending() {
this.processes.SetTaskToPending(this.serialnumber).subscribe(res=>{ this.processes.SetTaskToPending(this.serialnumber).subscribe(res => {
this.goBack(); this.goBack();
},()=>{ }, () => {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
}); });
@@ -299,7 +404,7 @@ export class PedidoPage implements OnInit {
async openExpedientActionsModal(taskAction: any, task: any) { async openExpedientActionsModal(taskAction: any, task: any) {
let classs; let classs;
if( window.innerWidth <= 800) { if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -314,7 +419,7 @@ export class PedidoPage implements OnInit {
cssClass: classs, cssClass: classs,
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
console.log('Modal closed'); console.log('Modal closed');
this.goBack(); this.goBack();
}); });
@@ -322,7 +427,7 @@ export class PedidoPage implements OnInit {
async openBookMeetingModal(task: any) { async openBookMeetingModal(task: any) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -356,7 +461,7 @@ export class PedidoPage implements OnInit {
// }); // });
// } // }
async distartExpedientModal(){ async distartExpedientModal() {
console.log(this.fulltask); console.log(this.fulltask);
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: DiscartExpedientModalPage, component: DiscartExpedientModalPage,
@@ -370,8 +475,8 @@ export class PedidoPage implements OnInit {
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
if(res['data']=='close'){ if (res['data'] == 'close') {
this.close(); this.close();
/* console.log('2Expedient Discard closed2'); /* console.log('2Expedient Discard closed2');
this.close(); this.close();
@@ -385,7 +490,7 @@ export class PedidoPage implements OnInit {
console.log(task); console.log(task);
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -405,7 +510,7 @@ export class PedidoPage implements OnInit {
async openForwardModal(task: any) { async openForwardModal(task: any) {
let classs; let classs;
if( window.innerWidth <= 800) { if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
@@ -426,7 +531,7 @@ export class PedidoPage implements OnInit {
console.log(task); console.log(task);
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'add-note-modal-no-height showAsideOptions' classs = 'add-note-modal-no-height showAsideOptions'
@@ -441,21 +546,21 @@ export class PedidoPage implements OnInit {
backdropDismiss: false backdropDismiss: false
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
this.goBack(); this.goBack();
}); });
} }
async openAddNoteModal(actionName:string) { async openAddNoteModal(actionName: string) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'add-note-modal-no-height' classs = 'add-note-modal-no-height'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: AddNotePage, component: AddNotePage,
componentProps:{ componentProps: {
showAttachmentBtn: true, showAttachmentBtn: true,
}, },
cssClass: classs, cssClass: classs,
@@ -465,8 +570,8 @@ export class PedidoPage implements OnInit {
await modal.present(); await modal.present();
modal.onDidDismiss().then( async (res) => { modal.onDidDismiss().then(async (res) => {
const DocumentToSave = await res.data.documents.map( async (e) => { const DocumentToSave = await res.data.documents.map(async (e) => {
return { return {
ApplicationId: e.ApplicationType, ApplicationId: e.ApplicationType,
SourceId: e.Id, SourceId: e.Id,
@@ -477,16 +582,16 @@ export class PedidoPage implements OnInit {
Attachments: DocumentToSave, Attachments: DocumentToSave,
} }
if(res.data){ if (res.data) {
if(actionName == 'Solicitar Reapreciação') { if (actionName == 'Solicitar Reapreciação') {
await this.repreciar(res.data.note, docs); await this.repreciar(res.data.note, docs);
this.goBack(); this.goBack();
} }
else if(actionName == 'Arquivar') { else if (actionName == 'Arquivar') {
await this.arquivar(res.data.note, docs); await this.arquivar(res.data.note, docs);
this.goBack(); this.goBack();
} }
else if(actionName == 'Assignar') { else if (actionName == 'Assignar') {
await this.assignar(res.data.note, docs); await this.assignar(res.data.note, docs);
} }
} }
@@ -38,13 +38,13 @@
<div class="width-100" [ngSwitch]="segment"> <div class="width-100" [ngSwitch]="segment">
<ion-progress-bar type="indeterminate" *ngIf="skeletonLoader"></ion-progress-bar> <ion-progress-bar type="indeterminate" *ngIf="skeletonLoader"></ion-progress-bar>
<div *ngIf="pedidosstorage.listparecer"> <div *ngIf="listToPresentparecerList">
<ion-list *ngSwitchCase="'parecer'"> <ion-list *ngSwitchCase="'parecer'">
<!-- *ngFor = "let task of pedidosstorage.listparecer; let i = index" <!-- *ngFor = "let task of pedidosstorage.listparecer; let i = index"
(click)="viewExpedientDetail(task.SerialNumber)" --> (click)="viewExpedientDetail(task.SerialNumber)" -->
<div <div
class="expediente ion-no-padding ion-no-margin cursor-pointer" class="expediente ion-no-padding ion-no-margin cursor-pointer"
*ngFor = "let task of pedidosstorage.listparecer" *ngFor = "let task of listToPresentparecerList"
(click)="goToPedido(task.SerialNumber)" (click)="goToPedido(task.SerialNumber)"
> >
<!-- (click)="viewExpedientDetail(task.SerialNumber)" --> <!-- (click)="viewExpedientDetail(task.SerialNumber)" -->
@@ -77,11 +77,11 @@
</ion-list> </ion-list>
</div> </div>
<div *ngIf="pedidosstorage.listdeferimento"> <div *ngIf="listToPresentdeferimentoList">
<ion-list *ngSwitchCase="'deferimento'"> <ion-list *ngSwitchCase="'deferimento'">
<div <div
class="expediente ion-no-padding ion-no-margin cursor-pointer" class="expediente ion-no-padding ion-no-margin cursor-pointer"
*ngFor = "let task of pedidosstorage.listdeferimento" *ngFor = "let task of listToPresentdeferimentoList"
(click)="goToPedido(task.SerialNumber)" (click)="goToPedido(task.SerialNumber)"
> >
<!-- (click)="viewExpedientDetail(task.SerialNumber)" --> <!-- (click)="viewExpedientDetail(task.SerialNumber)" -->
@@ -7,6 +7,10 @@ import { ModalController, NavParams } from '@ionic/angular';
import { AlertService } from 'src/app/services/alert.service'; import { AlertService } from 'src/app/services/alert.service';
import { PedidosStore } from 'src/app/store/pedidos-store.service'; import { PedidosStore } from 'src/app/store/pedidos-store.service';
import { ModalService } from 'src/app/services/modal.service'; import { ModalService } from 'src/app/services/modal.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
@Component({ @Component({
selector: 'app-pedidos', selector: 'app-pedidos',
templateUrl: './pedidos.page.html', templateUrl: './pedidos.page.html',
@@ -18,6 +22,8 @@ export class PedidosPage implements OnInit {
taskslist:DailyWorkTask[] = []; taskslist:DailyWorkTask[] = [];
parecerList:any[] = []; parecerList:any[] = [];
listToPresentparecerList: any[] = [];
listToPresentdeferimentoList: any[] = [];
fulltask:any; fulltask:any;
parecerListResult:customTask[] = []; parecerListResult:customTask[] = [];
@@ -38,7 +44,8 @@ export class PedidosPage implements OnInit {
private modalController: ModalController, private modalController: ModalController,
private alertService: AlertService, private alertService: AlertService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private modalService: ModalService private modalService: ModalService,
private sqliteservice: SqliteService
) { ) {
//Inicializar segment //Inicializar segment
this.segment = 'parecer'; this.segment = 'parecer';
@@ -57,21 +64,7 @@ export class PedidosPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.getFromDb();
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()
}
}
});
} }
goBack() { goBack() {
@@ -141,7 +134,8 @@ export class PedidosPage implements OnInit {
} }
this.parecerList.push(task); this.parecerList.push(task);
}); });
this.pedidosstorage.resetparecer(this.parecerList); this.sqliteservice.addProcess(this.parecerList);
this.listToPresentparecerList = this.parecerList
} }
else if(this.segment == 'deferimento') { else if(this.segment == 'deferimento') {
@@ -181,7 +175,8 @@ export class PedidosPage implements OnInit {
}); });
this.pedidosstorage.resetdeferimento(this.deferimentoList); this.sqliteservice.addProcess(this.deferimentoList);
this.listToPresentdeferimentoList = this.deferimentoList
}); });
@@ -189,6 +184,83 @@ export class PedidosPage implements OnInit {
} }
getFromDb() {
if(synchro.connected === true) {
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()
}
}
});
}
if(synchro.connected === false) {
let parecerlist = [];
let deferimentolist = []
this.sqliteservice.getprocessByworkflowpedido("Pedido de Parecer", "Pedido de Parecer do Presidente").then((process: any[]) => {
process.forEach((element) => {
if(JSON.parse(element.workflowInstanceDataFields).Status == "Active") {
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 = {
"SerialNumber": element.serialNumber,
"Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
"Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
}
parecerlist.push(task)
}
})
this.listToPresentparecerList = parecerlist;
console.log('parecer',process)
})
this.sqliteservice.getprocessByworkflow("Pedido de Deferimento").then((process: any[]) => {
process.forEach((element) => {
if(JSON.parse(element.workflowInstanceDataFields).Status == "Active") {
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 = {
"SerialNumber": element.serialNumber,
"Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
"Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
}
deferimentolist.push(task)
}
})
this.listToPresentdeferimentoList = deferimentolist;
console.log('deferimento',process)
})
}
}
segmentChanged(ev: any) { segmentChanged(ev: any) {
this.LoadList(); this.LoadList();
} }
@@ -27,7 +27,7 @@
</ion-refresher> </ion-refresher>
<app-task-list class="height-100" <app-task-list class="height-100"
[taskList] = pendentesstore.list [taskList] = listToPresent
[skeletonLoader] = skeletonLoader [skeletonLoader] = skeletonLoader
(viewTaskDetail)="viewTaskDetails($event)" (viewTaskDetail)="viewTaskDetails($event)"
> </app-task-list> > </app-task-list>
@@ -10,6 +10,10 @@ import { LoginUserRespose } from 'src/app/models/user.model';
import { AuthService } from 'src/app/services/auth.service'; import { AuthService } from 'src/app/services/auth.service';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe'; import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
import { Platform } from '@ionic/angular';
@Component({ @Component({
selector: 'app-pendentes', selector: 'app-pendentes',
@@ -20,23 +24,28 @@ export class PendentesPage implements OnInit {
@ViewChild(CalendarComponent) myCal: CalendarComponent; @ViewChild(CalendarComponent) myCal: CalendarComponent;
taskType: string; taskType: string;
serialNumber:string; serialNumber: string;
totalDocs:any; totalDocs: any;
showLoader: boolean; showLoader: boolean;
loggeduser: LoginUserRespose; loggeduser: LoginUserRespose;
@Input() profile:string; @Input() profile: string;
segment:string; segment: string;
skeletonLoader = true skeletonLoader = true
pendentesstore = PendentesStore; pendentesstore = PendentesStore;
customTaskPipe = new CustomTaskPipe() customTaskPipe = new CustomTaskPipe()
listToPresent = [];
synch = synchro
constructor( constructor(
private processes:ProcessesService, private processes: ProcessesService,
private alertService: AlertService, private alertService: AlertService,
private router: Router, private router: Router,
private authService: AuthService, private authService: AuthService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private sqliteservice: SqliteService,
private platform: Platform
) { ) {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
this.profile = 'mdgpr'; this.profile = 'mdgpr';
@@ -45,21 +54,7 @@ export class PendentesPage implements OnInit {
ngOnInit() { ngOnInit() {
//Inicializar segment //Inicializar segment
this.segment = "despachos"; this.segment = "despachos";
this.getFromDb();
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()
}
}
});
} }
@@ -87,20 +82,69 @@ export class PendentesPage implements OnInit {
pendentesList.push(task); pendentesList.push(task);
}); });
pendentesList = removeDuplicate( pendentesList) pendentesList = removeDuplicate(pendentesList)
pendentesList = this.sortArrayISODate(pendentesList); pendentesList = this.sortArrayISODate(pendentesList);
this.listToPresent = pendentesList;
this.pendentesstore.reset(pendentesList);
this.skeletonLoader = false; this.skeletonLoader = false;
} }
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
return myArray.sort(function(a, b) { return myArray.sort(function (a, b) {
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0); return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
}); });
} }
getFromDb() {
if (synchro.connected === true) {
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()
}
}
});
}
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.sqliteservice.getAllProcess().then((process: any[]) => {
var pendingList = []
process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
if (workflow.Status === "Pending") {
let task = {
"CreateDate": element.taskStartDate,
"DocumentsQty": element.totalDocuments,
"FolderID": workflow.FolderID,
"Folio": workflow.Subject,
"Senders": workflow.Sender,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"WorkflowName": element.workflowDisplayName
}
pendingList.push(task)
}
});
pendingList = this.sortArrayISODate(pendingList);
this.listToPresent = pendingList;
console.log('pendentes', pendingList)
})
})
})
}
async refreshing() { async refreshing() {
setTimeout(() => { setTimeout(() => {
this.LoadList(); this.LoadList();
@@ -115,24 +159,24 @@ export class PendentesPage implements OnInit {
}, 2000); }, 2000);
} }
async viewTaskDetails({ SerialNumber, WorkflowName, activityInstanceName }:customTask) { async viewTaskDetails({ SerialNumber, WorkflowName, activityInstanceName }: customTask) {
if(WorkflowName == 'Despacho') { if (WorkflowName == 'Despacho') {
this.router.navigate(['/home/gabinete-digital/despachos',SerialNumber,'gabinete-digital']); 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') { 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']); this.router.navigate(['/home/gabinete-digital/pedidos', SerialNumber, 'gabinete-digital']);
} }
else if(WorkflowName == 'Expediente') { else if (WorkflowName == 'Expediente') {
this.router.navigate(['/home/gabinete-digital/expediente',SerialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/expediente', SerialNumber, 'gabinete-digital']);
} }
else if(WorkflowName == 'Expediente' && this.loggeduser.Profile == 'PR') { else if (WorkflowName == 'Expediente' && this.loggeduser.Profile == 'PR') {
this.router.navigate(['/home/gabinete-digital/expedientes-pr',SerialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/expedientes-pr', SerialNumber, 'gabinete-digital']);
} }
else if (activityInstanceName == "Tarefa de Parecer") { else if (activityInstanceName == "Tarefa de Parecer") {
this.router.navigate(['/home/gabinete-digital/pedidos',SerialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/pedidos', SerialNumber, 'gabinete-digital']);
} }
else if(activityInstanceName == "Tarefa de Despacho") { else if (activityInstanceName == "Tarefa de Despacho") {
this.router.navigate(['/home/gabinete-digital/despachos',SerialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/despachos', SerialNumber, 'gabinete-digital']);
} }
else { else {
console.log('cant find page for this task', WorkflowName, activityInstanceName) console.log('cant find page for this task', WorkflowName, activityInstanceName)
@@ -144,4 +188,4 @@ export class PendentesPage implements OnInit {
return new Date(e).toDateString() return new Date(e).toDateString()
} }
} }
+6 -9
View File
@@ -85,21 +85,17 @@ class SynchroService {
//if(!this._connected) { if(!this._connected === true) {
this.BackgroundService.online() this.BackgroundService.online()
console.log('Online',this._connected)
this.callBacks.forEach((e)=>{ this.callBacks.forEach((e)=>{
if(e.type == 'Online') { if(e.type == 'Online') {
e.funx() e.funx()
} }
}) })
}
//}
console.log('open ======================= welcome to socket server') console.log('open ======================= welcome to socket server')
this.eventtrigger.publishSomeData({
internet: "online"
})
this._connected = true this._connected = true
@@ -185,14 +181,15 @@ class SynchroService {
// if(this._connected){ if(this._connected === false){
this.BackgroundService.offline(); this.BackgroundService.offline();
console.log('Offline',this._connected)
this.callBacks.forEach((e)=>{ this.callBacks.forEach((e)=>{
if(e.type == 'Offline') { if(e.type == 'Offline') {
e.funx() e.funx()
} }
}) })
//} }
// status // status
+39 -1
View File
@@ -94,7 +94,8 @@ export class SqliteService {
workflowID INTERGER, workflowID INTERGER,
workflowInstanceDataFields Text, workflowInstanceDataFields Text,
workflowInstanceID INTERGER, workflowInstanceID INTERGER,
workflowName varchar(255) workflowName varchar(255),
interveners Text
)`, []) )`, [])
.then((res) => { .then((res) => {
console.log("Sucess AllProcess Table created: ", res) console.log("Sucess AllProcess Table created: ", res)
@@ -168,6 +169,13 @@ export class SqliteService {
console.log("process attachment updated") console.log("process attachment updated")
}) })
} }
//updateAttachment
updateProcessInterveners(id, interveners,) {
let data = [document];
return this.dbInstance.executeSql(`UPDATE ${this.allprocess} SET interveners = ? WHERE serialNumber = ${id}`, [interveners]).then(() => {
console.log("process interveners updated")
})
}
//getAllEvents //getAllEvents
getAllEvents() { getAllEvents() {
var hashattachment = false; var hashattachment = false;
@@ -264,6 +272,21 @@ export class SqliteService {
}); });
} }
//getDespachosProcess
getDespachosProcess(process) {
return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE activityInstanceName = ?`, [process]).then((res) => {
this.ALLPROCESS = [];
if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) {
this.ALLPROCESS.push(res.rows.item(i));
}
return this.ALLPROCESS;
}
}, (e) => {
console.log(" Get all process error", JSON.stringify(e));
});
}
//getprocessByworkflow //getprocessByworkflow
getprocessByworkflow(process) { getprocessByworkflow(process) {
return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE workflowDisplayName = ? `, [process]).then((res) => { return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE workflowDisplayName = ? `, [process]).then((res) => {
@@ -279,6 +302,21 @@ export class SqliteService {
}); });
} }
//getprocessByworkflowpedido
getprocessByworkflowpedido(process, process2) {
return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE workflowDisplayName = ? OR workflowDisplayName = ? `, [process, process2]).then((res) => {
this.ALLPROCESS = [];
if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) {
this.ALLPROCESS.push(res.rows.item(i));
}
return this.ALLPROCESS;
}
}, (e) => {
console.log(" Get all process error", JSON.stringify(e));
});
}
getProcessById(serial) { getProcessById(serial) {
return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE serialNumber = ? `, [serial]).then((res) => { return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE serialNumber = ? `, [serial]).then((res) => {
this.PROCESS = []; this.PROCESS = [];
@@ -33,38 +33,7 @@ export class AllProcessesPage implements OnInit {
ngOnInit() { ngOnInit() {
this.sqliteservice.getAllProcess().then((allprocess: any[]) => { this.getAllProcessFromDB()
this.allProcessesList = allprocess;
console.log("All process from db ", allprocess)
})
/* synchro.registerCallback('Online', () => {
this.platform.ready().then(() => {
this.loadAllProcesses();
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.refreshing();
} else {
this.loadAllProcesses();
}
}
});
})
})
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.sqliteservice.getAllProcess().then((allprocess: any[]) => {
this.allProcessesList = allprocess;
console.log("All process from db ", allprocess)
})
})
console.log('Offlineee')
}) */
} }
doRefresh() { doRefresh() {
@@ -150,8 +119,7 @@ export class AllProcessesPage implements OnInit {
getAllProcessFromDB() { getAllProcessFromDB() {
synchro.registerCallback('Online', () => { if(synchro.connected === true) {
this.platform.ready().then(() => {
this.loadAllProcesses(); this.loadAllProcesses();
this.router.events.forEach((event) => { this.router.events.forEach((event) => {
@@ -163,12 +131,7 @@ export class AllProcessesPage implements OnInit {
} }
} }
}); });
}) } else {
})
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.sqliteservice.getAllProcess().then((allprocess: any[]) => { this.sqliteservice.getAllProcess().then((allprocess: any[]) => {
allprocess.forEach(element => { allprocess.forEach(element => {
let date = new Date(element.taskStartDate); let date = new Date(element.taskStartDate);
@@ -176,7 +139,6 @@ export class AllProcessesPage implements OnInit {
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields); var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields);
console.log("WORKFLOW all process", workflowInstanceDataFields)
let task = { let task = {
"SerialNumber": element.serialNumber, "SerialNumber": element.serialNumber,
@@ -206,9 +168,7 @@ export class AllProcessesPage implements OnInit {
this.allProcessesList = allprocess; this.allProcessesList = allprocess;
console.log("All process from db ", allprocess) console.log("All process from db ", allprocess)
}) })
}) }
console.log('Offlineee')
})
} }
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {