Gabinete digital offline complete

This commit is contained in:
Eudes Inácio
2021-09-29 16:47:58 +01:00
parent b59070f35e
commit 0b42dba6ca
25 changed files with 1324 additions and 746 deletions
@@ -9,7 +9,7 @@ import { ModalController, PopoverController } from '@ionic/angular';
import { ExpedientTaskModalPage } from '../expedient-task-modal/expedient-task-modal.page';
import { BookMeetingModalPage } from '../book-meeting-modal/book-meeting-modal.page';
import { ViewEventPage } from 'src/app/pages/agenda/view-event/view-event.page';
import { momentG } from 'src/plugin/momentG'
import { momentG } from 'src/plugin/momentG'
import { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart-expedient-modal.page';
import { OptsExpedientePage } from 'src/app/shared/popover/opts-expediente/opts-expediente.page';
import { ToastService } from 'src/app/services/toast.service';
@@ -37,18 +37,18 @@ export class ExpedienteDetailPage implements OnInit {
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"];
customDate:any;
customDate: any;
task: expedienteTask;
fulltask: any;
eventsList: Event[];
serialNumber: string;
caller:string;
caller: string;
profile: string;
intervenientes: any;
cc: any = [];
documents:SearchList[] = [];
attachments:any;
documents: SearchList[] = [];
attachments: any;
hideSendToPendentes = true
searchDocumentPipe = new SearchDocumentPipe()
@@ -75,10 +75,10 @@ export class ExpedienteDetailPage implements OnInit {
private sqliteservice: SqliteService,
) {
this.activatedRoute.paramMap.subscribe(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;
}
});
@@ -86,9 +86,6 @@ export class ExpedienteDetailPage implements OnInit {
ngOnInit() {
this.getFromDB();
if(this.onlinecheck) {
this.LoadTaskDetail(this.serialNumber);
}
}
@@ -102,53 +99,58 @@ export class ExpedienteDetailPage implements OnInit {
getFromDB() {
synchro.registerCallback('Online', () => {
this.onlinecheck = true;
})
if(synchro.connected === true) {
this.LoadTaskDetail(this.serialNumber);
}
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.onlinecheck = false;
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
console.log("expedient ditail", process)
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)
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var origina
if (process[0].originator === "undefined") {
origina = ""
} else {
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
}
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,
"WorkflowName": process[0].workflowDisplayName,
"Status": workflow.Status,
"DispatchNumber": workflow.DispatchNumber,
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
"InstanceID": workflow.InstanceID
}
})
})
})
})
}
async approve(note:string, documents:any) {
async approve(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Aprovar",
"ActionTypeId": 100000004 ,
"ActionTypeId": 100000004,
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
"AttachmentList": documents,
}
console.log(body);
@@ -159,15 +161,15 @@ export class ExpedienteDetailPage implements OnInit {
await this.processes.CompleteTask(body).toPromise();
this.close();
this.toastService.successMessage('Processo aprovado')
} catch(error) {
} catch (error) {
this.toastService.badRequest('Processo não aprovado')
} finally {
} finally {
loader.remove()
}
}
async sendToReview(note:string, documents:any) {
async sendToReview(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Retificar",
@@ -175,7 +177,7 @@ export class ExpedienteDetailPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
},
"AttachmentList" :documents,
"AttachmentList": documents,
}
const loader = this.toastService.loading()
@@ -184,7 +186,7 @@ export class ExpedienteDetailPage implements OnInit {
await this.processes.CompleteTask(body).toPromise()
this.close();
this.toastService.successMessage()
} catch(error) {
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
@@ -192,16 +194,16 @@ export class ExpedienteDetailPage implements OnInit {
}
async openAddNoteModal(actionName:string) {
async openAddNoteModal(actionName: string) {
let classs;
if( window.innerWidth < 701) {
if (window.innerWidth < 701) {
classs = 'modal modal-desktop'
} else {
} else {
classs = 'add-note-modal'
}
const modal = await this.modalController.create({
component: AddNotePage,
componentProps:{
componentProps: {
showAttachmentBtn: false,
},
cssClass: classs,
@@ -212,7 +214,7 @@ export class ExpedienteDetailPage implements OnInit {
modal.onDidDismiss().then(res => {
console.log(res);
if(res.data){
if (res.data) {
const DocumentToSave = res.data.documents.map((e) => {
return {
ApplicationId: e.ApplicationType,
@@ -225,10 +227,10 @@ export class ExpedienteDetailPage implements OnInit {
Attachments: DocumentToSave,
}
if(actionName == 'Aprovar'){
if (actionName == 'Aprovar') {
this.approve(res.data.note, docs);
}
else if(actionName == 'Revisão'){
else if (actionName == 'Revisão') {
this.sendToReview(res.data.note, docs);
}
this.goBack();
@@ -278,14 +280,14 @@ export class ExpedienteDetailPage implements OnInit {
}
sendExpedienteToPending() {
this.processes.SetTaskToPending(this.serialNumber).subscribe(res=>{
this.processes.SetTaskToPending(this.serialNumber).subscribe(res => {
console.log(res);
this.toastService.successMessage('Processo enviado para pendentes')
this.goBack();
},
(error)=>{
this.toastService.badRequest('Processo não enviado para pendentes')
});
(error) => {
this.toastService.badRequest('Processo não enviado para pendentes')
});
}
async LoadTaskDetail(serial: string) {
@@ -297,7 +299,7 @@ export class ExpedienteDetailPage 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,
@@ -315,14 +317,14 @@ export class ExpedienteDetailPage 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.intervenientes = users.filter(user=>{
this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users => {
this.intervenientes = users.filter(user => {
return user.Type == 'I';
});
this.cc = users.filter(user=>{
this.cc = users.filter(user => {
return user.Type == 'CC';
});
})
@@ -330,14 +332,14 @@ export class ExpedienteDetailPage implements OnInit {
console.log('this.task', this.task.InstanceID)
console.log('this.task.DocumentURL', this.task.DocumentURL)
}, (error)=>{
}, (error) => {
try {
this.toastService.badRequest('Processo não encontrado')
this.goBack()
} catch (e) {
window.history.back();
} finally {
if(error.status == 0) {
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')
@@ -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) {
console.log(serialNumber);
this.attachmentsService.getAttachmentsBySerial(serialNumber).subscribe(res=>{
this.attachmentsService.getAttachmentsBySerial(serialNumber).subscribe(res => {
this.attachments = res;
console.log('res', res);
});
@@ -382,45 +384,45 @@ export class ExpedienteDetailPage implements OnInit {
}
});
await modal.present();
modal.onDidDismiss().then( async (res)=> {
if(res){
const data = res.data;
this.documents.push(data.selected);
this.documents.forEach((element: any) => {
modal.onDidDismiss().then(async (res) => {
if (res) {
const data = res.data;
this.documents.push(data.selected);
this.documents.forEach((element: any) => {
let body = {
"InstanceID": this.task.InstanceID,
"WorkflowDisplayName": this.task.WorkflowName,
"FolderID": this.task.FolderId,
"DispatchNumber": this.task.DispatchNumber,
"AttachmentsProcessLastInstanceID": this.task.AttachmentsProcessLastInstanceID,
"Attachments": []
}
let body = {
"InstanceID": this.task.InstanceID,
"WorkflowDisplayName": this.task.WorkflowName,
"FolderID": this.task.FolderId,
"DispatchNumber": this.task.DispatchNumber,
"AttachmentsProcessLastInstanceID": this.task.AttachmentsProcessLastInstanceID,
"Attachments": []
}
const Attachments = this.searchDocumentPipe.transformToAttachment(element)
body.Attachments = Attachments;
const Attachments = this.searchDocumentPipe.transformToAttachment(element)
body.Attachments = Attachments;
const loader = this.toastService.loading()
const loader = this.toastService.loading()
this.attachmentsService.AddAttachment(body).subscribe((res)=> {
this.toastService.successMessage()
}, ()=> {
this.toastService.badRequest()
}, ()=> {
loader.remove()
});
this.attachmentsService.AddAttachment(body).subscribe((res) => {
this.toastService.successMessage()
}, () => {
this.toastService.badRequest()
}, () => {
loader.remove()
});
});
}
}
});
}
async openExpedientActionsModal(taskAction: any, task: any) {
let classs;
if( window.innerWidth <= 800){
if (window.innerWidth <= 800) {
classs = 'modal modal-desktop'
} else {
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
@@ -433,9 +435,9 @@ export class ExpedienteDetailPage implements OnInit {
cssClass: classs,
});
await modal.present();
modal.onDidDismiss().then( async(res)=>{
modal.onDidDismiss().then(async (res) => {
let body = res['data'];
if(res['data']) {
if (res['data']) {
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise();
@@ -446,47 +448,47 @@ export class ExpedienteDetailPage implements OnInit {
loader.remove()
}
}
else{
else {
this.close();
}
});
}
async distartExpedientModal(body:any) {
async distartExpedientModal(body: any) {
const modal = await this.modalController.create({
component: DiscartExpedientModalPage,
componentProps: {
componentProps: {
},
cssClass: 'discart-expedient-modal',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss().then( async (res)=>{
modal.onDidDismiss().then(async (res) => {
console.log(res['data']);
if(body == 'descartar') {
if(res['data']== 'Yes') {
if (body == 'descartar') {
if (res['data'] == 'Yes') {
const loader = this.toastService.loading()
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.goBack();
} catch (error) {
this.toastService.badRequest('Processo não descartado')
} finally {
} finally {
loader.remove()
}
}
else if(res['data'] == 'No'){
else if (res['data'] == 'No') {
//Do nothing
}
}
else{
if(res['data']== 'Yes') {
else {
if (res['data'] == 'Yes') {
const loader = this.toastService.loading()
try {
@@ -500,7 +502,7 @@ export class ExpedienteDetailPage implements OnInit {
}
}
else if(res['data'] == 'No') {
else if (res['data'] == 'No') {
console.log('Update');
const loader = this.toastService.loading()
try {
@@ -509,7 +511,7 @@ export class ExpedienteDetailPage implements OnInit {
this.goBack();
} catch (error) {
this.toastService.badRequest()
} finally {
} finally {
loader.remove()
}
}
@@ -521,9 +523,9 @@ export class ExpedienteDetailPage implements OnInit {
console.log(task);
let classs;
if( window.innerWidth < 701){
if (window.innerWidth < 701) {
classs = 'book-meeting-modal modal modal-desktop'
} else {
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
@@ -535,12 +537,12 @@ export class ExpedienteDetailPage implements OnInit {
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss().then(res=>{
modal.onDidDismiss().then(res => {
this.goBack();
});
}
goToEvent(eventId:any) {
goToEvent(eventId: any) {
this.router.navigate(['/home/events', eventId, 'expediente']);
}
@@ -570,7 +572,7 @@ export class ExpedienteDetailPage implements OnInit {
componentProps: {
task: this.task,
fulltask: this.fulltask,
taskAction:taskAction,
taskAction: taskAction,
},
translucent: true
});