Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
877311f9
Unverified
Commit
877311f9
authored
Dec 17, 2020
by
Pom
Committed by
GitHub
Dec 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(table): Update useDataSource.ts (#131)
假如数据变少,导致总页数变少并小于当前选中页码,通过getPaginationRef获取到的页码是不正确的,需获取正确的页码再次执行
parent
de25557f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
useDataSource.ts
src/components/Table/src/hooks/useDataSource.ts
+13
-1
No files found.
src/components/Table/src/hooks/useDataSource.ts
View file @
877311f9
...
...
@@ -89,10 +89,12 @@ export function useDataSource(
loadingRef
.
value
=
true
;
const
{
pageField
,
sizeField
,
listField
,
totalField
}
=
fetchSetting
||
FETCH_SETTING
;
let
pageParams
:
any
=
{};
const
{
current
,
pageSize
}
=
unref
(
getPaginationRef
)
as
PaginationProps
;
if
(
isBoolean
(
getPaginationRef
))
{
pageParams
=
{};
}
else
{
const
{
current
,
pageSize
}
=
unref
(
getPaginationRef
)
as
PaginationProps
;
pageParams
[
pageField
]
=
(
opt
&&
opt
.
page
)
||
current
;
pageParams
[
sizeField
]
=
pageSize
;
}
...
...
@@ -112,6 +114,16 @@ export function useDataSource(
const
res
=
await
api
(
params
);
let
resultItems
:
any
[]
=
get
(
res
,
listField
);
const
resultTotal
:
number
=
get
(
res
,
totalField
);
// 假如数据变少,导致总页数变少并小于当前选中页码,通过getPaginationRef获取到的页码是不正确的,需获取正确的页码再次执行
var
currentTotalPage
=
Math
.
ceil
(
resultTotal
/
pageSize
);
if
(
current
>
currentTotalPage
)
{
setPagination
({
current
:
currentTotalPage
,
});
fetch
(
opt
);
}
if
(
afterFetch
&&
isFunction
(
afterFetch
))
{
resultItems
=
afterFetch
(
resultItems
)
||
resultItems
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment