Files
doneit-web/src/app/modals/document-detail/document-detail.page.ts
T
Peter Maquiran ff2d8aa43c improve
2021-07-23 17:16:27 +01:00

177 lines
5.4 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { MenuController, ModalController, NavParams } from '@ionic/angular';
import { AlertService } from 'src/app/services/alert.service';
import { ProcessesService } from 'src/app/services/processes.service';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
@Component({
selector: 'app-document-detail',
templateUrl: './document-detail.page.html',
styleUrls: ['./document-detail.page.scss'],
})
export class DocumentDetailPage 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;
docId: string;
applicationId:string;
LoadedDocument:any = null;
constructor(
private navParams: NavParams,
private modalController: ModalController,
private alertService: AlertService,
private processes: ProcessesService,
private menu: MenuController,
private iab: InAppBrowser,
) {
this.docId = this.navParams.get('docId');
this.applicationId = this.navParams.get('applicationId');
}
ngOnInit() {
this.LoadDocumentDetails();
}
async LoadDocumentDetails() {
this.processes.GetDocumentDetails(this.docId, this.applicationId).subscribe(res=>{
this.LoadedDocument = res;
this.LoadedDocument.Subject = this.LoadedDocument.Assunto
let thedate = new Date(this.LoadedDocument.DateDispatch);
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]);
});
}
viewDocument() {
this.processes.GetDocumentUrl(this.docId, '8').subscribe(res=>{
console.log(res);
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
const browser = this.iab.create(url,"_blank");
browser.show();
});
}
openMenu() {
this.menu.open();
this.modalController.dismiss();
}
close() {
this.modalController.dismiss();
}
notImplemented() {
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
}
// efetuar despacho
async openExpedientActionsModal( taskAction: any) {
let task;
if(this.LoadedDocument.ApplicationID == 361) {
task = {
serialNumber: this.LoadedDocument.DispatchNumber,
taskStartDate: this.LoadedDocument.DateDispatch,
isEvent: true,
workflowInstanceDataFields: {
FsId: this.LoadedDocument.ApplicationID,
FolderID: null,
DocId: this.LoadedDocument.DispatchNumber,
Subject: this.LoadedDocument.Assunto
},
}
} else if (this.LoadedDocument.ApplicationID == 8 || this.LoadedDocument.ApplicationId == 8) {
task = {
serialNumber: this.LoadedDocument.DocId,
taskStartDate: this.LoadedDocument.DocDate,
isEvent: true,
workflowInstanceDataFields: {
FsId: this.LoadedDocument.ApplicationID || this.LoadedDocument.ApplicationId,
FolderID: null,
DocId: this.LoadedDocument.DocId,
Subject: this.LoadedDocument.Assunto
}
}
}
let classs;
if( window.innerWidth <= 800) {
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: ExpedientTaskModalPage,
componentProps: {
taskAction: taskAction,
task: task,
},
cssClass: classs,
});
await modal.present();
modal.onDidDismiss().then( async(res)=>{});
}
async openBookMeetingModal() {
let task;
if(this.LoadedDocument.ApplicationID == 361) {
task = {
serialNumber: this.LoadedDocument.DispatchNumber,
taskStartDate: this.LoadedDocument.DateDispatch,
isEvent: true,
Folio: this.LoadedDocument.Assunto,
FsId: this.LoadedDocument.ApplicationID,
workflowInstanceDataFields: {
FsId: this.LoadedDocument.ApplicationID,
FolderID: null,
DocId: this.LoadedDocument.DispatchNumber,
Subject: this.LoadedDocument.Assunto
},
}
} else if (this.LoadedDocument.ApplicationID == 8 || this.LoadedDocument.ApplicationId == 8) {
task = {
serialNumber: this.LoadedDocument.SourceId,
taskStartDate: this.LoadedDocument.CreateDate,
isEvent: true,
Folio: this.LoadedDocument.Assunto,
FsId: this.LoadedDocument.ApplicationID,
workflowInstanceDataFields: {
FsId: this.LoadedDocument.ApplicationID,
FolderID: null,
DocId: this.LoadedDocument.SourceId,
Subject: this.LoadedDocument.SourceName
}
}
}
let classs;
if( window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: BookMeetingModalPage,
componentProps: {
task: task,
},
cssClass: classs,
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss();
}
}