mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve
This commit is contained in:
@@ -17,6 +17,8 @@ import { ToastService } from 'src/app/services/toast.service';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
|
||||
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
|
||||
import { PermissionService } from 'src/app/OtherService/permission.service';
|
||||
import { DespachoService } from 'src/app/Rules/despacho.service';
|
||||
|
||||
|
||||
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
|
||||
@@ -91,6 +93,8 @@ export class CreateProcessPage implements OnInit {
|
||||
private userAuth: AuthService,
|
||||
private animationController: AnimationController,
|
||||
private toastService: ToastService,
|
||||
public p: PermissionService,
|
||||
private despachoService: DespachoService
|
||||
) {
|
||||
this.loggeduser = userAuth.ValidatedUser;
|
||||
this.task = this.navParams.get('task');
|
||||
@@ -193,11 +197,13 @@ export class CreateProcessPage implements OnInit {
|
||||
|
||||
async saveTask() {
|
||||
|
||||
this.injectValidation()
|
||||
this.runValidation()
|
||||
|
||||
if(this.Form.invalid) return false
|
||||
|
||||
if(!this.p.userRole(['PR'])) {
|
||||
this.injectValidation()
|
||||
this.runValidation()
|
||||
if(this.Form.invalid) return false
|
||||
}
|
||||
|
||||
|
||||
if(this.postData.Priority=='99999861') {
|
||||
this.dispatchFolder.DeadlineType = 'Normal';
|
||||
@@ -232,11 +238,12 @@ export class CreateProcessPage implements OnInit {
|
||||
this.dispatchFolder.SubjectTypes = this.selectedTypes;
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
|
||||
switch (this.loggeduser.Profile) {
|
||||
case 'MDGPR':
|
||||
|
||||
switch (this.taskType) {
|
||||
case '0':
|
||||
case '0': // Despacho
|
||||
this.postData = {
|
||||
DistributionType: "Paralelo",
|
||||
CountryCode: 'AO',
|
||||
@@ -252,6 +259,7 @@ export class CreateProcessPage implements OnInit {
|
||||
await this.FinalizarDespacho(loader, 'Despacho criado');
|
||||
} catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -272,6 +280,7 @@ export class CreateProcessPage implements OnInit {
|
||||
}
|
||||
catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -292,10 +301,10 @@ export class CreateProcessPage implements OnInit {
|
||||
}
|
||||
catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
loader.remove()
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.modalController.dismiss();
|
||||
|
||||
break;
|
||||
|
||||
@@ -313,10 +322,14 @@ export class CreateProcessPage implements OnInit {
|
||||
console.log('this.postData', this.postData, this.taskType);
|
||||
|
||||
try {
|
||||
await this.processes.postDespatcho(this.postData).toPromise();
|
||||
await this.executado(loader, 'Despacho criado');
|
||||
await this.despachoService.createDespacho(this.postData).toPromise();
|
||||
await this.despachoService.CompleteTask({serialNumber: this.task.serialNumber}).toPromise();
|
||||
this.modalController.dismiss();
|
||||
this.toastService.successMessage('Despacho criado');
|
||||
} catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -337,6 +350,7 @@ export class CreateProcessPage implements OnInit {
|
||||
this.toastService.successMessage('Pedido de Parecer criado');
|
||||
}
|
||||
catch (error) {
|
||||
loader.remove()
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
}
|
||||
|
||||
@@ -358,12 +372,12 @@ export class CreateProcessPage implements OnInit {
|
||||
this.toastService.successMessage('Pedido de Deferimento criado');
|
||||
}
|
||||
catch (error) {
|
||||
loader.remove()
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
this.modalController.dismiss();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -387,6 +401,16 @@ export class CreateProcessPage implements OnInit {
|
||||
}
|
||||
else if(this.task.activityInstanceName =='Concluir Despacho' || this.task.activityInstanceName == 'Concluir Parecer') {
|
||||
|
||||
body = {
|
||||
"serialNumber": this.task.serialNumber,
|
||||
"action": "Despacho",
|
||||
"ActionTypeId": 94,
|
||||
"dataFields": {
|
||||
"ReviewUserComment": '',
|
||||
},
|
||||
"AttachmentList" :null,
|
||||
}
|
||||
} else {
|
||||
body = {
|
||||
"serialNumber": this.task.serialNumber,
|
||||
"action": "Despacho",
|
||||
@@ -401,8 +425,11 @@ export class CreateProcessPage implements OnInit {
|
||||
try {
|
||||
await this.processes.CompleteTask(body).toPromise();
|
||||
this.toastService.successMessage(message);
|
||||
this.modalController.dismiss();
|
||||
} catch (error) {
|
||||
this.toastService.badRequest('Processo não efectuado');
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user