diff --git a/src/components/Table/src/BasicTable.vue b/src/components/Table/src/BasicTable.vue index 174d6d971..943b98d3b 100644 --- a/src/components/Table/src/BasicTable.vue +++ b/src/components/Table/src/BasicTable.vue @@ -144,6 +144,7 @@ getDataSourceRef, getDataSource, getRawDataSource, + getSearchInfo, setTableData, updateTableDataRecord, deleteTableDataRecord, @@ -300,6 +301,7 @@ setLoading, getDataSource, getRawDataSource, + getSearchInfo, setProps, getRowSelection, getPaginationRef: getPagination, diff --git a/src/components/Table/src/hooks/useDataSource.ts b/src/components/Table/src/hooks/useDataSource.ts index aa6a85f3c..f5da7d45c 100644 --- a/src/components/Table/src/hooks/useDataSource.ts +++ b/src/components/Table/src/hooks/useDataSource.ts @@ -50,6 +50,7 @@ export function useDataSource( }); const dataSourceRef = ref([]); const rawDataSourceRef = ref({}); + const searchInfoRef = ref({}); watchEffect(() => { tableData.value = unref(dataSourceRef); @@ -275,7 +276,7 @@ export function useDataSource( if (beforeFetch && isFunction(beforeFetch)) { params = (await beforeFetch(params)) || params; } - + searchInfoRef.value = params; const res = await api(params); rawDataSourceRef.value = res; @@ -339,6 +340,10 @@ export function useDataSource( return await fetch(opt); } + function getSearchInfo() { + return searchInfoRef.value as T; + } + onMounted(() => { useTimeoutFn(() => { unref(propsRef).immediate && fetch(); @@ -349,6 +354,8 @@ export function useDataSource( getDataSourceRef, getDataSource, getRawDataSource, + searchInfoRef, + getSearchInfo, getRowKey, setTableData, getAutoCreateKey, diff --git a/src/components/Table/src/hooks/useTable.ts b/src/components/Table/src/hooks/useTable.ts index 196eecd94..1e353ab03 100644 --- a/src/components/Table/src/hooks/useTable.ts +++ b/src/components/Table/src/hooks/useTable.ts @@ -89,6 +89,9 @@ export function useTable(tableProps?: Props): [ getRawDataSource: () => { return getTableInstance().getRawDataSource(); }, + getSearchInfo: () => { + return getTableInstance().getSearchInfo(); + }, getColumns: ({ ignoreIndex = false }: { ignoreIndex?: boolean } = {}) => { const columns = getTableInstance().getColumns({ ignoreIndex }) || []; return toRaw(columns); diff --git a/src/components/Table/src/types/table.ts b/src/components/Table/src/types/table.ts index ed268f178..653b736b0 100644 --- a/src/components/Table/src/types/table.ts +++ b/src/components/Table/src/types/table.ts @@ -114,6 +114,7 @@ export interface TableActionType { setColumns: (columns: BasicColumn[] | string[]) => void; getDataSource: () => T[]; getRawDataSource: () => T; + getSearchInfo: () => T; setLoading: (loading: boolean) => void; setProps: (props: Partial) => void; redoHeight: () => void; diff --git a/src/views/demo/system/account/index.vue b/src/views/demo/system/account/index.vue index fd406acba..86e0dbc1e 100644 --- a/src/views/demo/system/account/index.vue +++ b/src/views/demo/system/account/index.vue @@ -4,6 +4,7 @@