mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
577 lines
15 KiB
TypeScript
577 lines
15 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 { momentG } from 'src/plugin/momentG';
|
|
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { BookMeetingModalPage } from '../../expediente/book-meeting-modal/book-meeting-modal.page';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
|
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { RouteService } from 'src/app/services/route.service';
|
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
|
import { AttachmentList } from 'src/app/models/Excludetask';
|
|
import { DespachoService } from 'src/app/Rules/despacho.service'
|
|
import { CreateProcessPage } from 'src/app/modals/create-process/create-process.page';
|
|
import { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart-expedient-modal.page';
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
import { TinyMCEPage } from 'src/app/tiny-mce/tiny-mce.page';
|
|
import { DespachosPrOptionsPage } from 'src/app/shared/popover/despachos-pr-options/despachos-pr-options.page';
|
|
import { DiplomaOptionsPage } 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;
|
|
caller: string;
|
|
profile: string;
|
|
task: any
|
|
fulltask: any
|
|
intervenientes: any = []
|
|
cc: any = [];
|
|
attachments: any;
|
|
customDate: any;
|
|
mergedArray: any = [];
|
|
|
|
|
|
DraftNames = ""
|
|
DraftIds = ""
|
|
|
|
showOptions = false
|
|
constructor(
|
|
private processes: ProcessesService,
|
|
public popoverController: PopoverController,
|
|
private modalController: ModalController,
|
|
private activatedRoute: ActivatedRoute,
|
|
private toastService: ToastService,
|
|
private RouteService: RouteService,
|
|
private backgroundservice: BackgroundService,
|
|
public ThemeService: ThemeService,
|
|
private httpErrorHandle: HttpErrorHandle,
|
|
private despachoService: DespachoService,
|
|
public TaskService: TaskService
|
|
) {
|
|
this.activatedRoute.paramMap.subscribe(params => {
|
|
//
|
|
|
|
if (params["params"].SerialNumber) {
|
|
this.serialNumber = params["params"].SerialNumber;
|
|
}
|
|
if (params["params"].caller) {
|
|
this.caller = params["params"].caller;
|
|
}
|
|
|
|
});
|
|
|
|
|
|
window['tinyupdate'] = () => {
|
|
this.LoadTaskDetail(this.serialNumber);
|
|
}
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.profile = "mdgpr";
|
|
this.LoadTaskDetail(this.serialNumber);
|
|
this.backgroundservice.registerBackService('Online', () => {
|
|
this.LoadTaskDetail(this.serialNumber);
|
|
});
|
|
}
|
|
|
|
goBack() {
|
|
this.RouteService.goBack();
|
|
|
|
}
|
|
|
|
async openOptions() {
|
|
|
|
|
|
if (window.innerWidth > 500) {
|
|
|
|
this.showOptions = true
|
|
} else {
|
|
const popover = await this.popoverController.create({
|
|
component: DiplomaOptionsPage,
|
|
cssClass: 'exp-options',
|
|
componentProps: {
|
|
serialNumber: this.serialNumber,
|
|
task: this.task,
|
|
fulltask: this.fulltask,
|
|
showEnviarPendentes: false
|
|
},
|
|
translucent: true
|
|
});
|
|
|
|
popover.onDidDismiss().then(() => {
|
|
this.TaskService.loadDiplomas()
|
|
}, (error) => {
|
|
console.log(error)
|
|
}).catch((e) => {
|
|
console.log(e)
|
|
})
|
|
|
|
|
|
let a = await popover.present();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
async LoadTaskDetail(serial: string) {
|
|
this.processes.GetTask(serial).subscribe(res => {
|
|
this.TaskService.loadDiplomas();
|
|
|
|
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.TaskMessage || res.workflowInstanceDataFields.Note,
|
|
"FolderId": res.workflowInstanceDataFields.FolderID,
|
|
"FsId": '361',
|
|
"DocId": res.workflowInstanceDataFields.DispatchDocId,
|
|
"WorkflowName": res.workflowDisplayName,
|
|
"DeadlineType": res.workflowInstanceDataFields.DeadlineType,
|
|
"activityInstanceName": res.activityInstanceName,
|
|
"DraftIds": res.workflowInstanceDataFields?.DraftIds
|
|
}
|
|
this.fulltask = res;
|
|
console.log('Diploma anexo',this.fulltask.Documents )
|
|
// this.updateProcessOnDB(res)
|
|
let stringDraft = res.workflowInstanceDataFields.DraftIds;
|
|
let split_stringDraft = stringDraft?.split(";").filter(Boolean);
|
|
|
|
console.log({split_stringDraft})
|
|
|
|
this.mergedArray = []
|
|
try {
|
|
this.getDraft(split_stringDraft);
|
|
} catch (error) {
|
|
console.log(error)
|
|
}
|
|
this.getDocumentPdf(this.fulltask.Documents)
|
|
|
|
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.updateProcessInterveners(users)
|
|
this.intervenientes = users.filter(user => {
|
|
return user.Type == 'I';
|
|
});
|
|
this.cc = users.filter(user => {
|
|
return user.Type == 'CC';
|
|
});
|
|
});
|
|
this.getDocumentDetails(this.task.FolderId, '361');
|
|
|
|
}, (error) => {
|
|
if (error.status == 0) {
|
|
this.getFromDb();
|
|
} else {
|
|
try {
|
|
this.goBack()
|
|
} catch (e) {
|
|
window.history.back();
|
|
}
|
|
this.httpErrorHandle.httpStatusHandle(error)
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
// updateProcessOnDB(res) {
|
|
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
// } else {
|
|
// this.sqliteservice.updateProcess(res);
|
|
// }
|
|
// }
|
|
// updateProcessInterveners(users) {
|
|
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
// } else {
|
|
// this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users))
|
|
// }
|
|
// }
|
|
|
|
|
|
getFromDb() {
|
|
|
|
|
|
}
|
|
|
|
async viewDocument({Document, content}) {
|
|
|
|
if (Document.content == "") {
|
|
const modal = await this.modalController.create({
|
|
component: ViewDocumentPage,
|
|
componentProps: {
|
|
trustedUrl: '',
|
|
file: {
|
|
title: Document.Assunto,
|
|
url: '',
|
|
title_link: '',
|
|
},
|
|
Document,
|
|
applicationId: Document.ApplicationId,
|
|
docId: Document.DocId || Document.SourceId,
|
|
folderId: this.task.FolderId,
|
|
task: this.fulltask
|
|
},
|
|
cssClass: 'modal modal-desktop'
|
|
});
|
|
await modal.present();
|
|
} else {
|
|
const modal = await this.modalController.create({
|
|
component: TinyMCEPage,
|
|
componentProps: {
|
|
Document,
|
|
content
|
|
},
|
|
cssClass: 'modal modal-desktop'
|
|
});
|
|
await modal.present();
|
|
}
|
|
|
|
}
|
|
|
|
getDocumentDetails(forlderId: string, applicationId: string) {
|
|
this.processes.GetDocumentDetails(forlderId, applicationId).subscribe(res => {
|
|
this.attachments = res.Documents;
|
|
|
|
|
|
})
|
|
}
|
|
|
|
async askSignature(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialNumber,
|
|
"action": "Aprovar",
|
|
"ActionTypeId": 99999840,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
|
|
this.httpErrorHandle.httpsSucessMessagge('Solicitar Assinatura',() => {
|
|
this.close();
|
|
})
|
|
|
|
} catch (error) {
|
|
this.httpErrorHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
}
|
|
|
|
async askToChange(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialNumber,
|
|
"action": "Retificar",
|
|
"ActionTypeId": 99999841,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.httpErrorHandle.httpsSucessMessagge('Solicitar alteração')
|
|
this.TaskService.loadDiplomas()
|
|
} catch (error) {
|
|
this.httpErrorHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
async finish(note: string, documents: any) {
|
|
|
|
let body = {
|
|
"serialNumber": this.serialNumber,
|
|
"action": "Concluir",
|
|
"ActionTypeId": 95,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise();
|
|
this.httpErrorHandle.httpsSucessMessagge('Concluir')
|
|
this.TaskService.loadDiplomas()
|
|
} catch (error) {
|
|
this.httpErrorHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
toDateString(e) {
|
|
return new Date(e).toDateString()
|
|
}
|
|
|
|
async openAddNoteModal(actionName: string) {
|
|
let classs;
|
|
if (window.innerWidth <= 800) {
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'add-note-modal'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: AddNotePage,
|
|
componentProps: {
|
|
showAttachmentBtn: false,
|
|
actionName:actionName
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: true
|
|
});
|
|
|
|
|
|
|
|
modal.onDidDismiss().then(async (res) => {
|
|
this.TaskService.loadDiplomas()
|
|
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') {
|
|
await this.askSignature(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
else if (actionName == 'Solicitar alteração') {
|
|
await this.askToChange(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
else if (actionName == 'Concluir diploma') {
|
|
await this.finish(res.data.note, docs);
|
|
this.goBack();
|
|
} else if (actionName == 'Arquivo') {
|
|
await this.arquivar(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
}
|
|
}, (error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
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,
|
|
fulltask: this.fulltask
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
|
|
modal.onDidDismiss().then(
|
|
()=>{},
|
|
(error) => {
|
|
console.log(error)
|
|
})
|
|
await modal.present();
|
|
}
|
|
|
|
async arquivar(note: string, documents: AttachmentList) {
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.despachoService.arquivar(note, documents, this.serialNumber).toPromise()
|
|
this.httpErrorHandle.httpsSucessMessagge('Arquivar')
|
|
this.TaskService.loadDiplomas()
|
|
this.close();
|
|
} catch (error) {
|
|
this.httpErrorHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
|
|
close() {
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
tempMethod(actionname) {
|
|
// console.log(actionname)
|
|
}
|
|
|
|
|
|
async openExpedientActionsModal(taskAction: any, task: any) {
|
|
|
|
let classs;
|
|
if (window.innerWidth <= 800) {
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: CreateProcessPage,
|
|
componentProps: {
|
|
taskAction: taskAction,
|
|
task: task,
|
|
profile: this.profile,
|
|
fulltask: this.fulltask
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
|
|
modal.onDidDismiss().then(async (res) => {
|
|
|
|
|
|
if (res['data'] == 'openDiscart') {
|
|
await this.distartExpedientModal();
|
|
}
|
|
|
|
this.TaskService.loadDiplomas()
|
|
|
|
if(taskAction != '0') {
|
|
this.goBack();
|
|
}
|
|
|
|
}, (error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
async distartExpedientModal() {
|
|
|
|
const modal = await this.modalController.create({
|
|
component: DiscartExpedientModalPage,
|
|
componentProps: {
|
|
serialNumber: this.fulltask.serialNumber,
|
|
folderId: this.fulltask.workflowInstanceDataFields.FolderID,
|
|
action: 'complete',
|
|
},
|
|
cssClass: 'discart-expedient-modal',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
|
|
modal.onDidDismiss().then(res => {
|
|
this.TaskService.loadDiplomas()
|
|
if (res['data'] == 'close') {
|
|
this.close();
|
|
/*
|
|
this.close();
|
|
this.openMenu(); */
|
|
}
|
|
|
|
}, (error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
getDocumentPdf(Documents: any) {
|
|
Documents.forEach(element => {
|
|
let docObject = {
|
|
"ApplicationId": element.ApplicationId,
|
|
"Assunto": element.Assunto,
|
|
"DocDate": element.DocDate,
|
|
"DocId": element.DocId,
|
|
"DocNumber": element.DocNumber,
|
|
"FolderId": element.FolderId,
|
|
"Sender": element.Sender,
|
|
"SourceDocId": element.SourceDocId,
|
|
"content": "",
|
|
"path": "",
|
|
"ownerId": "",
|
|
"status": "",
|
|
}
|
|
this.mergedArray.push(docObject);
|
|
});
|
|
}
|
|
async getDraft(split_stringDraft: string[]) {
|
|
this.DraftNames = ""
|
|
|
|
for(const strg of split_stringDraft) {
|
|
console.log('List of ids', strg)
|
|
const resd = await this.processes.GetDraftByID(strg).toPromise()
|
|
|
|
console.log('DRAFT FFF',resd)
|
|
let object = {
|
|
"ApplicationId": "",
|
|
"Assunto": resd.data.description,
|
|
"DocDate": "",
|
|
"DocId": resd.data.id,
|
|
"DocNumber": "",
|
|
"FolderId": "",
|
|
"Sender": "",
|
|
"SourceDocId": "",
|
|
"content": resd.data.content || " ",
|
|
"path": resd.data.path,
|
|
"ownerId": resd.data.ownerId,
|
|
"status": resd.data.status,
|
|
}
|
|
this.mergedArray.push(object)
|
|
this.DraftNames = this.DraftNames + resd.data.description+";"
|
|
console.log('List of draff', resd)
|
|
}
|
|
|
|
this.DraftNames = this.DraftNames.slice(0, -1);
|
|
this.DraftIds = this.DraftIds.slice(0, -1);
|
|
}
|
|
|
|
|
|
}
|