Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: fetching picklist items using pagination, added filterByDate check while fetching picklists (#215) #216

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 47 additions & 34 deletions src/store/modules/picklist/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"viewIndex": payload.viewIndex,
"fieldList": ["picklistId", "picklistDate", "statusId", "partyId"],
"entityName": "PicklistAndRole",
"noConditionFind": "Y"
"noConditionFind": "Y",
"filterByDate": "Y"
} as any

if (state.filters.showMyPicklists) params.inputFields.partyId = this.state.user.current.partyId;
Expand Down Expand Up @@ -62,7 +63,8 @@
"viewSize": 10,
"fieldList": ["picklistId", "picklistDate", "statusId", "partyId"],
"entityName": "PicklistAndRole",
"noConditionFind": "Y"
"noConditionFind": "Y",
"filterByDate": "Y"
} as any

if (state.filters.showMyPicklists) params.inputFields.partyId = this.state.user.current.partyId
Expand Down Expand Up @@ -95,52 +97,63 @@
return current
}

let resp;
const params = {
"inputFields": {
"picklistId": payload.id,
},
"fieldList": ["productId", "productName", "picklistId", "locationSeqId", "picklistBinId", "statusId"],
"entityName": "PicklistItemsView",
"noConditionFind": "Y"
}
let resp, isScrollable = true, viewIndex = 0, total = 0;
let pickingItemList = [] as any;

try {
resp = await PicklistService.getPicklist(params);
if (!hasError(resp) && resp.data.count) {
const pickingItemList = resp.data.docs.map((picklist: any, index: any) => ({ id: index, ...picklist, isChecked: false }))

current = { picklistId: payload.id, statusId: pickingItemList[0].statusId, pickingItemList }
commit(types.PICKLIST_CURRENT_UPDATED, current)

let productIds: any = new Set(
pickingItemList.map((picklist: any) => {
return picklist.productId
})
);

productIds = [...productIds]
if (productIds.length) {
this.dispatch('product/fetchProducts', { productIds })
while(isScrollable) {
resp = await PicklistService.getPicklist({
"inputFields": {
"picklistId": payload.id,
"itemStatusId": "PICKITEM_CANCELLED",
"itemStatusId_op": "notEqual"
},
"fieldList": ["productId", "productName", "picklistId", "locationSeqId", "picklistBinId", "statusId"],
"entityName": "PicklistItemsView",
"noConditionFind": "Y",
"viewSize": 200,
viewIndex
});

if (!hasError(resp) && resp.data.count) {
pickingItemList = pickingItemList.concat(resp.data.docs)
viewIndex++;
total = resp.data.count;

if(pickingItemList.length >= total) isScrollable = false;
} else {
throw resp.data;
}

return current;
} else {
showToast(translate('Something went wrong'));
console.error("error", resp.data);
return Promise.reject(new Error(resp.data));
}
} catch (err: any) {
showToast(translate('Something went wrong'));
console.error("error", err);
return Promise.reject(new Error(err))
return [];
}

if(pickingItemList.length) {
pickingItemList = pickingItemList.map((picklist: any, index: any) => ({ id: index, ...picklist, isChecked: false }))

current = { picklistId: payload.id, statusId: pickingItemList[0].statusId, pickingItemList }
commit(types.PICKLIST_CURRENT_UPDATED, current)

let productIds: any = new Set(
pickingItemList.map((picklist: any) => {
return picklist.productId
})
);

productIds = [...productIds]
if (productIds.length) {
this.dispatch('product/fetchProducts', { productIds })
}
}
},

/**
* Complete Picklist
*/
async completePicklist ({ commit }, payload) {

Check warning on line 156 in src/store/modules/picklist/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'commit' is defined but never used

Check warning on line 156 in src/store/modules/picklist/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'commit' is defined but never used
let resp;

try {
Expand Down
Loading