save
This commit is contained in:
parent
5bb83ff8e5
commit
29b7afae8f
3 changed files with 49 additions and 38 deletions
|
@ -87,7 +87,7 @@
|
||||||
},
|
},
|
||||||
value: {
|
value: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 1
|
default: null
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
validator (value) {
|
validator (value) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<li
|
<li
|
||||||
:title="t('i.page.prev')"
|
:title="t('i.page.prev')"
|
||||||
:class="prevClasses"
|
:class="prevClasses"
|
||||||
@click="prev">
|
@click.stop="prev">
|
||||||
<a><i class="ivu-icon ivu-icon-ios-arrow-back"></i></a>
|
<a><i class="ivu-icon ivu-icon-ios-arrow-back"></i></a>
|
||||||
</li>
|
</li>
|
||||||
<div :class="simplePagerClasses" :title="currentPage + '/' + allPages">
|
<div :class="simplePagerClasses" :title="currentPage + '/' + allPages">
|
||||||
|
@ -12,7 +12,6 @@
|
||||||
: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">
|
||||||
|
@ -22,7 +21,7 @@
|
||||||
<li
|
<li
|
||||||
:title="t('i.page.next')"
|
:title="t('i.page.next')"
|
||||||
:class="nextClasses"
|
:class="nextClasses"
|
||||||
@click="next">
|
@click.stop="next">
|
||||||
<a><i class="ivu-icon ivu-icon-ios-arrow-forward"></i></a>
|
<a><i class="ivu-icon ivu-icon-ios-arrow-forward"></i></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -33,24 +32,24 @@
|
||||||
<li
|
<li
|
||||||
:title="t('i.page.prev')"
|
:title="t('i.page.prev')"
|
||||||
:class="prevClasses"
|
: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>
|
<a><template v-if="prevText !== ''">{{ prevText }}</template><i v-else class="ivu-icon ivu-icon-ios-arrow-back"></i></a>
|
||||||
</li>
|
</li>
|
||||||
<li title="1" :class="firstPageClasses" @click="changePage(1)"><a>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="fastPrev"><a><i class="ivu-icon ivu-icon-ios-arrow-back"></i></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="changePage(currentPage - 3)"><a>{{ currentPage - 3 }}</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="changePage(currentPage - 2)"><a>{{ currentPage - 2 }}</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="changePage(currentPage - 1)"><a>{{ currentPage - 1 }}</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" 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 + 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="changePage(currentPage + 2)"><a>{{ currentPage + 2 }}</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="changePage(currentPage + 3)"><a>{{ currentPage + 3 }}</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="fastNext"><a><i class="ivu-icon ivu-icon-ios-arrow-forward"></i></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="changePage(allPages)"><a>{{ allPages }}</a></li>
|
<li :title="allPages" v-if="allPages > 1" :class="lastPageClasses" @click.stop="changePage(allPages)"><a>{{ allPages }}</a></li>
|
||||||
<li
|
<li
|
||||||
:title="t('i.page.next')"
|
:title="t('i.page.next')"
|
||||||
:class="nextClasses"
|
: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>
|
<a><template v-if="nextText !== ''">{{ nextText }}</template><i v-else class="ivu-icon ivu-icon-ios-arrow-forward"></i></a>
|
||||||
</li>
|
</li>
|
||||||
<Options
|
<Options
|
||||||
|
@ -62,7 +61,6 @@
|
||||||
: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"
|
||||||
|
@ -147,7 +145,11 @@
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
disabled: {
|
cacheKey: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
cachePageSize: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
|
@ -198,7 +200,6 @@
|
||||||
`${prefixCls}`,
|
`${prefixCls}`,
|
||||||
{
|
{
|
||||||
[`${this.className}`]: !!this.className,
|
[`${this.className}`]: !!this.className,
|
||||||
[`${prefixCls}-with-disabled`]: this.disabled,
|
|
||||||
'mini': !!this.size
|
'mini': !!this.size
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -207,7 +208,7 @@
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-prev`,
|
`${prefixCls}-prev`,
|
||||||
{
|
{
|
||||||
[`${prefixCls}-disabled`]: this.currentPage === 1 || this.disabled,
|
[`${prefixCls}-disabled`]: this.currentPage === 1,
|
||||||
[`${prefixCls}-custom-text`]: this.prevText !== ''
|
[`${prefixCls}-custom-text`]: this.prevText !== ''
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -216,7 +217,7 @@
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-next`,
|
`${prefixCls}-next`,
|
||||||
{
|
{
|
||||||
[`${prefixCls}-disabled`]: this.currentPage === this.allPages || this.disabled,
|
[`${prefixCls}-disabled`]: this.currentPage === this.allPages,
|
||||||
[`${prefixCls}-custom-text`]: this.nextText !== ''
|
[`${prefixCls}-custom-text`]: this.nextText !== ''
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -236,11 +237,17 @@
|
||||||
[`${prefixCls}-item-active`]: this.currentPage === this.allPages
|
[`${prefixCls}-item-active`]: this.currentPage === this.allPages
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
},
|
||||||
|
pageSizeKey() {
|
||||||
|
if (this.cachePageSize && this.cacheKey !== null) {
|
||||||
|
return `pageSize_${this.cacheKey}`;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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);
|
||||||
|
@ -248,7 +255,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
prev () {
|
prev () {
|
||||||
if (this.disabled) return;
|
|
||||||
const current = this.currentPage;
|
const current = this.currentPage;
|
||||||
if (current <= 1) {
|
if (current <= 1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -256,7 +262,6 @@
|
||||||
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;
|
||||||
|
@ -264,7 +269,6 @@
|
||||||
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);
|
||||||
|
@ -273,7 +277,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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);
|
||||||
|
@ -282,13 +285,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
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);
|
||||||
|
if (this.cachePageSize && this.cacheKey !== null) {
|
||||||
|
window.localStorage.setItem(this.pageSizeKey, pageSize);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onPage (page) {
|
onPage (page) {
|
||||||
if (this.disabled) return;
|
|
||||||
this.changePage(page);
|
this.changePage(page);
|
||||||
},
|
},
|
||||||
keyDown (e) {
|
keyDown (e) {
|
||||||
|
|
|
@ -112,6 +112,11 @@
|
||||||
padding: {
|
padding: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
// 增加模态特性
|
||||||
|
modal: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
// 3.4.0
|
// 3.4.0
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -213,6 +218,7 @@
|
||||||
if (this.transfer) this.disableCloseUnderTransfer = true;
|
if (this.transfer) this.disableCloseUnderTransfer = true;
|
||||||
},
|
},
|
||||||
handleClose () {
|
handleClose () {
|
||||||
|
if (!this.modal) {
|
||||||
if (this.disableCloseUnderTransfer) {
|
if (this.disableCloseUnderTransfer) {
|
||||||
this.disableCloseUnderTransfer = false;
|
this.disableCloseUnderTransfer = false;
|
||||||
return false;
|
return false;
|
||||||
|
@ -225,6 +231,7 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleFocus (fromInput = true) {
|
handleFocus (fromInput = true) {
|
||||||
if (this.disabled) return;
|
if (this.disabled) return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue