mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Event to aprove and Expediente already have offline mode
This commit is contained in:
+54
-2
@@ -23,6 +23,10 @@ import { ExpedienteService } from 'src/app/Rules/expediente.service';
|
||||
import { expedienteTask } from 'src/app/models/dailyworktask.model';
|
||||
import { TaskService } from 'src/app/Rules/task.service';
|
||||
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { synchro } from 'src/app/services/socket/synchro.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-expediente-detail',
|
||||
templateUrl: './expediente-detail.page.html',
|
||||
@@ -49,6 +53,9 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
hideSendToPendentes = true
|
||||
searchDocumentPipe = new SearchDocumentPipe()
|
||||
|
||||
synch = synchro
|
||||
onlinecheck: boolean;
|
||||
|
||||
constructor(
|
||||
private processes: ProcessesService,
|
||||
private iab: InAppBrowser,
|
||||
@@ -63,7 +70,9 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
private attachmentsService: AttachmentsService,
|
||||
public p: PermissionService,
|
||||
private taskService: TaskService,
|
||||
private expedienteService: ExpedienteService
|
||||
private expedienteService: ExpedienteService,
|
||||
public platform: Platform,
|
||||
private sqliteservice: SqliteService,
|
||||
) {
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
if(params["params"].SerialNumber) {
|
||||
@@ -76,7 +85,10 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.LoadTaskDetail(this.serialNumber);
|
||||
this.getFromDB();
|
||||
if(this.onlinecheck) {
|
||||
this.LoadTaskDetail(this.serialNumber);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,6 +100,45 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
this.toastService.presentToast('Não foi possível fazer login"');
|
||||
}
|
||||
|
||||
getFromDB() {
|
||||
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.onlinecheck = true;
|
||||
})
|
||||
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.onlinecheck = false;
|
||||
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
|
||||
console.log("expedient ditail", process)
|
||||
|
||||
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
|
||||
var origina = JSON.parse(process[0].originator)
|
||||
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": workflow.Subject,
|
||||
"Senders": origina.email,
|
||||
"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,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"Status": workflow.Status,
|
||||
"DispatchNumber": workflow.DispatchNumber,
|
||||
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
|
||||
"InstanceID": workflow.InstanceID
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
async approve(note:string, documents:any) {
|
||||
let body = {
|
||||
@@ -261,6 +312,7 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
}
|
||||
|
||||
this.fulltask = res;
|
||||
this.sqliteservice.updateProcess(res)
|
||||
|
||||
let thedate = new Date(this.task.CreateDate);
|
||||
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]);
|
||||
|
||||
Reference in New Issue
Block a user