mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
660 lines
18 KiB
TypeScript
660 lines
18 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { Event } from '../../../../models/event.model';
|
|
import { MenuController, ModalController, PopoverController } from '@ionic/angular';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
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 { DarParecerPage } from 'src/app/modals/dar-parecer/dar-parecer.page';
|
|
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
import { ForwardPage } from 'src/app/modals/forward/forward.page';
|
|
|
|
import { PedidoService } from 'src/app/Rules/pedido.service';
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
|
|
|
import { PermissionService } from 'src/app/services/permission.service';
|
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { DataService } from 'src/app/services/data.service';
|
|
import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page';
|
|
import { RouteService } from 'src/app/services/route.service';
|
|
import { SessionStore } from 'src/app/store/session.service';
|
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
import { RequestOptionsPage } from 'src/app/shared/popover/request-options/request-options.page';
|
|
|
|
@Component({
|
|
selector: 'app-pedido',
|
|
templateUrl: './pedido.page.html',
|
|
styleUrls: ['./pedido.page.scss'],
|
|
})
|
|
export class PedidoPage 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;
|
|
attachments: any;
|
|
fulltask: any;
|
|
eventsList: Event[];
|
|
serialnumber: string;
|
|
caller: string;
|
|
intervenientes: any = []
|
|
cc: any = [];
|
|
loggeduser: LoginUserRespose;
|
|
taskArrayActions = [];
|
|
|
|
showOptions = false
|
|
constructor(private activatedRoute: ActivatedRoute,
|
|
private processes: ProcessesService,
|
|
private menu: MenuController,
|
|
private router: Router,
|
|
private modalController: ModalController,
|
|
private alertService: AlertService,
|
|
public popoverController: PopoverController,
|
|
private toastService: ToastService,
|
|
public p: PermissionService,
|
|
private RouteService: RouteService,
|
|
private pedidoService: PedidoService,
|
|
private backgroundservices: BackgroundService,
|
|
public ThemeService: ThemeService,
|
|
private dataService: DataService,
|
|
private htppErroHandle: HttpErrorHandle,
|
|
public TaskService: TaskService ) {
|
|
this.loggeduser = SessionStore.user;
|
|
|
|
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.LoadTaskDetail(this.serialnumber);
|
|
this.backgroundservices.registerBackService('Online', () => {
|
|
this.LoadTaskDetail(this.serialnumber);
|
|
});
|
|
}
|
|
|
|
close() {
|
|
this.modalController.dismiss();
|
|
}
|
|
notImplemented() {
|
|
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
|
}
|
|
|
|
toDateString(e) {
|
|
return new Date(e).toDateString()
|
|
}
|
|
|
|
async LoadTaskDetail(serial: string) {
|
|
this.processes.GetTask(this.serialnumber).subscribe(res => {
|
|
|
|
this.fulltask = res
|
|
|
|
this.TaskService.loadPedidos();
|
|
|
|
if (res.workflowDisplayName == 'Pedido de Parecer' || res.workflowDisplayName == 'Pedido de Parecer do Presidente') {
|
|
|
|
let date = new Date(res.taskStartDate);
|
|
date.setMonth(date.getMonth() + 1);
|
|
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
|
|
|
this.taskArrayActions = res.actions
|
|
this.task = {
|
|
"SerialNumber": res.serialNumber,
|
|
"Folio": res.workflowInstanceDataFields.Subject,
|
|
"Senders": res.workflowInstanceDataFields.Sender,
|
|
"CreateDate": taskDate,
|
|
"DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
|
|
"Remetente": res.workflowInstanceDataFields.Sender,
|
|
"Note": res.workflowInstanceDataFields.TaskMessage,
|
|
"FolderId": res.workflowInstanceDataFields.FolderID,
|
|
"FsId": '361',
|
|
"DocId": res.workflowInstanceDataFields.ParecerDocId,
|
|
"WorkflowName": res.workflowDisplayName,
|
|
"DeadlineType": res.workflowInstanceDataFields.DeadlineType,
|
|
"ProcessInstanceID": res.workflowInstanceDataFields.InstanceID,
|
|
"activityInstanceName": res.activityInstanceName,
|
|
"Status": res.workflowInstanceDataFields.Status,
|
|
"Deadline": res.deadline,
|
|
}
|
|
|
|
// this.updateProcess(res);
|
|
}
|
|
else if (res.workflowDisplayName == 'Pedido de Deferimento') {
|
|
|
|
let date = new Date(res.taskStartDate);
|
|
date.setMonth(date.getMonth() + 1);
|
|
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
|
|
|
this.task = {
|
|
"SerialNumber": res.serialNumber,
|
|
"Folio": res.workflowInstanceDataFields.Subject,
|
|
"Senders": res.workflowInstanceDataFields.Sender,
|
|
"CreateDate": taskDate,
|
|
"DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
|
|
"Remetente": res.workflowInstanceDataFields.Sender,
|
|
"Note": res.workflowInstanceDataFields.TaskMessage,
|
|
"FolderId": res.workflowInstanceDataFields.FolderID,
|
|
"FsId": '361',
|
|
"DocId": res.workflowInstanceDataFields.DocIdDeferimento,
|
|
"WorkflowName": res.workflowDisplayName,
|
|
"DeadlineType": res.workflowInstanceDataFields.DeadlineType,
|
|
"ProcessInstanceID": res.workflowInstanceDataFields.InstanceID,
|
|
"activityInstanceName": res.activityInstanceName,
|
|
"Status": res.workflowInstanceDataFields.Status,
|
|
"DraftIds": res.workflowInstanceDataFields?.DraftIds
|
|
}
|
|
// this.updateProcess(res)
|
|
}
|
|
|
|
let thedate = new Date(res.taskStartDate);
|
|
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
|
|
|
this.processes.GetTaskParticipants(res.workflowInstanceDataFields.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(res.workflowInstanceDataFields.FolderID, '361');
|
|
}, (error) => {
|
|
if (error.status == 0) {
|
|
// this.getfromDb();
|
|
} else {
|
|
this.htppErroHandle.httpsSucessMessagge(error)
|
|
try {
|
|
this.goBack()
|
|
this.close()
|
|
} catch (e) {
|
|
window.history.back();
|
|
}
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
checkStringInArray(str) {
|
|
return this.taskArrayActions.includes(str);
|
|
}
|
|
|
|
// updateProcess(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() {
|
|
// }
|
|
|
|
getDocumentDetails(forlderId: string, applicationId: string) {
|
|
this.processes.GetDocumentDetails(forlderId, applicationId).subscribe(res => {
|
|
this.attachments = res.Documents;
|
|
|
|
})
|
|
}
|
|
|
|
async viewDocument(DocId: string, Document) {
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
openMenu() {
|
|
this.menu.open();
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
async openOptions(taskAction?: any) {
|
|
|
|
|
|
if (window.innerWidth > 500) {
|
|
this.showOptions = true
|
|
} else {
|
|
const popover = await this.popoverController.create({
|
|
component: RequestOptionsPage,
|
|
cssClass: 'exp-options',
|
|
componentProps: {
|
|
task: this.task,
|
|
serialNumber: this.task.SerialNumber,
|
|
fulltask: this.fulltask,
|
|
taskAction: taskAction,
|
|
showEnviarPendentes: false,
|
|
actions: this.taskArrayActions
|
|
},
|
|
translucent: true
|
|
});
|
|
await popover.present();
|
|
|
|
popover.onDidDismiss().then((res => {
|
|
this.TaskService.loadPedidos();
|
|
if (res['data'] == 'close') {
|
|
this.goBack()
|
|
}
|
|
this.TaskService.loadPedidos();
|
|
|
|
|
|
}), (error) => {
|
|
console.log(error)
|
|
})
|
|
}
|
|
|
|
|
|
}
|
|
|
|
async repreciar(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Reapreciação",
|
|
"ActionTypeId": 100000009,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
|
|
this.htppErroHandle.httpsSucessMessagge('Solicitar alteração')
|
|
this.TaskService.loadPedidos();
|
|
this.close();
|
|
} catch (error) {
|
|
this.htppErroHandle.httpStatusHandle(error)
|
|
} finally {
|
|
loader.remove()
|
|
}
|
|
}
|
|
|
|
async arquivar(note: string, documents: any) {
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.pedidoService.arquivar({
|
|
serialNumber: this.serialnumber,
|
|
documents,
|
|
note
|
|
}).toPromise()
|
|
|
|
this.htppErroHandle.httpsSucessMessagge('Arquivar')
|
|
this.TaskService.loadPedidos();
|
|
this.close();
|
|
} catch (error) {
|
|
this.htppErroHandle.httpStatusHandle(error)
|
|
} finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
async assignar(note: string, documents: any) {
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Reencaminhar",
|
|
"ActionTypeId": 98,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList": documents,
|
|
}
|
|
|
|
const loader = this.toastService.loading()
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.toastService._successMessage()
|
|
this.close();
|
|
this.TaskService.loadPedidos();
|
|
} catch (error) {
|
|
if(error.status == 0) {
|
|
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
|
|
} else {
|
|
|
|
this.toastService._badRequest()
|
|
}
|
|
} finally {
|
|
loader.remove()
|
|
}
|
|
|
|
}
|
|
|
|
sendExpedienteToPending() {
|
|
const loader = this.toastService.loading()
|
|
this.processes.SetTaskToPending(this.serialnumber).subscribe(res => {
|
|
this.goBack();
|
|
loader.remove()
|
|
this.TaskService.loadPedidos();
|
|
}, (error) => {
|
|
loader.remove()
|
|
this.htppErroHandle.httpStatusHandle(error)
|
|
});
|
|
}
|
|
|
|
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: this.fulltask,
|
|
fulltask: this.fulltask
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
|
|
modal.onDidDismiss().then(res => {
|
|
|
|
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: task,
|
|
fulltask:this.fulltask
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
|
|
modal.onDidDismiss().then(
|
|
()=>{},
|
|
(error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
openNewGroupPage() {
|
|
if (window.innerWidth < 801) {
|
|
this.router.navigate(['/home/chat']);
|
|
this.newGroup();
|
|
}
|
|
else {
|
|
this.dataService.set("newGroup", true);
|
|
this.dataService.set("task", this.task);
|
|
this.dataService.set("newGroupName", this.task.Folio);
|
|
this.dataService.set("documents", this.fulltask.Documents);
|
|
this.router.navigate(['/home/chat']);
|
|
}
|
|
}
|
|
|
|
async newGroup() {
|
|
const modal = await this.modalController.create({
|
|
component: NewGroupPage,
|
|
cssClass: 'modal modal-desktop',
|
|
componentProps: {
|
|
name: this.task.Folio,
|
|
task: this.task
|
|
},
|
|
});
|
|
|
|
modal.onDidDismiss().then(
|
|
()=>{},
|
|
(error) => {
|
|
console.log(error)
|
|
}
|
|
)
|
|
await modal.present();
|
|
}
|
|
|
|
// async viewEventDetail(eventId: any) {
|
|
|
|
// const modal = await this.modalController.create({
|
|
// component: ViewEventPage,
|
|
// componentProps: {
|
|
// eventId: eventId,
|
|
// },
|
|
// cssClass: 'modal modal-desktop',
|
|
// backdropDismiss: false
|
|
// });
|
|
// await modal.present();
|
|
// modal.onDidDismiss().then((res) => {
|
|
// if (res) {
|
|
// }
|
|
// });
|
|
// }
|
|
|
|
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 => {
|
|
if (res['data'] == 'close') {
|
|
this.close();
|
|
/*
|
|
this.close();
|
|
this.openMenu(); */
|
|
}
|
|
|
|
}, (error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
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
|
|
});
|
|
|
|
modal.onDidDismiss().then(res => {
|
|
if(res){
|
|
const data = res.data;
|
|
if(data == 'close') {
|
|
this.goBack();
|
|
}
|
|
}
|
|
|
|
}, (error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
async openForwardModal(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: ForwardPage,
|
|
componentProps: {
|
|
task: this.task,
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
|
|
modal.onDidDismiss().then(
|
|
()=>{},
|
|
(error) => {
|
|
console.log(error)
|
|
})
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
async openDarParecer(task: any) {
|
|
|
|
|
|
let classs;
|
|
if (window.innerWidth < 701) {
|
|
classs = 'book-meeting-modal modal modal-desktop'
|
|
} else {
|
|
classs = 'add-note-modal-no-height showAsideOptions'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: DarParecerPage,
|
|
componentProps: {
|
|
serialNumber: this.task.SerialNumber,
|
|
ProcessInstanceID: this.task.ProcessInstanceID,
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
|
|
modal.onDidDismiss().then(res => {
|
|
this.TaskService.loadPedidos();
|
|
if(res.data == 'sucess'){
|
|
this.goBack();
|
|
}
|
|
}, (error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
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
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.onDidDismiss().then(async (res) => {
|
|
const DocumentToSave = await res.data.documents.map(async (e) => {
|
|
return {
|
|
ApplicationId: e.ApplicationType,
|
|
SourceId: e.Id,
|
|
}
|
|
});
|
|
let docs = {
|
|
ProcessInstanceID: "",
|
|
Attachments: DocumentToSave,
|
|
}
|
|
|
|
if (res.data) {
|
|
if (actionName == 'Solicitar Reapreciação') {
|
|
await this.repreciar(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
else if (actionName == 'Arquivar') {
|
|
await this.arquivar(res.data.note, docs);
|
|
this.goBack();
|
|
}
|
|
else if (actionName == 'Assignar') {
|
|
await this.assignar(res.data.note, docs);
|
|
}
|
|
this.TaskService.loadPedidos();
|
|
}
|
|
}, (error) => {
|
|
console.log(error)
|
|
});
|
|
|
|
await modal.present();
|
|
}
|
|
|
|
goBack() {
|
|
this.RouteService.goBack();
|
|
}
|
|
|
|
}
|