upgraded cancelation process
This commit is contained in:
		| @@ -14,13 +14,17 @@ const categoriesStore = useCategoriesStore(); | |||||||
|  |  | ||||||
| const { uuid } = storeToRefs(ordersStore); | const { uuid } = storeToRefs(ordersStore); | ||||||
| const { showCancellationModal, isLoading } = storeToRefs(siteControlStore); | const { showCancellationModal, isLoading } = storeToRefs(siteControlStore); | ||||||
| const cancellationReason = ref<string>(); | const cancellationReason = ref<string>(""); | ||||||
|  |  | ||||||
| async function cancelOrder() { | async function cancelOrder() { | ||||||
|   showCancellationModal.value = false; |   showCancellationModal.value = false; | ||||||
|   // console.log(cancellationReason.value); |   // console.log(cancellationReason.value); | ||||||
|   axiosInstance.delete('/zamowienie/' + uuid.value); |   axiosInstance.delete('/zamowienie/' + uuid.value, { | ||||||
|   siteControlStore.newOrder(true); |     data: { | ||||||
|  |       MZN_AnulowanePowod: cancellationReason.value | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  |   siteControlStore.newOrder("/orders"); | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| @@ -35,17 +39,15 @@ async function cancelOrder() { | |||||||
|         </header> |         </header> | ||||||
|         <section class="modal-card-body"> |         <section class="modal-card-body"> | ||||||
|           <div>Czy napewno chcesz anulować zamówienie? Czynności tej nie można odwrócić.</div> |           <div>Czy napewno chcesz anulować zamówienie? Czynności tej nie można odwrócić.</div> | ||||||
| <!--          <div class="pb-2">Podaj powód anulowania zamówienia: </div>--> |           <p class="control is-expanded" style="margin-top: 20px"> | ||||||
| <!--          <textarea--> |             <input class="input is-small" type="text" v-model="cancellationReason"  placeholder="Powód anulowania" > | ||||||
| <!--            class="textarea"--> |           </p> | ||||||
| <!--            rows="3"--> |  | ||||||
| <!--            v-model="cancellationReason"--> |  | ||||||
| <!--          ></textarea>--> |  | ||||||
|         </section> |         </section> | ||||||
|         <footer class="modal-card-foot"> |         <footer class="modal-card-foot"> | ||||||
|  |  | ||||||
|           <div class="buttons"> |           <div class="buttons"> | ||||||
| <!--            <button class="button is-success" @click="cancelOrder" v-bind:disabled="cancellationReason == undefined || cancellationReason == ''">Tak</button>--> | <!--            <button class="button is-success" @click="cancelOrder" v-bind:disabled="cancellationReason == undefined || cancellationReason == ''">Tak</button>--> | ||||||
|             <button class="button is-success" @click="cancelOrder">Tak</button> |             <button class="button is-success" :disabled="cancellationReason.length<3" @click="cancelOrder">Tak</button> | ||||||
|             <button class="button" @click="$emit('close')">Nie</button> |             <button class="button" @click="$emit('close')">Nie</button> | ||||||
|           </div> |           </div> | ||||||
|         </footer> |         </footer> | ||||||
|   | |||||||
| @@ -4,7 +4,6 @@ import { useOrdersStore } from '@/stores/orders.store' | |||||||
| import { storeToRefs } from 'pinia' | import { storeToRefs } from 'pinia' | ||||||
| import { useCategoriesStore } from '@/stores/categories.store' | import { useCategoriesStore } from '@/stores/categories.store' | ||||||
| import { useContractorsStore } from '@/stores/contractors.store' | import { useContractorsStore } from '@/stores/contractors.store' | ||||||
| import { axiosInstance } from '@/main' |  | ||||||
| import { useRoutesStore } from '@/stores/routes.store' | import { useRoutesStore } from '@/stores/routes.store' | ||||||
| import { useSiteControlStore } from '@/stores/siteControl.store' | import { useSiteControlStore } from '@/stores/siteControl.store' | ||||||
|  |  | ||||||
| @@ -32,19 +31,19 @@ function cancelOrder(event: Event) { | |||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <template> | <template> | ||||||
|   <form class="box is-shadowless"> |   <form class="box  is-shadowless"> | ||||||
|     <div class="mb-3"> |     <div class="mb-3  "> | ||||||
|       <div class="box"> |       <div class="box" :class="{'cancelled' : order.MZN_Anulowane == 1}"> | ||||||
|         <div class="mb-3"> |         <div class="mb-3"> | ||||||
|           <h1 class="title is-5" v-if="order != undefined"><b>ZAMÓWIENIE NR {{order.MZN_MZNID}}</b></h1> |           <h1 class="title is-5" v-if="order != undefined"><b>ZAMÓWIENIE NR {{ order.MZN_MZNID }}</b><b | ||||||
|  |             v-if="order.MZN_Anulowane == 1">, ZAMÓWIENIE ANULOWANE</b></h1> | ||||||
|         </div> |         </div> | ||||||
|         <div class="field mb-3" v-if="contractor != undefined"> |         <div class="field mb-3" v-if="contractor != undefined"> | ||||||
|           <label class="label is-small">Klient</label> |           <label class="label is-small">Klient</label> | ||||||
|           <div class="field is-small mb-3"> |           <div class="field is-small mb-3"> | ||||||
|             <input class="input is-small is-static" |             <p class="mb-3 is-size-7"> | ||||||
|                    type="text" |               {{ contractor.Knt_Nazwa1 + contractor.Knt_Nazwa2 + contractor.Knt_Nazwa3 }} | ||||||
|                    :value="contractor.Knt_Nazwa1 + contractor.Knt_Nazwa2 + contractor.Knt_Nazwa3" |             </p> | ||||||
|                    readonly/> |  | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|         <div class="field mb-3" v-if="order != undefined"> |         <div class="field mb-3" v-if="order != undefined"> | ||||||
| @@ -63,7 +62,7 @@ function cancelOrder(event: Event) { | |||||||
|         <div class="field mb-3" v-if="order != undefined"> |         <div class="field mb-3" v-if="order != undefined"> | ||||||
|           <label class="label is-small">Data zamówienia</label> |           <label class="label is-small">Data zamówienia</label> | ||||||
|           <div class="field is-small"> |           <div class="field is-small"> | ||||||
|             <VueDatePicker |            <VueDatePicker | ||||||
|               v-model="order.MZN_DataZam" |               v-model="order.MZN_DataZam" | ||||||
|               :enable-time-picker="false" |               :enable-time-picker="false" | ||||||
|               :clearable="true" |               :clearable="true" | ||||||
| @@ -76,23 +75,22 @@ function cancelOrder(event: Event) { | |||||||
|         <div class="field mb-3" v-if="route != undefined"> |         <div class="field mb-3" v-if="route != undefined"> | ||||||
|           <label class="label is-small">Trasa</label> |           <label class="label is-small">Trasa</label> | ||||||
|           <div class="field is-small mb-3"> |           <div class="field is-small mb-3"> | ||||||
|             <input class="input is-small is-static" |             <p class="mb-3 is-size-7"> | ||||||
|                    type="text" |               {{route.MZT_Nazwa1}} | ||||||
|                    :value="route.MZT_Nazwa1" |             </p> | ||||||
|                    readonly/> |  | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|         <div class="field mb-3" v-if="order != undefined && order.MZN_Uwagi != undefined"> |         <div class="field mb-3" v-if="order != undefined && order.MZN_Uwagi != undefined"> | ||||||
|           <label class="label is-small">Uwagi do zamówienia</label> |           <label class="label is-small">Uwagi do zamówienia</label> | ||||||
|           <p  class="mb-3"> |           <p  class="mb-3 is-size-7"> | ||||||
|             {{ order.MZN_Uwagi }} |             {{ order.MZN_Uwagi }} | ||||||
|           </p> |           </p> | ||||||
|         </div> |         </div> | ||||||
|         <button class="button is-danger" @click="cancelOrder">Anuluj zamówienie</button> |         <button v-if="order.MZN_Anulowane==0" class="button is-danger" @click="cancelOrder">Anuluj zamówienie</button> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|     <div v-for="category in categories" :key="category.Kod"> |     <div v-for="category in categories" :key="category.Kod"> | ||||||
|       <div class="box mb-3" v-if="category.isVisible"> |       <div class="box mb-3 " :class="{'cancelled' : order.MZN_Anulowane == 1}" v-if="category.isVisible"> | ||||||
|         <h1 class="title mb-3 is-6"><b>{{ category.Kod }}</b></h1> |         <h1 class="title mb-3 is-6"><b>{{ category.Kod }}</b></h1> | ||||||
|         <div class="field" v-for="(product) in category.Towary" :key="product.Twr_Nazwa"> |         <div class="field" v-for="(product) in category.Towary" :key="product.Twr_Nazwa"> | ||||||
|           <div v-if="Number(product.Quantity) > 0" class="mb-3"> |           <div v-if="Number(product.Quantity) > 0" class="mb-3"> | ||||||
| @@ -100,53 +98,38 @@ function cancelOrder(event: Event) { | |||||||
|             <div class="columns is-mobile"> |             <div class="columns is-mobile"> | ||||||
|               <div class="column"> |               <div class="column"> | ||||||
|                 <div class="field"> |                 <div class="field"> | ||||||
|                   <p class="control is-expanded"> |                   <p class="control is-expanded is-size-7"> | ||||||
|                     <input class="input is-small is-static" type="text" placeholder="Ilość" :value="product.Quantity + ' ' + product.ChosenOption" readonly> |                     {{ product.Quantity + ' ' + product.ChosenOption }} | ||||||
|                   </p> |                   </p> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|               <div class="column" v-if="product.ChosenOption == product.Twr_JM"> |               <div class="column" v-if="product.ChosenOption == product.Twr_JM"> | ||||||
|                 <div class="field"> |                 <div class="field"> | ||||||
|                   <input |                   <p class="mb-3 is-size-7"> | ||||||
|                     class="input is-small is-static" |                     {{ product.Twr_Cena }} PLN | ||||||
|                     type="text" |                   </p> | ||||||
|                     placeholder="Kwota" |  | ||||||
|                     :value="product.Twr_Cena + ' PLN'" |  | ||||||
|                     readonly |  | ||||||
|                   /> |  | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|               <div class="column" v-else-if="product.ChosenOption == product.Twr_JMZ"> |               <div class="column" v-else-if="product.ChosenOption == product.Twr_JMZ"> | ||||||
|                 <div class="field"> |                 <div class="field"> | ||||||
|                   <input |                   <p class="mb-3 is-size-7"> | ||||||
|                     class="input is-small is-static" |                     {{ product.Twr_CenaZ }} PLN | ||||||
|                     type="text" |                   </p> | ||||||
|                     placeholder="Kwota" |  | ||||||
|                     :value="product.Twr_CenaZ + ' PLN'" |  | ||||||
|                     readonly |  | ||||||
|                   /> |  | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|               <div class="column" v-if="product.ChosenOption == product.Twr_JM"> |               <div class="column" v-if="product.ChosenOption == product.Twr_JM"> | ||||||
|                 <div class="field"> |                 <div class="field"> | ||||||
|                   <input |                   <p class="mb-3 is-size-7"> | ||||||
|                     class="input is-small is-static" |                     {{ (Number(product.Twr_Cena) * Number(product.Quantity)).toFixed(2) }} PLN | ||||||
|                     type="text" |                   </p> | ||||||
|                     placeholder="Kwota" |  | ||||||
|                     :value="(Number(product.Twr_Cena) * Number(product.Quantity)).toFixed(2) + ' PLN'" |  | ||||||
|                     readonly |  | ||||||
|                   /> |  | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|               <div class="column" v-else-if="product.ChosenOption == product.Twr_JMZ"> |               <div class="column" v-else-if="product.ChosenOption == product.Twr_JMZ"> | ||||||
|                 <div class="field"> |                 <div class="field"> | ||||||
|                   <input |                   <p class="mb-3 is-size-7"> | ||||||
|                     class="input is-small is-static" |                     {{ (Number(product.Twr_CenaZ) * Number(product.Quantity)).toFixed(2) }} PLN | ||||||
|                     type="text" |                   </p> | ||||||
|                     placeholder="Kwota" |  | ||||||
|                     :value="(Number(product.Twr_CenaZ) * Number(product.Quantity)).toFixed(2) + ' PLN'" |  | ||||||
|                     readonly |  | ||||||
|                   /> |  | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|             </div> |             </div> | ||||||
| @@ -157,3 +140,8 @@ function cancelOrder(event: Event) { | |||||||
|     </div> |     </div> | ||||||
|   </form> |   </form> | ||||||
| </template> | </template> | ||||||
|  | <style> | ||||||
|  | .cancelled { | ||||||
|  |   --bulma-box-background-color: var(--bulma-danger-soft) | ||||||
|  | } | ||||||
|  | </style> | ||||||
| @@ -80,7 +80,7 @@ function routeLogin() { | |||||||
|       <div class="navbar-end"> |       <div class="navbar-end"> | ||||||
|         <div class="navbar-item"> |         <div class="navbar-item"> | ||||||
|           <div class="buttons"> |           <div class="buttons"> | ||||||
|             <button class="button is-info" @click="siteControlStore.newOrder"> |             <button class="button is-info" @click="() => siteControlStore.newOrder('/')"> | ||||||
|               Nowe Zamówienie |               Nowe Zamówienie | ||||||
|             </button> |             </button> | ||||||
|             <button class="button is-info" @click="routeLogin" > |             <button class="button is-info" @click="routeLogin" > | ||||||
|   | |||||||
| @@ -166,7 +166,7 @@ onMounted(async () => { | |||||||
|  |  | ||||||
| onBeforeUnmount(async function() { | onBeforeUnmount(async function() { | ||||||
|     const siteControlStore = useSiteControlStore(); |     const siteControlStore = useSiteControlStore(); | ||||||
|     await siteControlStore.newOrder(false); |     await siteControlStore.newOrder(null); | ||||||
| }) | }) | ||||||
|  |  | ||||||
| function documnetType(order : Order):string { | function documnetType(order : Order):string { | ||||||
|   | |||||||
| @@ -49,7 +49,8 @@ export const useCategoriesStore = defineStore('categories', () => { | |||||||
|             mapProduct.SummedPrice += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)); |             mapProduct.SummedPrice += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)); | ||||||
|           } |           } | ||||||
|           else if (product.MZE_TwrJm == mapProduct?.Twr_JMZ) { |           else if (product.MZE_TwrJm == mapProduct?.Twr_JMZ) { | ||||||
|             mapProduct.SummedQuantity += (Number(product.MZE_TwrIlosc) * Number(mapProduct.Twr_JMPrzelicznikM))/Number(mapProduct.Twr_JMPrzelicznikL); |             mapProduct.SummedQuantity += (Number(product.MZE_TwrIlosc) * Number(mapProduct.Twr_JMPrzelicznikL)/Number(mapProduct.Twr_JMPrzelicznikM)); | ||||||
|  |  | ||||||
|             mapProduct.SummedPrice += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)); |             mapProduct.SummedPrice += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)); | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -50,7 +50,7 @@ export const useSiteControlStore = defineStore('siteControl', () => { | |||||||
|     window.scrollTo(0,0); |     window.scrollTo(0,0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   async function newOrder(redirect : boolean) { |   async function newOrder(redirect : string) { | ||||||
|     const { order, uuid, deliveryDate, orderDate, additionalNotes } = storeToRefs(orderStore); |     const { order, uuid, deliveryDate, orderDate, additionalNotes } = storeToRefs(orderStore); | ||||||
|     const { contractor } = storeToRefs(contractorsStore); |     const { contractor } = storeToRefs(contractorsStore); | ||||||
|     const { route } = storeToRefs(routeStore); |     const { route } = storeToRefs(routeStore); | ||||||
| @@ -64,7 +64,7 @@ export const useSiteControlStore = defineStore('siteControl', () => { | |||||||
|     await categoriesStore.fetchCategories(); |     await categoriesStore.fetchCategories(); | ||||||
|     if (redirect) |     if (redirect) | ||||||
|     { |     { | ||||||
|       await router.push("/"); |       await router.push(redirect); | ||||||
|       window.scrollTo(0,0); |       window.scrollTo(0,0); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ async function onSubmit(values : any, { setErrors } : any) { | |||||||
|     const siteControlStore = useSiteControlStore(); |     const siteControlStore = useSiteControlStore(); | ||||||
|     const { username } = storeToRefs(userStore); |     const { username } = storeToRefs(userStore); | ||||||
|     username.value = body.data.displayName; |     username.value = body.data.displayName; | ||||||
|     await siteControlStore.newOrder(true); |     await siteControlStore.newOrder("/"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user