diff --git a/src/services/OrderService.ts b/src/services/OrderService.ts index 9ffbf623..5c0d5ce1 100644 --- a/src/services/OrderService.ts +++ b/src/services/OrderService.ts @@ -339,6 +339,14 @@ const fetchTrackingCodes = async (shipmentIds: Array): Promise => { return shipmentTrackingCodes; } +const packOrder = async (payload: any): Promise => { + return api({ + url: "/service/packStoreFulfillmentOrder", + method: "post", + data: payload + }) +} + export const OrderService = { fetchOrderItems, fetchOrderPaymentPreferences, @@ -359,6 +367,7 @@ export const OrderService = { getShipmentItems, getCustomerContactDetails, getShippingPhoneNumber, + packOrder, printPicklist, printShippingLabelAndPackingSlip } \ No newline at end of file diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 31da8e2b..ba085ec4 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -172,7 +172,8 @@ const actions: ActionTree ={ shippingInstructions: orderItem.shippingInstructions, shipGroupSeqId: orderItem.shipGroupSeqId, isPicked: orderItem.isPicked, - picklistId: orderItem.picklistId + picklistId: orderItem.picklistId, + picklistBinId: orderItem.picklistBinId } }) @@ -592,7 +593,7 @@ const actions: ActionTree ={ const shipmentMethodTypeId = payload.part?.shipmentMethodEnum?.shipmentMethodEnumId if (shipmentMethodTypeId !== 'STOREPICKUP') { // TODO: find a better way to get the shipmentId - const shipmentId = resp.data._EVENT_MESSAGE_.match(/\d+/g)[0] + const shipmentId = resp.data.shipmentId ? resp.data.shipmentId : resp.data._EVENT_MESSAGE_.match(/\d+/g)[0] await dispatch('packDeliveryItems', shipmentId).then((data) => { if (!hasError(data) && !data.data._EVENT_MESSAGE_) { showToast(translate("Something went wrong")) diff --git a/src/views/Orders.vue b/src/views/Orders.vue index 174e1c57..c8eaadde 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -72,7 +72,7 @@ {{ order.part.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP' ? translate("Ready for pickup") : translate("Ready to ship") }}
- + @@ -407,12 +407,43 @@ export default defineComponent({ },{ text: header, handler: () => { - this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility.facilityId}) + if(!pickup) { + this.packShippingOrders(order, part); + } else { + this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility.facilityId}) + } } }] }); return alert.present(); }, + async packShippingOrders(currenOrder: any, part: any) { + try { + const resp = await OrderService.packOrder({ + 'picklistBinId': currenOrder.picklistBinId, + 'orderId': currenOrder.orderId + }) + + if(!hasError(resp)) { + showToast(translate("Order packed and ready for delivery")); + const orders = JSON.parse(JSON.stringify(this.orders)); + const orderIndex = orders.findIndex((order: any) => { + return order.orderId === currenOrder.orderId && order.parts.some((part: any) => { + return part.orderPartSeqId === part.orderPartSeqId; + }); + }); + if (orderIndex > -1) { + orders.splice(orderIndex, 1); + this.store.dispatch("order/updateOpenOrder", { orders, total: orders.length }) + } + } else { + throw resp.data; + } + } catch(error: any) { + logger.error(error); + showToast(translate("Something went wrong")) + } + }, async deliverShipment (order: any) { await this.store.dispatch('order/deliverShipment', order) .then((resp) => { @@ -535,6 +566,7 @@ export default defineComponent({ const updatedOrder = orders.find((currentOrder: any) => currentOrder.orderId === order.orderId); updatedOrder["isPicked"] = "Y" updatedOrder["picklistId"] = resp.data.picklistId + updatedOrder["picklistBinId"] = resp.data.picklistBinId this.store.dispatch("order/updateOpenOrder", { orders, total: orders.length }) } else { throw resp.data;