Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer

This commit is contained in:
Peter Maquiran
2021-10-19 14:39:02 +01:00
50 changed files with 1851 additions and 1540 deletions
@@ -21,7 +21,7 @@ import { DespachoService } from 'src/app/Rules/despacho.service';
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-despacho-pr',
@@ -56,7 +56,8 @@ export class DespachoPrPage implements OnInit {
private toastService: ToastService,
private location: Location,
private despachoService: DespachoService,
private sqliteservice: SqliteService
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) {
this.activatedRoute.paramMap.subscribe(params => {
if (params["params"].SerialNumber) {
@@ -73,7 +74,21 @@ export class DespachoPrPage implements OnInit {
ngOnInit() {
this.profile = "mdgpr";
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);
this.backgroundservice.registerBackService('Online', () => {
this.LoadTaskDetail(this.serialNumber);
});
}
close() {
@@ -125,93 +140,81 @@ export class DespachoPrPage implements OnInit {
return user.Type == 'CC';
}) || []
if(!this.cc) {
if (!this.cc) {
this.cc = []
}
});
}, (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')
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.activateRoute.paramMap.subscribe(paramMap => {
if (!paramMap.has('SerialNumber')) {
return;
}
/* this.serialNumber = paramMap.get('SerialNumber'); */
this.LoadTaskDetail(this.serialNumber);
// this.LoadRelatedEvents(this.serialNumber);
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';
});
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';
});
})
}
})
}
async viewDocument(DocId:string, Document) {
async viewDocument(DocId: string, Document) {
const modal = await this.modalController.create({
component: ViewDocumentPage,