This commit is contained in:
2024-09-03 09:33:00 +02:00
parent ce89b79074
commit d7e28cd926
8 changed files with 1317 additions and 116 deletions

View File

@@ -1,25 +1,22 @@
<script setup lang="ts">
import { useOrdersStore } from '@/stores/orders.store'
import { storeToRefs } from 'pinia'
import { useRoute } from 'vue-router'
import NavBar from '@/components/NavBar.vue'
import VueDatePicker from '@vuepic/vue-datepicker'
import { useSiteControlStore } from '@/stores/siteControl.store'
import { onMounted, ref } from 'vue'
import { useCategoriesStore } from '@/stores/categories.store'
import type { Product } from '@/main'
const ordersStore = useOrdersStore();
const siteControlStore = useSiteControlStore();
const categoriesStore = useCategoriesStore();
const { orders, dates } = storeToRefs(ordersStore);
const { categories } = storeToRefs(categoriesStore);
const { isDarkTheme } = storeToRefs(siteControlStore);
const searchDate = ref<Date>(new Date(Date.now()));
const confirmedOrders = ref<boolean>();
const isSummed = ref<boolean>(true);
const printMe = ref();
const isLoading = ref<boolean>(true);
const summedProducts = ref<Array<Product>>([]);
const products = ref<Array<Object>>();
async function fetchOrders() {
isLoading.value=true;
@@ -27,13 +24,53 @@
orders.value = await ordersStore.fetchOrdersByDateStartAndEnd(searchDate.value != undefined ? searchDate.value : new Date(Date.now()),
searchDate.value != undefined ? searchDate.value : new Date(Date.now()),
(confirmedOrders.value) ? true : null);
await categoriesStore.sumProductsFromOrders(orders.value);
const productsMap = await categoriesStore.sumProductsFromOrders(orders.value);
for(const product of productsMap.values()) {
if(product.SummedQuantity > 0) {
summedProducts.value.push(product);
}
}
await prepareProductsFromOrders();
isLoading.value=false;
}
async function prepareProductsFromOrders() {
products.value = [];
if(orders.value == undefined) {
return;
}
for(const order of orders.value) {
for (const product of order.MZamElem) {
const newProduct = {
'kod': product.MZE_TwrKod,
'nazwa': product.MZE_TwrNazwa,
'ilosc': Number(product.MZE_TwrIlosc).toFixed(2),
'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);
}
}
}
onMounted(async () => {
orders.value = await ordersStore.fetchOrdersByDay(searchDate.value, null);
await categoriesStore.sumProductsFromOrders(orders.value);
const productsMap = await categoriesStore.sumProductsFromOrders(orders.value);
summedProducts.value = [];
for(const product of productsMap.values()) {
if(product.SummedQuantity > 0) {
summedProducts.value.push(product);
}
}
console.log(summedProducts.value);
await prepareProductsFromOrders();
console.log(products.value);
isLoading.value=false;
});
</script>
@@ -68,75 +105,49 @@
</div>
</div>
<div class="column is-four-fifths">
<div class="is-flex is-justify-content-center is-flex-direction-row box" style="width: 100%; height: 100%; align-content: space-evenly;">
<div class="is-flex is-justify-content-center is-flex-direction-row" id="printMe" style="">
<div v-if="isLoading == true" class="title is-1 has-text-centered element is-loading" style="height: 25%; align-self: center;"></div>
<table class="table blackBorder tableOverflow" v-else-if="orders != undefined && orders.length != 0 && !isSummed">
<thead style="width: 100%">
<tr class="has-background-grey-light">
<th>Indeks</th>
<th>Nazwa produktu</th>
<th>Ilość</th>
<th>Jednostka miary</th>
<th>Cena jednostkowa</th>
<th>Cena całkowita</th>
</tr>
</thead>
<tbody v-for="order in orders" :key="order.MZN_UUID">
<tr class="has-background-grey-lighter dashedBorder">
<td colspan="6">
{{ order.MZN_PodNazwa1 + order.MZN_PodNazwa2 + order.MZN_PodNazwa3 }}
</td>
</tr>
<tr v-for="product in order.MZamElem" :key="product.MZE_MZEID">
<td>{{product.MZE_TwrKod}}</td>
<td>{{ product.MZE_TwrNazwa }}</td>
<td>{{ Number(product.MZE_TwrIlosc).toFixed(2) }}</td>
<td>{{ product.MZE_TwrJm }}</td>
<td>{{ Number(product.MZE_TwrCena).toFixed(2) }} &nbsp;PLN</td>
<td>{{ (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)).toFixed(2) }}&nbsp;PLN</td>
</tr>
</tbody>
</table>
<table class="table blackBorder tableOverflow" v-else-if="orders != undefined && orders.length != 0 && isSummed">
<thead>
<tr class="has-background-grey-light">
<th>Indeks</th>
<th>Nazwa produktu</th>
<th>Ilość</th>
<th>Jednostka miary</th>
<th>Cena zsumowana</th>
</tr>
</thead>
<tbody>
<template v-for="category in categories" :key="category.Kod">
<template v-for="product in category.Towary" :key="product.Twr_Kod">
<tr v-if="product.SummedQuantity > 0">
<td>{{product.Twr_Kod}}</td>
<td>{{ product.Twr_Nazwa }}</td>
<td>{{ product.SummedQuantity.toFixed(2) }}</td>
<td>{{ product.Twr_JM }}</td>
<td>{{ product.SummedPrice.toFixed(2) }}&nbsp;PLN</td>
</tr>
<tr v-if="product.SummedQuantityZ > 0">
<td>{{product.Twr_Kod}}</td>
<td>{{ product.Twr_Nazwa }}</td>
<td>{{ product.SummedQuantityZ.toFixed(2) }}</td>
<td>{{ product.Twr_JM }}</td>
<td>{{ product.SummedPriceZ.toFixed(2) }}&nbsp;PLN</td>
</tr>
</template>
<div class="box" style="width: 100%; height: 100%; padding: 0">
<div style="width: 100%; height: 100%">
<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>
</tbody>
</table>
<p v-else class="title is-1 has-text-centered" style="height: min-content; align-self: center;">Brak zamówień</p>
</DataTable>
<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"/>
<Column field="SummedQuantity" header="Ilość">
<template #body="slotProps">
<span>{{ slotProps.data.SummedQuantity.toFixed(2)}}</span>
</template>
</Column>
<Column field="Twr_JM" header="JM">
</Column>
<Column field="SummedPrice" header="Suma">
<template #body="slotProps">
<span>{{ slotProps.data.SummedPrice.toFixed(2)}}</span>
</template>
</Column>
</DataTable>
<div v-else class="is-flex is-justify-content-center is-flex-direction-row">
<p class="title is-1 has-text-centered" style="height: min-content; align-self: center;">Brak zamówień</p>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
<style>
@media screen and (min-width: 500px) {
.box {
--bulma-box-padding: 1.5rem;
@@ -155,8 +166,37 @@
.tableOverflow {
overflow-x: scroll;
display: block;
padding: 0;
}
.test {
padding: 0.75rem;
}
tr th:first-child{
border-top-left-radius: 0.75rem;
}
tr th:last-child{
border-top-right-radius: 0.75rem;
}
.p-datatable-scrollable {
border-top-right-radius: 0.75rem;
border-top-left-radius: 0.75rem;
}
.p-datatable-table-container {
border-top-right-radius: 0.75rem;
border-top-left-radius: 0.75rem;
}
table {
border-top-right-radius: 0.75rem;
border-top-left-radius: 0.75rem;
}
@media print {
.dashedBorder{
border-style: dotted;