Skip to content

Commit

Permalink
FEAT ITEM-261-front-modifier-le-workflow-de-suppression :
Browse files Browse the repository at this point in the history
     - création d'un workflow pour les suppressions des EPN
  • Loading branch information
EryneKL committed Oct 14, 2024
1 parent ec533ae commit c85b8d4
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/service/ItemService.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class ItemService {
'charset': 'utf-8'
}};
const data = new FormData();
data.append('file',file);
data.append('file',file, 'fichier_valide.csv');
return this.client.post(`uploadDemande/${typeDemande}/${id}`,data,config);
}

Expand Down
130 changes: 89 additions & 41 deletions src/views/Suppression/SuppSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
>
</v-stepper-item>
<v-divider></v-divider>
<v-stepper-item v-if="typeFileSelected==='PPN'"
<v-stepper-item
:color="currentStep >= 2 ? 'primary' : ''"
:complete="currentStep > 2"
:editable="currentStep > 2"
Expand All @@ -35,6 +35,7 @@
</v-stepper-item>
<v-divider></v-divider>
<v-stepper-item
:color="currentStep >= 3 ? 'primary' : ''"
icon="mdi-numeric-4"
title="Simulation"
>
Expand All @@ -57,7 +58,7 @@
</v-stepper-window-item>
<v-stepper-window-item>
<type-file v-if="!typeFileSelected" v-model="typeFileSelected" @clicked="setTypeSelected()" @deleted="deleteDemande()"></type-file>
<select-file v-else-if="!isLoaded" :is-loading="isLoading" v-model="fileSelected" :typeFile="typeFileSelected" @deleted="deleteDemande()">Selection du fichier {{typeFileSelected}}</select-file>
<select-file v-else-if="!isLoaded" :is-loading="isLoading" v-model="fileSelected" typeFile="PPN" @deleted="deleteDemande()">Selection du fichier PPN</select-file>
<download-file v-if="isLoaded" :file-link="fileLink" :file-name="fileName" @clicked="isDownloaded = true" @deleted="deleteDemande()">Téléchargement du fichier PPN/RCR/EPN</download-file>
<v-alert
v-if="alertMessage"
Expand Down Expand Up @@ -93,26 +94,29 @@
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
<select-file v-model="fileFinalSelected" :is-loading="isLoading" @deleted="deleteDemande()">Charger le
fichier des exemplaires à supprimer
</select-file>
<v-alert
v-if="alertMessage"
:type="alertType"
>
<span v-html="alertMessage"></span>
</v-alert>
<v-container class="d-flex justify-space-between">
<v-btn @click="prev">
précédent
</v-btn>
<v-btn
:disabled="!fileFinalSelected"
@click="uploadFileFinal()"
:loading="isLoading"
<v-container>
<select-file v-if="typeFileSelected==='PPN'" v-model="fileFinalSelected" :is-loading="isLoading" @deleted="deleteDemande()">Charger le
fichier des exemplaires à supprimer
</select-file>
<select-file v-else-if="typeFileSelected==='EPN'" v-model="fileSelected" :is-loading="isLoading" typeFile="EPN" @deleted="deleteDemande()">Selection du fichier EPN</select-file>
<v-alert
v-if="alertMessage"
:type="alertType"
>
Lancer le traitement en simulation
</v-btn>
<span v-html="alertMessage"></span>
</v-alert>
<v-container class="d-flex justify-space-between">
<v-btn @click="prevSelectFileFinal()">
précédent
</v-btn>
<v-btn
:disabled="!(fileFinalSelected || (fileSelected && typeFileSelected==='EPN'))"
@click="uploadFileFinal()"
:loading="isLoading"
>
Lancer le traitement en simulation
</v-btn>
</v-container>
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
Expand Down Expand Up @@ -256,7 +260,51 @@ function uploadFile() {
});
}
function setTypeSelected(){
itemService.modifierTypeFileDemande(demande.value.id, typeFileSelected.value)
itemService.modifierTypeFileDemande(demande.value.id, typeFileSelected.value);
if (typeFileSelected.value==='EPN'){
next();
}
}
function uploadFileFinal() {
alertMessage.value = '';
alertType.value = 'success';
isLoading.value = true;
if (typeFileSelected.value==='PPN'){
itemService.uploadDemande(demande.value.id, fileFinalSelected.value, 'SUPP')
.then(() => {
alertMessage.value = "Fichier envoyé";
next();
})
.catch(err => {
alertMessage.value = err.response.data.message;
alertType.value = 'error';
})
.finally(() => {
isLoading.value = false;
});
} else if (typeFileSelected.value==='EPN') {
itemService.uploadDemande(demande.value.id, fileSelected.value, 'SUPP')
.then(() => {
alertMessage.value = "Fichier envoyé";
itemService.getFile(demande.value.id, 'SUPP','fichier_correspondance', '.csv')
.then(response => {
let blob = new Blob([response.data], {type: 'application/csv'});
itemService.uploadDemande(demande.value.id, blob, 'SUPP')
.then(() => {
goSimulation();
})
.finally(() => {
isLoading.value = false;
});
})
})
.catch(err => {
alertMessage.value = err.response.data.message;
alertType.value = 'error';
})
}
}
function changeEtape() {
Expand All @@ -268,10 +316,17 @@ function changeEtape() {
typeFileSelected.value = null;
}
if ((currentStep.value + 1) === 2 && typeFileSelected.value) { //Changement d'etat pour le chargement du fichier car le back est perdu sinon
itemService.choixEtape(demande.value.id, 2, 'SUPP')
if(typeFileSelected.value === 'PPN') {
itemService.choixEtape(demande.value.id, 2, 'SUPP')
.then(response => {
demande.value = response.data;
});
} else {
itemService.choixEtape(demande.value.id, 3, 'SUPP')
.then(response => {
demande.value = response.data;
});
}
}
if ((currentStep.value + 1) === 3 ) {
itemService.choixEtape(demande.value.id, 3, 'SUPP')
Expand All @@ -281,24 +336,6 @@ function changeEtape() {
}
}
function uploadFileFinal() {
alertMessage.value = '';
alertType.value = 'success';
isLoading.value = true;
itemService.uploadDemande(demande.value.id, fileFinalSelected.value, 'SUPP')
.then(() => {
alertMessage.value = "Fichier envoyé";
next();
})
.catch(err => {
alertMessage.value = err.response.data.message;
alertType.value = 'error';
})
.finally(() => {
isLoading.value = false;
});
}
function prevSelectTypeFile(){
typeFileSelected.value = null;
changeEtape()
Expand All @@ -308,11 +345,22 @@ function prevSelectFile(){
changeEtape()
raz();
}
function prevSelectFileFinal(){
if(typeFileSelected.value==='EPN'){
typeFileSelected.value = null;
}
prev();
}
function next() {
currentStep.value++;
raz();
}
function goSimulation(){
currentStep.value = 3;
raz();
}
function prev() {
currentStep.value--;
changeEtape()
Expand Down

0 comments on commit c85b8d4

Please sign in to comment.