统一后台 Table 分页:常开 10/20/50/100 条数切换
- 新增 admin-pagination 工具,标准列表与云触手记录分别配置 - 用户/审计等页补齐 showSizeChanger,避免 total≤50 时无法切换 - ConfigProvider 默认开启条数切换
This commit is contained in:
@@ -21,6 +21,12 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<ConfigProvider
|
<ConfigProvider
|
||||||
locale={zhCN}
|
locale={zhCN}
|
||||||
|
// 全局分页:常开条数切换(ConfigProvider 仅支持 showSizeChanger 等字段)
|
||||||
|
// 具体 10/20/50/100 由 utils/admin-pagination 在各 Table 上统一配置
|
||||||
|
pagination={{
|
||||||
|
showSizeChanger: true,
|
||||||
|
totalBoundaryShowSizeChanger: 0,
|
||||||
|
}}
|
||||||
theme={{
|
theme={{
|
||||||
token: {
|
token: {
|
||||||
colorPrimary: '#1677ff',
|
colorPrimary: '#1677ff',
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ import type { AdminAuditLogItem } from '@/types/admin'
|
|||||||
import { hasAdminRole } from '@/utils/admin-auth'
|
import { hasAdminRole } from '@/utils/admin-auth'
|
||||||
import { formatAuditAction, formatAuditTargetType } from '@/utils/admin-display'
|
import { formatAuditAction, formatAuditTargetType } from '@/utils/admin-display'
|
||||||
import { adminAuditActionOptions, adminAuditTargetTypeOptions } from '@/utils/admin-options'
|
import { adminAuditActionOptions, adminAuditTargetTypeOptions } from '@/utils/admin-options'
|
||||||
|
import {
|
||||||
|
ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
buildAdminTablePagination,
|
||||||
|
resolveAdminPageSize,
|
||||||
|
} from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
import { stringifyDisplayJson } from '@/utils/date-time'
|
import { stringifyDisplayJson } from '@/utils/date-time'
|
||||||
|
|
||||||
@@ -27,7 +32,7 @@ export default function AdminAuditLogsPage() {
|
|||||||
const isAdmin = hasAdminRole('admin')
|
const isAdmin = hasAdminRole('admin')
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
const page = Number(searchParams.get('page') || 1) || 1
|
const page = Number(searchParams.get('page') || 1) || 1
|
||||||
const pageSize = Number(searchParams.get('pageSize') || 20) || 20
|
const pageSize = resolveAdminPageSize(searchParams.get('pageSize'), ADMIN_DEFAULT_PAGE_SIZE)
|
||||||
const filters = {
|
const filters = {
|
||||||
actorUsername: searchParams.get('actorUsername') || '',
|
actorUsername: searchParams.get('actorUsername') || '',
|
||||||
action: searchParams.get('action') || '',
|
action: searchParams.get('action') || '',
|
||||||
@@ -195,17 +200,16 @@ export default function AdminAuditLogsPage() {
|
|||||||
dataSource={data?.items || []}
|
dataSource={data?.items || []}
|
||||||
locale={{ emptyText: <Empty description="暂无审计记录" /> }}
|
locale={{ emptyText: <Empty description="暂无审计记录" /> }}
|
||||||
scroll={{ x: 980 }}
|
scroll={{ x: 980 }}
|
||||||
pagination={{
|
pagination={buildAdminTablePagination({
|
||||||
current: data?.pagination.page || page,
|
current: data?.pagination.page || page,
|
||||||
pageSize: data?.pagination.pageSize || pageSize,
|
pageSize: data?.pagination.pageSize || pageSize,
|
||||||
total: data?.pagination.total || 0,
|
total: data?.pagination.total || 0,
|
||||||
showTotal: (total) => `共 ${total} 条`,
|
|
||||||
onChange: (nextPage, nextPageSize) => {
|
onChange: (nextPage, nextPageSize) => {
|
||||||
setSearchParams(
|
setSearchParams(
|
||||||
cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }),
|
cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
}}
|
})}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ import {
|
|||||||
} from '@/services/admin'
|
} from '@/services/admin'
|
||||||
import type { AdminCloudtentaclesDeliveryRecordItem } from '@/types/admin'
|
import type { AdminCloudtentaclesDeliveryRecordItem } from '@/types/admin'
|
||||||
import { getAdminToken } from '@/utils/admin-auth'
|
import { getAdminToken } from '@/utils/admin-auth'
|
||||||
|
import {
|
||||||
|
buildCloudtentaclesTablePagination,
|
||||||
|
CLOUDTENTACLES_DEFAULT_PAGE_SIZE,
|
||||||
|
} from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
|
|
||||||
type RecordSourceOption = {
|
type RecordSourceOption = {
|
||||||
@@ -43,9 +47,6 @@ type RecordSourceOption = {
|
|||||||
|
|
||||||
type DateRangeValue = [Dayjs | null, Dayjs | null] | null
|
type DateRangeValue = [Dayjs | null, Dayjs | null] | null
|
||||||
|
|
||||||
const DEFAULT_PAGE_SIZE = 100
|
|
||||||
const PAGE_SIZE_OPTIONS = [100, 200, 500, 1000]
|
|
||||||
|
|
||||||
export default function AdminCloudtentaclesRecordsPage() {
|
export default function AdminCloudtentaclesRecordsPage() {
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [sourceLoading, setSourceLoading] = useState(false)
|
const [sourceLoading, setSourceLoading] = useState(false)
|
||||||
@@ -54,7 +55,7 @@ export default function AdminCloudtentaclesRecordsPage() {
|
|||||||
const [platformOrderId, setPlatformOrderId] = useState('')
|
const [platformOrderId, setPlatformOrderId] = useState('')
|
||||||
const [dateRange, setDateRange] = useState<DateRangeValue>(createDefaultDateRange())
|
const [dateRange, setDateRange] = useState<DateRangeValue>(createDefaultDateRange())
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE)
|
const [pageSize, setPageSize] = useState(CLOUDTENTACLES_DEFAULT_PAGE_SIZE)
|
||||||
const [total, setTotal] = useState(0)
|
const [total, setTotal] = useState(0)
|
||||||
const [items, setItems] = useState<AdminCloudtentaclesDeliveryRecordItem[]>([])
|
const [items, setItems] = useState<AdminCloudtentaclesDeliveryRecordItem[]>([])
|
||||||
const [sourceOptions, setSourceOptions] = useState<RecordSourceOption[]>([])
|
const [sourceOptions, setSourceOptions] = useState<RecordSourceOption[]>([])
|
||||||
@@ -256,9 +257,9 @@ export default function AdminCloudtentaclesRecordsPage() {
|
|||||||
setPlatformOrderId('')
|
setPlatformOrderId('')
|
||||||
setDateRange(nextDateRange)
|
setDateRange(nextDateRange)
|
||||||
setPage(1)
|
setPage(1)
|
||||||
setPageSize(DEFAULT_PAGE_SIZE)
|
setPageSize(CLOUDTENTACLES_DEFAULT_PAGE_SIZE)
|
||||||
void loadRecords(1, {
|
void loadRecords(1, {
|
||||||
pageSize: DEFAULT_PAGE_SIZE,
|
pageSize: CLOUDTENTACLES_DEFAULT_PAGE_SIZE,
|
||||||
platformOrderId: '',
|
platformOrderId: '',
|
||||||
dateRange: nextDateRange,
|
dateRange: nextDateRange,
|
||||||
})
|
})
|
||||||
@@ -357,17 +358,14 @@ export default function AdminCloudtentaclesRecordsPage() {
|
|||||||
dataSource={items}
|
dataSource={items}
|
||||||
size="small"
|
size="small"
|
||||||
scroll={{ x: 1450 }}
|
scroll={{ x: 1450 }}
|
||||||
pagination={{
|
pagination={buildCloudtentaclesTablePagination({
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
total,
|
total,
|
||||||
pageSizeOptions: PAGE_SIZE_OPTIONS,
|
|
||||||
showSizeChanger: true,
|
|
||||||
showTotal: (nextTotal) => `共 ${nextTotal} 条`,
|
|
||||||
onChange: (nextPage, nextPageSize) => {
|
onChange: (nextPage, nextPageSize) => {
|
||||||
void loadRecords(nextPage, { pageSize: nextPageSize })
|
void loadRecords(nextPage, { pageSize: nextPageSize })
|
||||||
},
|
},
|
||||||
}}
|
})}
|
||||||
locale={{ emptyText: loading ? '发货记录加载中' : '当前筛选条件下暂无发货记录' }}
|
locale={{ emptyText: loading ? '发货记录加载中' : '当前筛选条件下暂无发货记录' }}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ import type {
|
|||||||
AdminKuaishouIndustryVoucherToolPayload,
|
AdminKuaishouIndustryVoucherToolPayload,
|
||||||
} from '@/types/admin'
|
} from '@/types/admin'
|
||||||
import { hasAdminRole } from '@/utils/admin-auth'
|
import { hasAdminRole } from '@/utils/admin-auth'
|
||||||
|
import {
|
||||||
|
ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
buildAdminLocalTablePagination,
|
||||||
|
buildAdminTablePagination,
|
||||||
|
} from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
import { stringifyDisplayJson } from '@/utils/date-time'
|
import { stringifyDisplayJson } from '@/utils/date-time'
|
||||||
|
|
||||||
@@ -594,13 +599,12 @@ export default function AdminKuaishouIndustryPage() {
|
|||||||
dataSource={vouchers}
|
dataSource={vouchers}
|
||||||
loading={voucherLoading}
|
loading={voucherLoading}
|
||||||
scroll={{ x: 1180 }}
|
scroll={{ x: 1180 }}
|
||||||
pagination={{
|
pagination={buildAdminTablePagination({
|
||||||
current: voucherFilters.page,
|
current: voucherFilters.page,
|
||||||
pageSize: voucherFilters.pageSize,
|
pageSize: voucherFilters.pageSize,
|
||||||
total: voucherTotal,
|
total: voucherTotal,
|
||||||
showSizeChanger: true,
|
|
||||||
onChange: (page, pageSize) => loadVouchers({ page, pageSize }),
|
onChange: (page, pageSize) => loadVouchers({ page, pageSize }),
|
||||||
}}
|
})}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -757,7 +761,7 @@ export default function AdminKuaishouIndustryPage() {
|
|||||||
columns={refundColumns}
|
columns={refundColumns}
|
||||||
dataSource={refundRows}
|
dataSource={refundRows}
|
||||||
scroll={{ x: 1120 }}
|
scroll={{ x: 1120 }}
|
||||||
pagination={{ pageSize: 10 }}
|
pagination={buildAdminLocalTablePagination({ pageSize: ADMIN_DEFAULT_PAGE_SIZE })}
|
||||||
style={{ marginTop: 16 }}
|
style={{ marginTop: 16 }}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ import StatusTag from '@/components/admin/StatusTag'
|
|||||||
import { fetchAdminOrders } from '@/services/admin'
|
import { fetchAdminOrders } from '@/services/admin'
|
||||||
import type { AdminOrderListItem } from '@/types/admin'
|
import type { AdminOrderListItem } from '@/types/admin'
|
||||||
import { adminPayStatusOptions } from '@/utils/admin-options'
|
import { adminPayStatusOptions } from '@/utils/admin-options'
|
||||||
|
import {
|
||||||
|
ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
buildAdminTablePagination,
|
||||||
|
resolveAdminPageSize,
|
||||||
|
} from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
|
|
||||||
type OrderFilterForm = {
|
type OrderFilterForm = {
|
||||||
@@ -22,7 +27,7 @@ export default function AdminOrdersPage() {
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [searchParams, setSearchParams] = useSearchParams()
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
const page = Number(searchParams.get('page') || 1) || 1
|
const page = Number(searchParams.get('page') || 1) || 1
|
||||||
const pageSize = Number(searchParams.get('pageSize') || 20) || 20
|
const pageSize = resolveAdminPageSize(searchParams.get('pageSize'), ADMIN_DEFAULT_PAGE_SIZE)
|
||||||
const filters = {
|
const filters = {
|
||||||
platformOrderId: searchParams.get('platformOrderId') || '',
|
platformOrderId: searchParams.get('platformOrderId') || '',
|
||||||
payStatus: searchParams.get('payStatus') || '',
|
payStatus: searchParams.get('payStatus') || '',
|
||||||
@@ -141,16 +146,14 @@ export default function AdminOrdersPage() {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items || []}
|
dataSource={data?.items || []}
|
||||||
scroll={{ x: 900 }}
|
scroll={{ x: 900 }}
|
||||||
pagination={{
|
pagination={buildAdminTablePagination({
|
||||||
current: data?.pagination.page || page,
|
current: data?.pagination.page || page,
|
||||||
pageSize: data?.pagination.pageSize || pageSize,
|
pageSize: data?.pagination.pageSize || pageSize,
|
||||||
total: data?.pagination.total || 0,
|
total: data?.pagination.total || 0,
|
||||||
showSizeChanger: true,
|
|
||||||
showTotal: (total) => `共 ${total} 条`,
|
|
||||||
onChange: (nextPage, nextPageSize) => {
|
onChange: (nextPage, nextPageSize) => {
|
||||||
setSearchParams(cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }))
|
setSearchParams(cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }))
|
||||||
},
|
},
|
||||||
}}
|
})}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ import {
|
|||||||
import type { AdminTaskActionResponse, AdminTaskListItem } from '@/types/admin'
|
import type { AdminTaskActionResponse, AdminTaskListItem } from '@/types/admin'
|
||||||
import { hasAdminRole } from '@/utils/admin-auth'
|
import { hasAdminRole } from '@/utils/admin-auth'
|
||||||
import { adminTaskStatusOptions } from '@/utils/admin-options'
|
import { adminTaskStatusOptions } from '@/utils/admin-options'
|
||||||
|
import {
|
||||||
|
ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
buildAdminTablePagination,
|
||||||
|
resolveAdminPageSize,
|
||||||
|
} from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
|
|
||||||
type TaskFilterForm = {
|
type TaskFilterForm = {
|
||||||
@@ -50,7 +55,7 @@ export default function AdminTasksPage() {
|
|||||||
const [actionLoadingId, setActionLoadingId] = useState<number | null>(null)
|
const [actionLoadingId, setActionLoadingId] = useState<number | null>(null)
|
||||||
const [lastClaimUrl, setLastClaimUrl] = useState('')
|
const [lastClaimUrl, setLastClaimUrl] = useState('')
|
||||||
const page = Number(searchParams.get('page') || 1) || 1
|
const page = Number(searchParams.get('page') || 1) || 1
|
||||||
const pageSize = Number(searchParams.get('pageSize') || 20) || 20
|
const pageSize = resolveAdminPageSize(searchParams.get('pageSize'), ADMIN_DEFAULT_PAGE_SIZE)
|
||||||
const canManageTaskLifecycle = hasAdminRole('operator')
|
const canManageTaskLifecycle = hasAdminRole('operator')
|
||||||
const canCloseTasks = hasAdminRole('support')
|
const canCloseTasks = hasAdminRole('support')
|
||||||
const filters = {
|
const filters = {
|
||||||
@@ -397,16 +402,14 @@ export default function AdminTasksPage() {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items || []}
|
dataSource={data?.items || []}
|
||||||
scroll={{ x: 1500 }}
|
scroll={{ x: 1500 }}
|
||||||
pagination={{
|
pagination={buildAdminTablePagination({
|
||||||
current: data?.pagination.page || page,
|
current: data?.pagination.page || page,
|
||||||
pageSize: data?.pagination.pageSize || pageSize,
|
pageSize: data?.pagination.pageSize || pageSize,
|
||||||
total: data?.pagination.total || 0,
|
total: data?.pagination.total || 0,
|
||||||
showSizeChanger: true,
|
|
||||||
showTotal: (total) => `共 ${total} 条`,
|
|
||||||
onChange: (nextPage, nextPageSize) => {
|
onChange: (nextPage, nextPageSize) => {
|
||||||
setSearchParams(cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }))
|
setSearchParams(cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }))
|
||||||
},
|
},
|
||||||
}}
|
})}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ import {
|
|||||||
import type { AdminRole, AdminUserListItem } from '@/types/admin'
|
import type { AdminRole, AdminUserListItem } from '@/types/admin'
|
||||||
import { getAdminUserId, hasAdminRole } from '@/utils/admin-auth'
|
import { getAdminUserId, hasAdminRole } from '@/utils/admin-auth'
|
||||||
import { adminUserRoleOptions, adminUserStatusOptions } from '@/utils/admin-options'
|
import { adminUserRoleOptions, adminUserStatusOptions } from '@/utils/admin-options'
|
||||||
|
import {
|
||||||
|
ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
buildAdminTablePagination,
|
||||||
|
resolveAdminPageSize,
|
||||||
|
} from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
|
|
||||||
type UserFilterForm = {
|
type UserFilterForm = {
|
||||||
@@ -68,7 +73,7 @@ export default function AdminUsersPage() {
|
|||||||
const [creating, setCreating] = useState(false)
|
const [creating, setCreating] = useState(false)
|
||||||
const [actionLoadingId, setActionLoadingId] = useState<number | null>(null)
|
const [actionLoadingId, setActionLoadingId] = useState<number | null>(null)
|
||||||
const page = Number(searchParams.get('page') || 1) || 1
|
const page = Number(searchParams.get('page') || 1) || 1
|
||||||
const pageSize = Number(searchParams.get('pageSize') || 20) || 20
|
const pageSize = resolveAdminPageSize(searchParams.get('pageSize'), ADMIN_DEFAULT_PAGE_SIZE)
|
||||||
const filters = {
|
const filters = {
|
||||||
username: searchParams.get('username') || '',
|
username: searchParams.get('username') || '',
|
||||||
role: searchParams.get('role') || '',
|
role: searchParams.get('role') || '',
|
||||||
@@ -407,15 +412,14 @@ export default function AdminUsersPage() {
|
|||||||
dataSource={data?.items || []}
|
dataSource={data?.items || []}
|
||||||
locale={{ emptyText: <Empty description="暂无用户" /> }}
|
locale={{ emptyText: <Empty description="暂无用户" /> }}
|
||||||
scroll={{ x: 1060 }}
|
scroll={{ x: 1060 }}
|
||||||
pagination={{
|
pagination={buildAdminTablePagination({
|
||||||
current: data?.pagination.page || page,
|
current: data?.pagination.page || page,
|
||||||
pageSize: data?.pagination.pageSize || pageSize,
|
pageSize: data?.pagination.pageSize || pageSize,
|
||||||
total: data?.pagination.total || 0,
|
total: data?.pagination.total || 0,
|
||||||
showTotal: (total) => `共 ${total} 条`,
|
|
||||||
onChange: (nextPage, nextPageSize) => {
|
onChange: (nextPage, nextPageSize) => {
|
||||||
setSearchParams(cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }))
|
setSearchParams(cleanParams({ ...filters, page: nextPage, pageSize: nextPageSize }))
|
||||||
},
|
},
|
||||||
}}
|
})}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import type {
|
|||||||
AdminKuaishouFeifeiProductRule,
|
AdminKuaishouFeifeiProductRule,
|
||||||
} from '@/types/admin'
|
} from '@/types/admin'
|
||||||
import { hasAdminRole } from '@/utils/admin-auth'
|
import { hasAdminRole } from '@/utils/admin-auth'
|
||||||
|
import { buildAdminLocalTablePagination } from '@/utils/admin-pagination'
|
||||||
|
|
||||||
type EditableOverrideRule = Omit<AdminCloudtentaclesOverrideRule, 'normalizedProductName'> & {
|
type EditableOverrideRule = Omit<AdminCloudtentaclesOverrideRule, 'normalizedProductName'> & {
|
||||||
normalizedProductName?: string
|
normalizedProductName?: string
|
||||||
@@ -666,7 +667,7 @@ function KuaishouFeifeiFulfillmentPanel() {
|
|||||||
rowKey={(row) => row.id || `${row.productName}-${row.productCode}`}
|
rowKey={(row) => row.id || `${row.productName}-${row.productCode}`}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={rules}
|
dataSource={rules}
|
||||||
pagination={{ pageSize: 20, showSizeChanger: true }}
|
pagination={buildAdminLocalTablePagination()}
|
||||||
scroll={{ x: 920, y: 520 }}
|
scroll={{ x: 920, y: 520 }}
|
||||||
locale={{ emptyText: '暂无 kuaishou-feifei 商品映射' }}
|
locale={{ emptyText: '暂无 kuaishou-feifei 商品映射' }}
|
||||||
className="platform-section-gap"
|
className="platform-section-gap"
|
||||||
@@ -1170,7 +1171,7 @@ function KuaishouCloudFulfillmentPanel() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
pagination={{ pageSize: 20, showSizeChanger: true }}
|
pagination={buildAdminLocalTablePagination()}
|
||||||
scroll={{ x: 1000, y: 420 }}
|
scroll={{ x: 1000, y: 420 }}
|
||||||
locale={{ emptyText: '当前账号暂无可展示商品' }}
|
locale={{ emptyText: '当前账号暂无可展示商品' }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -77,6 +77,11 @@ import type {
|
|||||||
AdminScheduledJobsConfig,
|
AdminScheduledJobsConfig,
|
||||||
} from '@/types/admin'
|
} from '@/types/admin'
|
||||||
import { hasAdminRole } from '@/utils/admin-auth'
|
import { hasAdminRole } from '@/utils/admin-auth'
|
||||||
|
import {
|
||||||
|
ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
buildAdminLocalTablePagination,
|
||||||
|
buildAdminTablePagination,
|
||||||
|
} from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
|
|
||||||
type PlatformTab =
|
type PlatformTab =
|
||||||
@@ -441,14 +446,12 @@ function NinetyonePanel({
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items || []}
|
dataSource={data?.items || []}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 1200 }}
|
||||||
pagination={{
|
pagination={buildAdminTablePagination({
|
||||||
current: data?.page || 1,
|
current: data?.page || 1,
|
||||||
pageSize: data?.pageSize || 20,
|
pageSize: data?.pageSize || ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
total: data?.total || 0,
|
total: data?.total || 0,
|
||||||
showSizeChanger: true,
|
|
||||||
showTotal: (total) => `共 ${total} 条`,
|
|
||||||
onChange: (nextPage, nextPageSize) => loadOrders(nextPage, nextPageSize),
|
onChange: (nextPage, nextPageSize) => loadOrders(nextPage, nextPageSize),
|
||||||
}}
|
})}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
@@ -1469,7 +1472,7 @@ function KuaishouFeifeiPlatformPanel({
|
|||||||
className="platform-section-gap"
|
className="platform-section-gap"
|
||||||
rowKey={(row) => row.id || row.productCode || row.productName}
|
rowKey={(row) => row.id || row.productCode || row.productName}
|
||||||
dataSource={source.productRules}
|
dataSource={source.productRules}
|
||||||
pagination={{ pageSize: 10, showSizeChanger: true }}
|
pagination={buildAdminLocalTablePagination()}
|
||||||
scroll={{ x: 980 }}
|
scroll={{ x: 980 }}
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import type { TablePaginationConfig } from 'antd'
|
||||||
|
|
||||||
|
/** 后台标准列表默认每页条数(与后端 normalizePageSize 默认 20 一致) */
|
||||||
|
export const ADMIN_DEFAULT_PAGE_SIZE = 20
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准列表可选页大小。
|
||||||
|
* 后端 admin normalizePageSize 上限 100,故不包含更大档位。
|
||||||
|
*/
|
||||||
|
export const ADMIN_PAGE_SIZE_OPTIONS = [10, 20, 50, 100] as const
|
||||||
|
|
||||||
|
/** 云触手发货记录:上游接口更适合大批量拉取 */
|
||||||
|
export const CLOUDTENTACLES_DEFAULT_PAGE_SIZE = 100
|
||||||
|
export const CLOUDTENTACLES_PAGE_SIZE_OPTIONS = [100, 200, 500, 1000] as const
|
||||||
|
|
||||||
|
export function formatAdminTotal(total: number) {
|
||||||
|
return `共 ${total} 条`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 可复用到 Table.pagination 的标准选项(常开条数切换) */
|
||||||
|
export const ADMIN_TABLE_PAGINATION_BASE: Pick<
|
||||||
|
TablePaginationConfig,
|
||||||
|
'showSizeChanger' | 'pageSizeOptions' | 'showTotal'
|
||||||
|
> = {
|
||||||
|
showSizeChanger: true,
|
||||||
|
pageSizeOptions: [...ADMIN_PAGE_SIZE_OPTIONS],
|
||||||
|
showTotal: formatAdminTotal,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务端分页列表(任务/订单/用户/审计等)。
|
||||||
|
* 始终展示 10/20/50/100,避免 antd「total ≤ 50 不显示」默认行为。
|
||||||
|
*/
|
||||||
|
export function buildAdminTablePagination(options: {
|
||||||
|
current?: number
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
total?: number
|
||||||
|
onChange?: TablePaginationConfig['onChange']
|
||||||
|
} & Partial<TablePaginationConfig>): TablePaginationConfig {
|
||||||
|
const { current, page, pageSize, total, onChange, ...rest } = options
|
||||||
|
return {
|
||||||
|
...ADMIN_TABLE_PAGINATION_BASE,
|
||||||
|
current: current ?? page ?? 1,
|
||||||
|
pageSize: pageSize ?? ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
total: total ?? 0,
|
||||||
|
onChange,
|
||||||
|
...rest,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 纯前端本地表格分页 */
|
||||||
|
export function buildAdminLocalTablePagination(
|
||||||
|
options: Partial<TablePaginationConfig> = {},
|
||||||
|
): TablePaginationConfig {
|
||||||
|
return {
|
||||||
|
...ADMIN_TABLE_PAGINATION_BASE,
|
||||||
|
pageSize: ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
...options,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 云触手发货记录分页(100–1000) */
|
||||||
|
export function buildCloudtentaclesTablePagination(options: {
|
||||||
|
current?: number
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
total?: number
|
||||||
|
onChange?: TablePaginationConfig['onChange']
|
||||||
|
} & Partial<TablePaginationConfig>): TablePaginationConfig {
|
||||||
|
const { current, page, pageSize, total, onChange, ...rest } = options
|
||||||
|
return {
|
||||||
|
showSizeChanger: true,
|
||||||
|
pageSizeOptions: [...CLOUDTENTACLES_PAGE_SIZE_OPTIONS],
|
||||||
|
showTotal: formatAdminTotal,
|
||||||
|
current: current ?? page ?? 1,
|
||||||
|
pageSize: pageSize ?? CLOUDTENTACLES_DEFAULT_PAGE_SIZE,
|
||||||
|
total: total ?? 0,
|
||||||
|
onChange,
|
||||||
|
...rest,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveAdminPageSize(
|
||||||
|
raw: unknown,
|
||||||
|
fallback: number = ADMIN_DEFAULT_PAGE_SIZE,
|
||||||
|
): number {
|
||||||
|
const parsed = Number(raw)
|
||||||
|
if (!Number.isFinite(parsed) || parsed <= 0) {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
return Math.min(100, Math.floor(parsed))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user