Poprawki błędów
This commit is contained in:
@@ -5,6 +5,7 @@ import { axiosInstance } from '@/main'
|
||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||
import { useContractorsStore } from '@/stores/contractors.store'
|
||||
import { useCategoriesStore } from '@/stores/categories.store'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const ordersStore = useOrdersStore();
|
||||
const siteControlStore = useSiteControlStore();
|
||||
@@ -13,9 +14,11 @@ const categoriesStore = useCategoriesStore();
|
||||
|
||||
const { uuid } = storeToRefs(ordersStore);
|
||||
const { showCancellationModal, isLoading } = storeToRefs(siteControlStore);
|
||||
const cancellationReason = ref<string>();
|
||||
|
||||
async function cancelOrder() {
|
||||
showCancellationModal.value = false;
|
||||
// console.log(cancellationReason.value);
|
||||
axiosInstance.delete('/zamowienie/' + uuid.value);
|
||||
siteControlStore.newOrder(true);
|
||||
}
|
||||
@@ -31,10 +34,17 @@ async function cancelOrder() {
|
||||
<button class="delete" aria-label="close" @click="$emit('close')"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
Czy napewno chcesz anulować zamówienie? Czynności tej nie można odwrócić.
|
||||
<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>-->
|
||||
<!-- <textarea-->
|
||||
<!-- class="textarea"-->
|
||||
<!-- rows="3"-->
|
||||
<!-- v-model="cancellationReason"-->
|
||||
<!-- ></textarea>-->
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
<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">Tak</button>
|
||||
<button class="button" @click="$emit('close')">Nie</button>
|
||||
</div>
|
||||
|
||||
@@ -6,11 +6,13 @@ import { useCategoriesStore } from '@/stores/categories.store'
|
||||
import { useContractorsStore } from '@/stores/contractors.store'
|
||||
import { axiosInstance } from '@/main'
|
||||
import { useRoutesStore } from '@/stores/routes.store'
|
||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||
|
||||
const ordersStore = useOrdersStore();
|
||||
const categoriesStore = useCategoriesStore();
|
||||
const contractorsStore = useContractorsStore();
|
||||
const routeStore = useRoutesStore();
|
||||
const siteControlStore = useSiteControlStore();
|
||||
|
||||
const { order, uuid} = storeToRefs(ordersStore);
|
||||
|
||||
@@ -20,9 +22,12 @@ const { contractor } = storeToRefs(contractorsStore);
|
||||
|
||||
const { route } = storeToRefs(routeStore);
|
||||
|
||||
const { showCancellationModal } = storeToRefs(siteControlStore);
|
||||
|
||||
function cancelOrder(event: Event) {
|
||||
event.preventDefault();
|
||||
axiosInstance.delete('/zamowienie/' + uuid.value);
|
||||
// axiosInstance.delete('/zamowienie/' + uuid.value);
|
||||
showCancellationModal.value = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -77,14 +82,11 @@ function cancelOrder(event: Event) {
|
||||
readonly/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mb-3" v-if="order != undefined">
|
||||
<div class="field mb-3" v-if="order != undefined && order.MZN_Uwagi != undefined">
|
||||
<label class="label is-small">Uwagi do zamówienia</label>
|
||||
<p v-if="order.MZN_Uwagi != undefined" class="mb-3">
|
||||
<p class="mb-3">
|
||||
{{ order.MZN_Uwagi }}
|
||||
</p>
|
||||
<p v-else class="mb-3">
|
||||
Brak uwag.
|
||||
</p>
|
||||
</div>
|
||||
<button class="button is-danger" @click="cancelOrder">Anuluj zamówienie</button>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import VueDatePicker from '@vuepic/vue-datepicker';
|
||||
import { axiosInstance, type Contractor, type OrderProduct, type Route } from '@/main'
|
||||
import { axiosInstance, type Contractor, type OrderProduct, type Route, type Order } from '@/main'
|
||||
import { useCategoriesStore } from '@/stores/categories.store'
|
||||
import { useContractorsStore } from '@/stores/contractors.store'
|
||||
import { useOrdersStore } from '@/stores/orders.store'
|
||||
@@ -8,7 +8,6 @@ import { storeToRefs } from 'pinia'
|
||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useRoutesStore } from '@/stores/routes.store'
|
||||
import { Order } from '@/main'
|
||||
|
||||
const categoriesStore = useCategoriesStore();
|
||||
const contractorsStore = useContractorsStore();
|
||||
@@ -321,7 +320,7 @@ onBeforeUnmount( function () {
|
||||
<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)"
|
||||
<a class="dropdown-item is-clipped" @click = "selectRouteFromDropdown(null)"
|
||||
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)"
|
||||
|
||||
@@ -4,7 +4,7 @@ import { computed, ref, watch } from 'vue'
|
||||
import { useOrdersStore } from '@/stores/orders.store'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||
import type { Order } from '@/main'
|
||||
import { addDays, type Order } from '@/main'
|
||||
|
||||
const ordersStore = useOrdersStore();
|
||||
const siteControlStore = useSiteControlStore();
|
||||
@@ -63,7 +63,7 @@ function viewOrder(order : Order) {
|
||||
siteControlStore.viewOrder(order.MZN_UUID);
|
||||
}
|
||||
|
||||
async function fetchOrders(event : Event) {
|
||||
async function fetchOrders(event : Event | null) {
|
||||
event?.preventDefault();
|
||||
areOrdersLoading.value = true;
|
||||
console.log(searchOrderDate.value);
|
||||
@@ -72,9 +72,10 @@ async function fetchOrders(event : Event) {
|
||||
orders.value = await ordersStore.fetchOrdersByBuffer(buffer.value);
|
||||
}
|
||||
if(searchOrderDate.value != undefined) {
|
||||
orders.value = await ordersStore.fetchOrdersByDateStartAndEnd(searchOrderDate.value[0], searchOrderDate.value[1], buffer.value);
|
||||
orders.value = await ordersStore.fetchOrdersByDateStartAndEnd(addDays(searchOrderDate.value[0], 1), addDays(searchOrderDate.value[1], 1), buffer.value);
|
||||
}
|
||||
areOrdersLoading.value = false;
|
||||
console.log("orders");
|
||||
console.log(orders.value);
|
||||
}
|
||||
|
||||
@@ -161,14 +162,13 @@ fetchOrders(null);
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label class="label is-small" :class="{'is-invisible': areOrdersLoading}">Uwagi</label>
|
||||
<div class="field is-small mb-3" :class="{'is-invisible': areOrdersLoading}">
|
||||
<div v-if=" order.MZN_Uwagi != null && order.MZN_Uwagi != ''">
|
||||
<label class="label is-small" :class="{'is-invisible': areOrdersLoading} ">Uwagi</label>
|
||||
<div class="field is-small mb-3" :class="{'is-invisible': areOrdersLoading}">
|
||||
<span v-if=" order.MZN_Uwagi != null && order.MZN_Uwagi != ''">
|
||||
{{ order.MZN_Uwagi }}
|
||||
</span>
|
||||
<span v-else>
|
||||
Brak
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<label class="label is-small mb-4" :class="{'is-invisible': areOrdersLoading}">Produkty</label>
|
||||
<div class="field columns is-multiline is-mobile">
|
||||
|
||||
@@ -3,20 +3,36 @@
|
||||
import { storeToRefs } from 'pinia'
|
||||
import VueDatePicker from '@vuepic/vue-datepicker'
|
||||
import { useSiteControlStore } from '@/stores/siteControl.store'
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useCategoriesStore } from '@/stores/categories.store'
|
||||
import type { Product } from '@/main'
|
||||
import type { Product, Route, Order } from '@/main'
|
||||
import { useRoutesStore } from '@/stores/routes.store'
|
||||
|
||||
const ordersStore = useOrdersStore();
|
||||
const categoriesStore = useCategoriesStore();
|
||||
const routeStore = useRoutesStore();
|
||||
|
||||
const { orders, dates } = storeToRefs(ordersStore);
|
||||
const { routes } = storeToRefs(routeStore);
|
||||
const searchDate = ref<Date>(new Date(Date.now()));
|
||||
const confirmedOrders = ref<boolean>();
|
||||
const isSummed = ref<boolean>(true);
|
||||
const isLoading = ref<boolean>(true);
|
||||
const summedProducts = ref<Array<Product>>([]);
|
||||
const products = ref<Array<Object>>();
|
||||
const ordersByRoute = ref<Map<string, Array<Order>>>();
|
||||
|
||||
const watchSearchDate = watch(searchDate, async (oldSearchDate, newSeatchDate) => {
|
||||
if(oldSearchDate != newSeatchDate) {
|
||||
await fetchOrders();
|
||||
}
|
||||
});
|
||||
|
||||
const watchConfirmedOrders = watch(confirmedOrders, async (oldConfirmedOrders, newConfirmedOrders) => {
|
||||
if (oldConfirmedOrders != newConfirmedOrders) {
|
||||
await fetchOrders();
|
||||
}
|
||||
})
|
||||
|
||||
async function fetchOrders() {
|
||||
isLoading.value=true;
|
||||
@@ -36,11 +52,17 @@
|
||||
|
||||
async function prepareProductsFromOrders() {
|
||||
products.value = [];
|
||||
if(orders.value == undefined) {
|
||||
if(orders.value == undefined || routes.value == undefined) {
|
||||
return;
|
||||
}
|
||||
ordersByRoute.value = new Map<string, Array<Order>>();
|
||||
for(const route of routes.value) {
|
||||
ordersByRoute.value.set(route.MZT_Nazwa1, []);
|
||||
}
|
||||
ordersByRoute.value.set("brak", []);
|
||||
|
||||
for(const order of orders.value) {
|
||||
order.products = [];
|
||||
for (const product of order.MZamElem) {
|
||||
const newProduct = {
|
||||
'kod': product.MZE_TwrKod,
|
||||
@@ -49,14 +71,17 @@
|
||||
'jm': product.MZE_TwrJm,
|
||||
'cena': Number(product.MZE_TwrCena).toFixed(2),
|
||||
'suma': Number(Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)).toFixed(2),
|
||||
'order': {
|
||||
'uuid': order.MZN_UUID,
|
||||
'nazwaklienta': order.MZN_PodNazwa1 + order.MZN_PodNazwa2 + order.MZN_PodNazwa3
|
||||
}
|
||||
}
|
||||
products.value.push(newProduct);
|
||||
order.products.push(newProduct);
|
||||
}
|
||||
const routeName = routes.value.find( route => {
|
||||
return route.MZT_MZTID == order.MZN_MZTID
|
||||
})?.MZT_Nazwa1;
|
||||
|
||||
ordersByRoute.value.get(routeName != undefined ? routeName : "brak")?.push(order);
|
||||
}
|
||||
console.log(orders.value);
|
||||
console.log(ordersByRoute.value);
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -100,8 +125,6 @@
|
||||
Tylko potwierdzone zamówienia?
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button class="button mt-3" @click="fetchOrders">Potwierdź</button>
|
||||
</div>
|
||||
<div class="box mt-3">
|
||||
<button class="button is-fullwidth mb-3" @click="isSummed=false">Rozdzielone zamówienia</button>
|
||||
@@ -115,18 +138,40 @@
|
||||
<div v-if="isLoading == true" class="is-flex is-justify-content-center is-flex-direction-row" style="height: 100%; align-content:space-evenly">
|
||||
<div class="title is-1 has-text-centered element is-loading" style="min-height: 150px; align-self: center;"></div>
|
||||
</div>
|
||||
<DataTable :value="products" class="mb-3" style="padding:0" scrollable id="printMe" rowGroupMode="subheader" groupRowsBy="order.uuid" v-else-if="orders != undefined && orders.length != 0 && !isSummed">
|
||||
<Column field="order.uuid" header="UUID"/>
|
||||
<Column field="kod" header="Indeks" frozen></Column>
|
||||
<Column field="nazwa" header="Nazwa"/>
|
||||
<Column field="ilosc" header="Ilość"/>
|
||||
<Column field="jm" header="JM"/>
|
||||
<Column field="cena" header="Cena"/>
|
||||
<Column field="suma" header="Suma"/>
|
||||
<template #groupheader="slotProps">
|
||||
<span>{{ slotProps.data.order.nazwaklienta }}</span>
|
||||
</template>
|
||||
</DataTable>
|
||||
<div v-else-if="orders != undefined && orders.length != 0 && !isSummed" id="printMe">
|
||||
<div v-for="route in routes" :key="route.MZT_MZTID">
|
||||
<div v-if="route.MZT_Nazwa1 != undefined && ordersByRoute != undefined && ordersByRoute.has(route.MZT_Nazwa1)">
|
||||
<div v-if="
|
||||
//@ts-ignore
|
||||
ordersByRoute.has(route.MZT_Nazwa1) && ordersByRoute?.get(route.MZT_Nazwa1) != undefined && ordersByRoute?.get(route.MZT_Nazwa1).length > 0"
|
||||
style="page-break-after: always;">
|
||||
<h1 class="is-size-2 is-fullwidth has-text-centered">{{
|
||||
//@ts-ignore
|
||||
route.MZT_Nazwa1 + ' ' + ordersByRoute?.get(route.MZT_Nazwa1)[0].MZN_DataDos
|
||||
}}</h1>
|
||||
|
||||
<div v-for="order of ordersByRoute.get(route.MZT_Nazwa1)" :key="order.MZN_MZNID" class="pb-4" style="display: block; page-break-inside: avoid;">
|
||||
<p class="is-size-6 px-2">NIP {{order.MZN_PodNipE}}</p>
|
||||
<p class="is-size-6 px-2">{{order.MZN_PodNazwa1 + order.MZN_PodNazwa2 + order.MZN_PodNazwa3}}</p>
|
||||
<p class="is-size-5 px-2">ZAMÓWIENIE NR {{order.MZN_MZNID}}</p>
|
||||
<DataTable :value="order.products" class="mb-3" style="padding:0" scrollable>
|
||||
<Column field="kod" header="Indeks" frozen></Column>
|
||||
<Column field="nazwa" header="Nazwa"/>
|
||||
<Column field="ilosc" header="Ilość"/>
|
||||
<Column field="jm" header="JM"/>
|
||||
<Column field="cena" header="Cena"/>
|
||||
<Column field="suma" header="Suma"/>
|
||||
</DataTable>
|
||||
<div v-if="order.MZN_Uwagi != undefined">
|
||||
<p class="is-size-6 px-2">Uwagi</p>
|
||||
<p class="is-size-6 px-2">{{order.MZN_Uwagi}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<DataTable :value="summedProducts" class="mb-3" style="padding:0" scrollable id="printMe" v-else-if="orders != undefined && orders.length != 0 && isSummed">
|
||||
<Column field="Twr_Kod" header="Indeks" frozen></Column>
|
||||
<Column field="Twr_Nazwa" header="Nazwa"/>
|
||||
|
||||
@@ -150,7 +150,8 @@ export interface Order {
|
||||
MZN_UUID: string,
|
||||
MZN_Uwagi: string,
|
||||
MZN_MZTID: number,
|
||||
MZamElem: Array<OrderProduct>
|
||||
MZamElem: Array<OrderProduct>,
|
||||
products: any
|
||||
}
|
||||
|
||||
export interface OrderProduct {
|
||||
@@ -170,3 +171,9 @@ export interface Route {
|
||||
MZT_Nazwa1: string
|
||||
}
|
||||
|
||||
export function addDays(date : Date, days : number) {
|
||||
const result = new Date(date);
|
||||
result.setDate(result.getDate() + days);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ export const useOrdersStore = defineStore('orders', () => {
|
||||
}
|
||||
|
||||
async function fetchOrdersByDateStartAndEnd(dateStart : Date, dateEnd : Date, inBuffer : boolean | null) {
|
||||
let urlString = '/zamowienia?od=' + dateStart.toISOString().split('T')[0] + '&do=' + dateEnd.toISOString().split('T')[0]
|
||||
let urlString = '/zamowienia?od=' + dateStart.toISOString().split('T')[0] + '&do=' + dateEnd.toISOString().split('T')[0];
|
||||
console.log(urlString);
|
||||
if(inBuffer != null) {
|
||||
urlString += '&bufor=' + Number(inBuffer).toString();
|
||||
}
|
||||
@@ -64,7 +65,12 @@ export const useOrdersStore = defineStore('orders', () => {
|
||||
|
||||
async function fetchDates(offset : number) {
|
||||
const date = new Date(Date.now());
|
||||
const urlString = "/kalendarz/" + date.getFullYear() + '-' + Number(date.getMonth() + offset);
|
||||
let urlString;
|
||||
if(Number(date.getMonth() + offset) > 12) {
|
||||
urlString = "/kalendarz/" + Number(date.getFullYear() + 1) + '-' + "1";
|
||||
} else {
|
||||
urlString = "/kalendarz/" + date.getFullYear() + '-' + Number(date.getMonth() + offset);
|
||||
}
|
||||
const response = await axiosInstance.get(urlString, {withCredentials: true});
|
||||
const datesTemp :Array<Date> = response.data;
|
||||
return datesTemp;
|
||||
|
||||
@@ -36,7 +36,7 @@ async function onSubmit(values : any, { setErrors } : any) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container is-flex is-justify-content-space-evenly is-align-items-center" style="min-height: 100vh;">
|
||||
<div class="container is-flex is-justify-content-space-evenly is-align-items-center" style="min-height: calc(100vh - 3.5rem)">
|
||||
<div class="box" style="width: 75%">
|
||||
<h1 class="title is-3 mb-3">Login</h1>
|
||||
<Form @submit="onSubmit" :validation-schema="schema" v-slot="{ errors, isSubmitting }">
|
||||
|
||||
Reference in New Issue
Block a user