Files
doneit-web/src/app/modals/dar-parecer/dar-parecer.page.ts
T

112 lines
2.8 KiB
TypeScript
Raw Normal View History

2021-05-04 17:03:44 +01:00
import { Component, OnInit } from '@angular/core';
2021-06-08 15:59:06 +01:00
import { AnimationController, ModalController, NavParams } from '@ionic/angular';
2021-08-20 12:02:27 +01:00
import { SearchList } from 'src/app/models/search-document';
2021-05-12 16:15:30 +01:00
import { SearchPage } from 'src/app/pages/search/search.page';
import { ProcessesService } from 'src/app/services/processes.service';
2021-06-15 15:09:20 +01:00
import { ToastService } from 'src/app/services/toast.service';
2023-02-27 09:34:36 +01:00
import { ThemeService } from 'src/app/services/theme.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
2023-08-31 12:00:52 +01:00
import { TaskService } from 'src/app/services/task.service'
2021-05-04 17:03:44 +01:00
@Component({
selector: 'app-dar-parecer',
templateUrl: './dar-parecer.page.html',
styleUrls: ['./dar-parecer.page.scss'],
})
export class DarParecerPage implements OnInit {
note:string;
2021-05-12 16:15:30 +01:00
serialNumber:string;
instanceId: string;
2021-08-20 12:02:27 +01:00
documents:SearchList[] = [];
2021-05-04 17:03:44 +01:00
constructor(
2021-05-12 16:15:30 +01:00
private processes: ProcessesService,
2021-05-04 17:03:44 +01:00
private modalController: ModalController,
2021-05-12 16:15:30 +01:00
private navParams: NavParams,
2021-06-08 15:59:06 +01:00
private animationController: AnimationController,
2021-06-15 15:09:20 +01:00
private toastService: ToastService,
2023-02-27 09:34:36 +01:00
public ThemeService: ThemeService,
2023-08-31 12:00:52 +01:00
private httpErroHanlde: HttpErrorHandle,
public TaskService: TaskService
2022-02-18 11:37:56 +01:00
) {
2021-05-12 16:15:30 +01:00
this.serialNumber = this.navParams.get('serialNumber');
this.instanceId = this.navParams.get('ProcessInstanceID');
}
2021-05-04 17:03:44 +01:00
ngOnInit() {
2022-02-18 11:37:56 +01:00
2021-05-04 17:03:44 +01:00
}
2022-02-18 11:37:56 +01:00
2021-08-17 17:02:41 +01:00
cancel() {
2021-05-04 17:03:44 +01:00
this.modalController.dismiss();
}
2022-02-18 11:37:56 +01:00
2021-05-28 15:45:41 +01:00
async save() {
2022-02-18 11:37:56 +01:00
2021-05-12 16:15:30 +01:00
const DocumentToSave = this.documents.map((e) => {
return {
ApplicationId: e.ApplicationType,
SourceId: e.Id,
}
});
let docs = {
2021-05-25 13:38:46 +01:00
ProcessInstanceID: "",
2021-05-12 16:15:30 +01:00
Attachments: DocumentToSave,
}
2022-02-18 11:37:56 +01:00
let body = {
"serialNumber": this.serialNumber,
2021-05-12 16:15:30 +01:00
"action": "Registar",
"ActionTypeId": 104,
"dataFields": {
2021-05-21 10:05:59 +01:00
"ReviewUserComment": this.note,
2021-05-12 16:15:30 +01:00
},
"AttachmentList": docs,
}
2021-05-28 15:45:41 +01:00
2021-08-17 17:02:41 +01:00
const loader = this.toastService.loading()
try {
2021-06-04 15:59:36 +01:00
await this.processes.CompleteTask(body).toPromise();
2022-02-18 11:37:56 +01:00
this.modalController.dismiss('sucess');
2023-02-27 09:34:36 +01:00
this.httpErroHanlde.httpsSucessMessagge('Dar o meu Parecer')
2021-05-28 15:45:41 +01:00
} catch (error) {
2023-02-27 09:34:36 +01:00
this.httpErroHanlde.httpStatusHandle(error)
2021-08-17 17:02:41 +01:00
} finally {
loader.remove()
2021-05-28 15:45:41 +01:00
}
2021-05-12 16:15:30 +01:00
}
2021-05-04 17:03:44 +01:00
2021-05-12 16:15:30 +01:00
removeAttachment(index: number){
this.documents = this.documents.filter( (e, i) => index != i);
}
2022-02-18 11:37:56 +01:00
2021-07-16 19:32:13 +01:00
async getDoc() {
2021-05-12 16:15:30 +01:00
const modal = await this.modalController.create({
component: SearchPage,
cssClass: 'modal-width-100-width-background modal',
componentProps: {
type: 'AccoesPresidenciais & ArquivoDespachoElect',
showSearchInput: true,
select: true
}
});
2023-07-15 11:01:09 +01:00
modal.onDidDismiss().then((res)=>{
2021-05-12 16:15:30 +01:00
if(res){
const data = res.data;
this.documents.push(data.selected);
}
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-05-12 16:15:30 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-05-04 17:03:44 +01:00
}
2021-05-28 15:45:41 +01:00
2021-06-08 15:59:06 +01:00
2022-02-18 11:37:56 +01:00
2021-05-04 17:03:44 +01:00
}