diff --git a/src/locales/en.json b/src/locales/en.json index 3726e597..fb247111 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -23,6 +23,7 @@ "Assigned to": "Assigned to", "Authenticating": "Authenticating", "Back to Launchpad": "Back to Launchpad", + "Barcode Identifier": "Barcode Identifier", "Before": "Before", "Browser TimeZone": "Browser TimeZone", "Browser time zone": "Browser time zone", @@ -200,6 +201,7 @@ "REJECTED": "REJECTED", "Rejected": "Rejected", "rejected": "rejected", + "Require inventory to be scanned when counting instead of manually entering values. If the identifier is not found, the scan will default to using the internal name.": "Require inventory to be scanned when counting instead of manually entering values.{space} If the identifier is not found, the scan will default to using the internal name.", "Required": "Required", "Recount requested": "Recount requested", "Rename": "Rename", @@ -209,7 +211,6 @@ "Review count": "Review count", "rejected counts": "rejected counts", "Require barcode scanning": "Require barcode scanning", - "Require inventory to be scanned when counting instead of manually entering values.": "Require inventory to be scanned when counting instead of manually entering values.", "Save": "Save", "Save count": "Save count", "Save re-count": "Save re-count", @@ -222,7 +223,7 @@ "Scan items": "Scan items", "Scanned item does not match current product": "Scanned item does not match current product", "Scan or search products": "Scan or search products", - "Scan a valid product sku": "Scan a valid product sku", + "Scan a valid product barcode identifier": "Scan a valid product barcode identifier", "Scanned quantity": "Scanned quantity", "selected": "selected", "Select": "Select", diff --git a/src/store/index.ts b/src/store/index.ts index 99961a17..888039f2 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -17,7 +17,7 @@ import { setPermissions } from "@/authorization" const state: any = {} const persistState = createPersistedState({ - paths: ["user"], + paths: ["user", "product.cached"], fetchBeforeUse: true }) diff --git a/src/store/modules/product/actions.ts b/src/store/modules/product/actions.ts index be86ac2e..e14a1c17 100644 --- a/src/store/modules/product/actions.ts +++ b/src/store/modules/product/actions.ts @@ -72,6 +72,10 @@ const actions: ActionTree = { async clearProducts({ commit }) { commit(types.PRODUCT_LIST_UPDATED, { products: [], total: 0 }); + }, + + async clearCachedProducts({ commit }) { + commit(types.PRODUCT_CACHED_CLEARED); } } diff --git a/src/store/modules/product/mutation-types.ts b/src/store/modules/product/mutation-types.ts index afe2e46a..ac08b68b 100644 --- a/src/store/modules/product/mutation-types.ts +++ b/src/store/modules/product/mutation-types.ts @@ -3,3 +3,4 @@ export const PRODUCT_ADD_TO_CACHED = SN_PRODUCT + '/ADD_TO_CACHED' export const PRODUCT_CURRENT_UPDATED = SN_PRODUCT + '/CURRENT_UPDATED' export const PRODUCT_ADD_TO_CACHED_MULTIPLE = SN_PRODUCT + '/ADD_TO_CACHED_MULTIPLE' export const PRODUCT_LIST_UPDATED = SN_PRODUCT + '/LIST_UPDATED' +export const PRODUCT_CACHED_CLEARED = SN_PRODUCT + '/CACHED_CLEARED' diff --git a/src/store/modules/product/mutations.ts b/src/store/modules/product/mutations.ts index 08a692c7..d2f07837 100644 --- a/src/store/modules/product/mutations.ts +++ b/src/store/modules/product/mutations.ts @@ -23,6 +23,9 @@ const mutations: MutationTree = { [types.PRODUCT_LIST_UPDATED](state, payload) { state.list.items = payload.products state.list.total = payload.total - } + }, + [types.PRODUCT_CACHED_CLEARED] (state) { + state.cached = {} + }, } export default mutations; \ No newline at end of file diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index 35de61ea..e8132d45 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -24,7 +24,8 @@ export default interface UserState { productIdentificationPref: { primaryId: string, secondaryId: string - } + }, + barcodeIdentificationPref: string; }, goodIdentificationTypes: Array; } \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 45715d50..d80c990e 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -102,7 +102,7 @@ const actions: ActionTree = { commit(types.USER_FACILITIES_UPDATED, []) commit(types.USER_CURRENT_FACILITY_UPDATED, {}) commit(types.USER_PRODUCT_STORES_UPDATED, []) - commit(types.USER_PRODUCT_STORE_SETTING_UPDATED, { showQoh: false, forceScan: false, productIdentificationPref: { + commit(types.USER_PRODUCT_STORE_SETTING_UPDATED, { showQoh: false, forceScan: false, barcodeIdentificationPref: "internalName", productIdentificationPref: { primaryId: 'productId', secondaryId: '' }}) @@ -264,14 +264,17 @@ const actions: ActionTree = { async updateCurrentProductStore({ commit, dispatch }, productStore) { commit(types.USER_CURRENT_PRODUCT_STORE_UPDATED, productStore) - commit(types.USER_PRODUCT_STORE_SETTING_UPDATED, { showQoh: false, forceScan: false }) + commit(types.USER_PRODUCT_STORE_SETTING_UPDATED, { showQoh: false, forceScan: false, barcodeIdentificationPref: "internalName", productIdentificationPref: { + primaryId: 'productId', + secondaryId: '' + } }) dispatch("getProductStoreSetting") }, async getProductStoreSetting({ commit, state }, productStoreId?: string) { const payload = { "productStoreId": productStoreId ? productStoreId : state.currentProductStore.productStoreId, - "settingTypeEnumId": "INV_CNT_VIEW_QOH,INV_FORCE_SCAN,PRDT_IDEN_PREF", + "settingTypeEnumId": "INV_CNT_VIEW_QOH,INV_FORCE_SCAN,PRDT_IDEN_PREF,BARCODE_IDEN_PREF", "settingTypeEnumId_op": "in", "pageSize": 10 } @@ -291,10 +294,15 @@ const actions: ActionTree = { if(setting.settingTypeEnumId === "PRDT_IDEN_PREF" && setting.settingValue) { settings["productIdentificationPref"] = JSON.parse(setting.settingValue) } + + if(setting.settingTypeEnumId === "BARCODE_IDEN_PREF" && setting.settingValue) { + settings["barcodeIdentificationPref"] = setting.settingValue + } return settings }, { showQoh: false, - forceScan: false + forceScan: false, + barcodeIdentificationPref: "internalName" }) commit(types.USER_PRODUCT_STORE_SETTING_UPDATED, settings) } @@ -307,11 +315,18 @@ const actions: ActionTree = { const eComStoreId = state.currentProductStore.productStoreId; const fromDate = Date.now() + let settingValue = false as any; + if(payload.enumId === "BARCODE_IDEN_PREF") settingValue = "internalName" + if(payload.enumId === "PRDT_IDEN_PREF") settingValue = JSON.stringify({ + primaryId: 'productId', + secondaryId: '' + }) + const params = { fromDate, "productStoreId": eComStoreId, "settingTypeEnumId": payload.enumId, - "settingValue": false + settingValue } try { @@ -322,7 +337,7 @@ const actions: ActionTree = { // not checking for resp success and fail case as every time we need to update the state with the // default value when creating a scan setting - commit(types.USER_PRODUCT_STORE_SETTING_UPDATED, { [payload.key]: false }) + commit(types.USER_PRODUCT_STORE_SETTING_UPDATED, { [payload.key]: settingValue }) return fromDate; }, @@ -344,6 +359,10 @@ const actions: ActionTree = { enumId = "PRDT_IDEN_PREF" } + if(payload.key === "barcodeIdentificationPref") { + enumId = "BARCODE_IDEN_PREF" + } + let fromDate; try { @@ -366,7 +385,7 @@ const actions: ActionTree = { "fromDate": fromDate, "productStoreId": eComStoreId, "settingTypeEnumId": enumId, - "settingValue": JSON.stringify(payload.value) + "settingValue": payload.key !== "barcodeIdentificationPref" ? JSON.stringify(payload.value) : payload.value } try { diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 94535e84..117f5882 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -34,6 +34,7 @@ const userModule: Module = { primaryId: 'productId', secondaryId: '' }, + barcodeIdentificationPref: "" }, goodIdentificationTypes: [] }, diff --git a/src/views/CountDetail.vue b/src/views/CountDetail.vue index be6e7baa..0fe71473 100644 --- a/src/views/CountDetail.vue +++ b/src/views/CountDetail.vue @@ -354,28 +354,20 @@ function handleBlur() { async function handleInput(event) { if (!isInputFocused.value) return; - let sku = event.target.value; - if(!sku) { - showToast(translate("Scan a valid product sku")); + let scannedValue = event.target.value; + if(!scannedValue) { + showToast(translate("Scan a valid product barcode identifier")); return; } const cachedProducts = getCachedProducts.value; - let scannedItemId = Object.keys(cachedProducts).find(productId => cachedProducts[productId].sku === sku); - if (!scannedItemId) { - const product = await findProduct(sku); - if(product) { - scannedItemId = product.data.response?.docs[0]?.productId - } - } - if (scannedItemId) { - if (scannedItemId === product.value.productId) { - inputCount.value++; - } else { - showToast(translate('Scanned item does not match current product')); - } - } else { - showToast(translate('Product not found')); + const barcodeIdentifer = productStoreSettings.value["barcodeIdentificationPref"]; + + const itemVal = getProductIdentificationValue(barcodeIdentifer, cachedProducts[product.value.productId]) ? getProductIdentificationValue(barcodeIdentifer, cachedProducts[product.value.productId]) : cachedProducts[product.value.productId]?.internalName + if(itemVal && itemVal === scannedValue) { + inputCount.value++; + } else { + showToast(translate('Scanned item does not match current product')); } scannedCount.value = '' } diff --git a/src/views/StorePermissions.vue b/src/views/StorePermissions.vue index 3f4959c0..0f202619 100644 --- a/src/views/StorePermissions.vue +++ b/src/views/StorePermissions.vue @@ -29,14 +29,17 @@ {{ translate('Force scan') }} - -

{{ translate("Require inventory to be scanned when counting instead of manually entering values.") }}

-
+ {{ translate("Require barcode scanning") }} + + + {{ identification }} + + @@ -53,6 +56,8 @@ import { IonHeader, IonItem, IonPage, + IonSelect, + IonSelectOption, IonTitle, IonToggle, IonToolbar, @@ -62,7 +67,9 @@ import { translate } from '@/i18n' import store from "@/store"; import { computed } from "vue"; +const barcodeContentMessage = translate("Require inventory to be scanned when counting instead of manually entering values. If the identifier is not found, the scan will default to using the internal name.", { space: '

' }) const productStoreSettings = computed(() => store.getters["user/getProductStoreSettings"]) +const productIdentifications = computed(() => store.getters["user/getGoodIdentificationTypes"]) onIonViewWillEnter(async () => { await store.dispatch("user/getProductStoreSetting") @@ -72,6 +79,10 @@ function updateProductStoreSetting(event: any, key: string) { event.stopImmediatePropagation(); store.dispatch("user/setProductStoreSetting", { key, value: !productStoreSettings.value[key] }) } + +function setBarcodeIdentificationPref(value: any) { + store.dispatch("user/setProductStoreSetting", { key: "barcodeIdentificationPref", value }) +}