mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
309 lines
8.4 KiB
TypeScript
309 lines
8.4 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ModalController, PopoverController } from '@ionic/angular';
|
|
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 { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
|
|
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
|
import { BookMeetingModalPage } from '../../expediente/book-meeting-modal/book-meeting-modal.page';
|
|
import { BadRequestComponent } from 'src/app/shared/popover/bad-request/bad-request.component';
|
|
import { SuccessMessageComponent } from 'src/app/shared/popover/success-message/success-message.component';
|
|
import { DeplomaOptionsPage } from 'src/app/shared/popover/deploma-options/deploma-options.page';
|
|
|
|
@Component({
|
|
selector: 'app-diploma',
|
|
templateUrl: './diploma.page.html',
|
|
styleUrls: ['./diploma.page.scss'],
|
|
})
|
|
export class DiplomaPage 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"];
|
|
|
|
serialnumber: string;
|
|
profile: string;
|
|
task: any
|
|
fulltask: any
|
|
intervenientes: any;
|
|
cc: any;
|
|
attachments:any;
|
|
customDate: any
|
|
|
|
constructor(
|
|
private processes: ProcessesService,
|
|
public popoverController: PopoverController,
|
|
private modalController: ModalController,
|
|
private iab: InAppBrowser,
|
|
private activatedRoute: ActivatedRoute,
|
|
private router: Router,
|
|
) {
|
|
this.activatedRoute.queryParams.subscribe(params => {
|
|
if(params["serialNumber"]) {
|
|
this.serialnumber = params["serialNumber"];
|
|
console.log(params["serialNumber"]);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.profile = "mdgpr";
|
|
this.LoadTaskDetail(this.serialnumber);
|
|
}
|
|
|
|
goBack() {
|
|
// let navigationExtras: NavigationExtras = {
|
|
// queryParams: {
|
|
// "diplomas": true,
|
|
// }
|
|
// };
|
|
// this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
|
|
window.history.back()
|
|
}
|
|
|
|
async openOptions(taskAction?: any) {
|
|
const popover = await this.popoverController.create({
|
|
component: DeplomaOptionsPage,
|
|
cssClass: 'exp-options',
|
|
componentProps: {
|
|
task: this.task,
|
|
fulltask: this.fulltask,
|
|
taskAction:taskAction,
|
|
showEnviarPendentes: false
|
|
},
|
|
translucent: true
|
|
});
|
|
return await popover.present();
|
|
}
|
|
|
|
async LoadTaskDetail(serial: string) {
|
|
|
|
this.processes.GetTask(serial).subscribe(res => {
|
|
this.task = {
|
|
"SerialNumber": res.serialNumber,
|
|
"Folio": res.workflowInstanceDataFields.Subject,
|
|
"Senders": res.originator.email,
|
|
"CreateDate": momentG(new Date(res.taskStartDate),'yyyy-MM-dd HH:mm:ss'),
|
|
"DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
|
|
"Remetente": res.workflowInstanceDataFields.Sender,
|
|
"Note": res.workflowInstanceDataFields.Note,
|
|
"FolderId": res.workflowInstanceDataFields.FolderID,
|
|
"FsId": '361',
|
|
"DocId": res.workflowInstanceDataFields.DispatchDocId,
|
|
"WorkflowName": res.workflowDisplayName,
|
|
"DeadlineType": res.workflowInstanceDataFields.DeadlineType,
|
|
"activityInstanceName": res.activityInstanceName,
|
|
}
|
|
|
|
this.fulltask = res;
|
|
console.log(this.task);
|
|
|
|
console.log('GetTask', res);
|
|
|
|
let thedate = new Date(this.task.CreateDate);
|
|
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=>{
|
|
return user.Type == 'I';
|
|
});
|
|
this.cc = users.filter(user=>{
|
|
return user.Type == 'CC';
|
|
});
|
|
console.log(users);
|
|
|
|
});
|
|
this.getDocumentDetails(this.task.FolderId, '361');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
viewDocument(docId:string){
|
|
this.processes.GetDocumentUrl(docId, '361').subscribe(res=>{
|
|
console.log(res);
|
|
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
|
const browser = this.iab.create(url,"_blank");
|
|
browser.show();
|
|
});
|
|
}
|
|
|
|
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){
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Aprovar",
|
|
"ActionTypeId": 99999840,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
try {
|
|
await this.processes.CompleteTask(body);
|
|
this.close();
|
|
this.successMessage()
|
|
} catch (error) {
|
|
this.badRequest()
|
|
}
|
|
}
|
|
|
|
async askToChange(note:string, documents:any){
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Retificar",
|
|
"ActionTypeId": 99999841,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body);
|
|
this.close();
|
|
this.successMessage()
|
|
} catch (error) {
|
|
this.badRequest()
|
|
}
|
|
}
|
|
|
|
async finish(note:string, documents:any){
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Concluir",
|
|
"ActionTypeId": 95,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
try {
|
|
await this.processes.CompleteTask(body);
|
|
this.successMessage()
|
|
this.close();
|
|
} catch (error) {
|
|
this.badRequest()
|
|
}
|
|
|
|
}
|
|
|
|
async openAddNoteModal(actionName:string) {
|
|
let classs;
|
|
if( window.innerWidth <= 800){
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: AddNotePage,
|
|
componentProps:{
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: true
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss().then(res => {
|
|
if(res.data){
|
|
|
|
|
|
const DocumentToSave = res.data.documents.map((e) => {
|
|
return {
|
|
ApplicationId: e.ApplicationType,
|
|
SourceId: e.Id,
|
|
}
|
|
});
|
|
|
|
let docs = {
|
|
ProcessInstanceID: "",
|
|
Attachments: DocumentToSave,
|
|
}
|
|
|
|
|
|
if(actionName == 'Solicitar assinatura'){
|
|
this.askSignature(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
else if(actionName == 'Solicitar alteração'){
|
|
this.askToChange(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
else if(actionName == 'Concluir diploma'){
|
|
this.finish(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
async openBookMeetingModal(task: any) {
|
|
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: this.task,
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss();
|
|
}
|
|
|
|
close(){
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
async successMessage(message?: string) {
|
|
|
|
const modal = await this.modalController.create({
|
|
component: SuccessMessageComponent,
|
|
componentProps: {
|
|
message: message || 'Processo efetuado' ,
|
|
},
|
|
cssClass: 'modal modal-desktop'
|
|
});
|
|
|
|
modal.present()
|
|
|
|
setTimeout(()=>{
|
|
modal.dismiss()
|
|
},3000)
|
|
|
|
}
|
|
|
|
async badRequest(message?: string) {
|
|
const modal = await this.modalController.create({
|
|
component: BadRequestComponent,
|
|
componentProps: {
|
|
message: message || 'Processo não efetuado' ,
|
|
},
|
|
cssClass: 'modal modal-desktop'
|
|
});
|
|
|
|
modal.present()
|
|
|
|
setTimeout(()=>{
|
|
modal.dismiss()
|
|
},3000)
|
|
}
|
|
|
|
}
|