diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 9e522f3e..a198787f 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -8,7 +8,7 @@ import * as types from './mutation-types' import { prepareOrderQuery } from '@/utils/solrHelper' import { UtilService } from '@/services/UtilService' import logger from '@/logger' -import { getOrderCategory } from '@/utils/order' +import { getOrderCategory, isKitComponent, prepareKitProducts } from '@/utils/order' const actions: ActionTree = { async fetchInProgressOrdersAdditionalInformation({ commit, state }, payload = { viewIndex: 0 }) { @@ -29,46 +29,46 @@ const actions: ActionTree = { try { // maintaining an object containing information of shipmentIds for each order - const shipmentIdsForOrderAndPicklistBin = await UtilService.findShipmentIdsForOrders(picklistBinIds, orderIds); + const shipmentIdsForOrderAndPicklistBin = await UtilService.findShipmentIdsForOrders(picklistBinIds, orderIds); - let shipmentPackagesByOrderAndPicklistBin = {} as any, itemInformationByOrder = {} as any, carrierPartyIdsByShipment = {} as any, carrierShipmentBoxType = {} as any + let shipmentPackagesByOrderAndPicklistBin = {} as any, itemInformationByOrder = {} as any, carrierPartyIdsByShipment = {} as any, carrierShipmentBoxType = {} as any - // storing all the shipmentIds for all the orders in an array to use furthur - const orderShipmentIds = [...(new Set(Object.values(shipmentIdsForOrderAndPicklistBin).flat()))] as Array + // storing all the shipmentIds for all the orders in an array to use furthur + const orderShipmentIds = [...(new Set(Object.values(shipmentIdsForOrderAndPicklistBin).flat()))] as Array - // TODO: handle case when shipmentIds is empty - // https://stackoverflow.com/questions/28066429/promise-all-order-of-resolved-values - const [shipmentPackagesByOrderInformationAndPicklistBin, itemInformationByOrderInformation, carrierPartyIdsByShipmentInformation] = await Promise.all([UtilService.findShipmentPackages(orderShipmentIds), UtilService.findShipmentItemInformation(orderShipmentIds), UtilService.findCarrierPartyIdsForShipment(orderShipmentIds)]) + // TODO: handle case when shipmentIds is empty + // https://stackoverflow.com/questions/28066429/promise-all-order-of-resolved-values + const [shipmentPackagesByOrderInformationAndPicklistBin, itemInformationByOrderInformation, carrierPartyIdsByShipmentInformation] = await Promise.all([UtilService.findShipmentPackages(orderShipmentIds), UtilService.findShipmentItemInformation(orderShipmentIds), UtilService.findCarrierPartyIdsForShipment(orderShipmentIds)]) - // TODO: try fetching the carrierPartyIds when fetching packages information, as ShipmentPackageRouteSegDetail entity contain carrierPartyIds as well - const carrierPartyIds = [...new Set(Object.values(carrierPartyIdsByShipmentInformation).map((carrierPartyIds: any) => carrierPartyIds.map((carrier: any) => carrier.carrierPartyId)).flat())] + // TODO: try fetching the carrierPartyIds when fetching packages information, as ShipmentPackageRouteSegDetail entity contain carrierPartyIds as well + const carrierPartyIds = [...new Set(Object.values(carrierPartyIdsByShipmentInformation).map((carrierPartyIds: any) => carrierPartyIds.map((carrier: any) => carrier.carrierPartyId)).flat())] - shipmentPackagesByOrderAndPicklistBin = { - ...shipmentPackagesByOrderAndPicklistBin, - ...shipmentPackagesByOrderInformationAndPicklistBin - } + shipmentPackagesByOrderAndPicklistBin = { + ...shipmentPackagesByOrderAndPicklistBin, + ...shipmentPackagesByOrderInformationAndPicklistBin + } - itemInformationByOrder = { - ...itemInformationByOrder, - ...itemInformationByOrderInformation - } + itemInformationByOrder = { + ...itemInformationByOrder, + ...itemInformationByOrderInformation + } - carrierPartyIdsByShipment = { - ...carrierPartyIdsByShipment, - ...carrierPartyIdsByShipmentInformation - } + carrierPartyIdsByShipment = { + ...carrierPartyIdsByShipment, + ...carrierPartyIdsByShipmentInformation + } - carrierShipmentBoxType = { - ...carrierShipmentBoxType, - ...await UtilService.findCarrierShipmentBoxType(carrierPartyIds) - } + carrierShipmentBoxType = { + ...carrierShipmentBoxType, + ...await UtilService.findCarrierShipmentBoxType(carrierPartyIds) + } - const orderShipmentPackages = this.state.util.productStoreShipmentMethCount > 0 ? await OrderService.fetchShipmentPackages(orderShipmentIds) : []; + const orderShipmentPackages = this.state.util.productStoreShipmentMethCount > 0 ? await OrderService.fetchShipmentPackages(orderShipmentIds) : []; - inProgressOrders = inProgressOrders.map((order: any) => { + inProgressOrders = inProgressOrders.map((order: any) => { - // if for an order shipment information is not available then returning the same order information again - if(!shipmentIdsForOrderAndPicklistBin[`${order.orderId}_${order.picklistBinId}`]) { + // if for an order shipment information is not available then returning the same order information again + if (!shipmentIdsForOrderAndPicklistBin[`${order.orderId}_${order.picklistBinId}`]) { // if there are no shipment for the order, there is some issue with the order if (picklistBinIds.includes(order.picklistBinId) && orderIds.includes(order.orderId)) { return { @@ -77,60 +77,63 @@ const actions: ActionTree = { } } return order - } + } - order.items.map((item: any) => { - // fetching shipmentItemInformation for the current order item and then assigning the shipmentItemSeqId to item - const shipment = itemInformationByOrder[item.orderId]?.find((shipmentItem: any) => shipmentItem.orderItemSeqId === item.orderItemSeqId) + order.items.map((item: any) => { + // fetching shipmentItemInformation for the current order item and then assigning the shipmentItemSeqId to item + const shipment = itemInformationByOrder[item.orderId]?.find((shipmentItem: any) => shipmentItem.orderItemSeqId === item.orderItemSeqId) - if(shipment) { - item.shipmentId = shipment.shipmentId - item.shipmentItemSeqId = shipment.shipmentItemSeqId - } + if (shipment) { + item.shipmentId = shipment.shipmentId + item.shipmentItemSeqId = shipment.shipmentItemSeqId + } - item.selectedBox = shipmentPackagesByOrderAndPicklistBin[`${item.orderId}_${item.picklistBinId}`]?.find((shipmentPackage: any) => shipmentPackage.shipmentId === item.shipmentId)?.packageName - }) + item.selectedBox = shipmentPackagesByOrderAndPicklistBin[`${item.orderId}_${item.picklistBinId}`]?.find((shipmentPackage: any) => shipmentPackage.shipmentId === item.shipmentId)?.packageName + }) - const orderItem = order.items[0]; - const carrierPartyIds = [...new Set(orderShipmentIds.map((id: any) => carrierPartyIdsByShipment[id]?.map((carrierParty: any) => carrierParty.carrierPartyId)).flat())]; + const orderItem = order.items[0]; + const carrierPartyIds = [...new Set(orderShipmentIds.map((id: any) => carrierPartyIdsByShipment[id]?.map((carrierParty: any) => carrierParty.carrierPartyId)).flat())]; - const shipmentBoxTypeByCarrierParty = carrierPartyIds.reduce((shipmentBoxType: any, carrierPartyId: any) => { - if(shipmentBoxType[carrierPartyId]) { - shipmentBoxType[carrierPartyId].push(carrierShipmentBoxType[carrierPartyId]) - } else { - shipmentBoxType[carrierPartyId] = carrierShipmentBoxType[carrierPartyId] - } + const shipmentBoxTypeByCarrierParty = carrierPartyIds.reduce((shipmentBoxType: any, carrierPartyId: any) => { + if (shipmentBoxType[carrierPartyId]) { + shipmentBoxType[carrierPartyId].push(carrierShipmentBoxType[carrierPartyId]) + } else { + shipmentBoxType[carrierPartyId] = carrierShipmentBoxType[carrierPartyId] + } - return shipmentBoxType - }, {}); + return shipmentBoxType + }, {}); - const shipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].map((shipmentPackage: any) => { - return { - ...shipmentPackage, - shipmentBoxTypes: shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] ? shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] : [] - } - }); + const shipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].map((shipmentPackage: any) => { + return { + ...shipmentPackage, + shipmentBoxTypes: shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] ? shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] : [] + } + }); - const currentShipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].reduce((currentShipmentPackages: any, shipment: any) => { - currentShipmentPackages.push(...orderShipmentPackages.filter((shipmentPackage: any) => shipmentPackage.shipmentId === shipment.shipmentId )); - return currentShipmentPackages; - }, []); + const currentShipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].reduce((currentShipmentPackages: any, shipment: any) => { + currentShipmentPackages.push(...orderShipmentPackages.filter((shipmentPackage: any) => shipmentPackage.shipmentId === shipment.shipmentId)); + return currentShipmentPackages; + }, []); - // When the shipment method for product store is configured then only check for shipmentPackages otherwise we won't show missing label error button - const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? currentShipmentPackages.length > 0 : false; + // When the shipment method for product store is configured then only check for shipmentPackages otherwise we won't show missing label error button + const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? currentShipmentPackages.length > 0 : false; + const kitProducts = prepareKitProducts(order) - return { - ...order, - shipmentIds: shipmentIdsForOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`], - shipmentPackages: shipmentPackages, - carrierPartyIds, - shipmentBoxTypeByCarrierParty: shipmentBoxTypeByCarrierParty, - missingLabelImage - } - }) + return { + ...order, + items: order.items.filter((item: any) => !isKitComponent(item)), + ...(!!(Object.keys(kitProducts)).length && { kitProducts }), + shipmentIds: shipmentIdsForOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`], + shipmentPackages: shipmentPackages, + carrierPartyIds, + shipmentBoxTypeByCarrierParty: shipmentBoxTypeByCarrierParty, + missingLabelImage + } + }) - this.dispatch('util/fetchShipmentBoxTypeDesc', [...new Set(Object.values(carrierShipmentBoxType).flat())]) - } catch(err) { + this.dispatch('util/fetchShipmentBoxTypeDesc', [...new Set(Object.values(carrierShipmentBoxType).flat())]) + } catch (err) { inProgressOrders = inProgressOrders.map((order: any) => { orderIds.includes(order.orderId) && (order.hasMissingInfo = true); return order; @@ -139,7 +142,7 @@ const actions: ActionTree = { } // updating the state with the updated orders information - commit(types.ORDER_INPROGRESS_UPDATED, {orders: inProgressOrders, total: state.inProgress.total}) + commit(types.ORDER_INPROGRESS_UPDATED, { orders: inProgressOrders, total: state.inProgress.total }) }, async fetchCompletedOrdersAdditionalInformation({ commit, state }) { @@ -212,9 +215,12 @@ const actions: ActionTree = { // If there is any shipment package with missing tracking code, retry shipping label const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? currentShipmentPackages.length > 0 : false; + const kitProducts = prepareKitProducts(order) return { ...order, + items: order.items.filter((item: any) => !isKitComponent(item)), + ...(!!(Object.keys(kitProducts)).length && { kitProducts }), shipments: orderShipments, missingLabelImage, trackingCode, @@ -371,6 +377,8 @@ const actions: ActionTree = { orders = orders.map((order: any) => { const orderItem = order.doclist.docs[0]; + const kitProducts = prepareKitProducts({ items: order.doclist.docs }) + return { category: 'open', customerId: orderItem.customerId, @@ -379,7 +387,8 @@ const actions: ActionTree = { orderDate: orderItem.orderDate, orderName: orderItem.orderName, groupValue: order.groupValue, - items: order.doclist.docs, + items: order.doclist.docs.filter((item: any) => !isKitComponent(item)), + ...(!!(Object.keys(kitProducts)).length && { kitProducts }), shipGroupSeqId: orderItem.shipGroupSeqId, shipmentMethodTypeId: orderItem.shipmentMethodTypeId, shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc, @@ -643,6 +652,11 @@ const actions: ActionTree = { resp = await OrderService.findOpenOrders(orderQueryPayload); if (!hasError(resp) && resp.data.grouped?.orderId.matches > 0) { const orderItem = resp.data.grouped.orderId.groups[0].doclist.docs[0]; + const kitProducts = prepareKitProducts({ items: resp.data.grouped.orderId.groups[0].doclist.docs }) + let productIds = resp.data.grouped.orderId.groups[0].doclist.docs.map((item: any) => item.productId) + if (Object.keys(kitProducts).length) { + productIds = [...productIds, ...Object.values(kitProducts).map((item: any) => item.parentProductId)] + } order = { category: 'open', customerId: orderItem.customerId, @@ -651,13 +665,15 @@ const actions: ActionTree = { orderDate: orderItem.orderDate, orderName: orderItem.orderName, groupValue: resp.data.grouped.orderId.groups[0].groupValue, - items: resp.data.grouped.orderId.groups[0].doclist.docs, + ...(!!(Object.keys(kitProducts)).length && { kitProducts }), + items: resp.data.grouped.orderId.groups[0].doclist.docs.filter((item: any) => !isKitComponent(item)), shipGroupSeqId: orderItem.shipGroupSeqId, shipmentMethodTypeId: orderItem.shipmentMethodTypeId, shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc, reservedDatetime: orderItem.reservedDatetime } - await this.dispatch('product/fetchProducts', { productIds: order.items.map((item: any) => item.productId) }) + + await this.dispatch('product/fetchProducts', { productIds }) } else { throw resp.data } @@ -907,12 +923,21 @@ const actions: ActionTree = { // If there is any shipment package with missing tracking code, retry shipping label const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? currentShipmentPackages.length > 0 : false; + const kitProducts = prepareKitProducts(current) + current = { ...current, + items: current.items.filter((item: any) => !isKitComponent(item)), + ...(!!(Object.keys(kitProducts)).length && { kitProducts }), shipments: orderShipments, missingLabelImage, shipmentPackages: currentShipmentPackages // ShipmentPackages information is required when performing retryShippingLabel action } + + if (Object.keys(kitProducts).length) { + const productIds = [...Object.values(kitProducts).map((item: any) => item.parentProductId)] + await this.dispatch('product/fetchProducts', { productIds }) + } } catch(err) { current.hasMissingPackageInfo = true; logger.error('Something went wrong', err) @@ -965,69 +990,76 @@ const actions: ActionTree = { const orderShipmentPackages = this.state.util.productStoreShipmentMethCount > 0 ? await OrderService.fetchShipmentPackages(orderShipmentIds) : []; - // if for an order shipment information is not available then returning the same order information again - if (!shipmentIdsForOrderAndPicklistBin[`${current.orderId}_${current.picklistBinId}`]) { - // if there are no shipment for the order, there is some issue with the order - if (picklistBinIds.includes(current.picklistBinId) && orderIds.includes(current.orderId)) { - current = { - ...current, - hasMissingInfo: true, - } - return + // if for an order shipment information is not available then returning the same order information again + if (!shipmentIdsForOrderAndPicklistBin[`${current.orderId}_${current.picklistBinId}`]) { + // if there are no shipment for the order, there is some issue with the order + if (picklistBinIds.includes(current.picklistBinId) && orderIds.includes(current.orderId)) { + current = { + ...current, + hasMissingInfo: true, } return } + return + } - current.items.map((item: any) => { - // fetching shipmentItemInformation for the current order item and then assigning the shipmentItemSeqId to item - const shipment = itemInformationByOrder[item.orderId]?.find((shipmentItem: any) => shipmentItem.orderItemSeqId === item.orderItemSeqId) + current.items.map((item: any) => { + // fetching shipmentItemInformation for the current order item and then assigning the shipmentItemSeqId to item + const shipment = itemInformationByOrder[item.orderId]?.find((shipmentItem: any) => shipmentItem.orderItemSeqId === item.orderItemSeqId) - if (shipment) { - item.shipmentId = shipment.shipmentId - item.shipmentItemSeqId = shipment.shipmentItemSeqId - } + if (shipment) { + item.shipmentId = shipment.shipmentId + item.shipmentItemSeqId = shipment.shipmentItemSeqId + } - item.selectedBox = shipmentPackagesByOrderAndPicklistBin[`${item.orderId}_${item.picklistBinId}`]?.find((shipmentPackage: any) => shipmentPackage.shipmentId === item.shipmentId)?.packageName - }) + item.selectedBox = shipmentPackagesByOrderAndPicklistBin[`${item.orderId}_${item.picklistBinId}`]?.find((shipmentPackage: any) => shipmentPackage.shipmentId === item.shipmentId)?.packageName + }) - const orderItem = current.items[0]; - const carrierPartyIdsOnOrderShipment = [...new Set(orderShipmentIds.map((id: any) => carrierPartyIdsByShipment[id]?.map((carrierParty: any) => carrierParty.carrierPartyId)).flat())]; + const orderItem = current.items[0]; + const carrierPartyIdsOnOrderShipment = [...new Set(orderShipmentIds.map((id: any) => carrierPartyIdsByShipment[id]?.map((carrierParty: any) => carrierParty.carrierPartyId)).flat())]; - const shipmentBoxTypeByCarrierParty = carrierPartyIdsOnOrderShipment.reduce((shipmentBoxType: any, carrierPartyId: any) => { - if (shipmentBoxType[carrierPartyId]) { - shipmentBoxType[carrierPartyId].push(carrierShipmentBoxType[carrierPartyId]) - } else { - shipmentBoxType[carrierPartyId] = carrierShipmentBoxType[carrierPartyId] - } + const shipmentBoxTypeByCarrierParty = carrierPartyIdsOnOrderShipment.reduce((shipmentBoxType: any, carrierPartyId: any) => { + if (shipmentBoxType[carrierPartyId]) { + shipmentBoxType[carrierPartyId].push(carrierShipmentBoxType[carrierPartyId]) + } else { + shipmentBoxType[carrierPartyId] = carrierShipmentBoxType[carrierPartyId] + } - return shipmentBoxType - }, {}); + return shipmentBoxType + }, {}); - const shipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].map((shipmentPackage: any) => { - return { - ...shipmentPackage, - shipmentBoxTypes: shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] ? shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] : [] - } - }); + const shipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].map((shipmentPackage: any) => { + return { + ...shipmentPackage, + shipmentBoxTypes: shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] ? shipmentBoxTypeByCarrierParty[shipmentPackage.carrierPartyId] : [] + } + }); - const currentShipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].reduce((currentShipmentPackages: any, shipment: any) => { - currentShipmentPackages.push(...orderShipmentPackages.filter((shipmentPackage: any) => shipmentPackage.shipmentId === shipment.shipmentId )); - return currentShipmentPackages; - }, []); + const currentShipmentPackages = shipmentPackagesByOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`].reduce((currentShipmentPackages: any, shipment: any) => { + currentShipmentPackages.push(...orderShipmentPackages.filter((shipmentPackage: any) => shipmentPackage.shipmentId === shipment.shipmentId)); + return currentShipmentPackages; + }, []); - // When the shipment method for product store is configured then only check for shipmentPackages otherwise we won't show missing label error button - const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? currentShipmentPackages.length > 0 : false; + // When the shipment method for product store is configured then only check for shipmentPackages otherwise we won't show missing label error button + const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? currentShipmentPackages.length > 0 : false; + const kitProducts = prepareKitProducts(current) - current = { - ...current, - shipmentIds: shipmentIdsForOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`], - shipmentPackages: shipmentPackages, - carrierPartyIdsOnOrderShipment, - shipmentBoxTypeByCarrierParty: shipmentBoxTypeByCarrierParty, - missingLabelImage - } + current = { + ...current, + items: current.items.filter((item: any) => !isKitComponent(item)), + ...(!!(Object.keys(kitProducts)).length && { kitProducts }), + shipmentIds: shipmentIdsForOrderAndPicklistBin[`${orderItem.orderId}_${orderItem.picklistBinId}`], + shipmentPackages: shipmentPackages, + carrierPartyIdsOnOrderShipment, + shipmentBoxTypeByCarrierParty: shipmentBoxTypeByCarrierParty, + missingLabelImage + } + if (Object.keys(kitProducts).length) { + const productIds = [...Object.values(kitProducts).map((item: any) => item.parentProductId)] + await this.dispatch('product/fetchProducts', { productIds }) + } this.dispatch('util/fetchShipmentBoxTypeDesc', [...new Set(Object.values(carrierShipmentBoxType).flat())]) } catch (err) { current.hasMissingPackageInfo = true; diff --git a/src/store/modules/product/actions.ts b/src/store/modules/product/actions.ts index 7382c692..54254dbc 100644 --- a/src/store/modules/product/actions.ts +++ b/src/store/modules/product/actions.ts @@ -5,6 +5,7 @@ import ProductState from './ProductState' import * as types from './mutation-types' import { hasError } from '@/adapter' import logger from "@/logger"; +import { isKitComponent } from "@/utils/order"; const actions: ActionTree = { @@ -48,7 +49,10 @@ const actions: ActionTree = { let productIds: any = new Set(); orders.forEach((list: any) => { list.doclist.docs.forEach((order: any) => { - if (order.productId) productIds.add(order.productId) + if (order.productId) { + productIds.add(order.productId) + !isKitComponent(order) && productIds.add(order.parentProductId) + } }) }) diff --git a/src/utils/order.ts b/src/utils/order.ts index a26fd7a9..8dd6c25f 100644 --- a/src/utils/order.ts +++ b/src/utils/order.ts @@ -79,7 +79,31 @@ const getOrderCategory = (order: any) => { return result; } +const isKitComponent = (item: any) => { + return item.toOrderItemAssocs?.some((assoc: any) => assoc.split("/")[0] === 'KIT_COMPONENT') +} + +const prepareKitProducts = (order: any) => { + return order.items.reduce((kitProducts: any, item: any) => { + if (item.toOrderItemAssocs && isKitComponent(item)) { + // getting second and third values i.e kit product's orderItemSeqId and parentProductId + const [, orderItemSeqId, parentProductId] = item.toOrderItemAssocs[0].split('/') + if (!kitProducts[orderItemSeqId]) { + kitProducts[orderItemSeqId] = [] + } + + kitProducts[orderItemSeqId].push({ + parentProductId, + ...item + }) + } + + return kitProducts + }, {}) +} export { - getOrderCategory + prepareKitProducts, + getOrderCategory, + isKitComponent } \ No newline at end of file diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 5781cdb6..6a48850d 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -81,8 +81,6 @@ - - +
+
+ +
+ +

{{ getProduct(kitProduct[0].parentProductId).productName }}

+

{{ getProduct(kitProduct[0].parentProductId).sku }}

+
+
+
+ +
+
+ + + + + +

{{ item.productSku }}

+ {{ item.productName }} +

{{ getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/')}} {{ getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/')}}

+
+
+
+ + +
+
+
+
@@ -153,6 +186,7 @@ import { IonInfiniteScroll, IonInfiniteScrollContent, IonItem, + IonItemDivider, IonLabel, IonMenuButton, IonNote, @@ -202,6 +236,7 @@ export default defineComponent({ IonInfiniteScroll, IonInfiniteScrollContent, IonItem, + IonItemDivider, IonLabel, IonMenuButton, IonNote, @@ -255,7 +290,7 @@ export default defineComponent({ }) }, getCompletedOrders() { - return this.completedOrders.list.slice(0, (this.completedOrders.query.viewIndex + 1) * (process.env.VUE_APP_VIEW_SIZE as any) ); + return JSON.parse(JSON.stringify(this.completedOrders.list)).slice(0, (this.completedOrders.query.viewIndex + 1) * (process.env.VUE_APP_VIEW_SIZE as any)); }, async loadMoreCompletedOrders(event: any) { const completedOrdersQuery = JSON.parse(JSON.stringify(this.completedOrders.query)) diff --git a/src/views/InProgress.vue b/src/views/InProgress.vue index 3011e803..287f2b06 100644 --- a/src/views/InProgress.vue +++ b/src/views/InProgress.vue @@ -45,7 +45,6 @@
{{ translate("Pack orders") }} -
@@ -85,7 +84,7 @@
-
+
@@ -110,6 +109,7 @@
+
@@ -149,6 +149,55 @@
+
+
+ +
+ +

{{ getProduct(kitProduct[0].parentProductId).productName }}

+

{{ getProduct(kitProduct[0].parentProductId).sku }}

+
+
+ +
+ + + {{ `Box ${kitProduct[0].selectedBox}` }} + + +
+ + +
+ +
+
+ + + + + +

{{ item.productSku }}

+ {{ item.productName }} +

{{ getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/')}} {{ getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/')}}

+
+
+
+ + +
+
+
+
{{ translate("Pack using default packaging") }} @@ -220,6 +269,7 @@ import { IonFooter, IonHeader, IonItem, + IonItemDivider, IonIcon, IonInfiniteScroll, IonInfiniteScrollContent, @@ -251,6 +301,7 @@ import { checkmarkDoneOutline, cubeOutline, ellipsisVerticalOutline, + fileTrayOutline, pencilOutline, optionsOutline, pricetagOutline, @@ -276,6 +327,8 @@ import EditPickersModal from '@/components/EditPickersModal.vue'; import ShipmentBoxTypePopover from '@/components/ShipmentBoxTypePopover.vue' import OrderActionsPopover from '@/components/OrderActionsPopover.vue' import ShippingLabelErrorModal from '@/components/ShippingLabelErrorModal.vue' +import ReportIssuePopover from '@/components/ReportIssuePopover.vue' +import ShipmentBoxPopover from '@/components/ShipmentBoxPopover.vue' import QRCodeModal from '@/components/QRCodeModal.vue' import { useAuthStore } from '@hotwax/dxp-components' @@ -292,6 +345,7 @@ export default defineComponent({ IonFooter, IonHeader, IonItem, + IonItemDivider, IonIcon, IonInfiniteScroll, IonInfiniteScrollContent, @@ -339,11 +393,67 @@ export default defineComponent({ } }, methods: { + async openRejectReasonPopover(ev: Event, kitProducts: any, order: any) { + const reportIssuePopover = await popoverController.create({ + component: ReportIssuePopover, + event: ev, + translucent: true, + showBackdrop: false, + }); + + reportIssuePopover.present(); + + const result = await reportIssuePopover.onDidDismiss(); + + if (result.data) { + // reject kit products in bulk + const itemsToReject = kitProducts.map((item: any) => ({ ...item, rejectReason: result.data })) + this.reportIssue(order, itemsToReject) + } + }, + async openShipmentBoxPopover(ev: Event, kitProducts: any, orderItemSeqId: number, order: any) { + const popover = await popoverController.create({ + component: ShipmentBoxPopover, + componentProps: { + shipmentPackages: order.shipmentPackages + }, + showBackdrop: false, + event: ev + }); + + popover.present(); + + const result = await popover.onDidDismiss(); + + if (result.data && kitProducts[0].selectedBox !== result.data) { + this.confirmUpdateBox(kitProducts, orderItemSeqId, order, result.data) + } + }, + async confirmUpdateBox(kitProducts: any, orderItemSeqId: number, order: any, selectedBox: string) { + const alert = await alertController.create({ + message: translate("Are you sure you want to update box selection?"), + header: translate("Update box selection?"), + buttons: [ + { + text: translate("Cancel"), + role: 'cancel' + }, + { + text: translate("Confirm"), + handler: async () => { + order.kitProducts[orderItemSeqId] = kitProducts.map((item: any) => ({ ...item, selectedBox })) + await this.updateOrder(order, 'box-selection') + } + } + ], + }); + return alert.present(); + }, getErrorMessage() { return this.searchedQuery === '' ? translate("doesn't have any orders in progress right now.", { facilityName: this.currentFacility.facilityName }) : translate( "No results found for . Try searching Open or Completed tab instead. If you still can't find what you're looking for, try switching stores.", { searchedQuery: this.searchedQuery, lineBreak: '
' }) }, getInProgressOrders() { - return JSON.parse(JSON.stringify(this.inProgressOrders.list)).splice(0, (this.inProgressOrders.query.viewIndex + 1) * (process.env.VUE_APP_VIEW_SIZE as any) ); + return JSON.parse(JSON.stringify(this.inProgressOrders.list)).splice(0, (this.inProgressOrders.query.viewIndex + 1) * (process.env.VUE_APP_VIEW_SIZE as any)); }, isIssueSegmentSelectedForItem(item: any) { return this.itemsIssueSegmentSelected.includes(`${item.orderId}-${item.orderItemSeqId}`) @@ -608,7 +718,7 @@ export default defineComponent({ this.itemsIssueSegmentSelected = [] await this.store.dispatch('order/findInProgressOrders') }, - async updateOrder(order: any) { + async updateOrder(order: any, updateParameter?: string) { const form = new FormData() form.append('facilityId', this.currentFacility.facilityId) @@ -632,10 +742,10 @@ export default defineComponent({ const shipmentPackage = order.shipmentPackages.find((shipmentPackage: any) => shipmentPackage.packageName === item.selectedBox) let prefix = 'rtp' - if(this.isIssueSegmentSelectedForItem(item)) { + if(this.isIssueSegmentSelectedForItem(item) || updateParameter === 'report') { prefix = 'rej' form.append(`${prefix}_rejectionReason_${index}`, item.rejectReason) - } else { + } else if (!this.isIssueSegmentSelectedForItem(item) || updateParameter === 'box-selection') { form.append(`${prefix}_newShipmentId_${index}`, shipmentPackage.shipmentId) } @@ -1062,6 +1172,7 @@ export default defineComponent({ printOutline, pencilOutline, ellipsisVerticalOutline, + fileTrayOutline, optionsOutline, formatUtcDate, getFeature, diff --git a/src/views/OpenOrders.vue b/src/views/OpenOrders.vue index c74a4e03..d6474b12 100644 --- a/src/views/OpenOrders.vue +++ b/src/views/OpenOrders.vue @@ -60,31 +60,61 @@
-
-
-
- - - - +
+
+ + + + + +

{{ item.productSku }}

+ {{ item.virtualProductName }} +

{{ getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/')}} {{ getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/')}}

+
+
+
+ +
+ +
+
+ +
-

{{ item.productSku }}

- {{ item.virtualProductName }} -

{{ getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/')}} {{ getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/')}}

+

{{ getProduct(kitProduct[0].parentProductId).productName }}

+

{{ getProduct(kitProduct[0].parentProductId).sku }}

- -
+
+ - -
-