Skip to content

Commit

Permalink
Merge pull request #190 from abes-esr/ITEM-429-Reappeler-le-ws-pour-o…
Browse files Browse the repository at this point in the history
…btenir-le-nbLine

Ajout refresh a chaque fois qu'on revient en simu
  • Loading branch information
EryneKL authored Dec 6, 2024
2 parents 8b21eeb + 4d78c14 commit 9f2c943
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 161 deletions.
51 changes: 25 additions & 26 deletions src/components/Simulation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@

<recap-demande :demande="demande"></recap-demande>
<!-- CONTENU SIMULATION -->
<v-alert icon="mdi-alert" type="error" v-if="alertMessageError" class="my-3" border="left">Simulation impossible : {{ alertMessageError }}</v-alert>
<v-alert icon="mdi-alert" type="error" v-if="alertMessageError" class="my-3" border="left">Simulation impossible :
{{ alertMessageError }}
</v-alert>
<v-card flat class="pb-2">
<v-card-title class="d-flex justify-space-between custom-card-title">
<span>Ecran de simulation</span>
<v-btn depressed variant="text" @click="deleted()" prepend-icon="mdi-delete">Supprimer</v-btn>
</v-card-title>
<!--TEMPLATE DE SIMULATION-->
<v-alert type="warning" class="my-3 pa-2" dense prominent border="left">
<v-alert type="warning" class="my-3 pa-2" dense prominent border="left">
Cet écran est une <strong>prévisualisation</strong> du traitement.<br>
Il s'agit de la <strong>dernière étape</strong> avant de lancer le traitement en <strong>base de
production</strong>. Merci de <strong>vérifier vos données</strong>.
Expand All @@ -36,7 +38,7 @@
</v-card>
</v-col>
<v-col cols="12" sm="12" md="2" class="pb-10">
<navigate-notice v-model="nbNotice" @clicked="refresh()"></navigate-notice>
<navigate-notice v-model="nbNotice" @clicked="refresh(nbNotice.nbNoticeEnCours)"></navigate-notice>
</v-col>
<v-col cols="12" sm="12" md="5"> <!--Exemplaire à créer-->
<v-card class="pa-1 mr-1" outlined tile>
Expand All @@ -54,7 +56,7 @@
import RecapDemande from '@/components/RecapDemande.vue';
import NavigateNotice from '@/components/NavigateNotice.vue';
import { onMounted, ref } from 'vue';
import { onMounted, ref, watchEffect } from 'vue';
import itemService from '@/service/ItemService';
const props = defineProps({
Expand All @@ -71,48 +73,44 @@ const props = defineProps({
default: 'Après'
}
});
const emits = defineEmits(['deleted'])
const emits = defineEmits(['deleted']);
const nbNotice = ref({
nbNoticeEnCours: 0,
nbTotalNotice: 0
});
const numeroPPNNotice = ref();
const noticeAvant = ref("");
const noticeApres = ref("");
const noticeAvant = ref('');
const noticeApres = ref('');
const isLoading = ref(true);
const alertMessageError = ref();
onMounted(() => {
itemService.getNbLigneFichier(props.demande.id, props.demande.type)
.then(response => {
nbNotice.value.nbTotalNotice = response.data;
});
itemService.simulerLigne(props.demande.id, 0, props.demande.type)
.then(response => {
numeroPPNNotice.value = response.data[0];
noticeAvant.value = response.data[1];
noticeApres.value = response.data[2];
})
.catch(err => {
alertMessageError.value = err.response.data.message
})
.finally(() => {
isLoading.value = false;
});
refresh(0);
});
watchEffect(() => {
if (props.demande.etatDemande === 'En simulation') {
refresh(0);
}
});
function refresh() {
//nbNotice.value.nbNoticeEnCours
function refresh(nbNoticeEnCours) {
isLoading.value = true;
alertMessageError.value = null;
itemService.simulerLigne(props.demande.id, nbNotice.value.nbNoticeEnCours, props.demande.type)
itemService.getNbLigneFichier(props.demande.id, props.demande.type)
.then(response => {
nbNotice.value.nbTotalNotice = response.data;
});
itemService.simulerLigne(props.demande.id, nbNoticeEnCours, props.demande.type)
.then(response => {
numeroPPNNotice.value = response.data[0];
noticeAvant.value = response.data[1];
noticeApres.value = response.data[2];
})
.catch(err => {
alertMessageError.value = err.response.data.message
alertMessageError.value = err.response.data.message;
})
.finally(() => {
isLoading.value = false;
Expand All @@ -134,6 +132,7 @@ h4 {
font-size: x-large;
font-weight: normal;
}
h5 {
font-size: x-large;
font-weight: normal;
Expand Down
88 changes: 52 additions & 36 deletions src/views/Exemplarisation/ExempSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</v-row>
<v-row align="center" justify="center">
<v-col :md="(currentStep === 3) ? '' : '7'">
<v-stepper v-model="currentStep" @update:model-value="changeEtat()" alt-labels>
<v-stepper v-model="currentStep" @update:model-value="changeEtat()" alt-labels>
<v-stepper-header>
<v-stepper-item
:color="currentStep >= 0 ? 'primary' : ''"
Expand Down Expand Up @@ -58,15 +58,18 @@
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
<type-exemp v-model="typeDocumentSelected" :is-loading="isLoading" @deleted="deleteDemande()" @click="modifiTypeExemp"></type-exemp>
<type-exemp v-model="typeDocumentSelected" :is-loading="isLoading" @deleted="deleteDemande()"
@click="modifiTypeExemp"></type-exemp>
<v-container class="d-flex justify-space-between">
<v-btn @click="prev">
précédent
</v-btn>
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
<select-file v-model="fileSelected" :is-loading="isLoading" @deleted="deleteDemande()">Charger le fichier des exemplaires à traiter</select-file>
<select-file v-model="fileSelected" :is-loading="isLoading" @deleted="deleteDemande()">Charger le
fichier des exemplaires à traiter
</select-file>
<v-alert
v-if="alertMessage"
:type="alertType"
Expand All @@ -86,7 +89,8 @@
</v-container>
</v-stepper-window-item>
<v-stepper-window-item>
<simulation :demande="demande" label-before="Exemplaire(s) existant(s)" label-after="Exemplaire à créer" @deleted="deleteDemande()"></simulation>
<simulation :demande="demande" label-before="Exemplaire(s) existant(s)" label-after="Exemplaire à créer"
@deleted="deleteDemande()"></simulation>
<v-container class="d-flex justify-space-between">
<v-btn @click="prev">
précédent
Expand All @@ -102,40 +106,41 @@
</v-row>
</v-col>
</v-container>
<dialog-lancer-traitement v-model="dialog" :is-loading="isLoading" rubrique="Gérer mes créations" route="exemplarisation-tableau" @launch="launchDemande()"></dialog-lancer-traitement>
<dialog-suppression v-model="suppDialog" :demande="demande" return-to-accueil></dialog-suppression>
<dialog-lancer-traitement v-model="dialog" :is-loading="isLoading" rubrique="Gérer mes créations"
route="exemplarisation-tableau" @launch="launchDemande()"></dialog-lancer-traitement>
<dialog-suppression v-model="suppDialog" :demande="demande" return-to-accueil></dialog-suppression>
</template>

<script setup>
import {onMounted, ref} from 'vue'
import { onMounted, ref } from 'vue';
import itemService from '@/service/ItemService';
import router from '@/router';
import SelectFile from '@/components/SelectFile.vue';
import Rcr from '@/components/Rcr.vue';
import TypeExemp from '@/components/Exemp/TypeExemp.vue';
import Simulation from "@/components/Simulation.vue";
import Simulation from '@/components/Simulation.vue';
import DialogLancerTraitement from '@/components/Dialog/DialogLancerTraitement.vue';
import DialogSuppression from '@/components/Dialog/DialogSuppression.vue';
import RecapDemande from '@/components/RecapDemande.vue';
const emits = defineEmits(['backendError', 'backendSuccess', 'login-success'])
const props = defineProps({id : {type: String}});
const emits = defineEmits(['backendError', 'backendSuccess', 'login-success']);
const props = defineProps({ id: { type: String } });
const demande = ref();
const currentStep = ref(0);
const typeDocumentSelected = ref();
const rcrSelected = ref()
const rcrSelected = ref();
const fileSelected = ref();
const alertMessage = ref();
const alertType = ref();
const isLoading = ref(false);
const dialog = ref(false);
const suppDialog = ref(false);
onMounted(()=>{
if(props.id){
itemService.getDemande(props.id, "EXEMP")
onMounted(() => {
if (props.id) {
itemService.getDemande(props.id, 'EXEMP')
.then(response => {
demande.value = response.data;
switch (demande.value.etatDemande) {
Expand All @@ -160,11 +165,12 @@ onMounted(()=>{
};
break;
}
}).catch(() => {
router.replace("/exemplarisation");
})
})
.catch(() => {
router.replace('/exemplarisation');
});
}
})
});
function createDemande() {
if (demande.value && (rcrSelected.value === demande.value.rcr)) {
Expand All @@ -175,35 +181,39 @@ function createDemande() {
.then(response => {
demande.value = response.data;
next();
}).catch(err => {
emits('backendError',err);
}).finally(() => {
})
.catch(err => {
emits('backendError', err);
})
.finally(() => {
isLoading.value = false;
});
} else {
isLoading.value = true;
itemService.creerDemande(rcrSelected.value, 'EXEMP')
.then(response => {
demande.value = response.data;
router.replace(`/exemplarisation/${demande.value.id}`)
router.replace(`/exemplarisation/${demande.value.id}`);
next();
}).catch(err => {
emits('backendError',err);
}).finally(() => {
})
.catch(err => {
emits('backendError', err);
})
.finally(() => {
isLoading.value = false;
});
}
}
function modifiTypeExemp() {
if(demande.value.typeExemp === typeDocumentSelected.value.libelle){
if (demande.value.typeExemp === typeDocumentSelected.value.libelle) {
next();
} else {
isLoading.value = true;
itemService.modifierTypeExempDemande(demande.value.id, typeDocumentSelected.value.id)
.then(response => {
demande.value = response.data
next()
demande.value = response.data;
next();
})
.catch(err => {
emits('backendError', err);
Expand All @@ -220,7 +230,11 @@ function uploadFile() {
isLoading.value = true;
itemService.uploadDemande(demande.value.id, fileSelected.value, 'EXEMP')
.then(() => {
alertMessage.value = "Fichier envoyé";
alertMessage.value = 'Fichier envoyé';
itemService.getDemande(demande.value.id, demande.value.type)
.then(response => {
demande.value = response.data;
});
next();
})
.catch(err => {
Expand All @@ -232,23 +246,25 @@ function uploadFile() {
});
}
function launchDemande(){
function launchDemande() {
isLoading.value = true;
itemService.lancerDemande(demande.value.id,'EXEMP')
itemService.lancerDemande(demande.value.id, 'EXEMP')
.then(response => {
demande.value = response.data;
}).finally(() => {
})
.finally(() => {
isLoading.value = false;
})
});
}
function deleteDemande(){
function deleteDemande() {
suppDialog.value = true;
}
function next() {
currentStep.value++;
}
function prev() {
currentStep.value--;
changeEtat();
Expand All @@ -259,9 +275,9 @@ function changeEtat() {
itemService.choixEtape(demande.value.id, 2, 'EXEMP')
.then(response => {
demande.value = response.data;
})
});
}
if((currentStep.value + 1) === 3) { //Changement d'etat pour le chargement du fichier car le back est perdu sinon
if ((currentStep.value + 1) === 3) { //Changement d'etat pour le chargement du fichier car le back est perdu sinon
itemService.choixEtape(demande.value.id, currentStep.value + 1, 'EXEMP')
.then(response => {
demande.value = response.data;
Expand Down
Loading

0 comments on commit 9f2c943

Please sign in to comment.