added duplication
This commit is contained in:
1
components.d.ts
vendored
1
components.d.ts
vendored
@@ -13,6 +13,7 @@ declare module 'vue' {
|
||||
ConfirmationModal: typeof import('./src/components/ConfirmationModal.vue')['default']
|
||||
ConfirmedForm: typeof import('./src/components/ConfirmedForm.vue')['default']
|
||||
DataTable: typeof import('primevue/datatable')['default']
|
||||
Divider: typeof import('primevue/divider')['default']
|
||||
IconCommunity: typeof import('./src/components/icons/IconCommunity.vue')['default']
|
||||
IconDocumentation: typeof import('./src/components/icons/IconDocumentation.vue')['default']
|
||||
IconEcosystem: typeof import('./src/components/icons/IconEcosystem.vue')['default']
|
||||
|
||||
@@ -244,8 +244,10 @@ onBeforeUnmount( function () {
|
||||
<div>
|
||||
<div class="box mb-5">
|
||||
<div class="mb-3">
|
||||
<h1 class="title is-5" v-if="uuid == undefined"><b>NOWE ZAMÓWIENIE</b></h1>
|
||||
<h1 class="title is-5" v-else-if="order != undefined"><b>ZAMÓWIENIE NR {{order.MZN_MZNID}}</b></h1>
|
||||
<h1 class="title is-5" v-if="order == undefined"><b>NOWE ZAMÓWIENIE</b></h1>
|
||||
<h1 class="title is-5" v-else-if="!ordersStore.orderToClone"><b>ZAMÓWIENIE NR {{order.MZN_MZNID}}</b></h1>
|
||||
<h1 class="title is-5" v-else-if="ordersStore.orderToClone"><b>DUPLIKACJA ZAMÓWIENIA NR {{order.MZN_MZNID}}</b></h1>
|
||||
|
||||
</div>
|
||||
<div class="field mb-3">
|
||||
<label class="label is-small">Klient</label>
|
||||
@@ -402,6 +404,7 @@ onBeforeUnmount( function () {
|
||||
</select>
|
||||
</span>
|
||||
</p>
|
||||
<!--TODO intesting part -->
|
||||
<p class="control is-expanded">
|
||||
<input class="input is-small" type="text" placeholder="Ilość" v-model="product.Quantity" v-bind:class="{ 'is-danger has-background-danger-soft': product.Quantity != undefined && isNaN(Number(product.Quantity)),'is-success has-background-success-soft': product.Quantity != undefined && product.Quantity as unknown as string != '' && !isNaN(Number(product.Quantity))}">
|
||||
</p>
|
||||
|
||||
@@ -58,9 +58,9 @@ const datesWithOrders = computed( ()=>{
|
||||
return datesWithOrders;
|
||||
})
|
||||
|
||||
function viewOrder(order : Order) {
|
||||
function viewOrder(order : Order, clone: boolean) {
|
||||
order.loading = true;
|
||||
siteControlStore.viewOrder(order.MZN_UUID);
|
||||
siteControlStore.viewOrder(order.MZN_UUID, clone);
|
||||
}
|
||||
|
||||
async function fetchOrders(event : Event | null) {
|
||||
@@ -177,7 +177,9 @@ fetchOrders(null);
|
||||
<div class="column is-6 py-0">{{Number(product.MZE_TwrIlosc).toFixed(2) + " " + product.MZE_TwrJm}}</div>
|
||||
</template>
|
||||
</div>
|
||||
<button class="button is-info is-small is-expanded" :class="{'is-invisible': areOrdersLoading, 'is-loading': order.loading}" @click="viewOrder(order)">Podgląd</button>
|
||||
<button class="button is-info is-small is-expanded mr-2" :class="{'is-invisible': areOrdersLoading, 'is-loading': order.loading}" @click="viewOrder(order, false)">Podgląd</button>
|
||||
<button class="button is-info is-small is-expanded mr-2" :class="{'is-invisible': areOrdersLoading}" @click="viewOrder(order, true)">Duplikuj</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -52,7 +52,7 @@ watch (
|
||||
|
||||
|
||||
export const axiosInstance = axios.create({
|
||||
baseURL: 'https://zamowienia.mleczarnia-kuzma.pl/api',
|
||||
baseURL: 'https://zamowienia-test.mleczarnia-kuzma.pl/api',
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ export const router = createRouter({
|
||||
routes: [
|
||||
{ path: '/', component: MainView },
|
||||
{ path: '/login', component: LoginView },
|
||||
{ path: '/summary', component: SummaryView, },
|
||||
{ path: '/orders', component: OrdersView}
|
||||
{ path: '/summary', component: SummaryView},
|
||||
{ path: '/orders', component: OrdersView},
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ export const useOrdersStore = defineStore('orders', () => {
|
||||
const deliveryDate = ref<Date>();
|
||||
const orderDate = ref<Date>();
|
||||
const additionalNotes = ref<string>();
|
||||
const orderToClone = ref<boolean>();
|
||||
|
||||
async function fetchOrders() {
|
||||
const response = await axiosInstance.get('/zamowienia', {withCredentials: true});
|
||||
@@ -72,45 +73,52 @@ export const useOrdersStore = defineStore('orders', () => {
|
||||
return datesTemp;
|
||||
}
|
||||
|
||||
|
||||
function updateStores(contractor: Ref<Contractor | undefined>, contractors: Ref<Array<Contractor>>, tempOrder, route: Ref<Route | undefined>, routes: Ref<Array<Route> | undefined>, uuidString: string) {
|
||||
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)
|
||||
orderDate.value = new Date(tempOrder.MZN_DataZam)
|
||||
if(!orderToClone.value) {
|
||||
uuid.value = uuidString
|
||||
}else {
|
||||
uuid.value = undefined
|
||||
}
|
||||
order.value = tempOrder
|
||||
additionalNotes.value = tempOrder.MZN_Uwagi
|
||||
}
|
||||
|
||||
function setOrderQuantities(tempOrder, categories: Ref<Array<Category>>) {
|
||||
for (const orderProduct of tempOrder.MZamElem) {
|
||||
for (const category of categories.value) {
|
||||
const product = category.Towary.find(product => (product.Twr_TwrId == orderProduct.MZE_TwrId))
|
||||
if (product != undefined && orderProduct.MZE_TwrCena != null) {
|
||||
console.log(product)
|
||||
if (orderProduct.MZE_TwrJm == product.Twr_JM) {
|
||||
product.Twr_Cena = orderProduct.MZE_TwrCena.slice(0, -2)
|
||||
} else if (orderProduct.Twr_Cena == product.Twr_JMZ) {
|
||||
product.Twr_CenaZ = orderProduct.MZE_TwrCena.slice(0, -2)
|
||||
}
|
||||
product.Quantity = orderProduct.MZE_TwrIlosc.slice(0, -2)
|
||||
product.ChosenOption = orderProduct.MZE_TwrJm
|
||||
category.isVisible = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 tempOrder = response.data;
|
||||
console.log(tempOrder);
|
||||
|
||||
if(confirmed) {
|
||||
tempOrder.MZN_Bufor = 0;
|
||||
if(confirmed)tempOrder.MZN_Bufor = 0;
|
||||
|
||||
updateStores(contractor, contractors, tempOrder, route, routes, uuidString)
|
||||
if(categories.value == undefined) return;
|
||||
setOrderQuantities(tempOrder, categories)
|
||||
}
|
||||
|
||||
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);
|
||||
orderDate.value = new Date(tempOrder.MZN_DataZam);
|
||||
uuid.value = uuidString;
|
||||
order.value = tempOrder;
|
||||
additionalNotes.value = tempOrder.MZN_Uwagi;
|
||||
|
||||
if(categories.value == undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(const orderProduct of tempOrder.MZamElem){
|
||||
for(const category of categories.value) {
|
||||
const product = category.Towary.find(product => (product.Twr_TwrId == orderProduct.MZE_TwrId));
|
||||
if(product != undefined && orderProduct.MZE_TwrCena != null) {
|
||||
console.log(product);
|
||||
if(orderProduct.MZE_TwrJm == product.Twr_JM) {
|
||||
product.Twr_Cena = orderProduct.MZE_TwrCena.slice(0, -2);
|
||||
} else if(orderProduct.Twr_Cena == product.Twr_JMZ) {
|
||||
product.Twr_CenaZ = orderProduct.MZE_TwrCena.slice(0, -2);
|
||||
}
|
||||
product.Quantity = orderProduct.MZE_TwrIlosc.slice(0, -2);
|
||||
product.ChosenOption = orderProduct.MZE_TwrJm;
|
||||
category.isVisible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {orders, order, uuid, deliveryDate, orderDate, dates, additionalNotes, fetchOrders, loadOrder, fetchOrdersByDay, fetchOrdersByBuffer, fetchOrdersByDateStartAndEnd, fetchDates, getOrderDates}
|
||||
return {orders,orderToClone, order, uuid, deliveryDate, orderDate, dates, additionalNotes, fetchOrders, loadOrder, fetchOrdersByDay, fetchOrdersByBuffer, fetchOrdersByDateStartAndEnd, fetchDates, getOrderDates}
|
||||
})
|
||||
@@ -14,6 +14,11 @@ export const useSiteControlStore = defineStore('siteControl', () => {
|
||||
const isDarkTheme = ref<boolean>(false);
|
||||
const isLoading = ref<boolean>(true);
|
||||
|
||||
const orderStore = useOrdersStore();
|
||||
const contractorsStore = useContractorsStore();
|
||||
const categoriesStore = useCategoriesStore();
|
||||
const routeStore = useRoutesStore();
|
||||
|
||||
|
||||
async function switchToForm() {
|
||||
await router.push("/");
|
||||
@@ -21,21 +26,9 @@ export const useSiteControlStore = defineStore('siteControl', () => {
|
||||
|
||||
async function switchToOrders() {
|
||||
await router.push("/orders");
|
||||
// const orderStore = useOrdersStore();
|
||||
// const { orders } = storeToRefs(orderStore);
|
||||
// isLoading.value = true;
|
||||
// const date = new Date(Date.now());
|
||||
// const startDate = new Date(date.getFullYear(), date.getMonth(), (date.getDate() - 2));
|
||||
// const endDate = new Date(date.getFullYear()+1, date.getMonth(), date.getDay());
|
||||
// orders.value = await orderStore.fetchOrdersByDateStartAndEnd(startDate, endDate, null);
|
||||
// console.log(orders.value);
|
||||
// isLoading.value = false;
|
||||
}
|
||||
|
||||
async function switchToTable() {
|
||||
// const ordersStore = useOrdersStore();
|
||||
// const { orders } = storeToRefs(ordersStore);
|
||||
// orders.value = await ordersStore.fetchOrdersByDay(new Date(Date.now()), null);
|
||||
await router.push("/summary");
|
||||
}
|
||||
|
||||
@@ -43,17 +36,14 @@ export const useSiteControlStore = defineStore('siteControl', () => {
|
||||
isDarkTheme.value = !!window?.matchMedia?.('(prefers-color-scheme:dark)')?.matches;
|
||||
}
|
||||
|
||||
async function viewOrder(uuid : string) {
|
||||
const orderStore = useOrdersStore();
|
||||
const contractorsStore = useContractorsStore();
|
||||
const categoriesStore = useCategoriesStore();
|
||||
const routeStore = useRoutesStore();
|
||||
async function viewOrder(uuid : string, clone:boolean ) {
|
||||
shownComponent.value = "mainForm";
|
||||
isLoading.value = true;
|
||||
await categoriesStore.fetchCategories();
|
||||
const { contractor, contractors } = storeToRefs(contractorsStore);
|
||||
const { categories } = storeToRefs(categoriesStore);
|
||||
const { route, routes } = storeToRefs( routeStore );
|
||||
orderStore.orderToClone = clone;
|
||||
await orderStore.loadOrder(uuid, false, contractor, contractors, categories, route, routes);
|
||||
isLoading.value=false;
|
||||
await router.push("/");
|
||||
@@ -61,11 +51,7 @@ export const useSiteControlStore = defineStore('siteControl', () => {
|
||||
}
|
||||
|
||||
async function newOrder(redirect : boolean) {
|
||||
const ordersStore = useOrdersStore();
|
||||
const contractorsStore = useContractorsStore();
|
||||
const categoriesStore = useCategoriesStore();
|
||||
const routeStore = useRoutesStore();
|
||||
const { order, uuid, deliveryDate, orderDate, additionalNotes } = storeToRefs(ordersStore);
|
||||
const { order, uuid, deliveryDate, orderDate, additionalNotes } = storeToRefs(orderStore);
|
||||
const { contractor } = storeToRefs(contractorsStore);
|
||||
const { route } = storeToRefs(routeStore);
|
||||
contractor.value = undefined;
|
||||
@@ -76,11 +62,11 @@ export const useSiteControlStore = defineStore('siteControl', () => {
|
||||
route.value = undefined;
|
||||
additionalNotes.value = undefined;
|
||||
await categoriesStore.fetchCategories();
|
||||
if (redirect) {
|
||||
if (redirect)
|
||||
{
|
||||
await router.push("/");
|
||||
window.scrollTo(0,0);
|
||||
}
|
||||
}
|
||||
|
||||
return {isLoading, showConfirmationModal, showCancellationModal, isDarkTheme, shownComponent, switchToForm, switchToOrders, switchToTable, checkTheme, viewOrder ,newOrder};
|
||||
})
|
||||
@@ -5,7 +5,7 @@
|
||||
</div>
|
||||
<div v-else>
|
||||
<MainForm
|
||||
v-if="order == undefined || order.MZN_Bufor==1"
|
||||
v-if="order == undefined || order.MZN_Bufor==1 || ordersStore.orderToClone"
|
||||
/>
|
||||
<ConfirmedForm v-else-if="order.MZN_Bufor==0"/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user