mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
516 lines
15 KiB
TypeScript
516 lines
15 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
|
|
import { DailyWorkTask } from '../../../../models/dailyworktask.model';
|
|
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
|
import { formatDate } from '@angular/common';
|
|
import { Event } from '../../../../models/event.model';
|
|
import { AnimationController, MenuController, ModalController, PopoverController } from '@ionic/angular';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
import { ViewEventPage } from 'src/app/pages/agenda/view-event/view-event.page';
|
|
import { momentG } from 'src/plugin/momentG'
|
|
import { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart-expedient-modal.page';
|
|
import { ExpedientTaskModalPage } from '../../expediente/expedient-task-modal/expedient-task-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 { OptsExpedientePage } from 'src/app/shared/popover/opts-expediente/opts-expediente.page';
|
|
import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page';
|
|
import { SuccessMessagePage } from 'src/app/shared/popover/success-message/success-message.page';
|
|
import { DespachosOptionsPage } from 'src/app/shared/popover/despachos-options/despachos-options.page';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
@Component({
|
|
selector: 'app-despacho',
|
|
templateUrl: './despacho.page.html',
|
|
styleUrls: ['./despacho.page.scss'],
|
|
})
|
|
export class DespachoPage 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;
|
|
profile: string;
|
|
intervenientes: any;
|
|
cc: any = [];
|
|
|
|
constructor(private activateRoute: ActivatedRoute,
|
|
private processes: ProcessesService,
|
|
private iab: InAppBrowser,
|
|
private attachmentsService: AttachmentsService,
|
|
private events: EventsService,
|
|
private menu: MenuController,
|
|
private modalController: ModalController,
|
|
private alertService: AlertService,
|
|
public popoverController: PopoverController,
|
|
private activatedRoute: ActivatedRoute,
|
|
private router: Router,
|
|
private animationController: AnimationController,
|
|
private toastService: ToastService,
|
|
) {
|
|
|
|
this.activatedRoute.queryParams.subscribe(params => {
|
|
if(params["serialNumber"]) {
|
|
this.serialnumber = params["serialNumber"];
|
|
console.log(params["serialNumber"]);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.profile = "mdgpr";
|
|
console.log(this.serialnumber);
|
|
|
|
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);
|
|
}
|
|
|
|
close(){
|
|
this.modalController.dismiss();
|
|
}
|
|
|
|
goBack() {
|
|
// window.history.back()
|
|
|
|
let navigationExtras: NavigationExtras = {
|
|
queryParams: {
|
|
// "serialNumber": serialNumber,
|
|
//'despachos': true
|
|
}
|
|
}
|
|
|
|
this.router.navigate(['/home/gabinete-digital/despachos'], navigationExtras);
|
|
|
|
}
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
}
|
|
|
|
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 LoadRelatedEvents(serial: string) {
|
|
if (this.eventsList == null) {
|
|
this.attachmentsService.getAttachmentsBySerial(serial).subscribe(res => {
|
|
console.log(res);
|
|
res.forEach(att => {
|
|
if (this.eventsList == null) {
|
|
this.eventsList = new Array();
|
|
}
|
|
this.events.getEvent(att.ParentId).subscribe(event => {
|
|
this.eventsList.push(event);
|
|
console.log(this.eventsList);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
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();
|
|
});
|
|
}
|
|
|
|
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,
|
|
}
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.close();
|
|
this.toastService.successMessage('Processo criado')
|
|
} catch(error) {
|
|
this.toastService.badRequest("Processo não criado")
|
|
}
|
|
}
|
|
|
|
async arquivar(note:string, documents:any){
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Arquivo",
|
|
"ActionTypeId": 95,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.toastService.successMessage('Processo descartado')
|
|
this.close();
|
|
} catch (error) {
|
|
this.toastService.badRequest("Processo não descartado")
|
|
}
|
|
|
|
}
|
|
|
|
async reencaminhar(note:string, documents:any) {
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Reencaminhar",
|
|
"ActionTypeId": 98,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.toastService.successMessage()
|
|
this.close();
|
|
} catch (error) {
|
|
this.toastService.badRequest()
|
|
}
|
|
}
|
|
|
|
async reexecute(note:string, documents:any) {
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Reexecução",
|
|
"ActionTypeId": 100000010,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.toastService.successMessage()
|
|
this.close();
|
|
|
|
} catch (error) {
|
|
this.toastService.badRequest()
|
|
}
|
|
|
|
}
|
|
|
|
async sendExpedienteToPending() {
|
|
this.processes.SetTaskToPending(this.serialnumber).subscribe(res=>{
|
|
console.log(res);
|
|
this.close();
|
|
this.toastService.successMessage('Processo enviado para despacho')
|
|
},
|
|
error => {
|
|
this.toastService.badRequest("Processo não enviado para despacho")
|
|
});
|
|
}
|
|
|
|
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 => {
|
|
console.log(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'){
|
|
|
|
this.executado(res.data.note, docs);
|
|
}
|
|
else if(actionName == 'Arquivar'){
|
|
this.arquivar(res.data.note, docs);
|
|
}
|
|
else if(actionName == 'Reexecução'){
|
|
this.reexecute(res.data.note, docs);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
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,
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then(res=>{
|
|
console.log(res['data']);
|
|
if(res['data']=='openDiscart'){
|
|
console.log('open discart');
|
|
|
|
this.distartExpedientModal();
|
|
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
async distartExpedientModal(){
|
|
console.log(this.fulltask);
|
|
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();
|
|
/* console.log('2Expedient Discard closed2');
|
|
this.close();
|
|
this.openMenu(); */
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
async openOptions(taskAction?: any) {
|
|
|
|
const popover = await this.popoverController.create({
|
|
component: DespachosOptionsPage,
|
|
cssClass: 'exp-options',
|
|
componentProps: {
|
|
task: this.task,
|
|
fulltask: this.fulltask,
|
|
taskAction: taskAction,
|
|
showEnviarPendentes: false
|
|
},
|
|
translucent: true
|
|
});
|
|
return await popover.present();
|
|
}
|
|
|
|
async successMessage(message?: any, callback?) {
|
|
var notification = document.createElement('div')
|
|
notification.id = 'notification'
|
|
notification.innerHTML = `
|
|
|
|
<div class="main-content width-100 pa-20">
|
|
<p class="message d-flex align-center">
|
|
<ion-icon slot="end" class="title-icon pr-10" src="/assets/images/nofitication-success.svg"></ion-icon>
|
|
<p class="text">{{ message }}</p>
|
|
</p>
|
|
|
|
</div>
|
|
`
|
|
|
|
document.body.append(notification)
|
|
notification.querySelector('.text').innerHTML = message || 'Processo efetuado'
|
|
setTimeout(()=>{
|
|
notification.remove()
|
|
},7000)
|
|
|
|
}
|
|
|
|
async badRequest(message?: string, callback?) {
|
|
const enterAnimation = (baseEl: any) => {
|
|
const backdropAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
.keyframes([
|
|
{ offset: 0, opacity: '1', right: '-100%' },
|
|
{ offset: 1, opacity: '1', right: '0px' }
|
|
]);
|
|
|
|
return this.animationController.create()
|
|
.addElement(baseEl)
|
|
.easing('ease-out')
|
|
.duration(7000)
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
}
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
}
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
enterAnimation,
|
|
leaveAnimation,
|
|
component: BadRequestPage,
|
|
componentProps: {
|
|
message: message || 'Processo efetuado' ,
|
|
},
|
|
cssClass: 'notification-modal'
|
|
});
|
|
|
|
modal.present()
|
|
|
|
setTimeout(()=>{
|
|
if (callback) {
|
|
callback()
|
|
}
|
|
modal.dismiss()
|
|
},7000)
|
|
}
|
|
}
|