diff --git a/src/App.vue b/src/App.vue index 8cbdbcc7f..88e866edd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -618,8 +618,14 @@ onUnmounted(() => { @editor-cursor-change="(p: number) => (cursorPos = p)" @format-error="toast(t('toolbar.formatSqlFailed'))" @reload=" - (sql?: string, searchText?: string, whereInput?: string, orderBy?: string) => - onReloadData(sql, searchText, whereInput, orderBy) + ( + sql?: string, + searchText?: string, + whereInput?: string, + orderBy?: string, + limit?: number, + offset?: number, + ) => onReloadData(sql, searchText, whereInput, orderBy, limit, offset) " @paginate="onPaginate" @sort="onSort" diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue index 043d444ad..a66f1cc43 100644 --- a/src/components/grid/DataGrid.vue +++ b/src/components/grid/DataGrid.vue @@ -101,7 +101,7 @@ const props = defineProps<{ }>(); const emit = defineEmits<{ - reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string]; + reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number]; paginate: [offset: number, limit: number, whereInput?: string, orderBy?: string]; sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string]; }>(); @@ -857,6 +857,8 @@ const editor = useDataGridEditor({ rowStatusFilter, initialEditColumn: firstVisibleColumnIndex, getRowItem, + pageSize, + currentPage, emit, }); @@ -904,6 +906,8 @@ async function onToolbarRefresh() { searchText.value, whereFilterInput.value.trim() || undefined, orderByInput.value.trim() || undefined, + pageSize.value, + (currentPage.value - 1) * pageSize.value, ); } @@ -919,6 +923,8 @@ function onToolbarRollback() { searchText.value, whereFilterInput.value.trim() || undefined, orderByInput.value.trim() || undefined, + pageSize.value, + (currentPage.value - 1) * pageSize.value, ); } diff --git a/src/components/layout/ContentArea.vue b/src/components/layout/ContentArea.vue index 670c00b9e..aac3ee480 100644 --- a/src/components/layout/ContentArea.vue +++ b/src/components/layout/ContentArea.vue @@ -40,7 +40,7 @@ const emit = defineEmits<{ editorSelectionChange: [value: string]; editorCursorChange: [pos: number]; formatError: []; - reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string]; + reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number]; paginate: [offset: number, limit: number, whereInput?: string, orderBy?: string]; sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string]; executeSql: [sql: string]; @@ -283,8 +283,14 @@ function onHandleCloseColumnPanel() { :table-meta="activeTab.tableMeta" :on-execute-sql="async (sql: string) => emit('executeSql', sql)" @reload=" - (sql?: string, searchText?: string, whereInput?: string, orderBy?: string) => - emit('reload', sql, searchText, whereInput, orderBy) + ( + sql?: string, + searchText?: string, + whereInput?: string, + orderBy?: string, + limit?: number, + offset?: number, + ) => emit('reload', sql, searchText, whereInput, orderBy, limit, offset) " @paginate=" (offset: number, limit: number, whereInput?: string, orderBy?: string) => @@ -381,8 +387,14 @@ function onHandleCloseColumnPanel() { :table-meta="activeTab.tableMeta" :on-execute-sql="async (sql: string) => emit('executeSql', sql)" @reload=" - (sql?: string, searchText?: string, whereInput?: string, orderBy?: string) => - emit('reload', sql, searchText, whereInput, orderBy) + ( + sql?: string, + searchText?: string, + whereInput?: string, + orderBy?: string, + limit?: number, + offset?: number, + ) => emit('reload', sql, searchText, whereInput, orderBy, limit, offset) " @paginate=" (offset: number, limit: number, whereInput?: string, orderBy?: string) => diff --git a/src/composables/useDataGridActions.ts b/src/composables/useDataGridActions.ts index df7fc7ccb..46a2f33bf 100644 --- a/src/composables/useDataGridActions.ts +++ b/src/composables/useDataGridActions.ts @@ -51,12 +51,19 @@ export function useDataGridActions(activeTab: ComputedRef) await queryStore.executeTabSql(tab.id, sql); } - async function onReloadData(sql?: string, _searchText?: string, whereInput?: string, orderBy?: string) { + async function onReloadData( + sql?: string, + _searchText?: string, + whereInput?: string, + orderBy?: string, + limit?: number, + offset?: number, + ) { const tab = activeTab.value; if (!tab) return; if (tab.mode === "data" && tab.tableMeta) { tab.whereInput = whereInput ?? ""; - queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy })); + queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy, limit, offset })); await queryStore.executeCurrentTab(); return; } diff --git a/src/composables/useDataGridEditor.ts b/src/composables/useDataGridEditor.ts index 0dc9fc048..3d9b2b983 100644 --- a/src/composables/useDataGridEditor.ts +++ b/src/composables/useDataGridEditor.ts @@ -66,8 +66,18 @@ export interface UseDataGridEditorOptions { rowStatusFilter: Ref; initialEditColumn?: ComputedRef; getRowItem: (rowId: number) => RowItem | undefined; + pageSize: Ref; + currentPage: Ref; emit: { - (event: "reload", sql?: string, searchText?: string, whereInput?: string, orderBy?: string): void; + ( + event: "reload", + sql?: string, + searchText?: string, + whereInput?: string, + orderBy?: string, + limit?: number, + offset?: number, + ): void; }; } @@ -91,6 +101,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) { rowStatusFilter, initialEditColumn, getRowItem, + pageSize, + currentPage, emit, } = options; @@ -486,6 +498,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) { searchText.value, whereFilterInput.value.trim() || undefined, orderByInput.value.trim() || undefined, + pageSize.value, + (currentPage.value - 1) * pageSize.value, ); return; } @@ -571,6 +585,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) { searchText.value, whereFilterInput.value.trim() || undefined, orderByInput.value.trim() || undefined, + pageSize.value, + (currentPage.value - 1) * pageSize.value, ); }