7fa943eb
梁灏
init
|
1
2
3
|
<template>
<div v-if="showSizer || showElevator" :class="optsClasses">
<div v-if="showSizer" :class="sizerClasses">
|
6932b4d7
梁灏
update Page compo...
|
4
|
<i-select :model.sync="pageSize" :size="size" @on-change="changeSize">
|
012cbf28
梁灏
update locale
|
5
|
<i-option v-for="item in pageSizeOpts" :value="item" style="text-align:center;">{{ item }} {{ t('i.page.page') }}</i-option>
|
e355dd49
梁灏
add Select Component
|
6
|
</i-select>
|
7fa943eb
梁灏
init
|
7
8
|
</div>
<div v-if="showElevator" :class="ElevatorClasses">
|
012cbf28
梁灏
update locale
|
9
|
{{ t('i.page.goto') }}
|
7fa943eb
梁灏
init
|
10
|
<input type="text" :value="_current" @keyup.enter="changePage">
|
012cbf28
梁灏
update locale
|
11
|
{{ t('i.page.p') }}
|
7fa943eb
梁灏
init
|
12
13
14
15
|
</div>
</div>
</template>
<script>
|
e355dd49
梁灏
add Select Component
|
16
17
|
import iSelect from '../../components/select/select.vue';
import iOption from '../../components/select/option.vue';
|
012cbf28
梁灏
update locale
|
18
|
import Locale from '../../mixins/locale';
|
e355dd49
梁灏
add Select Component
|
19
|
|
7fa943eb
梁灏
init
|
20
21
22
23
24
25
26
|
const prefixCls = 'ivu-page';
function isValueNumber (value) {
return (/^[1-9][0-9]*$/).test(value + '');
}
export default {
|
012cbf28
梁灏
update locale
|
27
|
mixins: [ Locale ],
|
e355dd49
梁灏
add Select Component
|
28
|
components: { iSelect, iOption },
|
7fa943eb
梁灏
init
|
29
30
31
32
33
34
35
|
props: {
pageSizeOpts: Array,
showSizer: Boolean,
showElevator: Boolean,
current: Number,
_current: Number,
pageSize: Number,
|
6932b4d7
梁灏
update Page compo...
|
36
37
|
allPages: Number,
isSmall: Boolean
|
7fa943eb
梁灏
init
|
38
39
|
},
computed: {
|
6932b4d7
梁灏
update Page compo...
|
40
41
42
|
size () {
return this.isSmall ? 'small' : 'default';
},
|
7fa943eb
梁灏
init
|
43
44
45
|
optsClasses () {
return [
`${prefixCls}-options`
|
b0893113
jingsam
add eslint
|
46
|
];
|
7fa943eb
梁灏
init
|
47
48
49
50
|
},
sizerClasses () {
return [
`${prefixCls}-options-sizer`
|
b0893113
jingsam
add eslint
|
51
|
];
|
7fa943eb
梁灏
init
|
52
53
54
55
|
},
ElevatorClasses () {
return [
`${prefixCls}-options-elevator`
|
b0893113
jingsam
add eslint
|
56
|
];
|
7fa943eb
梁灏
init
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
}
},
methods: {
changeSize () {
this.$emit('on-size', this.pageSize);
},
changePage (event) {
let val = event.target.value.trim();
let page = 0;
if (isValueNumber(val)) {
val = Number(val);
if (val != this.current) {
const allPages = this.allPages;
if (val > allPages) {
page = allPages;
} else {
page = val;
}
}
} else {
page = 1;
}
if (page) {
this.$emit('on-page', page);
event.target.value = page;
}
}
}
|
b0893113
jingsam
add eslint
|
88
89
|
};
</script>
|