refactor: 04 => improve fetchWorkflowList for mobile handling and adjust pagination logic

This commit is contained in:
puriphatt 2025-01-31 11:57:52 +07:00
parent a61d2225f9
commit 17b527c078
2 changed files with 107 additions and 64 deletions

View file

@ -127,7 +127,7 @@ async function deleteWorkflow(id?: string) {
message: t('dialog.message.confirmDelete'),
action: async () => {
await workflowStore.deleteWorkflowTemplate(targetId);
await fetchWorkflowList();
await fetchWorkflowList($q.screen.xs);
resetForm();
},
@ -263,10 +263,12 @@ function resetForm() {
}
async function fetchWorkflowList(mobileFetch?: boolean) {
console.log(workflowData.value.length);
const res = await workflowStore.getWorkflowTemplateList({
page: mobileFetch ? 1 : workflowPage.value,
pageSize: mobileFetch ? workflowData.value.length : workflowPageSize.value,
pageSize: mobileFetch
? workflowData.value.length +
(pageState.total - workflowData.value.length === 0 ? 1 : 0)
: workflowPageSize.value,
query: pageState.inputSearch,
status:
statusFilter.value === 'all'
@ -515,7 +517,7 @@ watch([() => pageState.inputSearch, workflowPageSize], () => {
<article v-else class="col q-pa-md surface-2 scroll full-width">
<q-infinite-scroll
:offset="100"
:offset="10"
@load="
(_, done) => {
if ($q.screen.gt.xs || workflowPage === workflowPageMax) return;
@ -789,7 +791,7 @@ watch([() => pageState.inputSearch, workflowPageSize], () => {
<PaginationComponent
v-model:current-page="workflowPage"
v-model:max-page="workflowPageMax"
:fetch-data="fetchWorkflowList"
:fetch-data="() => fetchWorkflowList()"
/>
</nav>
</footer>