This commit is contained in:
prefert 2020-09-03 16:11:11 +08:00
parent 5bb83ff8e5
commit 29b7afae8f
3 changed files with 49 additions and 38 deletions

View file

@ -87,7 +87,7 @@
},
value: {
type: Number,
default: 1
default: null
},
size: {
validator (value) {

View file

@ -3,7 +3,7 @@
<li
:title="t('i.page.prev')"
:class="prevClasses"
@click="prev">
@click.stop="prev">
<a><i class="ivu-icon ivu-icon-ios-arrow-back"></i></a>
</li>
<div :class="simplePagerClasses" :title="currentPage + '/' + allPages">
@ -12,7 +12,6 @@
:value="currentPage"
autocomplete="off"
spellcheck="false"
:disabled="disabled"
@keydown="keyDown"
@keyup="keyUp"
@change="keyUp">
@ -22,7 +21,7 @@
<li
:title="t('i.page.next')"
:class="nextClasses"
@click="next">
@click.stop="next">
<a><i class="ivu-icon ivu-icon-ios-arrow-forward"></i></a>
</li>
</ul>
@ -33,24 +32,24 @@
<li
:title="t('i.page.prev')"
:class="prevClasses"
@click="prev">
@click.stop="prev">
<a><template v-if="prevText !== ''">{{ prevText }}</template><i v-else class="ivu-icon ivu-icon-ios-arrow-back"></i></a>
</li>
<li title="1" :class="firstPageClasses" @click="changePage(1)"><a>1</a></li>
<li :title="t('i.page.prev5')" v-if="currentPage > 5" :class="[prefixCls + '-item-jump-prev']" @click="fastPrev"><a><i class="ivu-icon ivu-icon-ios-arrow-back"></i></a></li>
<li :title="currentPage - 3" v-if="currentPage === 5" :class="[prefixCls + '-item']" @click="changePage(currentPage - 3)"><a>{{ currentPage - 3 }}</a></li>
<li :title="currentPage - 2" v-if="currentPage - 2 > 1" :class="[prefixCls + '-item']" @click="changePage(currentPage - 2)"><a>{{ currentPage - 2 }}</a></li>
<li :title="currentPage - 1" v-if="currentPage - 1 > 1" :class="[prefixCls + '-item']" @click="changePage(currentPage - 1)"><a>{{ currentPage - 1 }}</a></li>
<li title="1" :class="firstPageClasses" @click.stop="changePage(1)"><a>1</a></li>
<li :title="t('i.page.prev5')" v-if="currentPage > 5" :class="[prefixCls + '-item-jump-prev']" @click.stop="fastPrev"><a><i class="ivu-icon ivu-icon-ios-arrow-back"></i></a></li>
<li :title="currentPage - 3" v-if="currentPage === 5" :class="[prefixCls + '-item']" @click.stop="changePage(currentPage - 3)"><a>{{ currentPage - 3 }}</a></li>
<li :title="currentPage - 2" v-if="currentPage - 2 > 1" :class="[prefixCls + '-item']" @click.stop="changePage(currentPage - 2)"><a>{{ currentPage - 2 }}</a></li>
<li :title="currentPage - 1" v-if="currentPage - 1 > 1" :class="[prefixCls + '-item']" @click.stop="changePage(currentPage - 1)"><a>{{ currentPage - 1 }}</a></li>
<li :title="currentPage" v-if="currentPage != 1 && currentPage != allPages" :class="[prefixCls + '-item',prefixCls + '-item-active']"><a>{{ currentPage }}</a></li>
<li :title="currentPage + 1" v-if="currentPage + 1 < allPages" :class="[prefixCls + '-item']" @click="changePage(currentPage + 1)"><a>{{ currentPage + 1 }}</a></li>
<li :title="currentPage + 2" v-if="currentPage + 2 < allPages" :class="[prefixCls + '-item']" @click="changePage(currentPage + 2)"><a>{{ currentPage + 2 }}</a></li>
<li :title="currentPage + 3" v-if="allPages - currentPage === 4" :class="[prefixCls + '-item']" @click="changePage(currentPage + 3)"><a>{{ currentPage + 3 }}</a></li>
<li :title="t('i.page.next5')" v-if="allPages - currentPage >= 5" :class="[prefixCls + '-item-jump-next']" @click="fastNext"><a><i class="ivu-icon ivu-icon-ios-arrow-forward"></i></a></li>
<li :title="allPages" v-if="allPages > 1" :class="lastPageClasses" @click="changePage(allPages)"><a>{{ allPages }}</a></li>
<li :title="currentPage + 1" v-if="currentPage + 1 < allPages" :class="[prefixCls + '-item']" @click.stop="changePage(currentPage + 1)"><a>{{ currentPage + 1 }}</a></li>
<li :title="currentPage + 2" v-if="currentPage + 2 < allPages" :class="[prefixCls + '-item']" @click.stop="changePage(currentPage + 2)"><a>{{ currentPage + 2 }}</a></li>
<li :title="currentPage + 3" v-if="allPages - currentPage === 4" :class="[prefixCls + '-item']" @click.stop="changePage(currentPage + 3)"><a>{{ currentPage + 3 }}</a></li>
<li :title="t('i.page.next5')" v-if="allPages - currentPage >= 5" :class="[prefixCls + '-item-jump-next']" @click.stop="fastNext"><a><i class="ivu-icon ivu-icon-ios-arrow-forward"></i></a></li>
<li :title="allPages" v-if="allPages > 1" :class="lastPageClasses" @click.stop="changePage(allPages)"><a>{{ allPages }}</a></li>
<li
:title="t('i.page.next')"
:class="nextClasses"
@click="next">
@click.stop="next">
<a><template v-if="nextText !== ''">{{ nextText }}</template><i v-else class="ivu-icon ivu-icon-ios-arrow-forward"></i></a>
</li>
<Options
@ -62,7 +61,6 @@
:show-elevator="showElevator"
:_current.once="currentPage"
:current="currentPage"
:disabled="disabled"
:all-pages="allPages"
:is-small="isSmall"
@on-size="onSize"
@ -147,7 +145,11 @@
type: String,
default: ''
},
disabled: {
cacheKey: {
type: String,
default: ''
},
cachePageSize: {
type: Boolean,
default: false
}
@ -198,7 +200,6 @@
`${prefixCls}`,
{
[`${this.className}`]: !!this.className,
[`${prefixCls}-with-disabled`]: this.disabled,
'mini': !!this.size
}
];
@ -207,7 +208,7 @@
return [
`${prefixCls}-prev`,
{
[`${prefixCls}-disabled`]: this.currentPage === 1 || this.disabled,
[`${prefixCls}-disabled`]: this.currentPage === 1,
[`${prefixCls}-custom-text`]: this.prevText !== ''
}
];
@ -216,7 +217,7 @@
return [
`${prefixCls}-next`,
{
[`${prefixCls}-disabled`]: this.currentPage === this.allPages || this.disabled,
[`${prefixCls}-disabled`]: this.currentPage === this.allPages,
[`${prefixCls}-custom-text`]: this.nextText !== ''
}
];
@ -236,11 +237,17 @@
[`${prefixCls}-item-active`]: this.currentPage === this.allPages
}
];
},
pageSizeKey() {
if (this.cachePageSize && this.cacheKey !== null) {
return `pageSize_${this.cacheKey}`;
} else {
return null;
}
}
},
methods: {
changePage (page) {
if (this.disabled) return;
if (this.currentPage != page) {
this.currentPage = page;
this.$emit('update:current', page);
@ -248,7 +255,6 @@
}
},
prev () {
if (this.disabled) return;
const current = this.currentPage;
if (current <= 1) {
return false;
@ -256,7 +262,6 @@
this.changePage(current - 1);
},
next () {
if (this.disabled) return;
const current = this.currentPage;
if (current >= this.allPages) {
return false;
@ -264,7 +269,6 @@
this.changePage(current + 1);
},
fastPrev () {
if (this.disabled) return;
const page = this.currentPage - 5;
if (page > 0) {
this.changePage(page);
@ -273,7 +277,6 @@
}
},
fastNext () {
if (this.disabled) return;
const page = this.currentPage + 5;
if (page > this.allPages) {
this.changePage(this.allPages);
@ -282,13 +285,14 @@
}
},
onSize (pageSize) {
if (this.disabled) return;
this.currentPageSize = pageSize;
this.$emit('on-page-size-change', pageSize);
this.changePage(1);
if (this.cachePageSize && this.cacheKey !== null) {
window.localStorage.setItem(this.pageSizeKey, pageSize);
}
},
onPage (page) {
if (this.disabled) return;
this.changePage(page);
},
keyDown (e) {

View file

@ -112,6 +112,11 @@
padding: {
type: String
},
//
modal: {
type: Boolean,
default: false,
},
// 3.4.0
disabled: {
type: Boolean,
@ -213,6 +218,7 @@
if (this.transfer) this.disableCloseUnderTransfer = true;
},
handleClose () {
if (!this.modal) {
if (this.disableCloseUnderTransfer) {
this.disableCloseUnderTransfer = false;
return false;
@ -225,6 +231,7 @@
return false;
}
this.visible = false;
}
},
handleFocus (fromInput = true) {
if (this.disabled) return;