Bugfix
This commit is contained in:
1193
package-lock.json
generated
1193
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -14,20 +14,22 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "^6.6.0",
|
||||
"@primevue/themes": "^4.0.4",
|
||||
"@vuepic/vue-datepicker": "^8.7.0",
|
||||
"axios": "^1.7.2",
|
||||
"bulma": "^1.0.1",
|
||||
"cors": "^2.8.5",
|
||||
"pinia": "^2.1.7",
|
||||
"primevue": "^4.0.4",
|
||||
"vee-validate": "^4.13.1",
|
||||
"vue": "^3.4.21",
|
||||
"vue-router": "^4.3.3",
|
||||
"vue-to-print": "^1.1.0",
|
||||
"vue3-cookies": "^1.0.6",
|
||||
"vue3-print-nb": "^0.1.4",
|
||||
"yup": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@primevue/auto-import-resolver": "^4.0.4",
|
||||
"@rushstack/eslint-patch": "^1.8.0",
|
||||
"@tsconfig/node20": "^20.1.4",
|
||||
"@types/node": "^20.12.5",
|
||||
@@ -41,6 +43,7 @@
|
||||
"prettier": "^3.2.5",
|
||||
"sass": "^1.77.2",
|
||||
"typescript": "~5.4.0",
|
||||
"unplugin-vue-components": "^0.27.3",
|
||||
"vite": "^5.2.8",
|
||||
"vue-tsc": "^2.0.11"
|
||||
}
|
||||
|
||||
@@ -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) }} PLN</td>
|
||||
<td>{{ (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)).toFixed(2) }} 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) }} 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) }} PLN</td>
|
||||
</tr>
|
||||
<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>
|
||||
</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>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-else class="title is-1 has-text-centered" style="height: min-content; align-self: center;">Brak zamówień</p>
|
||||
</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;
|
||||
|
||||
19
src/main.ts
19
src/main.ts
@@ -17,6 +17,8 @@ import { useUserStore } from '@/stores/user.store'
|
||||
import print from 'vue3-print-nb'
|
||||
import CancelationModal from '@/components/CancelationModal.vue'
|
||||
import SummaryComponent from '@/components/SummaryComponent.vue'
|
||||
import PrimeVue from "primevue/config";
|
||||
import Lara from '@primevue/themes/lara';
|
||||
|
||||
const app = createApp(App);
|
||||
const pinia = createPinia();
|
||||
@@ -24,6 +26,17 @@ app.use(pinia);
|
||||
app.use(VueCookies);
|
||||
app.use(router);
|
||||
app.use(print);
|
||||
app.use(PrimeVue, {
|
||||
// Default theme configuration
|
||||
theme: {
|
||||
preset: Lara,
|
||||
options: {
|
||||
prefix: 'p',
|
||||
darkModeSelector: 'system',
|
||||
cssLayer: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(localStorage.getItem('piniaState')) {
|
||||
pinia.state.value = JSON.parse(localStorage.getItem('piniaState') as string);
|
||||
@@ -95,9 +108,7 @@ export interface Product {
|
||||
BasePrice: string,
|
||||
BasePriceZ: string,
|
||||
SummedQuantity: number,
|
||||
SummedQuantityZ: number,
|
||||
SummedPrice: number,
|
||||
SummedPriceZ: number
|
||||
SummedPrice: number
|
||||
}
|
||||
|
||||
export interface Contractor {
|
||||
@@ -150,6 +161,6 @@ export interface OrderProduct {
|
||||
MZE_TwrJm: string,
|
||||
MZE_TwrNazwa: string,
|
||||
MZE_TwrKod: string,
|
||||
MZE_TwrStawka: string | undefined
|
||||
MZE_TwrStawka: string | undefined,
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@ export const useCategoriesStore = defineStore('categories', () => {
|
||||
product.BasePrice = product.Twr_Cena;
|
||||
product.BasePriceZ = product.Twr_CenaZ;
|
||||
product.SummedQuantity = 0;
|
||||
product.SummedQuantityZ = 0;
|
||||
product.SummedPrice = 0;
|
||||
product.SummedPriceZ = 0;
|
||||
if (product.Twr_JMZ != null) {
|
||||
product.Options.push(product.Twr_JMZ);
|
||||
}
|
||||
@@ -46,22 +44,18 @@ export const useCategoriesStore = defineStore('categories', () => {
|
||||
for (const order of orders) {
|
||||
for (const product of order.MZamElem) {
|
||||
const mapProduct = productsMap.get(String(product.MZE_TwrId));
|
||||
if(product.MZE_TwrJm == mapProduct?.Twr_JM) {
|
||||
if (product.MZE_TwrJm == mapProduct?.Twr_JM) {
|
||||
mapProduct.SummedQuantity += Number(product.MZE_TwrIlosc);
|
||||
mapProduct.SummedPrice += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc));
|
||||
}
|
||||
if (product.MZE_TwrJm == mapProduct?.Twr_JMZ) {
|
||||
mapProduct.SummedQuantityZ += Number(product.MZE_TwrIlosc);
|
||||
mapProduct.SummedPriceZ += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc));
|
||||
// mapProduct.SummedQuantity += Number(product.MZE_TwrIlosc) * Number(product.mnoznik);
|
||||
// mapProduct.SummedPrice += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc));
|
||||
}
|
||||
|
||||
|
||||
else if (product.MZE_TwrJm == mapProduct?.Twr_JMZ) {
|
||||
mapProduct.SummedQuantity += (Number(product.MZE_TwrIlosc) * Number(mapProduct.Twr_JMPrzelicznikM))/Number(mapProduct.Twr_JMPrzelicznikL);
|
||||
mapProduct.SummedPrice += (Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc));
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(categories.value);
|
||||
}
|
||||
return productsMap;
|
||||
}
|
||||
|
||||
return {categories, fetchCategories, sumProductsFromOrders}
|
||||
|
||||
@@ -38,15 +38,13 @@ const { showConfirmationModal, showCancellationModal, isLoading, shownComponent
|
||||
|
||||
|
||||
async function fetchData() {
|
||||
await categoriesStore.fetchCategories();
|
||||
//await categoriesStore.fetchCategories();
|
||||
await contractorsStore.fetchContractors();
|
||||
siteControlStore.newOrder(false);
|
||||
|
||||
//siteControlStore.newOrder(false);
|
||||
isLoading.value = false;
|
||||
}
|
||||
siteControlStore.checkTheme();
|
||||
//fetchData();
|
||||
isLoading.value = false;
|
||||
fetchData();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -7,5 +7,8 @@
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
}
|
||||
]
|
||||
],
|
||||
"compilerOptions": {
|
||||
"allowJs": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,18 @@ import { fileURLToPath, URL } from 'node:url'
|
||||
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import {PrimeVueResolver} from '@primevue/auto-import-resolver';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
Components({
|
||||
resolvers: [
|
||||
PrimeVueResolver()
|
||||
]
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
|
||||
Reference in New Issue
Block a user