This commit is contained in:
prefert 2020-09-03 16:15:54 +08:00
parent 29b7afae8f
commit ad11b165bd

View file

@ -12,6 +12,7 @@
:value="currentPage"
autocomplete="off"
spellcheck="false"
:disabled="disabled"
@keydown="keyDown"
@keyup="keyUp"
@change="keyUp">
@ -61,6 +62,7 @@
:show-elevator="showElevator"
:_current.once="currentPage"
:current="currentPage"
:disabled="disabled"
:all-pages="allPages"
:is-small="isSmall"
@on-size="onSize"
@ -152,6 +154,10 @@
cachePageSize: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
}
},
data () {
@ -200,6 +206,7 @@
`${prefixCls}`,
{
[`${this.className}`]: !!this.className,
[`${prefixCls}-with-disabled`]: this.disabled,
'mini': !!this.size
}
];
@ -208,7 +215,7 @@
return [
`${prefixCls}-prev`,
{
[`${prefixCls}-disabled`]: this.currentPage === 1,
[`${prefixCls}-disabled`]: this.currentPage === 1 || this.disabled,
[`${prefixCls}-custom-text`]: this.prevText !== ''
}
];
@ -217,7 +224,7 @@
return [
`${prefixCls}-next`,
{
[`${prefixCls}-disabled`]: this.currentPage === this.allPages,
[`${prefixCls}-disabled`]: this.currentPage === this.allPages || this.disabled,
[`${prefixCls}-custom-text`]: this.nextText !== ''
}
];
@ -248,6 +255,7 @@
},
methods: {
changePage (page) {
if (this.disabled) return;
if (this.currentPage != page) {
this.currentPage = page;
this.$emit('update:current', page);
@ -255,6 +263,7 @@
}
},
prev () {
if (this.disabled) return;
const current = this.currentPage;
if (current <= 1) {
return false;
@ -262,6 +271,7 @@
this.changePage(current - 1);
},
next () {
if (this.disabled) return;
const current = this.currentPage;
if (current >= this.allPages) {
return false;
@ -269,6 +279,7 @@
this.changePage(current + 1);
},
fastPrev () {
if (this.disabled) return;
const page = this.currentPage - 5;
if (page > 0) {
this.changePage(page);
@ -277,6 +288,7 @@
}
},
fastNext () {
if (this.disabled) return;
const page = this.currentPage + 5;
if (page > this.allPages) {
this.changePage(this.allPages);
@ -285,6 +297,7 @@
}
},
onSize (pageSize) {
if (this.disabled) return;
this.currentPageSize = pageSize;
this.$emit('on-page-size-change', pageSize);
this.changePage(1);
@ -293,6 +306,7 @@
}
},
onPage (page) {
if (this.disabled) return;
this.changePage(page);
},
keyDown (e) {