From a4232a128544c04797b98c993e1ddaa097e27682 Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 23 Oct 2023 11:15:38 +0530 Subject: [PATCH] Improved: actions to fetch product info for sinlge ordes --- src/router/index.ts | 1 + src/store/modules/order/actions.ts | 12 ++++++------ src/store/modules/product/actions.ts | 15 +++++---------- src/views/OrderDetail.vue | 6 ++++-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index e3efad21..463a059f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -81,6 +81,7 @@ const routes: Array = [ name: 'OrderDetail', component: OrderDetail, beforeEnter: authGuard, + props: true, meta: { permissionId: "APP_ORDER_DETAIL_VIEW" } diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 747ca0c3..4de2926d 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -567,7 +567,7 @@ const actions: ActionTree = { } } - let resp, order = {}; + let resp, order = {} as any; emitter.emit('presentLoader'); const params = { @@ -603,7 +603,7 @@ const actions: ActionTree = { shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc, reservedDatetime: orderItem.reservedDatetime } - this.dispatch('product/getProductInformation', order) + await this.dispatch('product/fetchProducts', { productIds: order.items.map((item: any) => item.productId) }) } else { throw resp.data } @@ -633,7 +633,7 @@ const actions: ActionTree = { } } emitter.emit('presentLoader'); - let resp, order = {}; + let resp, order = {} as any; try { const params = { @@ -669,7 +669,7 @@ const actions: ActionTree = { shipmentMethodTypeId: orderItem.shipmentMethodTypeId, shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc, } - this.dispatch('product/getProductInformation', order) + await this.dispatch('product/fetchProducts', { productIds: order.items.map((item: any) => item.productId) }) } else { throw resp.data } @@ -698,7 +698,7 @@ const actions: ActionTree = { } } emitter.emit('presentLoader'); - let resp, order = {}; + let resp, order = {} as any; try { const params = { @@ -738,7 +738,7 @@ const actions: ActionTree = { isGeneratingPackingSlip: false } - this.dispatch('product/getProductInformation', order) + await this.dispatch('product/fetchProducts', { productIds: order.items.map((item: any) => item.productId) }) } else { throw resp.data } diff --git a/src/store/modules/product/actions.ts b/src/store/modules/product/actions.ts index 9850798c..7382c692 100644 --- a/src/store/modules/product/actions.ts +++ b/src/store/modules/product/actions.ts @@ -44,18 +44,13 @@ const actions: ActionTree = { return resp; }, - async getProductInformation ({ dispatch }, payload) { + async getProductInformation({ dispatch }, { orders }) { let productIds: any = new Set(); - // checking if its a single order or multiple orders - Array.isArray(payload) ? - payload.forEach((list: any) => { - list.doclist.docs.forEach((order: any) => { - if (order.productId) productIds.add(order.productId) - }) - }) : - payload.items.forEach((item: any) => { - if (item.productId) productIds.add(item.productId) + orders.forEach((list: any) => { + list.doclist.docs.forEach((order: any) => { + if (order.productId) productIds.add(order.productId) }) + }) productIds = [...productIds] if (productIds.length) { diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 4e93c1f9..9715a695 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -54,8 +54,10 @@ -
- {{ translate("Add Box") }} +
+ + {{ translate("Add Box") }} + {{ `Box ${shipmentPackage?.packageName}` }} {{ shipmentPackage.shipmentBoxTypes.length ? `| ${boxTypeDesc(getShipmentPackageType(shipmentPackage))}` : '' }}