From 4edb01f331da8c1c8ee9b6888704def418cc1684 Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Tue, 16 Jul 2024 11:50:57 +0200 Subject: [PATCH] Ajout RCR --- src/views/Suppression/SuppSteps.vue | 57 ++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/src/views/Suppression/SuppSteps.vue b/src/views/Suppression/SuppSteps.vue index 3530ff5..6723db8 100644 --- a/src/views/Suppression/SuppSteps.vue +++ b/src/views/Suppression/SuppSteps.vue @@ -44,16 +44,16 @@ - - - - - - - - - - + + + + + Valider + + @@ -107,19 +107,42 @@ const demande = ref(); const emits = defineEmits(['backendError']); const props = defineProps({id: {type: String}}); +const rcrSelected = ref(); const typeFileSelected = ref(); const fileSelected = ref(); const isLoading = ref(false); const alertMessage = ref(''); const alertType = ref('success'); -onMounted(() => { - demandesService.creerDemande('341725201', 'SUPP') - .then(response => { - demande.value = response.data; - next(); - }) -}) + +function createDemande() { + if (demande.value && (rcrSelected.value === demande.value.rcr)) { + next(); + } else if (demande.value) { + isLoading.value = true; + demandesService.modifierRcrDemande(demande.value.id, rcrSelected.value, 'SUPP') + .then(response => { + demande.value = response.data; + next(); + }).catch(err => { + emits('backendError', err); + }).finally(() => { + isLoading.value = false; + }); + } else { + isLoading.value = true; + demandesService.creerDemande(rcrSelected.value, 'SUPP') + .then(response => { + demande.value = response.data; + next(); + }).catch(err => { + emits('backendError', err); + }).finally(() => { + isLoading.value = false; + }); + } +} + function uploadFile() { alertMessage.value = ''; alertType.value = 'success';