Commit 7b6d5e44a9fe9ad9fcf1487fc6282ff194d0981d

Authored by 无木
1 parent e85649bd

fix(table): `reload` in useTable not support await

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