This commit is contained in:
Viet An
2026-06-05 09:30:16 +07:00
parent 3cfa103306
commit fdd52d7fad
23 changed files with 336 additions and 344 deletions

View File

@@ -18,7 +18,6 @@
>
<a
v-else
href="#"
class="pagination-link"
:aria-label="`Goto page ${v}`"
@click="changePage(v)"
@@ -26,45 +25,32 @@
>
</li>
<a
@click="previous()"
@click="previous"
class="pagination-previous ml-5"
>
<SvgIcon
v-bind="{
name: 'left1.svg',
type: 'dark',
size: 20,
alt: 'Tìm kiếm',
}"
></SvgIcon>
<Icon name="material-symbols:arrow-back-ios-new-rounded" />
</a>
<a
@click="next()"
@click="next"
class="pagination-next"
>
<SvgIcon
v-bind="{
name: 'right.svg',
type: 'dark',
size: 20,
alt: 'Tìm kiếm',
}"
></SvgIcon>
<Icon name="material-symbols:arrow-forward-ios-rounded" />
</a>
</ul>
</nav>
</template>
<script setup>
const emit = defineEmits(["changepage"]);
var props = defineProps({
const props = defineProps({
data: Array,
perPage: Number,
});
var currentPage = 1;
var totalRows = props.data.length;
var lastPage = parseInt(totalRows / props.perPage);
const emit = defineEmits(["changepage"]);
let currentPage = 1;
let totalRows = props.data.length;
let lastPage = parseInt(totalRows / props.perPage);
if (lastPage * props.perPage < totalRows) lastPage += 1;
var pageInfo = ref();
const pageInfo = ref();
function pages(current_page, last_page, onSides = 2) {
// pages
let pages = [];
@@ -81,6 +67,7 @@ function pages(current_page, last_page, onSides = 2) {
}
return pages;
}
function changePage(page) {
if (page === "...") return;
currentPage = page;
@@ -90,7 +77,7 @@ function changePage(page) {
pageInfo.value = pages(1, lastPage, 2);
watch(
() => props.data,
(newVal, oldVal) => {
() => {
totalRows = props.data.length;
lastPage = parseInt(totalRows / props.perPage);
if (lastPage * props.perPage < totalRows) lastPage += 1;