From ff3b22fb1b14bb96da5edd447513349c4c68d5d2 Mon Sep 17 00:00:00 2001 From: patrykb Date: Tue, 16 Jul 2024 17:12:52 +0200 Subject: [PATCH] Summed table of products, small improvements --- src/components/MainForm.vue | 28 +++++-- src/main.ts | 8 +- src/stores/categories.store.ts | 41 ++++++++- src/views/MainView.vue | 6 +- src/views/SummedOrdersView.vue | 148 +++++++++++++++++++++++---------- 5 files changed, 176 insertions(+), 55 deletions(-) diff --git a/src/components/MainForm.vue b/src/components/MainForm.vue index 8b3d646..a14e06d 100644 --- a/src/components/MainForm.vue +++ b/src/components/MainForm.vue @@ -25,7 +25,9 @@ const showContractorsDropdown = ref(false); const contractorInput = ref(null); const showErrorNotification = ref(false); +const showSuccessNotification = ref(false); const errorNotificationMessage = ref(); +const successNotificationMessage = ref(); const route = useRoute(); watch(contractor, (contractor) => { @@ -41,8 +43,8 @@ function createJSON(event: Event) { console.log(route); const json = { MZN_UUID: uuid.value, - MZN_DataZam: new Date(Date.now()).toISOString().split('T')[0], - MZN_DataDos: deliveryDate.value != undefined ? deliveryDate.value.toISOString() : null, + MZN_DataZam: new Date(Date.now()).toISOString(), + MZN_DataDos: deliveryDate.value != undefined ? deliveryDate.value.toISOString().split('T')[0] : null, MZN_PodID: contractor.value?.Knt_KntId, MZamElem: new Array }; @@ -73,6 +75,8 @@ function createJSON(event: Event) { errorNotificationMessage.value = "W zamówieniu znajdują się niepoprawne wartości."; return; } + product.Twr_Cena = product.Twr_Cena == "" || product.Twr_Cena == null ? product.BasePrice : product.Twr_Cena; + product.Twr_CenaZ = product.Twr_CenaZ == "" || product.Twr_CenaZ == null ? product.BasePriceZ : product.Twr_CenaZ; const productObject : OrderProduct = { MZE_TwrId: product.Twr_TwrId, MZE_TwrJm: product.ChosenOption, @@ -97,6 +101,8 @@ function createJSON(event: Event) { console.log(JSON.stringify(json)); axiosInstance.post('/zamowienie', JSON.stringify(json)).then( response => { uuid.value = response.data.MZN_UUID; + showSuccessNotification.value = true; + successNotificationMessage.value = "Zamówienie zostało zapisane do bazy danych." }); } @@ -172,8 +178,8 @@ onBeforeUnmount( function () {