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