提交
This commit is contained in:
1 parent
d84f4b944c
commit
7c838cfb2d
249 files changed
+50600
-18556
No files matched your search
@@ -34,7 +34,7 @@ import {
|
||||
createSmartDebounce,
|
||||
createErrorHandler
|
||||
} from '../../utils/table/tableUtils'
|
||||
import { tableConfig } from '../../utils/table/tableConfig'
|
||||
import { tableConfig, DEFAULT_LIST_PAGE_SIZE } from '../../utils/table/tableConfig'
|
||||
|
||||
// 类型推导工具类型
|
||||
type InferApiParams<T> = T extends (params: infer P) => any ? P : never
|
||||
@@ -205,7 +205,7 @@ function useTableImpl<TApiFn extends (params: any) => Promise<any>>(
|
||||
Object.assign(
|
||||
{
|
||||
[pageKey]: 1,
|
||||
[sizeKey]: 10
|
||||
[sizeKey]: DEFAULT_LIST_PAGE_SIZE
|
||||
},
|
||||
apiParams || {}
|
||||
) as TParams
|
||||
@@ -214,7 +214,7 @@ function useTableImpl<TApiFn extends (params: any) => Promise<any>>(
|
||||
// 分页配置
|
||||
const pagination = reactive<Api.Common.PaginationParams>({
|
||||
current: ((searchParams as Record<string, unknown>)[pageKey] as number) || 1,
|
||||
size: ((searchParams as Record<string, unknown>)[sizeKey] as number) || 10,
|
||||
size: ((searchParams as Record<string, unknown>)[sizeKey] as number) || DEFAULT_LIST_PAGE_SIZE,
|
||||
total: 0
|
||||
})
|
||||
|
||||
@@ -394,7 +394,7 @@ function useTableImpl<TApiFn extends (params: any) => Promise<any>>(
|
||||
if (err instanceof Error && err.message === '请求已取消') {
|
||||
// 请求被取消,回到 idle 状态
|
||||
loadingState.value = 'idle'
|
||||
return { records: [], total: 0, current: 1, size: 10 }
|
||||
return { records: [], total: 0, current: 1, size: DEFAULT_LIST_PAGE_SIZE }
|
||||
}
|
||||
|
||||
// 状态机:请求失败,进入 error 状态
|
||||
@@ -448,7 +448,7 @@ function useTableImpl<TApiFn extends (params: any) => Promise<any>>(
|
||||
const paramsRecord = searchParams as Record<string, unknown>
|
||||
const defaultPagination = {
|
||||
[pageKey]: 1,
|
||||
[sizeKey]: (paramsRecord[sizeKey] as number) || 10
|
||||
[sizeKey]: (paramsRecord[sizeKey] as number) || DEFAULT_LIST_PAGE_SIZE
|
||||
}
|
||||
|
||||
// 清空所有搜索参数
|
||||
@@ -482,7 +482,7 @@ function useTableImpl<TApiFn extends (params: any) => Promise<any>>(
|
||||
// 替换搜索参数:适用于表单查询,避免旧字段残留
|
||||
const replaceSearchParams = (params?: Partial<TParams>): void => {
|
||||
const paramsRecord = searchParams as Record<string, unknown>
|
||||
const currentSize = pagination.size || ((paramsRecord[sizeKey] as number) ?? 10)
|
||||
const currentSize = pagination.size || ((paramsRecord[sizeKey] as number) ?? DEFAULT_LIST_PAGE_SIZE)
|
||||
|
||||
Object.keys(searchParams).forEach((key) => {
|
||||
if (key !== pageKey && key !== sizeKey) {
|
||||
|
||||
Reference in new issue
Block a user