mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
300 lines
8.2 KiB
TypeScript
300 lines
8.2 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
|
import { AnimationController, MenuController, ModalController, NavParams, PopoverController } from '@ionic/angular';
|
|
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
|
|
import { User } from 'src/app/models/user.model';
|
|
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
|
|
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
|
|
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
|
|
import { AlertService } from 'src/app/services/alert.service';
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
import { EventsService } from 'src/app/services/events.service';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
import { BadRequestPage } from '../bad-request/bad-request.page';
|
|
import { SuccessMessagePage } from '../success-message/success-message.page';
|
|
|
|
@Component({
|
|
selector: 'app-opts-expediente-pr',
|
|
templateUrl: './opts-expediente-pr.page.html',
|
|
styleUrls: ['./opts-expediente-pr.page.scss'],
|
|
})
|
|
export class OptsExpedientePrPage 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;
|
|
profile: string;
|
|
|
|
showEnviarPendentes = false;
|
|
|
|
loggeduser: User;
|
|
|
|
constructor(
|
|
private popoverController: PopoverController,
|
|
private modalController: ModalController,
|
|
private processes: ProcessesService,
|
|
private attachments: AttachmentsService,
|
|
private activatedRoute: ActivatedRoute,
|
|
private userAuth: AuthService,
|
|
private navParams: NavParams,
|
|
private animationController: AnimationController,
|
|
private router: Router,
|
|
private toastService: ToastService
|
|
|
|
) {
|
|
|
|
this.task = this.navParams.get('task');
|
|
this.fulltask = this.navParams.get('fulltask');
|
|
|
|
this.loggeduser = userAuth.ValidatedUser;
|
|
if(this.task.Status != 'Pending'){
|
|
this.showEnviarPendentes = true;
|
|
}
|
|
}
|
|
|
|
ngOnInit() {
|
|
}
|
|
|
|
close(){
|
|
if( window.innerWidth <= 1024){
|
|
this.popoverController.dismiss();
|
|
}
|
|
else{
|
|
this.modalController.dismiss();
|
|
}
|
|
}
|
|
|
|
async openAddNoteModal(actionName:string) {
|
|
this.popoverController.dismiss();
|
|
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 == 'Aprovar'){
|
|
this.approve(res.data.note, docs);
|
|
}
|
|
else if(actionName == 'Revisão'){
|
|
this.sendToReview(res.data.note, docs);
|
|
}
|
|
this.goBack();
|
|
}
|
|
});
|
|
}
|
|
|
|
async approve(note:string, documents:any){
|
|
this.popoverController.dismiss();
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Aprovar",
|
|
"ActionTypeId": 100000004 ,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise()
|
|
this.close();
|
|
this.toastService.successMessage()
|
|
} catch(error) {
|
|
this.toastService.badRequest()
|
|
}
|
|
}
|
|
|
|
async distartExpedientModal(body:any){
|
|
this.popoverController.dismiss();
|
|
const modal = await this.modalController.create({
|
|
component: DiscartExpedientModalPage,
|
|
componentProps: {
|
|
},
|
|
cssClass: 'discart-expedient-modal',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
modal.onDidDismiss().then( async (res)=>{
|
|
console.log(res['data']);
|
|
|
|
if(body == 'descartar'){
|
|
if(res['data']== 'Yes'){
|
|
let otherbody = {
|
|
"serialNumber": this.task.SerialNumber,
|
|
"action": "Passivo",
|
|
"ActionTypeId": 99999877,
|
|
"dataFields": {
|
|
"Note": "",
|
|
}
|
|
}
|
|
|
|
try {
|
|
await this.processes.CompleteTask(otherbody).toPromise()
|
|
this.toastService.successMessage('Processo descartado');
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest('Processo não descartado')
|
|
}
|
|
|
|
}
|
|
else if(res['data'] == 'No'){
|
|
//Do nothing
|
|
}
|
|
}
|
|
else{
|
|
if(res['data']== 'Yes'){
|
|
try {
|
|
await this.processes.CompleteTask(body).toPromise();
|
|
this.toastService.successMessage('Processo descartado');
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest('Processo não descartado')
|
|
}
|
|
this.goBack();
|
|
}
|
|
else if(res['data'] == 'No'){
|
|
console.log('Update');
|
|
try {
|
|
await this.processes.UpdateTaskStatus(this.task.FolderId).toPromise();
|
|
this.toastService.successMessage();
|
|
this.goBack();
|
|
} catch (error) {
|
|
this.toastService.badRequest()
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
async sendToReview(note:string, documents:any){
|
|
let body = {
|
|
"serialNumber": this.serialnumber,
|
|
"action": "Retificar",
|
|
"ActionTypeId": 99999877,
|
|
"dataFields": {
|
|
"ReviewUserComment": note,
|
|
},
|
|
"AttachmentList" :documents,
|
|
}
|
|
|
|
try {
|
|
await this.processes.CompleteTask(body);
|
|
this.close();
|
|
this.toastService.successMessage()
|
|
} catch(error) {
|
|
this.toastService.badRequest()
|
|
}
|
|
}
|
|
|
|
sendExpedienteToPending(){
|
|
this.popoverController.dismiss();
|
|
this.processes.SetTaskToPending(this.serialnumber).subscribe(res=>{
|
|
console.log(res);
|
|
this.close();
|
|
});
|
|
}
|
|
|
|
async openExpedientActionsModal(taskAction: any, task: any) {
|
|
this.popoverController.dismiss();
|
|
let classs;
|
|
if( window.innerWidth <= 800){
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: ExpedientTaskModalPage,
|
|
componentProps: {
|
|
taskAction: taskAction,
|
|
task: task,
|
|
profile: this.profile,
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then(res=>{
|
|
console.log(res['data']);
|
|
let body = res['data'];
|
|
// alert('close '+ res['data'])
|
|
if(res['data']){
|
|
console.log('open discart');
|
|
|
|
this.distartExpedientModal(body);
|
|
|
|
}
|
|
else{
|
|
console.log('Not open');
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
async openBookMeetingModal(task: any) {
|
|
this.popoverController.dismiss();
|
|
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();
|
|
}
|
|
|
|
goBack() {
|
|
let navigationExtras: NavigationExtras = {
|
|
queryParams: {
|
|
"expedientes-pr": true,
|
|
}
|
|
};
|
|
this.router.navigate(['/home/gabinete-digital'], navigationExtras);
|
|
|
|
// window.history.back();
|
|
|
|
}
|
|
|
|
}
|