diff --git a/src/hooks/common/table.ts b/src/hooks/common/table.ts index 6bb500ad..594fc466 100644 --- a/src/hooks/common/table.ts +++ b/src/hooks/common/table.ts @@ -104,7 +104,9 @@ export function useTable>); @@ -115,6 +117,18 @@ export function useTable) { + const formattedParams: Record = {}; + + Object.entries(params).forEach(([key, value]) => { + if (value !== null && value !== undefined) { + formattedParams[key] = value; + } + }); + + return formattedParams; + } + /** * update search params * diff --git a/src/router/elegant/routes.ts b/src/router/elegant/routes.ts index c6b0fb59..85a47e14 100644 --- a/src/router/elegant/routes.ts +++ b/src/router/elegant/routes.ts @@ -64,7 +64,7 @@ export const generatedRoutes: GeneratedRoute[] = [ meta: { title: 'function_hide-child', i18nKey: 'route.function_hide-child', - icon: 'material-symbols:filter-list-off', + icon: 'material-symbols:filter-list-off' }, redirect: '/function/hide-child/one', children: [ diff --git a/src/views/manage/role/index.vue b/src/views/manage/role/index.vue index 261720cc..8ab1b427 100644 --- a/src/views/manage/role/index.vue +++ b/src/views/manage/role/index.vue @@ -13,11 +13,17 @@ import RoleSearch from './modules/role-search.vue'; const appStore = useAppStore(); const { bool: drawerVisible, setTrue: openDrawer } = useBoolean(); -const { columns, filteredColumns, data, loading, pagination, getData, searchParams, resetSearchParams } = useTable< - Api.SystemManage.Role, - typeof fetchGetRoleList, - 'index' | 'operate' ->({ +const { + columns, + filteredColumns, + data, + loading, + pagination, + getData, + searchParams, + updateSearchParams, + resetSearchParams +} = useTable({ apiFn: fetchGetRoleList, apiParams: { current: 1, @@ -38,6 +44,16 @@ const { columns, filteredColumns, data, loading, pagination, getData, searchPara total }; }, + onPaginationChanged(pg) { + const { page, pageSize } = pg; + + updateSearchParams({ + current: page, + size: pageSize + }); + + getData(); + }, columns: () => [ { type: 'selection', @@ -179,6 +195,7 @@ function getIndex(index: number) { :flex-height="!appStore.isMobile" :scroll-x="702" :loading="loading" + remote :pagination="pagination" :row-key="item => item.id" class="sm:h-full" diff --git a/src/views/manage/user/index.vue b/src/views/manage/user/index.vue index 356d4aba..44456a38 100644 --- a/src/views/manage/user/index.vue +++ b/src/views/manage/user/index.vue @@ -13,11 +13,17 @@ import UserSearch from './modules/user-search.vue'; const appStore = useAppStore(); const { bool: drawerVisible, setTrue: openDrawer } = useBoolean(); -const { columns, filteredColumns, data, loading, pagination, getData, searchParams, resetSearchParams } = useTable< - Api.SystemManage.User, - typeof fetchGetUserList, - 'index' | 'operate' ->({ +const { + columns, + filteredColumns, + data, + loading, + pagination, + getData, + searchParams, + updateSearchParams, + resetSearchParams +} = useTable({ apiFn: fetchGetUserList, apiParams: { current: 1, @@ -41,6 +47,16 @@ const { columns, filteredColumns, data, loading, pagination, getData, searchPara total }; }, + onPaginationChanged(pg) { + const { page, pageSize } = pg; + + updateSearchParams({ + current: page, + size: pageSize + }); + + getData(); + }, columns: () => [ { type: 'selection', @@ -209,6 +225,7 @@ function getIndex(index: number) { :flex-height="!appStore.isMobile" :scroll-x="962" :loading="loading" + remote :pagination="pagination" :row-key="item => item.id" class="sm:h-full"