diff --git a/src/views/InProgress.vue b/src/views/InProgress.vue index b49163d6..a729d80a 100644 --- a/src/views/InProgress.vue +++ b/src/views/InProgress.vue @@ -10,6 +10,9 @@ {{ inProgressOrders.query.viewSize }} {{ $t('of') }} {{ inProgressOrders.total }} {{ $t('orders') }} + + {{ $t("Recycle all in progress orders") }} + @@ -208,6 +211,8 @@ import { prepareOrderQuery } from '@/utils/solrHelper'; import { UtilService } from '@/services/UtilService'; import { DateTime } from 'luxon'; import logger from '@/logger'; +import { UserService } from '@/services/UserService'; +import { Actions, hasPermission } from '@/authorization' export default defineComponent({ name: 'InProgress', @@ -820,6 +825,40 @@ export default defineComponent({ picklist.isGeneratingPicklist = true; await OrderService.printPicklist(picklist.id) picklist.isGeneratingPicklist = false; + }, + async recycleInProgressOrders() { + const alert = await alertController.create({ + header: translate('Recycle in progress orders'), + message: this.$t('Are you sure you want to recycle in progress order(s)?', { ordersCount: this.inProgressOrders.total }), + buttons: [{ + text: translate('No'), + role: 'cancel' + }, { + text: translate('Yes'), + handler: async () => { + let resp; + + try { + resp = await UserService.recycleInProgressOrders({ + "facilityId": this.currentFacility.facilityId, + "productStoreId": this.currentEComStore.productStoreId, + "reasonId": "INACTIVE_STORE" + }) + + if(!hasError(resp)) { + showToast(translate('Recycling has been started. All in progress orders will be recycled shortly.')) + } else { + throw resp.data + } + } catch(err) { + showToast(translate('Failed to recycle in progress orders')) + logger.error('Failed to recycle in progress orders', err) + } + } + }] + }); + + await alert.present(); } }, async mounted () { @@ -835,6 +874,7 @@ export default defineComponent({ const store = useStore(); return { + Actions, copyToClipboard, addOutline, printOutline, @@ -842,6 +882,7 @@ export default defineComponent({ optionsOutline, formatUtcDate, getFeature, + hasPermission, checkmarkDoneOutline, pricetagOutline, store diff --git a/src/views/OpenOrders.vue b/src/views/OpenOrders.vue index e2afb1e3..bb2ced71 100644 --- a/src/views/OpenOrders.vue +++ b/src/views/OpenOrders.vue @@ -9,6 +9,9 @@ {{ openOrders.query.viewSize }} {{ $t('of') }} {{ openOrders.total }} {{ $t('orders') }} + + {{ $t("Recycle all open orders") }} + @@ -123,19 +126,24 @@ import { IonThumbnail, IonTitle, IonToolbar, - modalController } from '@ionic/vue'; + modalController, + alertController +} from '@ionic/vue'; import { defineComponent } from 'vue'; import { optionsOutline, pricetagOutline, printOutline, refreshCircleOutline } from 'ionicons/icons'; import AssignPickerModal from '@/views/AssignPickerModal.vue'; import { mapGetters, useStore } from 'vuex'; import Image from '@/components/Image.vue' -import { copyToClipboard, formatUtcDate, getFeature } from '@/utils' +import { copyToClipboard, formatUtcDate, getFeature, showToast } from '@/utils' import { hasError } from '@/adapter'; import { UtilService } from '@/services/UtilService'; import { prepareOrderQuery } from '@/utils/solrHelper'; import ViewSizeSelector from '@/components/ViewSizeSelector.vue' import emitter from '@/event-bus'; import logger from '@/logger'; +import { translate } from '@/i18n'; +import { UserService } from '@/services/UserService'; +import { Actions, hasPermission } from '@/authorization' export default defineComponent({ name: 'OpenOrders', @@ -280,6 +288,39 @@ export default defineComponent({ openOrdersQuery.viewSize = process.env.VUE_APP_VIEW_SIZE await this.store.dispatch('order/updateOpenQuery', { ...openOrdersQuery }) }, + async recycleOutstandingOrders() { + const alert = await alertController.create({ + header: translate('Recycle outstanding orders'), + message: this.$t('Are you sure you want to recycle outstanding order(s)?', { ordersCount: this.openOrders.total }), + buttons: [{ + text: translate('No'), + role: 'cancel' + }, { + text: translate('Yes'), + handler: async () => { + let resp; + + try { + resp = await UserService.recycleOutstandingOrders({ + "facilityId": this.currentFacility.facilityId, + "productStoreId": this.currentEComStore.productStoreId, + "reasonId": "INACTIVE_STORE" + }) + + if (!hasError(resp)) { + showToast(translate('Recycling has been started. All outstanding orders will be recycled shortly.')) + } else { + throw resp.data + } + } catch (err) { + showToast(translate('Failed to recycle outstanding orders')) + logger.error('Failed to recycle outstanding orders', err) + } + } + }] + }); + await alert.present(); + }, }, async mounted () { emitter.on('updateOrderQuery', this.updateOrderQuery) @@ -293,9 +334,11 @@ export default defineComponent({ const store = useStore(); return{ + Actions, copyToClipboard, formatUtcDate, getFeature, + hasPermission, optionsOutline, pricetagOutline, printOutline, diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 0358d936..2616bb19 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -52,11 +52,6 @@ {{ $t("has outstanding orders and in progress orders.", {storeName: currentFacility.name, outstandingOrdersCount, inProgressOrdersCount}) }}
-
- {{ $t("Recycle all open orders") }} - {{ $t("Recycle all in progress orders") }} - -
{{ $t("Turn off fulfillment") }} {{ $t("Turn on fulfillment") }} @@ -137,9 +132,7 @@ export default defineComponent({ data() { return { baseURL: process.env.VUE_APP_BASE_URL, - currentFacilityDetails: {} as any, - outstandingOrdersCount: 0, - inProgressOrdersCount: 0 + currentFacilityDetails: {} as any }; }, computed: { @@ -157,74 +150,8 @@ export default defineComponent({ }, ionViewWillEnter() { this.getCurrentFacilityDetails() - this.getOutstandingOrdersCount() - this.getInProgressOrdersCount() }, methods: { - async getOutstandingOrdersCount() { - let resp; - - try { - this.outstandingOrdersCount = 0 - - const payload = { - "json": { - "params": { - "rows": "0", - "group": true, - "group.field": "orderId", - "group.limit": 10000, - "group.ngroups": true, - "q.op": "AND" - }, - "query": "(*:*)", - "filter": ["docType: OISGIR", "quantityNotAvailable: 0", "isPicked: N", "-shipmentMethodTypeId: STOREPICKUP", "-fulfillmentStatus: Cancelled", "orderStatusId: ORDER_APPROVED", "orderTypeId: SALES_ORDER", `facilityId: ${this.currentFacility.facilityId}`, `productStoreId: ${this.currentEComStore.productStoreId}`] - } - } - - resp = await UserService.getOutstandingOrdersCount(payload) - - if(!hasError(resp)) { - this.outstandingOrdersCount = resp.data.grouped.orderId.ngroups - } else { - throw resp.data - } - } catch(err) { - logger.error('Failed to get outstanding orders count', err) - } - }, - async getInProgressOrdersCount() { - let resp; - - try { - this.inProgressOrdersCount = 0 - - const payload = { - "json": { - "params": { - "rows": "0", - "group": true, - "group.field": "picklistBinId", - "group.limit": 10000, - "group.ngroups": true, - "q.op": "AND" - }, - "query": "(*:*)", - "filter": ["docType: OISGIR", "picklistItemStatusId: PICKITEM_PENDING", "-shipmentMethodTypeId: STOREPICKUP", "-fulfillmentStatus: Rejected", `facilityId: ${this.currentFacility.facilityId}`, `productStoreId: ${this.currentEComStore.productStoreId}`] - } - } - - resp = await UserService.getInProgressOrdersCount(payload) - - if(!hasError(resp)) { - this.inProgressOrdersCount = resp.data.grouped.picklistBinId.ngroups - } else { - throw resp.data - } - } catch(err) { - logger.error('Failed to get inProgress orders count', err) - } - }, async getCurrentFacilityDetails() { let resp: any; try { @@ -277,8 +204,6 @@ export default defineComponent({ }); this.store.dispatch('order/clearOrders') this.getCurrentFacilityDetails(); - this.getOutstandingOrdersCount(); - this.getInProgressOrdersCount(); } }, async changeTimeZone() { @@ -351,74 +276,6 @@ export default defineComponent({ await alert.present(); }, - async recycleOutstandingOrders() { - const alert = await alertController.create({ - header: translate('Recycle outstanding orders'), - message: this.$t('Are you sure you want to recycle outstanding order(s)?', { ordersCount: this.outstandingOrdersCount }), - buttons: [{ - text: translate('No'), - role: 'cancel' - }, { - text: translate('Yes'), - handler: async () => { - let resp; - - try { - resp = await UserService.recycleOutstandingOrders({ - "facilityId": this.currentFacility.facilityId, - "productStoreId": this.currentEComStore.productStoreId, - "reasonId": "INACTIVE_STORE" - }) - - if(!hasError(resp)) { - showToast(translate('Recycling has been started. All outstanding orders will be recycled shortly.')) - } else { - throw resp.data - } - } catch(err) { - showToast(translate('Failed to recycle outstanding orders')) - logger.error('Failed to recycle outstanding orders', err) - } - } - }] - }); - - await alert.present(); - }, - async recycleInProgressOrders() { - const alert = await alertController.create({ - header: translate('Recycle in progress orders'), - message: this.$t('Are you sure you want to recycle in progress order(s)?', { ordersCount: this.inProgressOrdersCount }), - buttons: [{ - text: translate('No'), - role: 'cancel' - }, { - text: translate('Yes'), - handler: async () => { - let resp; - - try { - resp = await UserService.recycleInProgressOrders({ - "facilityId": this.currentFacility.facilityId, - "productStoreId": this.currentEComStore.productStoreId, - "reasonId": "INACTIVE_STORE" - }) - - if(!hasError(resp)) { - showToast(translate('Recycling has been started. All in progress orders will be recycled shortly.')) - } else { - throw resp.data - } - } catch(err) { - showToast(translate('Failed to recycle in progress orders')) - logger.error('Failed to recycle in progress orders', err) - } - } - }] - }); - - await alert.present(); - }, async setEComStore(event: any) { // not updating the ecomstore when the current value in vuex state and selected value are same // or when an empty value is given (on logout) @@ -430,8 +287,6 @@ export default defineComponent({ await this.store.dispatch('user/setEComStore', { 'eComStore': this.userProfile.stores.find((str: any) => str.productStoreId == event.detail.value) }) - this.getOutstandingOrdersCount(); - this.getInProgressOrdersCount(); } }, setPrintShippingLabelPreference (ev: any) {