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'] |     ConfirmationModal: typeof import('./src/components/ConfirmationModal.vue')['default'] | ||||||
|     ConfirmedForm: typeof import('./src/components/ConfirmedForm.vue')['default'] |     ConfirmedForm: typeof import('./src/components/ConfirmedForm.vue')['default'] | ||||||
|     DataTable: typeof import('primevue/datatable')['default'] |     DataTable: typeof import('primevue/datatable')['default'] | ||||||
|  |     Divider: typeof import('primevue/divider')['default'] | ||||||
|     IconCommunity: typeof import('./src/components/icons/IconCommunity.vue')['default'] |     IconCommunity: typeof import('./src/components/icons/IconCommunity.vue')['default'] | ||||||
|     IconDocumentation: typeof import('./src/components/icons/IconDocumentation.vue')['default'] |     IconDocumentation: typeof import('./src/components/icons/IconDocumentation.vue')['default'] | ||||||
|     IconEcosystem: typeof import('./src/components/icons/IconEcosystem.vue')['default'] |     IconEcosystem: typeof import('./src/components/icons/IconEcosystem.vue')['default'] | ||||||
|   | |||||||
| @@ -244,8 +244,10 @@ onBeforeUnmount( function () { | |||||||
|     <div> |     <div> | ||||||
|       <div class="box mb-5"> |       <div class="box mb-5"> | ||||||
|         <div class="mb-3"> |         <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-if="order == 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-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> | ||||||
|         <div class="field mb-3"> |         <div class="field mb-3"> | ||||||
|           <label class="label is-small">Klient</label> |           <label class="label is-small">Klient</label> | ||||||
| @@ -402,6 +404,7 @@ onBeforeUnmount( function () { | |||||||
|                     </select> |                     </select> | ||||||
|                   </span> |                   </span> | ||||||
|                 </p> |                 </p> | ||||||
|  | <!--TODO intesting part                 --> | ||||||
|                 <p class="control is-expanded"> |                 <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))}"> |                   <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> |                 </p> | ||||||
|   | |||||||
| @@ -58,9 +58,9 @@ const datesWithOrders = computed( ()=>{ | |||||||
|   return datesWithOrders; |   return datesWithOrders; | ||||||
| }) | }) | ||||||
|  |  | ||||||
| function viewOrder(order : Order) { | function viewOrder(order : Order, clone: boolean) { | ||||||
|   order.loading = true; |   order.loading = true; | ||||||
|   siteControlStore.viewOrder(order.MZN_UUID); |   siteControlStore.viewOrder(order.MZN_UUID, clone); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function fetchOrders(event : Event | null) { | 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> |                       <div class="column is-6 py-0">{{Number(product.MZE_TwrIlosc).toFixed(2) + " " + product.MZE_TwrJm}}</div> | ||||||
|                     </template> |                     </template> | ||||||
|                   </div> |                   </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> | ||||||
|               </div> |               </div> | ||||||
|             </template> |             </template> | ||||||
|   | |||||||
| @@ -52,7 +52,7 @@ watch ( | |||||||
|  |  | ||||||
|  |  | ||||||
| export const axiosInstance = axios.create({ | export const axiosInstance = axios.create({ | ||||||
|   baseURL: 'https://zamowienia.mleczarnia-kuzma.pl/api', |   baseURL: 'https://zamowienia-test.mleczarnia-kuzma.pl/api', | ||||||
|   withCredentials: true |   withCredentials: true | ||||||
| }); | }); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ export const router = createRouter({ | |||||||
|   routes: [ |   routes: [ | ||||||
|     { path: '/', component: MainView }, |     { path: '/', component: MainView }, | ||||||
|     { path: '/login', component: LoginView }, |     { path: '/login', component: LoginView }, | ||||||
|     { path: '/summary', component: SummaryView,  }, |     { path: '/summary', component: SummaryView}, | ||||||
|     { path: '/orders', component: OrdersView} |     { path: '/orders', component: OrdersView}, | ||||||
|   ] |   ] | ||||||
| }); | }); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ export const useOrdersStore = defineStore('orders', () => { | |||||||
|   const deliveryDate = ref<Date>(); |   const deliveryDate = ref<Date>(); | ||||||
|   const orderDate = ref<Date>(); |   const orderDate = ref<Date>(); | ||||||
|   const additionalNotes = ref<string>(); |   const additionalNotes = ref<string>(); | ||||||
|  |   const orderToClone = ref<boolean>(); | ||||||
|  |  | ||||||
|   async function fetchOrders() { |   async function fetchOrders() { | ||||||
|     const response = await axiosInstance.get('/zamowienia', {withCredentials: true}); |     const response = await axiosInstance.get('/zamowienia', {withCredentials: true}); | ||||||
| @@ -72,45 +73,52 @@ 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>>, 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) { |   function updateStores(contractor: Ref<Contractor | undefined>, contractors: Ref<Array<Contractor>>, tempOrder, route: Ref<Route | undefined>, routes: Ref<Array<Route> | undefined>, uuidString: string) { | ||||||
|       tempOrder.MZN_Bufor = 0; |     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 | ||||||
|  |   } | ||||||
|  |  | ||||||
|     contractor.value = <Contractor>contractors.value?.find((contractor) => contractor.Knt_KntId == tempOrder.MZN_PodID); |   function setOrderQuantities(tempOrder, categories: Ref<Array<Category>>) { | ||||||
|     route.value = <Route>routes.value?.find((route) => route.MZT_MZTID == tempOrder.MZN_MZTID); |     for (const orderProduct of tempOrder.MZamElem) { | ||||||
|     deliveryDate.value = new Date(tempOrder.MZN_DataDos); |       for (const category of categories.value) { | ||||||
|     orderDate.value = new Date(tempOrder.MZN_DataZam); |         const product = category.Towary.find(product => (product.Twr_TwrId == orderProduct.MZE_TwrId)) | ||||||
|     uuid.value = uuidString; |         if (product != undefined && orderProduct.MZE_TwrCena != null) { | ||||||
|     order.value = tempOrder; |           console.log(product) | ||||||
|     additionalNotes.value = tempOrder.MZN_Uwagi; |           if (orderProduct.MZE_TwrJm == product.Twr_JM) { | ||||||
|  |             product.Twr_Cena = orderProduct.MZE_TwrCena.slice(0, -2) | ||||||
|     if(categories.value == undefined) { |           } else if (orderProduct.Twr_Cena == product.Twr_JMZ) { | ||||||
|       return; |             product.Twr_CenaZ = orderProduct.MZE_TwrCena.slice(0, -2) | ||||||
|     } |  | ||||||
|  |  | ||||||
|     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.Quantity = orderProduct.MZE_TwrIlosc.slice(0, -2) | ||||||
|           product.ChosenOption = orderProduct.MZE_TwrJm; |           product.ChosenOption = orderProduct.MZE_TwrJm | ||||||
|           category.isVisible = true; |           category.isVisible = true | ||||||
|           break; |           break | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   return {orders, order, uuid, deliveryDate, orderDate, dates, additionalNotes, fetchOrders, loadOrder, fetchOrdersByDay, fetchOrdersByBuffer, fetchOrdersByDateStartAndEnd, fetchDates, getOrderDates} |   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; | ||||||
|  |  | ||||||
|  |     updateStores(contractor, contractors, tempOrder, route, routes, uuidString) | ||||||
|  |     if(categories.value == undefined) return; | ||||||
|  |     setOrderQuantities(tempOrder, categories) | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   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 isDarkTheme = ref<boolean>(false); | ||||||
|   const isLoading = ref<boolean>(true); |   const isLoading = ref<boolean>(true); | ||||||
|  |  | ||||||
|  |   const orderStore = useOrdersStore(); | ||||||
|  |   const contractorsStore = useContractorsStore(); | ||||||
|  |   const categoriesStore = useCategoriesStore(); | ||||||
|  |   const routeStore = useRoutesStore(); | ||||||
|  |  | ||||||
|  |  | ||||||
|   async function switchToForm() { |   async function switchToForm() { | ||||||
|     await router.push("/"); |     await router.push("/"); | ||||||
| @@ -21,21 +26,9 @@ export const useSiteControlStore = defineStore('siteControl', () => { | |||||||
|  |  | ||||||
|   async function switchToOrders() { |   async function switchToOrders() { | ||||||
|     await router.push("/orders"); |     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() { |   async function switchToTable() { | ||||||
|     // const ordersStore = useOrdersStore(); |  | ||||||
|     // const { orders } = storeToRefs(ordersStore); |  | ||||||
|     // orders.value = await ordersStore.fetchOrdersByDay(new Date(Date.now()), null); |  | ||||||
|     await router.push("/summary"); |     await router.push("/summary"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -43,17 +36,14 @@ export const useSiteControlStore = defineStore('siteControl', () => { | |||||||
|     isDarkTheme.value = !!window?.matchMedia?.('(prefers-color-scheme:dark)')?.matches; |     isDarkTheme.value = !!window?.matchMedia?.('(prefers-color-scheme:dark)')?.matches; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   async function viewOrder(uuid : string) { |   async function viewOrder(uuid : string, clone:boolean ) { | ||||||
|     const orderStore = useOrdersStore(); |  | ||||||
|     const contractorsStore = useContractorsStore(); |  | ||||||
|     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); | ||||||
|     const { route, routes } = storeToRefs( routeStore ); |     const { route, routes } = storeToRefs( routeStore ); | ||||||
|  |     orderStore.orderToClone = clone; | ||||||
|     await orderStore.loadOrder(uuid, false, contractor, contractors, categories, route, routes); |     await orderStore.loadOrder(uuid, false, contractor, contractors, categories, route, routes); | ||||||
|     isLoading.value=false; |     isLoading.value=false; | ||||||
|     await router.push("/"); |     await router.push("/"); | ||||||
| @@ -61,11 +51,7 @@ export const useSiteControlStore = defineStore('siteControl', () => { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   async function newOrder(redirect : boolean) { |   async function newOrder(redirect : boolean) { | ||||||
|     const ordersStore = useOrdersStore(); |     const { order, uuid, deliveryDate, orderDate, additionalNotes } = storeToRefs(orderStore); | ||||||
|     const contractorsStore = useContractorsStore(); |  | ||||||
|     const categoriesStore = useCategoriesStore(); |  | ||||||
|     const routeStore = useRoutesStore(); |  | ||||||
|     const { order, uuid, deliveryDate, orderDate, additionalNotes } = storeToRefs(ordersStore); |  | ||||||
|     const { contractor } = storeToRefs(contractorsStore); |     const { contractor } = storeToRefs(contractorsStore); | ||||||
|     const { route } = storeToRefs(routeStore); |     const { route } = storeToRefs(routeStore); | ||||||
|     contractor.value = undefined; |     contractor.value = undefined; | ||||||
| @@ -76,11 +62,11 @@ export const useSiteControlStore = defineStore('siteControl', () => { | |||||||
|     route.value = undefined; |     route.value = undefined; | ||||||
|     additionalNotes.value = undefined; |     additionalNotes.value = undefined; | ||||||
|     await categoriesStore.fetchCategories(); |     await categoriesStore.fetchCategories(); | ||||||
|     if (redirect) { |     if (redirect) | ||||||
|  |     { | ||||||
|       await router.push("/"); |       await router.push("/"); | ||||||
|       window.scrollTo(0,0); |       window.scrollTo(0,0); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |   return {isLoading, showConfirmationModal, showCancellationModal, isDarkTheme, shownComponent, switchToForm, switchToOrders, switchToTable, checkTheme, viewOrder ,newOrder}; | ||||||
|   return {isLoading, showConfirmationModal, showCancellationModal, isDarkTheme, shownComponent, switchToForm, switchToOrders, switchToTable, checkTheme, viewOrder, newOrder}; |  | ||||||
| }) | }) | ||||||
| @@ -5,7 +5,7 @@ | |||||||
|   </div> |   </div> | ||||||
|   <div v-else> |   <div v-else> | ||||||
|     <MainForm |     <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"/> |       <ConfirmedForm v-else-if="order.MZN_Bufor==0"/> | ||||||
|   </div> |   </div> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user