Summed table of products, small improvements

This commit is contained in:
2024-07-16 17:12:52 +02:00
parent bbec759b08
commit ff3b22fb1b
5 changed files with 176 additions and 55 deletions

View File

@@ -25,7 +25,9 @@ const showContractorsDropdown = ref<boolean>(false);
const contractorInput = ref(null);
const showErrorNotification = ref<boolean>(false);
const showSuccessNotification = ref<boolean>(false);
const errorNotificationMessage = ref<string>();
const successNotificationMessage = ref<string>();
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<OrderProduct>
};
@@ -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 () {
<div ref="contractorInput" class="dropdown maxwidth"
v-bind:class="{'is-active': showContractorsDropdown == true}">
<div class="dropdown-trigger maxwidth" @click="toggleContractorsDropdown">
<div class="field maxwidth" @onclick.prevent="toggleContractorsDropdown">
<p class="control is-expanded has-icons-right is-small maxwidth" @onclick.prevent="toggleContractorsDropdown">
<div class="field maxwidth">
<p class="control is-expanded has-icons-right is-small maxwidth">
<input class="input is-small is-expanded maxwidth" type="search"
v-model="contractorSearch" @input="filterContractors" />
<span class="icon is-small is-right"><i class="fas fa-search"></i></span>
@@ -205,13 +211,25 @@ onBeforeUnmount( function () {
v-bind:dark = "isDarkTheme"/>
</div>
</div>
<div class="field mt-5">
<label class="label is-small">Uwagi do zamówienia</label>
<textarea
class="textarea"
placeholder="Jeszcze nie połączone z bazą danych"
rows="5"
></textarea>
</div>
<button class="button is-info mt-5">Zapisz</button>
<button class="button is-success mt-5 ml-3" @click="setConfirmationModal">Potwierdź</button>
<button class="button is-danger mt-5 ml-3" @click="cancelOrder" v-bind:disabled="uuid == undefined">Anuluj</button>
<div v-if="showErrorNotification==true" class="notification is-danger is-bold mt-5">
<div v-if="showErrorNotification" class="notification is-danger is-bold mt-5">
<button class="delete" @click.prevent="showErrorNotification = false"></button>
{{ errorNotificationMessage }}
</div>
<div v-if="showSuccessNotification" class="notification is-success is-bold mt-5">
<button class="delete" @click.prevent="showSuccessNotification = false"></button>
{{ successNotificationMessage }}
</div>
</div>
</div>
<div v-for="category in categories" :key="category.Kod">