fix: get list with head

This commit is contained in:
Methapon Metanipat 2024-09-25 14:13:40 +07:00
parent 630a667c64
commit ddf21992ff
2 changed files with 9 additions and 7 deletions

View file

@ -263,7 +263,7 @@ onMounted(async () => {
// object, we are effectively unselecting any HQ branch. // object, we are effectively unselecting any HQ branch.
]; ];
await fetchList({ pageSize: 99999, tree: true }); await fetchList({ pageSize: 99999, tree: true, withHead: true });
await calculateStats(); await calculateStats();
modeView.value = $q.screen.lt.md ? true : false; modeView.value = $q.screen.lt.md ? true : false;
@ -641,7 +641,7 @@ async function triggerDelete(id: string) {
const res = await branchStore.deleteById(id); const res = await branchStore.deleteById(id);
if (res) { if (res) {
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
modalDrawer.value = false; modalDrawer.value = false;
modal.value = false; modal.value = false;
await calculateStats(); await calculateStats();
@ -705,13 +705,14 @@ async function fetchList(opts: {
zipCode?: string; zipCode?: string;
query?: string; query?: string;
tree?: boolean; tree?: boolean;
withHead?: boolean;
filter?: 'head' | 'sub'; filter?: 'head' | 'sub';
}) { }) {
await branchStore.fetchList(opts); await branchStore.fetchList(opts);
} }
watch(inputSearch, () => { watch(inputSearch, () => {
fetchList({ tree: true, query: inputSearch.value }); fetchList({ tree: true, query: inputSearch.value, withHead: true });
currentSubBranch.value = undefined; currentSubBranch.value = undefined;
}); });
@ -737,7 +738,7 @@ async function triggerChangeStatus(
}); });
if (res) resolve(res); if (res) resolve(res);
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
}, },
cancel: () => {}, cancel: () => {},
}); });
@ -767,7 +768,7 @@ async function onSubmit(submitSelectedItem?: boolean) {
formData.value.codeHeadOffice = formData.value.code = res.code; formData.value.codeHeadOffice = formData.value.code = res.code;
imageUrl.value = `${baseUrl}/branch/${res.id}/image/${res.selectedImage}`; imageUrl.value = `${baseUrl}/branch/${res.id}/image/${res.selectedImage}`;
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
if (!imageDialog.value) modalDrawer.value = submitSelectedItem || false; if (!imageDialog.value) modalDrawer.value = submitSelectedItem || false;
} }
@ -797,7 +798,7 @@ async function onSubmit(submitSelectedItem?: boolean) {
formType.value = 'view'; formType.value = 'view';
} }
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
}; };
if ( if (
@ -2069,7 +2070,7 @@ watch(currentHq, () => {
formType = 'view'; formType = 'view';
} }
await fetchList({ tree: true, pageSize: 99999 }); await fetchList({ tree: true, pageSize: 99999, withHead: true });
} }
" "
:menu="formMenuIcon" :menu="formMenuIcon"

View file

@ -35,6 +35,7 @@ const useBranchStore = defineStore('api-branch', () => {
query?: string; query?: string;
tree?: boolean; tree?: boolean;
filter?: 'head' | 'sub'; filter?: 'head' | 'sub';
withHead?: boolean;
}, },
Data extends Pagination<Branch[]>, Data extends Pagination<Branch[]>,
>(opts?: Options): Promise<Data | false> { >(opts?: Options): Promise<Data | false> {