This commit is contained in:
tiago.kayaya
2021-10-19 14:34:51 +01:00
34 changed files with 1795 additions and 1505 deletions
@@ -3,7 +3,7 @@ import { AnimationController, ModalController, PopoverController } from '@ionic/
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { ProcessesService } from 'src/app/services/processes.service';
import { OptsExpedientePage } from 'src/app/shared/popover/opts-expediente/opts-expediente.page';
import { momentG } from 'src/plugin/momentG';
import { momentG } from 'src/plugin/momentG';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
@@ -14,7 +14,7 @@ import { Location } from '@angular/common';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-diploma',
@@ -27,13 +27,13 @@ export class DiplomaPage implements OnInit {
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
serialNumber: string;
caller:string;
caller: string;
profile: string;
task: any
fulltask: any
intervenientes: any;
cc: any = [];
attachments:any;
attachments: any;
customDate: any
constructor(
@@ -46,15 +46,16 @@ export class DiplomaPage implements OnInit {
private animationController: AnimationController,
private toastService: ToastService,
private location: Location,
private sqliteservice: SqliteService
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) {
this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]);
if(params["params"].SerialNumber) {
if (params["params"].SerialNumber) {
this.serialNumber = params["params"].SerialNumber;
}
if(params["params"].caller) {
if (params["params"].caller) {
this.caller = params["params"].caller;
}
@@ -64,7 +65,10 @@ export class DiplomaPage implements OnInit {
ngOnInit() {
this.profile = "mdgpr";
this.getFromDb();
this.LoadTaskDetail(this.serialNumber);
this.backgroundservice.registerBackService('Online', () => {
this.LoadTaskDetail(this.serialNumber);
});
}
goBack() {
@@ -104,7 +108,7 @@ export class DiplomaPage implements OnInit {
serialNumber: this.serialNumber,
task: this.task,
fulltask: this.fulltask,
taskAction:taskAction,
taskAction: taskAction,
showEnviarPendentes: false
},
translucent: true
@@ -118,7 +122,7 @@ export class DiplomaPage implements OnInit {
"SerialNumber": res.serialNumber,
"Folio": res.workflowInstanceDataFields.Subject,
"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,
"Remetente": res.workflowInstanceDataFields.Sender,
"Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note,
@@ -133,94 +137,90 @@ export class DiplomaPage implements OnInit {
this.sqliteservice.updateProcess(res)
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';
});
this.cc = users.filter(user=>{
this.cc = users.filter(user => {
return user.Type == 'CC';
});
});
this.getDocumentDetails(this.task.FolderId, '361');
}, (error)=>{
try {
this.goBack()
} catch (e) {
window.history.back();
} finally {
if(error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else {
this.toastService.badRequest('Processo não encontrado')
}, (error) => {
if (error.status == 0) {
this.getFromDb();
} else {
try {
this.goBack()
} catch (e) {
window.history.back();
}
this.toastService.badRequest('Processo não encontrado')
}
});
}
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,
}
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
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
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 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
this.intervenientes = JSON.parse(process[0].interveners).filter(user=>{
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=>{
this.cc = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'CC';
});
this.attachments = JSON.parse(process[0].Documents)
})
}
})
}
async viewDocument(DocId:string, Document) {
async viewDocument(DocId: string, Document) {
const modal = await this.modalController.create({
component: ViewDocumentPage,
@@ -243,15 +243,15 @@ export class DiplomaPage implements OnInit {
}
getDocumentDetails(forlderId:string, applicationId:string) {
this.processes.GetDocumentDetails(forlderId,applicationId).subscribe(res=>{
getDocumentDetails(forlderId: string, applicationId: string) {
this.processes.GetDocumentDetails(forlderId, applicationId).subscribe(res => {
this.attachments = res.Documents;
console.log(res['Documents']);
console.log(this.attachments);
})
}
async askSignature(note:string, documents:any){
async askSignature(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Aprovar",
@@ -259,7 +259,7 @@ export class DiplomaPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
"AttachmentList": documents,
}
const loader = this.toastService.loading()
@@ -267,7 +267,7 @@ export class DiplomaPage implements OnInit {
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage(false, ()=>{
this.toastService.successMessage(false, () => {
this.close();
})
@@ -279,7 +279,7 @@ export class DiplomaPage implements OnInit {
}
}
async askToChange(note:string, documents:any){
async askToChange(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Retificar",
@@ -287,7 +287,7 @@ export class DiplomaPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
"AttachmentList": documents,
}
const loader = this.toastService.loading()
@@ -303,7 +303,7 @@ export class DiplomaPage implements OnInit {
}
async finish(note:string, documents:any){
async finish(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
@@ -312,7 +312,7 @@ export class DiplomaPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
"AttachmentList": documents,
}
const loader = this.toastService.loading()
@@ -333,16 +333,16 @@ export class DiplomaPage implements OnInit {
return new Date(e).toDateString()
}
async openAddNoteModal(actionName:string) {
async openAddNoteModal(actionName: string) {
let classs;
if( window.innerWidth <= 800){
if (window.innerWidth <= 800) {
classs = 'modal modal-desktop'
} else {
} else {
classs = 'add-note-modal'
}
const modal = await this.modalController.create({
component: AddNotePage,
componentProps:{
componentProps: {
},
cssClass: classs,
backdropDismiss: true
@@ -351,7 +351,7 @@ export class DiplomaPage implements OnInit {
await modal.present();
modal.onDidDismiss().then(async (res) => {
if(res.data){
if (res.data) {
const DocumentToSave = res.data.documents.map((e) => {
@@ -367,15 +367,15 @@ export class DiplomaPage implements OnInit {
}
if(actionName == 'Solicitar assinatura'){
if (actionName == 'Solicitar assinatura') {
await this.askSignature(res.data.note, docs);
this.goBack();
}
else if(actionName == 'Solicitar alteração'){
else if (actionName == 'Solicitar alteração') {
await this.askToChange(res.data.note, docs);
this.goBack();
}
else if(actionName == 'Concluir diploma'){
else if (actionName == 'Concluir diploma') {
await this.finish(res.data.note, docs);
this.goBack();
}
@@ -385,9 +385,9 @@ export class DiplomaPage implements OnInit {
async openBookMeetingModal(task: any) {
let classs;
if( window.innerWidth <= 800){
if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop'
} else {
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
@@ -402,7 +402,7 @@ export class DiplomaPage implements OnInit {
modal.onDidDismiss();
}
close(){
close() {
this.modalController.dismiss();
}
@@ -4,7 +4,7 @@ import { DailyWorkTask } from '../../../models/dailyworktask.model';
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';
import { BackgroundService } from 'src/app/services/background.service';
import { SortService } from 'src/app/services/functions/sort.service';
@Component({
@@ -29,11 +29,10 @@ export class DiplomasPage implements OnInit, OnDestroy {
private router: Router,
private activatedRoute: ActivatedRoute,
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
private sortService: SortService,
) {
this.diplomasList = [];
//Inicializar segment
this.segment = 'validar';
this.activatedRoute.queryParams.subscribe(params => {
if (params['validar'] == 'true') {
@@ -56,7 +55,24 @@ export class DiplomasPage implements OnInit, OnDestroy {
}
});
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.refreshing()
} else {
this.LoadList()
}
}
});
this.backgroundservice.registerBackService('Online', () => {
this.LoadList();
});
}
@@ -154,69 +170,60 @@ export class DiplomasPage implements OnInit, OnDestroy {
async LoadList() {
this.skeletonLoader = true
this.processes.GetTasksList("Despacho do Presidente da República", false).subscribe(async res => {
let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
this.skeletonLoader = true
this.skeletonLoader = false
this.showLoader = false;
let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
this.skeletonLoader = false
this.showLoader = false;
let diplomasValidar = diplomas.filter(data => data.activityInstanceName == "Revisar Diploma");
let diplomasList = [];
diplomasValidar.forEach(async element => {
let diplomasValidar = diplomas.filter(data => data.activityInstanceName == "Revisar Diploma");
let diplomasList = [];
diplomasValidar.forEach(async element => {
let task = this.pipeTask(element)
diplomasList.push(task);
let task = this.pipeTask(element)
diplomasList.push(task);
});
this.diplomasList = this.sortService.sortArrayISODate(diplomasList).reverse();
});
this.diplomasList = this.sortService.sortArrayByDate(diplomasList.reverse());
let diplomasAssinados = diplomas.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
let diplomasAssinadoList = []
diplomasAssinados.forEach(async element => {
let diplomasAssinados = diplomas.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
let diplomasAssinadoList = []
diplomasAssinados.forEach(async element => {
let task = this.pipeTask(element)
diplomasAssinadoList.push(task);
});
console.log('diplomasAssinados', diplomasAssinados)
this.diplomasAssinadoList = this.sortService.sortArrayISODate(diplomasAssinadoList).reverse();
let task = this.pipeTask(element)
diplomasAssinadoList.push(task);
});
console.log('diplomasAssinados', diplomasAssinados)
this.diplomasAssinadoList = this.sortService.sortArrayByDate(diplomasAssinadoList).reverse();
}, (error) => {
this.getFromDb()
})
}
getFromDb() {
if (synchro.connected === true) {
const location = window.location
const pathname = location.pathname + location.search
this.LoadList()
this.sqliteservice.getprocessByworkflow("Despacho do Presidente da República").then((process: any[]) => {
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 diplomasValidar = process.filter(data => data.activityInstanceName == "Revisar Diploma");
let diplomasList = [];
diplomasValidar.forEach(async element => {
let task = this.pipeTaskOffline(element)
diplomasList.push(task);
let task = this.pipeTaskOffline(element)
diplomasList.push(task);
});
this.diplomasList = this.sortService.sortArrayISODate(diplomasList).reverse();
let diplomasAssinados = process.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
let diplomasAssinadoList = []
diplomasAssinados.forEach(async element => {
let diplomasAssinados = process.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
let diplomasAssinadoList = []
diplomasAssinados.forEach(async element => {
let task = this.pipeTaskOffline(element)
diplomasAssinadoList.push(task);
@@ -224,8 +231,7 @@ export class DiplomasPage implements OnInit, OnDestroy {
console.log('diplomasAssinados', diplomasAssinados)
this.diplomasAssinadoList = this.sortService.sortArrayISODate(diplomasAssinadoList).reverse();
})
}
})
}
pipeTask(element) {