diff --git a/src/store/modules/count/actions.ts b/src/store/modules/count/actions.ts index 3e884a05..3f5680c4 100644 --- a/src/store/modules/count/actions.ts +++ b/src/store/modules/count/actions.ts @@ -212,9 +212,8 @@ const actions: ActionTree = { }, async fetchCycleCountItems({commit, state} ,payload) { - const cachedProducts = state.cachedUnmatchProducts[payload.inventoryCountImportId]?.length ? JSON.parse(JSON.stringify(state.cachedUnmatchProducts[payload.inventoryCountImportId])) : []; let items = [] as any, resp, pageIndex = 0; - + try { do { resp = await CountService.fetchCycleCountItems({ ...payload, pageSize: 100, pageIndex }) @@ -232,7 +231,10 @@ const actions: ActionTree = { if(payload.isSortingRequired) items = sortListByField(items, "parentProductName"); this.dispatch("product/fetchProducts", { productIds: [...new Set(items.map((item: any) => item.productId))] }) - if(cachedProducts?.length) items = items.concat(cachedProducts) + if(payload.isHardCount) { + const cachedProducts = state.cachedUnmatchProducts[payload.inventoryCountImportId]?.length ? JSON.parse(JSON.stringify(state.cachedUnmatchProducts[payload.inventoryCountImportId])) : []; + if(cachedProducts?.length) items = items.concat(cachedProducts) + } commit(types.COUNT_ITEMS_UPDATED, { itemList: items }) }, diff --git a/src/views/HardCountDetail.vue b/src/views/HardCountDetail.vue index fc63327b..e4b1d6c5 100644 --- a/src/views/HardCountDetail.vue +++ b/src/views/HardCountDetail.vue @@ -258,11 +258,12 @@ const isScrolling = ref(false); let isScanningInProgress = ref(false); const scrollingContainerRef = ref(); const isScrollingAnimationEnabled = computed(() => store.getters["user/isScrollingAnimationEnabled"]) +const isSubmittingForReview = ref(false); onIonViewDidEnter(async() => { emitter.emit("presentLoader"); - await Promise.allSettled([fetchCycleCount(), await store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id, isSortingRequired: false }), store.dispatch("user/getProductStoreSetting", currentFacility.value?.productStore?.productStoreId)]) + await Promise.allSettled([fetchCycleCount(), await store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id, isSortingRequired: false, isHardCount: true }), store.dispatch("user/getProductStoreSetting", currentFacility.value?.productStore?.productStoreId)]) previousItem = itemsList.value[0]; await store.dispatch("product/currentProduct", itemsList.value?.length ? itemsList.value[0] : {}) barcodeInputRef.value?.$el?.setFocus(); @@ -307,7 +308,10 @@ async function handleBeforeUnload() { if(Object.keys(unmatchedItem)?.length) unmatchedProducts.push(unmatchedItem) }) - store.dispatch("count/updateCachedUnmatchProducts", { id: cycleCount.value.inventoryCountImportId, unmatchedProducts }); + if(!isSubmittingForReview.value && unmatchedProducts?.length) { + store.dispatch("count/updateCachedUnmatchProducts", { id: cycleCount.value.inventoryCountImportId, unmatchedProducts }); + } + isSubmittingForReview.value = false } function handleProductClick(item: any) { @@ -573,6 +577,7 @@ async function readyForReview() { inventoryCountImportId: props?.id, statusId: "INV_COUNT_REVIEW" }) + isSubmittingForReview.value = true; router.push("/tabs/count") store.dispatch('count/clearCurrentCountFromCachedUnmatchProducts', props.id); showToast(translate("Count has been submitted for review"))