Skip to content

Commit

Permalink
FEAT ITEM-213-front-ajouter-ecran-de-simulation :
Browse files Browse the repository at this point in the history
     - ajout de l'écran de simulation dans SuppSteps.vue
  • Loading branch information
EryneKL committed Sep 16, 2024
1 parent 3d65bb9 commit 9e68348
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/Simulation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import RecapDemande from '@/components/RecapDemande.vue';
import NavigateNotice from '@/components/NavigateNotice.vue';
import { onMounted, ref } from 'vue';
import demandesService from '@/service/ItemService';
import itemService from '@/service/ItemService';
const props = defineProps({
demande: {
Expand Down Expand Up @@ -103,7 +103,7 @@ onMounted(() => {
function refresh() {
isLoading.value = true;
alertMessageError.value = null;
demandesService.simulerLigne(props.demande.id, nbNotice.value.nbNoticeEnCours, props.demande.type)
itemService.simulerLigne(props.demande.id, nbNotice.value.nbNoticeEnCours, props.demande.type)
.then(response => {
numeroPPNNotice.value = response.data[0];
noticeAvant.value = response.data[1];
Expand Down
54 changes: 40 additions & 14 deletions src/views/Suppression/SuppSteps.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-container :class="(currentStep === 4) ? '' : 'fill-height'" fluid>
<v-container :class="(currentStep === 3) ? '' : 'fill-height'" fluid>
<v-row align="center" justify="center">
<v-col :md="(currentStep === 4) ? '' : '7'">
<v-col :md="(currentStep === 3) ? '' : '7'">
<v-stepper v-model="currentStep" @update:model-value="changeEtape()" alt-labels>
<v-stepper-header>
<v-stepper-item
Expand Down Expand Up @@ -33,6 +33,12 @@
subtitle="du fichier"
>
</v-stepper-item>
<v-divider></v-divider>
<v-stepper-item
icon="mdi-numeric-4"
title="Simulation"
>
</v-stepper-item>
</v-stepper-header>

<v-stepper-window>
Expand Down Expand Up @@ -105,7 +111,18 @@
@click="uploadFileFinal()"
:loading="isLoading"
>
Lancer le traitement en production
Lancer le traitement en simulation
</v-btn>
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
<simulation :demande="demande" label-before="Exemplaire(s) existant(s)" label-after="Exemplaire(s) restant(s)" @deleted="deleteDemande()"></simulation>
<v-container class="d-flex justify-space-between">
<v-btn @click="prev">
précédent
</v-btn>
<v-btn large @click="dialog = true"
aria-label="Lancer le traitement en production">Lancer le traitement en production
</v-btn>
</v-container>
</v-stepper-window-item>
Expand Down Expand Up @@ -139,10 +156,11 @@
import { onMounted, ref } from 'vue';
import TypeFile from '@/components/Supp/TypeFile.vue';
import SelectFile from '@/components/SelectFile.vue';
import demandesService from '@/service/ItemService';
import itemService from '@/service/ItemService';
import DownloadFile from "@/components/Modif/DownloadFile.vue";
import router from '@/router'
import Rcr from '@/components/Rcr.vue';
import Simulation from "@/components/Simulation.vue";
import DialogSuppression from '@/components/Dialog/DialogSuppression.vue';
const currentStep = ref(0);
Expand All @@ -167,7 +185,7 @@ const suppDialog = ref(false);
onMounted(()=>{
if (props.id) {
demandesService.getDemande(props.id, "SUPP")
itemService.getDemande(props.id, "SUPP")
.then(response => {
demande.value = response.data;
switch (demande.value.etatDemande) {
Expand All @@ -188,6 +206,14 @@ onMounted(()=>{
typeFileSelected.value = demande.value.typeSuppression;
currentStep.value = 2;
break;
case 'En simulation':
currentStep.value = 3;
rcrSelected.value = demande.value.rcr;
typeDocumentSelected.value = {
id: -1,
libelle: demande.value.typeExemp
};
break;
}
}).catch(() => {
router.replace("/suppression");
Expand All @@ -201,7 +227,7 @@ function createDemande() {
next();
} else if (demande.value) {
isLoading.value = true;
demandesService.modifierRcrDemande(demande.value.id, rcrSelected.value, 'SUPP')
itemService.modifierRcrDemande(demande.value.id, rcrSelected.value, 'SUPP')
.then(response => {
demande.value = response.data;
next();
Expand All @@ -212,7 +238,7 @@ function createDemande() {
});
} else {
isLoading.value = true;
demandesService.creerDemande(rcrSelected.value, 'SUPP')
itemService.creerDemande(rcrSelected.value, 'SUPP')
.then(response => {
demande.value = response.data;
next();
Expand All @@ -228,11 +254,11 @@ function uploadFile() {
alertMessage.value = '';
alertType.value = 'success';
isLoading.value = true;
demandesService.uploadDemande(demande.value.id, fileSelected.value, 'SUPP')
itemService.uploadDemande(demande.value.id, fileSelected.value, 'SUPP')
.then(() => {
alertMessage.value = "Fichier envoyé";
isLoaded.value = true;
demandesService.getFile(demande.value.id, 'SUPP','fichier_prepare', '.csv')
itemService.getFile(demande.value.id, 'SUPP','fichier_prepare', '.csv')
.then(response => {
let blob = new Blob([response.data], {type: 'application/csv'});
fileLink.value = window.URL.createObjectURL(blob);
Expand All @@ -248,19 +274,19 @@ function uploadFile() {
});
}
function setTypeSelected(){
demandesService.modifierTypeFileDemande(demande.value.id, typeFileSelected.value)
itemService.modifierTypeFileDemande(demande.value.id, typeFileSelected.value)
}
function changeEtape() {
if (((currentStep.value + 1) === 1) || ((currentStep.value + 1) === 2 && !typeFileSelected.value)) {
demandesService.choixEtape(demande.value.id, 1, 'SUPP')
itemService.choixEtape(demande.value.id, 1, 'SUPP')
.then(response => {
demande.value = response.data;
});
typeFileSelected.value = null;
}
if ((currentStep.value + 1) === 2 && typeFileSelected.value) { //Changement d'etat pour le chargement du fichier car le back est perdu sinon
demandesService.choixEtape(demande.value.id, 2, 'SUPP')
itemService.choixEtape(demande.value.id, 2, 'SUPP')
.then(response => {
demande.value = response.data;
});
Expand All @@ -271,10 +297,10 @@ function uploadFileFinal() {
alertMessage.value = '';
alertType.value = 'success';
isLoading.value = true;
demandesService.uploadDemande(demande.value.id, fileFinalSelected.value, 'SUPP')
itemService.uploadDemande(demande.value.id, fileFinalSelected.value, 'SUPP')
.then(() => {
alertMessage.value = "Fichier envoyé";
dialog.value = true;
next();
})
.catch(err => {
alertMessage.value = err.response.data.message;
Expand Down

0 comments on commit 9e68348

Please sign in to comment.