Commit 7b6d5e44a9fe9ad9fcf1487fc6282ff194d0981d
1 parent
e85649bd
fix(table): `reload` in useTable not support await
修复useTable返回的reload方法不支持使用await等待加载完毕的问题
Showing
3 changed files
with
5 additions
and
3 deletions
CHANGELOG.zh_CN.md
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | - **BasicTable** | 3 | - **BasicTable** |
4 | - 修复可编辑单元格某些情况下无法提交的问题 | 4 | - 修复可编辑单元格某些情况下无法提交的问题 |
5 | - 修复`inset`属性不起作用的问题 | 5 | - 修复`inset`属性不起作用的问题 |
6 | + - 修复`useTable`与`BasicTable`实例的`reload`方法`await`表现不一致的问题 | ||
6 | - **BasicModal** | 7 | - **BasicModal** |
7 | - 修复点击遮罩、按下`Esc`键都不能关闭`Modal`的问题 | 8 | - 修复点击遮罩、按下`Esc`键都不能关闭`Modal`的问题 |
8 | - 修复点击关闭按钮、最大化按钮旁边的空白区域也会导致`Modal`关闭的问题 | 9 | - 修复点击关闭按钮、最大化按钮旁边的空白区域也会导致`Modal`关闭的问题 |
src/components/Table/src/hooks/useDataSource.ts
@@ -275,7 +275,7 @@ export function useDataSource( | @@ -275,7 +275,7 @@ export function useDataSource( | ||
275 | setPagination({ | 275 | setPagination({ |
276 | current: currentTotalPage, | 276 | current: currentTotalPage, |
277 | }); | 277 | }); |
278 | - fetch(opt); | 278 | + return await fetch(opt); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
@@ -295,6 +295,7 @@ export function useDataSource( | @@ -295,6 +295,7 @@ export function useDataSource( | ||
295 | items: unref(resultItems), | 295 | items: unref(resultItems), |
296 | total: resultTotal, | 296 | total: resultTotal, |
297 | }); | 297 | }); |
298 | + return resultItems; | ||
298 | } catch (error) { | 299 | } catch (error) { |
299 | emit('fetch-error', error); | 300 | emit('fetch-error', error); |
300 | dataSourceRef.value = []; | 301 | dataSourceRef.value = []; |
@@ -319,7 +320,7 @@ export function useDataSource( | @@ -319,7 +320,7 @@ export function useDataSource( | ||
319 | } | 320 | } |
320 | 321 | ||
321 | async function reload(opt?: FetchParams) { | 322 | async function reload(opt?: FetchParams) { |
322 | - await fetch(opt); | 323 | + return await fetch(opt); |
323 | } | 324 | } |
324 | 325 | ||
325 | onMounted(() => { | 326 | onMounted(() => { |
src/components/Table/src/hooks/useTable.ts
@@ -68,7 +68,7 @@ export function useTable(tableProps?: Props): [ | @@ -68,7 +68,7 @@ export function useTable(tableProps?: Props): [ | ||
68 | getForm: () => FormActionType; | 68 | getForm: () => FormActionType; |
69 | } = { | 69 | } = { |
70 | reload: async (opt?: FetchParams) => { | 70 | reload: async (opt?: FetchParams) => { |
71 | - getTableInstance().reload(opt); | 71 | + return await getTableInstance().reload(opt); |
72 | }, | 72 | }, |
73 | setProps: (props: Partial<BasicTableProps>) => { | 73 | setProps: (props: Partial<BasicTableProps>) => { |
74 | getTableInstance().setProps(props); | 74 | getTableInstance().setProps(props); |