Nowe pole Trasa
This commit is contained in:
@@ -5,23 +5,27 @@ import { axiosInstance } from '@/main'
|
|||||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||||
import { useContractorsStore } from '@/stores/contractors.store'
|
import { useContractorsStore } from '@/stores/contractors.store'
|
||||||
import { useCategoriesStore } from '@/stores/categories.store'
|
import { useCategoriesStore } from '@/stores/categories.store'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { useRoutesStore } from '@/stores/routes.store'
|
||||||
|
|
||||||
const ordersStore = useOrdersStore();
|
const ordersStore = useOrdersStore();
|
||||||
const siteControlStore = useSiteControlStore();
|
const siteControlStore = useSiteControlStore();
|
||||||
const contractorStore = useContractorsStore();
|
const contractorStore = useContractorsStore();
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
|
const routeStore = useRoutesStore();
|
||||||
|
|
||||||
const { contractor, contractors } = storeToRefs(contractorStore);
|
const { contractor, contractors } = storeToRefs(contractorStore);
|
||||||
const { categories } = storeToRefs(categoriesStore);
|
const { categories } = storeToRefs(categoriesStore);
|
||||||
const { uuid } = storeToRefs(ordersStore);
|
const { uuid } = storeToRefs(ordersStore);
|
||||||
const { showConfirmationModal, isLoading} = storeToRefs(siteControlStore);
|
const { showConfirmationModal, isLoading} = storeToRefs(siteControlStore);
|
||||||
|
const { route, routes } = storeToRefs(routeStore);
|
||||||
|
|
||||||
async function confirmOrder() {
|
async function confirmOrder() {
|
||||||
await axiosInstance.put('/zamowienie/' + uuid.value);
|
await axiosInstance.put('/zamowienie/' + uuid.value);
|
||||||
showConfirmationModal.value = false;
|
showConfirmationModal.value = false;
|
||||||
if (uuid.value != undefined) {
|
if (uuid.value != undefined && route.value != undefined) {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
await ordersStore.loadOrder(uuid.value, true, contractor, contractors, categories);
|
await ordersStore.loadOrder(uuid.value, true, contractor, contractors, categories, route, routes);
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ 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 { axiosInstance } from '@/main'
|
||||||
|
import { useRoutesStore } from '@/stores/routes.store'
|
||||||
|
|
||||||
const ordersStore = useOrdersStore();
|
const ordersStore = useOrdersStore();
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
const contractorsStore = useContractorsStore();
|
const contractorsStore = useContractorsStore();
|
||||||
|
const routeStore = useRoutesStore();
|
||||||
|
|
||||||
const { order, uuid} = storeToRefs(ordersStore);
|
const { order, uuid} = storeToRefs(ordersStore);
|
||||||
|
|
||||||
@@ -16,6 +18,8 @@ const { categories } = storeToRefs(categoriesStore);
|
|||||||
|
|
||||||
const { contractor } = storeToRefs(contractorsStore);
|
const { contractor } = storeToRefs(contractorsStore);
|
||||||
|
|
||||||
|
const { route } = storeToRefs(routeStore);
|
||||||
|
|
||||||
function cancelOrder(event: Event) {
|
function cancelOrder(event: Event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
axiosInstance.delete('/zamowienie/' + uuid.value);
|
axiosInstance.delete('/zamowienie/' + uuid.value);
|
||||||
@@ -63,6 +67,15 @@ function cancelOrder(event: Event) {
|
|||||||
hide-input-icon/>
|
hide-input-icon/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field mb-3" v-if="route != undefined">
|
||||||
|
<label class="label is-small">Trasa</label>
|
||||||
|
<div class="field is-small mb-3">
|
||||||
|
<input class="input is-small is-static"
|
||||||
|
type="text"
|
||||||
|
:value="route.MZT_Nazwa1"
|
||||||
|
readonly/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<button class="button is-danger" @click="cancelOrder">Anuluj zamówienie</button>
|
<button class="button is-danger" @click="cancelOrder">Anuluj zamówienie</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,34 +1,40 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import VueDatePicker from '@vuepic/vue-datepicker';
|
import VueDatePicker from '@vuepic/vue-datepicker';
|
||||||
import { axiosInstance, type Contractor, type OrderProduct } from '@/main'
|
import { axiosInstance, type Contractor, type OrderProduct, type Route } from '@/main'
|
||||||
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 { useOrdersStore } from '@/stores/orders.store'
|
import { useOrdersStore } from '@/stores/orders.store'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoutesStore } from '@/stores/routes.store'
|
||||||
|
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
const contractorsStore = useContractorsStore();
|
const contractorsStore = useContractorsStore();
|
||||||
const ordersStore = useOrdersStore();
|
const ordersStore = useOrdersStore();
|
||||||
const siteControlStore = useSiteControlStore();
|
const siteControlStore = useSiteControlStore();
|
||||||
|
const routesStore = useRoutesStore();
|
||||||
|
|
||||||
const { contractor, contractors } = storeToRefs(contractorsStore);
|
const { contractor, contractors } = storeToRefs(contractorsStore);
|
||||||
const { deliveryDate, uuid, additionalNotes } = storeToRefs(ordersStore);
|
const { deliveryDate, uuid, additionalNotes } = storeToRefs(ordersStore);
|
||||||
const { categories } = storeToRefs(categoriesStore);
|
const { categories } = storeToRefs(categoriesStore);
|
||||||
const { showConfirmationModal, showCancellationModal, isDarkTheme } = storeToRefs(siteControlStore);
|
const { showConfirmationModal, showCancellationModal, isDarkTheme } = storeToRefs(siteControlStore);
|
||||||
|
const { route, routes } = storeToRefs(routesStore);
|
||||||
|
|
||||||
const contractorSearch = ref<string>();
|
const contractorSearch = ref<string>();
|
||||||
const filteredContractors = ref<Array<Contractor>>();
|
const filteredContractors = ref<Array<Contractor>>();
|
||||||
const showContractorsDropdown = ref<boolean>(false);
|
const showContractorsDropdown = ref<boolean>(false);
|
||||||
const contractorInput = ref(null);
|
const contractorInput = ref(null);
|
||||||
|
|
||||||
|
const routeSearch = ref<string>();
|
||||||
|
const filteredRoutes = ref<Array<Route>>();
|
||||||
|
const showRoutesDropdown = ref<boolean>(false);
|
||||||
|
const routeInput = ref(null);
|
||||||
|
|
||||||
const showErrorNotification = ref<boolean>(false);
|
const showErrorNotification = ref<boolean>(false);
|
||||||
const showSuccessNotification = ref<boolean>(false);
|
const showSuccessNotification = ref<boolean>(false);
|
||||||
const errorNotificationMessage = ref<string>();
|
const errorNotificationMessage = ref<string>();
|
||||||
const successNotificationMessage = ref<string>();
|
const successNotificationMessage = ref<string>();
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
watch(contractor, (contractor) => {
|
watch(contractor, (contractor) => {
|
||||||
if(contractor == undefined) {
|
if(contractor == undefined) {
|
||||||
@@ -38,9 +44,16 @@ watch(contractor, (contractor) => {
|
|||||||
}
|
}
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
|
watch(route, (route) => {
|
||||||
|
if(route == undefined) {
|
||||||
|
routeSearch.value = '';
|
||||||
|
} else {
|
||||||
|
routeSearch.value = route.MZT_Nazwa1;
|
||||||
|
}
|
||||||
|
}, { immediate: true });
|
||||||
|
|
||||||
function createJSON(event: Event) {
|
function createJSON(event: Event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
console.log(route);
|
|
||||||
console.log(deliveryDate.value);
|
console.log(deliveryDate.value);
|
||||||
if(typeof deliveryDate.value != typeof Date) {
|
if(typeof deliveryDate.value != typeof Date) {
|
||||||
deliveryDate.value = new Date(deliveryDate.value as unknown as string);
|
deliveryDate.value = new Date(deliveryDate.value as unknown as string);
|
||||||
@@ -50,6 +63,7 @@ function createJSON(event: Event) {
|
|||||||
MZN_DataZam: new Date(Date.now()).toISOString(),
|
MZN_DataZam: new Date(Date.now()).toISOString(),
|
||||||
MZN_DataDos: deliveryDate.value != undefined ? deliveryDate.value.toISOString().split('T')[0] : null,
|
MZN_DataDos: deliveryDate.value != undefined ? deliveryDate.value.toISOString().split('T')[0] : null,
|
||||||
MZN_PodID: contractor.value?.Knt_KntId,
|
MZN_PodID: contractor.value?.Knt_KntId,
|
||||||
|
MZN_MZTID: route.value?.MZT_MZTID,
|
||||||
MZamElem: new Array<OrderProduct>
|
MZamElem: new Array<OrderProduct>
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -148,36 +162,67 @@ function toggleContractorsDropdown() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClickOutsideDropdown(event : Event) {
|
|
||||||
if(contractorInput.value != null && !contractorInput.value.contains(event.target)){
|
|
||||||
showContractorsDropdown.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectContractorFromDropdown(selectedContractor : Contractor) {
|
function selectContractorFromDropdown(selectedContractor : Contractor) {
|
||||||
console.log(selectedContractor);
|
console.log(selectedContractor);
|
||||||
contractor.value = selectedContractor;
|
contractor.value = selectedContractor;
|
||||||
showContractorsDropdown.value = false;
|
showContractorsDropdown.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterRoutes() {
|
||||||
|
if (routeSearch.value == "") {
|
||||||
|
route.value = undefined;
|
||||||
|
filteredRoutes.value = routes.value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(routes.value != undefined) {
|
||||||
|
filteredRoutes.value = routes.value.filter(
|
||||||
|
route =>
|
||||||
|
route.MZT_Nazwa1.toLowerCase().includes(routeSearch.value?.toLowerCase() as string)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleRoutesDropdown() {
|
||||||
|
if(!showRoutesDropdown.value) {
|
||||||
|
showRoutesDropdown.value = true;
|
||||||
|
if(routeSearch.value == undefined || routeSearch.value == '') {
|
||||||
|
filteredRoutes.value = routes.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectRouteFromDropdown(selectedRoute : Route) {
|
||||||
|
route.value = selectedRoute;
|
||||||
|
showRoutesDropdown.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClickOutsideDropdown(event : Event) {
|
||||||
|
if(contractorInput.value != null && !contractorInput.value.contains(event.target)){
|
||||||
|
showContractorsDropdown.value = false;
|
||||||
|
}
|
||||||
|
if(routeInput.value != null && !routeInput.value.contains(event.target)){
|
||||||
|
showRoutesDropdown.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(function (){
|
onMounted(function (){
|
||||||
document.addEventListener('click', handleClickOutsideDropdown);
|
document.addEventListener('click', handleClickOutsideDropdown);
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount( function () {
|
onBeforeUnmount( function () {
|
||||||
document.removeEventListener('click', handleClickOutsideDropdown);
|
document.removeEventListener('click', handleClickOutsideDropdown);
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<form class="box is-shadowless" @submit.prevent="createJSON">
|
<form class="box is-shadowless" @submit.prevent="createJSON">
|
||||||
<div>
|
<div>
|
||||||
<div class="box">
|
<div class="box mb-5">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<h1 class="title is-5"><b>ZAMÓWIENIE</b></h1>
|
<h1 class="title is-5"><b>ZAMÓWIENIE</b></h1>
|
||||||
<h1 class="subtitle is-5" v-if="uuid != undefined" ><b>{{ uuid }}</b></h1>
|
<h1 class="subtitle is-5" v-if="uuid != undefined" ><b>{{ uuid }}</b></h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="field mb-5">
|
<div class="field mb-3">
|
||||||
<label class="label is-small">Klient</label>
|
<label class="label is-small">Klient</label>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div ref="contractorInput" class="dropdown maxwidth"
|
<div ref="contractorInput" class="dropdown maxwidth"
|
||||||
@@ -204,7 +249,7 @@ onBeforeUnmount( function () {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field mb-3">
|
||||||
<label class="label is-small">Data dostawy</label>
|
<label class="label is-small">Data dostawy</label>
|
||||||
<div class="field is-small">
|
<div class="field is-small">
|
||||||
<VueDatePicker class ="bulma-is-small"
|
<VueDatePicker class ="bulma-is-small"
|
||||||
@@ -217,7 +262,36 @@ onBeforeUnmount( function () {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field mt-5">
|
<div class="field mb-3">
|
||||||
|
<label class="label is-small">Trasa</label>
|
||||||
|
<div class="field">
|
||||||
|
<div ref="routeInput" class="dropdown maxwidth"
|
||||||
|
v-bind:class="{'is-active': showRoutesDropdown == true}">
|
||||||
|
<div class="dropdown-trigger maxwidth" @click="toggleRoutesDropdown">
|
||||||
|
<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="routeSearch" @input="filterRoutes" />
|
||||||
|
<span class="icon is-small is-right"><i class="fas fa-search"></i></span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="dropdown-menu is-clipped has-background-info-on-scheme-invert" id="dropdown-menu" role="menu" style="max-width: calc(100vw - 3rem); box-shadow: 0px 0px 6px -1px rgba(165, 165, 165, 0.8); border-radius: 10px 10px 10px 10px; overflow-x:auto">
|
||||||
|
<div class="dropdown-content" style="max-height: 50vh; overflow-x: auto">
|
||||||
|
<a v-if="filteredRoutes != undefined && filteredRoutes.length == 0" class="dropdown-item is-clipped">Brak wyników</a>
|
||||||
|
<a class="dropdown-item is-clipped" @click = "selectRouteFromDropdown(dropdownRoute)"
|
||||||
|
v-bind:class = "{'has-background-info' : route == null}">Brak</a>
|
||||||
|
<a v-for="dropdownRoute in filteredRoutes" v-bind:key="dropdownRoute.MZT_MZTID"
|
||||||
|
class="dropdown-item is-clipped" @click = "selectRouteFromDropdown(dropdownRoute)"
|
||||||
|
v-bind:class = "{'has-background-info' : dropdownRoute == route}">
|
||||||
|
{{dropdownRoute.MZT_Nazwa1}}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
<label class="label is-small">Uwagi do zamówienia</label>
|
<label class="label is-small">Uwagi do zamówienia</label>
|
||||||
<textarea
|
<textarea
|
||||||
v-model="additionalNotes"
|
v-model="additionalNotes"
|
||||||
@@ -226,14 +300,14 @@ onBeforeUnmount( function () {
|
|||||||
rows="5"
|
rows="5"
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button class="button is-info mt-5">Zapisz</button>
|
<button class="button is-info mt-3">Zapisz</button>
|
||||||
<button class="button is-success mt-5 ml-3" @click="setConfirmationModal" v-bind:disabled="uuid == undefined">Potwierdź</button>
|
<button class="button is-success mt-3 ml-3" @click="setConfirmationModal" v-bind:disabled="uuid == undefined">Potwierdź</button>
|
||||||
<button class="button is-danger mt-5 ml-3" @click="cancelOrder" v-bind:disabled="uuid == undefined">Anuluj</button>
|
<button class="button is-danger mt-3 ml-3" @click="cancelOrder" v-bind:disabled="uuid == undefined">Anuluj</button>
|
||||||
<div v-if="showErrorNotification" class="notification is-danger is-bold mt-5">
|
<div v-if="showErrorNotification" class="notification is-danger is-bold mt-3">
|
||||||
<button class="delete" @click.prevent="showErrorNotification = false"></button>
|
<button class="delete" @click.prevent="showErrorNotification = false"></button>
|
||||||
{{ errorNotificationMessage }}
|
{{ errorNotificationMessage }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="showSuccessNotification" class="notification is-success is-bold mt-5">
|
<div v-if="showSuccessNotification" class="notification is-success is-bold mt-3">
|
||||||
<button class="delete" @click.prevent="showSuccessNotification = false"></button>
|
<button class="delete" @click.prevent="showSuccessNotification = false"></button>
|
||||||
{{ successNotificationMessage }}
|
{{ successNotificationMessage }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ export interface Order {
|
|||||||
MZN_TypDokumentu: number,
|
MZN_TypDokumentu: number,
|
||||||
MZN_UUID: string,
|
MZN_UUID: string,
|
||||||
MZN_Uwagi: string,
|
MZN_Uwagi: string,
|
||||||
|
MZN_MZTID: number,
|
||||||
MZamElem: Array<OrderProduct>
|
MZamElem: Array<OrderProduct>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,3 +165,8 @@ export interface OrderProduct {
|
|||||||
MZE_TwrStawka: string | undefined,
|
MZE_TwrStawka: string | undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Route {
|
||||||
|
MZT_MZTID: number,
|
||||||
|
MZT_Nazwa1: string
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import type { Category, Contractor, Order } from '@/main'
|
import type { Category, Contractor, Order, Route } from '@/main'
|
||||||
import { type Ref, ref } from 'vue'
|
import { type Ref, ref } from 'vue'
|
||||||
import { axiosInstance } from '@/main'
|
import { axiosInstance } from '@/main'
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ export const useOrdersStore = defineStore('orders', () => {
|
|||||||
return datesTemp;
|
return datesTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadOrder(uuidString: string, confirmed: boolean, contractor: Ref<Contractor|undefined>, contractors: Ref<Array<Contractor>>, categories: Ref<Array<Category>>) {
|
async function loadOrder(uuidString: string, confirmed: boolean, contractor: Ref<Contractor|undefined>, contractors: Ref<Array<Contractor>>, categories: Ref<Array<Category>>, route: Ref<Route|undefined>, routes: Ref<Array<Route>|undefined>) {
|
||||||
const response = await axiosInstance.get('/zamowienie/' + uuidString);
|
const response = await axiosInstance.get('/zamowienie/' + uuidString);
|
||||||
const tempOrder = response.data;
|
const tempOrder = response.data;
|
||||||
console.log(tempOrder);
|
console.log(tempOrder);
|
||||||
@@ -80,6 +80,7 @@ export const useOrdersStore = defineStore('orders', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contractor.value = <Contractor>contractors.value?.find((contractor) => contractor.Knt_KntId == tempOrder.MZN_PodID);
|
contractor.value = <Contractor>contractors.value?.find((contractor) => contractor.Knt_KntId == tempOrder.MZN_PodID);
|
||||||
|
route.value = <Route>routes.value?.find((route) => route.MZT_MZTID == tempOrder.MZN_MZTID);
|
||||||
deliveryDate.value = new Date(tempOrder.MZN_DataDos);
|
deliveryDate.value = new Date(tempOrder.MZN_DataDos);
|
||||||
orderDate.value = new Date(tempOrder.MZN_DataZam);
|
orderDate.value = new Date(tempOrder.MZN_DataZam);
|
||||||
uuid.value = uuidString;
|
uuid.value = uuidString;
|
||||||
|
|||||||
17
src/stores/routes.store.ts
Normal file
17
src/stores/routes.store.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import type { Route } from '@/main'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { axiosInstance } from '@/main'
|
||||||
|
|
||||||
|
export const useRoutesStore = defineStore('routes', () => {
|
||||||
|
const routes = ref<Array<Route>>();
|
||||||
|
const route = ref<Route>();
|
||||||
|
|
||||||
|
async function fetchRoutes() {
|
||||||
|
const response = await axiosInstance.get('/trasy', {withCredentials: true});
|
||||||
|
routes.value = [];
|
||||||
|
routes.value.push(...response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {routes, route, fetchRoutes};
|
||||||
|
});
|
||||||
@@ -5,6 +5,7 @@ import type { Order } from '@/main'
|
|||||||
import { useContractorsStore } from '@/stores/contractors.store'
|
import { useContractorsStore } from '@/stores/contractors.store'
|
||||||
import { useCategoriesStore } from '@/stores/categories.store'
|
import { useCategoriesStore } from '@/stores/categories.store'
|
||||||
import { router } from '@/router/router'
|
import { router } from '@/router/router'
|
||||||
|
import { useRoutesStore } from '@/stores/routes.store'
|
||||||
|
|
||||||
export const useSiteControlStore = defineStore('siteControl', () => {
|
export const useSiteControlStore = defineStore('siteControl', () => {
|
||||||
const shownComponent = ref<string>("mainForm");
|
const shownComponent = ref<string>("mainForm");
|
||||||
@@ -46,12 +47,14 @@ export const useSiteControlStore = defineStore('siteControl', () => {
|
|||||||
const orderStore = useOrdersStore();
|
const orderStore = useOrdersStore();
|
||||||
const contractorsStore = useContractorsStore();
|
const contractorsStore = useContractorsStore();
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
|
const routeStore = useRoutesStore();
|
||||||
shownComponent.value = "mainForm";
|
shownComponent.value = "mainForm";
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
await categoriesStore.fetchCategories();
|
await categoriesStore.fetchCategories();
|
||||||
const { contractor, contractors } = storeToRefs(contractorsStore);
|
const { contractor, contractors } = storeToRefs(contractorsStore);
|
||||||
const { categories } = storeToRefs(categoriesStore);
|
const { categories } = storeToRefs(categoriesStore);
|
||||||
await orderStore.loadOrder(uuid, false, contractor, contractors, categories);
|
const { route, routes } = storeToRefs( routeStore );
|
||||||
|
await orderStore.loadOrder(uuid, false, contractor, contractors, categories, route, routes);
|
||||||
isLoading.value=false;
|
isLoading.value=false;
|
||||||
await router.push("/");
|
await router.push("/");
|
||||||
}
|
}
|
||||||
@@ -60,13 +63,16 @@ export const useSiteControlStore = defineStore('siteControl', () => {
|
|||||||
const ordersStore = useOrdersStore();
|
const ordersStore = useOrdersStore();
|
||||||
const contractorsStore = useContractorsStore();
|
const contractorsStore = useContractorsStore();
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
|
const routeStore = useRoutesStore();
|
||||||
const { order, uuid, deliveryDate, orderDate } = storeToRefs(ordersStore);
|
const { order, uuid, deliveryDate, orderDate } = storeToRefs(ordersStore);
|
||||||
const { contractor } = storeToRefs(contractorsStore);
|
const { contractor } = storeToRefs(contractorsStore);
|
||||||
|
const { route } = storeToRefs(routeStore);
|
||||||
contractor.value = undefined;
|
contractor.value = undefined;
|
||||||
order.value = undefined;
|
order.value = undefined;
|
||||||
uuid.value = undefined;
|
uuid.value = undefined;
|
||||||
deliveryDate.value = undefined;
|
deliveryDate.value = undefined;
|
||||||
orderDate.value = undefined;
|
orderDate.value = undefined;
|
||||||
|
route.value = undefined;
|
||||||
await categoriesStore.fetchCategories();
|
await categoriesStore.fetchCategories();
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
await router.push("/");
|
await router.push("/");
|
||||||
|
|||||||
@@ -23,12 +23,14 @@ import { useCategoriesStore } from '@/stores/categories.store'
|
|||||||
import { useOrdersStore } from '@/stores/orders.store'
|
import { useOrdersStore } from '@/stores/orders.store'
|
||||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||||
import { useUserStore } from '@/stores/user.store'
|
import { useUserStore } from '@/stores/user.store'
|
||||||
|
import { useRoutesStore } from '@/stores/routes.store'
|
||||||
|
|
||||||
const contractorsStore = useContractorsStore();
|
const contractorsStore = useContractorsStore();
|
||||||
const categoriesStore = useCategoriesStore();
|
const categoriesStore = useCategoriesStore();
|
||||||
const ordersStore = useOrdersStore();
|
const ordersStore = useOrdersStore();
|
||||||
const siteControlStore = useSiteControlStore();
|
const siteControlStore = useSiteControlStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const routesStore = useRoutesStore();
|
||||||
const contractors = storeToRefs(contractorsStore).contractors;
|
const contractors = storeToRefs(contractorsStore).contractors;
|
||||||
const contractor = storeToRefs(contractorsStore).contractor;
|
const contractor = storeToRefs(contractorsStore).contractor;
|
||||||
const categories = storeToRefs(categoriesStore).categories;
|
const categories = storeToRefs(categoriesStore).categories;
|
||||||
@@ -40,6 +42,7 @@ const { showConfirmationModal, showCancellationModal, isLoading, shownComponent
|
|||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
//await categoriesStore.fetchCategories();
|
//await categoriesStore.fetchCategories();
|
||||||
await contractorsStore.fetchContractors();
|
await contractorsStore.fetchContractors();
|
||||||
|
await routesStore.fetchRoutes();
|
||||||
//siteControlStore.newOrder(false);
|
//siteControlStore.newOrder(false);
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user