mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
631 lines
17 KiB
TypeScript
631 lines
17 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { fullTask } from '../../../../models/dailyworktask.model';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
|
import { Event } from '../../../../models/event.model';
|
|
import { MenuController, ModalController, PopoverController } from '@ionic/angular';
|
|
import { momentG } from 'src/plugin/momentG'
|
|
import { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart-expedient-modal.page';
|
|
import { BookMeetingModalPage } from '../../expediente/book-meeting-modal/book-meeting-modal.page';
|
|
import { CreateProcessPage } from 'src/app/modals/create-process/create-process.page';
|
|
import { DelegarPage } from 'src/app/modals/delegar/delegar.page';
|
|
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
|
|
import { DespachosPrOptionsPage } from 'src/app/shared/popover/despachos-pr-options/despachos-pr-options.page';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
import { DespachoService } from 'src/app/Rules/despacho.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 { PermissionService } from 'src/app/services/permission.service';
|
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
import { TinyMCEPage } from 'src/app/tiny-mce/tiny-mce.page';
|
|
|
|
@Component({
|
|
selector: 'app-despacho-pr',
|
|
templateUrl: './despacho-pr.page.html',
|
|
styleUrls: ['./despacho-pr.page.scss'],
|
|
})
|
|
export class DespachoPrPage 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;
|
|
|
|
task: any;
|
|
fulltask: any;
|
|
eventsList: Event[];
|
|
serialNumber: string;
|
|
caller: string;
|
|
profile: string;
|
|
intervenientes: any =[]
|
|
cc: any = [];
|
|
mergedArray: any = [];
|
|
|
|
constructor(
|
|
private activateRoute: ActivatedRoute,
|
|
private processes: ProcessesService,
|
|
private menu: MenuController,
|
|
private modalController: ModalController,
|
|
public popoverController: PopoverController,
|
|
private activatedRoute: ActivatedRoute,
|
|
private toastService: ToastService,
|
|
private despachoService: DespachoService,
|
|
private backgroundservice: BackgroundService,
|
|
public ThemeService: ThemeService,
|
|
private RouteService: RouteService,
|
|
public p: PermissionService,
|
|
private httpErroHandle: HttpErrorHandle,
|
|
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;
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.profile = "mdgpr";
|
|
|
|
|
|
this.activateRoute.paramMap.subscribe(paramMap => {
|
|
if (!paramMap.has('SerialNumber')) {
|
|
return;
|
|
}
|
|
/* this.serialNumber = paramMap.get('SerialNumber'); */
|
|
this.LoadTaskDetail(this.serialNumber);
|
|
// this.LoadRelatedEvents(this.serialNumber);
|
|
});
|
|
this.LoadTaskDetail(this.serialNumber);
|
|
// this.LoadRelatedEvents(this.serialNumber);
|
|
|
|
this.backgroundservice.registerBackService('Online', () => {
|
|
this.LoadTaskDetail(this.serialNumber);
|
|
});
|
|
}
|
|
|
|
close() {
|
|
this.goBack()
|
|
}
|
|
|
|
goBack() {
|
|
this.RouteService.goBack();
|
|
}
|
|
|
|
|
|
async LoadTaskDetail(serial: string) {
|
|
this.processes.GetTask(serial).subscribe((res: fullTask) => {
|
|
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,
|
|
"Deadline": res.deadline,
|
|
"activityInstanceName": res.activityInstanceName,
|
|
"TaskStartDate": res.taskStartDate
|
|
}
|
|
this.fulltask = res;
|
|
let stringDraft = res.workflowInstanceDataFields.DraftIds;
|
|
let split_stringDraft = stringDraft?.split(";").filter(Boolean);
|
|
|
|
try {
|
|
this.getDraft(split_stringDraft);
|
|
} catch (error) {
|
|
console.log(error)
|
|
}
|
|
this.getDocumentPdf(this.fulltask.Documents)
|
|
|
|
// this.updateProcessOnDB(res);
|
|
// console.log('this.fulltask', this.fulltask)
|
|
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';
|
|
}) || []
|
|
|
|
if (!this.cc) {
|
|
this.cc = []
|
|
}
|
|
|
|
});
|
|
|
|
}, (error) => {
|
|
|
|
if (error.status == 0) {
|
|
this.getFromDB()
|
|
} else {
|
|
try {
|
|
this.goBack()
|
|
} catch (e) {
|
|
window.history.back();
|
|
}
|
|
this.httpErroHandle.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(docId: string, 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();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
openMenu() {
|
|
this.menu.open();
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
async executado(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialNumber,
|
|
"action": "Conhecimento",
|
|
"ActionTypeId": 104,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.httpErroHandle.httpsSucessMessagge('Executado')
|
|
this.TaskService.loadDiplomas()
|
|
} catch (error) {
|
|
this.httpErroHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
async arquivar(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialNumber,
|
|
"action": "Arquivo",
|
|
"ActionTypeId": 95,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.httpErroHandle.httpsSucessMessagge('Arquivar')
|
|
this.TaskService.loadDiplomas()
|
|
} catch (error) {
|
|
this.httpErroHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
|
|
}
|
|
|
|
async generateDiploma(note: string, documents: any) {
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.despachoService.generateDiploma({
|
|
serialnumber: this.serialNumber,
|
|
note,
|
|
documents
|
|
}).toPromise()
|
|
|
|
this.httpErroHandle.httpsSucessMessagge('Gerar Diploma')
|
|
this.TaskService.loadDiplomas()
|
|
} catch (error) {
|
|
this.httpErroHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
async concluir(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialNumber,
|
|
"action": "Executado",
|
|
"ActionTypeId": 104,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.httpErroHandle.httpsSucessMessagge('Concluir Despacho')
|
|
this.TaskService.loadDiplomas()
|
|
} catch (error) {
|
|
this.httpErroHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
|
|
async reexecutar(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialNumber,
|
|
"action": "Reexecução",
|
|
"ActionTypeId": 100000010,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.httpErroHandle.httpsSucessMessagge('Reexecução')
|
|
this.TaskService.loadDiplomas()
|
|
} catch (error) {
|
|
this.httpErroHandle.httpStatusHandle(error)
|
|
}
|
|
finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
toDateString(e) {
|
|
return new Date(e).toDateString()
|
|
}
|
|
|
|
sendExpedienteToPending() {
|
|
const loader = this.toastService.loading()
|
|
this.processes.SetTaskToPending(this.serialNumber).subscribe(res => {
|
|
this.popoverController.dismiss('close')
|
|
this.httpErroHandle.httpsSucessMessagge('Enviar para Pendentes')
|
|
this.TaskService.loadDiplomas()
|
|
this.goBack()
|
|
loader.remove()
|
|
}, (error) => {
|
|
loader.remove()
|
|
this.httpErroHandle.httpStatusHandle(error)
|
|
});
|
|
}
|
|
|
|
async openAddNoteModal(actionName: string) {
|
|
let classs;
|
|
if (window.innerWidth <= 800) {
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'add-note-modal-no-height'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: AddNotePage,
|
|
componentProps: {
|
|
showAttachmentBtn: true,
|
|
actionName: actionName
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: true
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss().then(async (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 == 'Executado') {
|
|
await this.executado(res.data.note, docs);
|
|
}
|
|
else if (actionName == 'Arquivar') {
|
|
await this.arquivar(res.data.note, docs);
|
|
}
|
|
else if (actionName == 'Gerar Diploma') {
|
|
await this.generateDiploma(res.data.note, docs);
|
|
}
|
|
else if (actionName == 'Concluido') {
|
|
// console.log('actionName', actionName)
|
|
await this.concluir(res.data.note, docs);
|
|
}
|
|
else if (actionName == 'Reexecução') {
|
|
await this.reexecutar(res.data.note, docs);
|
|
}
|
|
|
|
this.TaskService.loadDiplomas()
|
|
this.goBack();
|
|
}
|
|
});
|
|
}
|
|
|
|
async openExpedientActionsModal(taskAction: any, task: any) {
|
|
//this.modalController.dismiss();
|
|
let classs;
|
|
if (window.innerWidth <= 700) {
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
|
|
// console.log('this.fulltask send', this.fulltask)
|
|
const modal = await this.modalController.create({
|
|
component: CreateProcessPage,
|
|
componentProps: {
|
|
taskAction: taskAction,
|
|
task: task,
|
|
profile: this.profile,
|
|
fulltask: this.fulltask
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then(res => {
|
|
|
|
if (res['data'] == 'openDiscart') {
|
|
|
|
this.distartExpedientModal();
|
|
}
|
|
|
|
this.goBack();
|
|
this.TaskService.loadDiplomas()
|
|
|
|
});
|
|
}
|
|
|
|
async distartExpedientModal2(task: any) {
|
|
const modal = await this.modalController.create({
|
|
component: DiscartExpedientModalPage,
|
|
componentProps: {
|
|
serialNumber: task.serialNumber,
|
|
folderId: task.workflowInstanceDataFields.FolderID,
|
|
action: 'discart',
|
|
},
|
|
cssClass: 'discart-expedient-modal',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
modal.onDidDismiss().then(() => {
|
|
this.TaskService.loadDiplomas()
|
|
})
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
async openDelegarModal(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: DelegarPage,
|
|
componentProps: {
|
|
task: this.task,
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then(res => {
|
|
if(res){
|
|
const data = res.data;
|
|
if(data == 'close') {
|
|
this.goBack();
|
|
}
|
|
this.TaskService.loadDiplomas()
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
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
|
|
});
|
|
|
|
await modal.present();
|
|
modal.onDidDismiss().then(res => {
|
|
if (res['data'] == 'close') {
|
|
this.close();
|
|
}
|
|
this.TaskService.loadDiplomas()
|
|
});
|
|
}
|
|
|
|
async openOptions(taskAction?: any) {
|
|
const popover = await this.popoverController.create({
|
|
component: DespachosPrOptionsPage,
|
|
cssClass: 'exp-options',
|
|
componentProps: {
|
|
task: this.task,
|
|
fulltask: this.fulltask,
|
|
taskAction: taskAction,
|
|
showEnviarPendentes: false
|
|
},
|
|
translucent: true
|
|
});
|
|
|
|
await popover.present();
|
|
|
|
popover.onDidDismiss().then((res => {
|
|
|
|
if (res['data'] == 'close') {
|
|
this.goBack()
|
|
|
|
}
|
|
|
|
this.TaskService.loadDiplomas()
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
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);
|
|
});
|
|
}
|
|
getDraft(split_stringDraft: string[]) {
|
|
split_stringDraft.forEach(element => {
|
|
console.log('List of ids', element)
|
|
this.processes.GetDraftByID(element).subscribe((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)
|
|
console.log('List of draff', resd)
|
|
})
|
|
|
|
});
|
|
}
|
|
|
|
|
|
}
|