3434 </div >
3535
3636 <div
37+ ref =" paginationRef"
3738 class =" complex-table__pagination flex items-center w-full sm:flex-row flex-col text-xs sm:text-sm"
3839 v-if =" props.paginationConfig"
3940 :class =" { '!justify-between': slots.paginationLeft, '!justify-end': !slots.paginationLeft }"
4748 :page-sizes =" [5, 10, 20, 50, 100, 200, 500]"
4849 @size-change =" sizeChange"
4950 @current-change =" currentChange"
51+ :pager-count =" responsivePagerCount"
5052 :size =" mobile || paginationConfig.small ? 'small' : 'default'"
51- :layout ="
52- mobile || paginationConfig.small
53- ? 'total, prev, pager, next'
54- : 'total, sizes, prev, pager, next, jumper'
55- "
53+ :layout =" responsivePaginationLayout"
5654 />
5755 </slot >
5856 </div >
@@ -114,7 +112,10 @@ const mobile = computed(() => {
114112const tableRef = ref ();
115113const tableHeight = ref <number | string >(' ' );
116114const menuRef = ref <HTMLElement | null >(null );
115+ const paginationRef = ref <HTMLElement | null >(null );
117116const leftSelect = ref (false );
117+ const paginationWidth = ref (0 );
118+ let paginationResizeObserver: ResizeObserver | null = null ;
118119
119120const rightClick = ref ({
120121 visible: false ,
@@ -197,6 +198,33 @@ function clearSort() {
197198 tableRef .value .refElTable .clearSort ();
198199}
199200
201+ const updatePaginationWidth = () => {
202+ paginationWidth .value = paginationRef .value ?.clientWidth || 0 ;
203+ };
204+
205+ const responsivePaginationLayout = computed (() => {
206+ if (mobile .value || props .paginationConfig ?.small ) {
207+ return ' total, prev, pager, next' ;
208+ }
209+ if (paginationWidth .value < 520 ) {
210+ return ' total, prev, pager, next' ;
211+ }
212+ return ' total, sizes, prev, pager, next, jumper' ;
213+ });
214+
215+ const responsivePagerCount = computed (() => {
216+ if (mobile .value || props .paginationConfig ?.small ) {
217+ return 5 ;
218+ }
219+ if (paginationWidth .value < 520 ) {
220+ return 3 ;
221+ }
222+ if (paginationWidth .value < 720 ) {
223+ return 5 ;
224+ }
225+ return 7 ;
226+ });
227+
200228const adjustedX = ref (rightClick .value .left );
201229const adjustedY = ref (rightClick .value .top );
202230
@@ -273,6 +301,13 @@ const toggleSelection = () => {
273301
274302onMounted (() => {
275303 calcHeight ();
304+ nextTick (() => {
305+ updatePaginationWidth ();
306+ if (paginationRef .value ) {
307+ paginationResizeObserver = new ResizeObserver (updatePaginationWidth );
308+ paginationResizeObserver .observe (paginationRef .value );
309+ }
310+ });
276311 window .addEventListener (' resize' , calcHeight );
277312 watch (
278313 () => props .height ,
@@ -284,6 +319,8 @@ onMounted(() => {
284319
285320onBeforeUnmount (() => {
286321 window .removeEventListener (' resize' , calcHeight );
322+ paginationResizeObserver ?.disconnect ();
323+ paginationResizeObserver = null ;
287324});
288325 </script >
289326
@@ -362,5 +399,15 @@ onBeforeUnmount(() => {
362399.complex-table__pagination {
363400 flex : 1 ;
364401 @include flex-row (flex-end );
402+
403+ :deep (.el-pagination__sizes .el-select ) {
404+ width : 128px ;
405+ min-width : 128px ;
406+ }
407+
408+ :deep(.el-pagination--small .el-pagination__sizes .el-select ) {
409+ width : 100px ;
410+ min-width : 100px ;
411+ }
365412}
366413 </style >
0 commit comments