Skip to content

Commit 4e2adfe

Browse files
committed
feat: enhance page size options to include dynamic selection and sorting
1 parent 2cc7c4e commit 4e2adfe

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,20 @@ const emits = defineEmits([
430430
]);
431431
432432
const pageSizeOptionsComputed = computed(() => {
433-
const options = props.resource?.options?.listPageSizeOptions || [10, 20, 50, 100];
434-
return options.map(size => ({
433+
let options = props.resource?.options?.listPageSizeOptions;
434+
435+
if (!options || options.length === 0) {
436+
return [];
437+
}
438+
439+
let combinedOptions = [...options];
440+
441+
if (props.pageSize && !combinedOptions.includes(props.pageSize)) {
442+
combinedOptions.push(props.pageSize);
443+
combinedOptions.sort((a, b) => a - b);
444+
}
445+
446+
return combinedOptions.map(size => ({
435447
value: size,
436448
label: size.toString()
437449
}));
@@ -444,6 +456,10 @@ const selectDynamicWidth = computed(() => {
444456
return `${length + 5}ch`;
445457
})
446458
459+
watch(() => props.pageSize, (newVal) => {
460+
pageSizeInternal.value = newVal;
461+
});
462+
447463
watch(() => pageSizeInternal.value, (newSize) => {
448464
if (newSize) {
449465
localStorage.setItem(`pageSize_${props.resource?.resourceId}`, newSize.toString());

0 commit comments

Comments
 (0)