Optimize pagination

This commit is contained in:
2023-11-30 10:51:19 +08:00
parent 9a39e05fdf
commit 99d2a73b6c
4 changed files with 24 additions and 4 deletions

View File

@@ -36,7 +36,11 @@ const Group: React.FC = () => {
pagination: { pagination: {
current: 1, current: 1,
pageSize: 20, pageSize: 20,
position: ['bottomCenter'] position: ['bottomCenter'],
showTotal: (total, range) =>
`${
range[0] === range[1] ? `${range[0]}` : `${range[0]}~${range[1]}`
} 项 共 ${total}`
} }
}) })
const [searchName, setSearchName] = useState('') const [searchName, setSearchName] = useState('')
@@ -138,6 +142,7 @@ const Group: React.FC = () => {
filters: Record<string, _FilterValue | null>, filters: Record<string, _FilterValue | null>,
sorter: _SorterResult<GroupWithRoleGetVo> | _SorterResult<GroupWithRoleGetVo>[] sorter: _SorterResult<GroupWithRoleGetVo> | _SorterResult<GroupWithRoleGetVo>[]
) => { ) => {
pagination = { ...tableParams.pagination, ...pagination }
if (Array.isArray(sorter)) { if (Array.isArray(sorter)) {
setTableParams({ setTableParams({
pagination, pagination,

View File

@@ -19,7 +19,11 @@ const Log: React.FC = () => {
pagination: { pagination: {
current: 1, current: 1,
pageSize: 20, pageSize: 20,
position: ['bottomCenter'] position: ['bottomCenter'],
showTotal: (total, range) =>
`${
range[0] === range[1] ? `${range[0]}` : `${range[0]}~${range[1]}`
} 项 共 ${total}`
} }
}) })
const [searchRequestUrl, setSearchRequestUrl] = useState('') const [searchRequestUrl, setSearchRequestUrl] = useState('')
@@ -134,6 +138,7 @@ const Log: React.FC = () => {
filters: Record<string, _FilterValue | null>, filters: Record<string, _FilterValue | null>,
sorter: _SorterResult<SysLogGetVo> | _SorterResult<SysLogGetVo>[] sorter: _SorterResult<SysLogGetVo> | _SorterResult<SysLogGetVo>[]
) => { ) => {
pagination = { ...tableParams.pagination, ...pagination }
if (Array.isArray(sorter)) { if (Array.isArray(sorter)) {
setTableParams({ setTableParams({
pagination, pagination,

View File

@@ -36,7 +36,11 @@ const Role: React.FC = () => {
pagination: { pagination: {
current: 1, current: 1,
pageSize: 20, pageSize: 20,
position: ['bottomCenter'] position: ['bottomCenter'],
showTotal: (total, range) =>
`${
range[0] === range[1] ? `${range[0]}` : `${range[0]}~${range[1]}`
} 项 共 ${total}`
} }
}) })
const [searchName, setSearchName] = useState('') const [searchName, setSearchName] = useState('')
@@ -130,6 +134,7 @@ const Role: React.FC = () => {
filters: Record<string, _FilterValue | null>, filters: Record<string, _FilterValue | null>,
sorter: _SorterResult<RoleWithPowerGetVo> | _SorterResult<RoleWithPowerGetVo>[] sorter: _SorterResult<RoleWithPowerGetVo> | _SorterResult<RoleWithPowerGetVo>[]
) => { ) => {
pagination = { ...tableParams.pagination, ...pagination }
if (Array.isArray(sorter)) { if (Array.isArray(sorter)) {
setTableParams({ setTableParams({
pagination, pagination,

View File

@@ -56,7 +56,11 @@ const User: React.FC = () => {
pagination: { pagination: {
current: 1, current: 1,
pageSize: 20, pageSize: 20,
position: ['bottomCenter'] position: ['bottomCenter'],
showTotal: (total, range) =>
`${
range[0] === range[1] ? `${range[0]}` : `${range[0]}~${range[1]}`
} 项 共 ${total}`
} }
}) })
const [tableSelectedItem, setTableSelectedItem] = useState<React.Key[]>([]) const [tableSelectedItem, setTableSelectedItem] = useState<React.Key[]>([])
@@ -214,6 +218,7 @@ const User: React.FC = () => {
filters: Record<string, _FilterValue | null>, filters: Record<string, _FilterValue | null>,
sorter: _SorterResult<UserWithRoleInfoVo> | _SorterResult<UserWithRoleInfoVo>[] sorter: _SorterResult<UserWithRoleInfoVo> | _SorterResult<UserWithRoleInfoVo>[]
) => { ) => {
pagination = { ...tableParams.pagination, ...pagination }
if (Array.isArray(sorter)) { if (Array.isArray(sorter)) {
setTableParams({ setTableParams({
pagination, pagination,