Files
order_site/apps/frontend/src/components/admin/AdminPaginationBar.vue
T
2026-04-08 16:30:42 +08:00

63 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
const props = defineProps<{
page: number
pageSize: number
total: number
loading?: boolean
}>()
const emit = defineEmits<{
(event: 'change', page: number): void
}>()
function goPrev() {
if (props.page <= 1 || props.loading) {
return
}
emit('change', props.page - 1)
}
function goNext() {
if (props.loading || props.page * props.pageSize >= props.total) {
return
}
emit('change', props.page + 1)
}
</script>
<template>
<footer class="pagination-bar">
<span> {{ page }} {{ Math.max(1, Math.ceil(total / pageSize)) }} 合计 {{ total }} </span>
<div class="actions">
<el-button :disabled="page <= 1 || loading" round @click="goPrev">上一页</el-button>
<el-button :disabled="page * pageSize >= total || loading" round @click="goNext">下一页</el-button>
</div>
</footer>
</template>
<style scoped>
.pagination-bar {
display: flex;
justify-content: space-between;
gap: 12px;
align-items: center;
margin-top: 14px;
color: #64748b;
font-size: 13px;
}
.actions {
display: flex;
gap: 8px;
}
@media (max-width: 780px) {
.pagination-bar {
flex-direction: column;
align-items: flex-start;
}
}
</style>