...
|
...
|
@@ -19,7 +19,7 @@ |
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
module.exports = {
|
|
|
export default {
|
|
|
props: {
|
|
|
pageSize: {
|
|
|
type: Number,
|
...
|
...
|
@@ -35,7 +35,7 @@ |
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
rowsTotal: function (newVal, oldVal) {
|
|
|
rowsTotal(newVal, oldVal) {
|
|
|
if (newVal !== oldVal) {
|
|
|
// init option when rows changes
|
|
|
this.page = 1
|
...
|
...
|
@@ -43,7 +43,7 @@ |
|
|
this.isLast = false
|
|
|
}
|
|
|
},
|
|
|
pageTotal: function (newVal, oldVal) {
|
|
|
pageTotal(newVal, oldVal) {
|
|
|
if (newVal === 1) {
|
|
|
// only one page
|
|
|
this.isFirst = true
|
...
|
...
|
@@ -52,7 +52,7 @@ |
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
pageChunkCurrent: function () {
|
|
|
pageChunkCurrent() {
|
|
|
let pageTotal = Math.ceil(this.rowsTotal / this.pageSize)
|
|
|
let pageArr = []
|
|
|
for (let i = 0; i < pageTotal; i++) {
|
...
|
...
|
@@ -65,7 +65,7 @@ |
|
|
}
|
|
|
return pageChunk[this.pageChunkIndex]
|
|
|
},
|
|
|
pageTotal: function () {
|
|
|
pageTotal() {
|
|
|
let total = Math.ceil(this.rowsTotal / this.pageSize)
|
|
|
if (total === 1) {
|
|
|
this.isLast = true
|
...
|
...
|
@@ -73,7 +73,7 @@ |
|
|
}
|
|
|
return Math.ceil(this.rowsTotal / this.pageSize)
|
|
|
},
|
|
|
isActive: function () {
|
|
|
isActive() {
|
|
|
let pageTotal = this.pageTotal
|
|
|
let o = {}
|
|
|
for (let i = 0; i < pageTotal; i++) {
|
...
|
...
|
@@ -84,7 +84,7 @@ |
|
|
return o
|
|
|
}
|
|
|
},
|
|
|
data: function () {
|
|
|
data() {
|
|
|
let pageTotal = this.pageTotal
|
|
|
let pageArr = []
|
|
|
for (let i = 0; i < pageTotal; i++) {
|
...
|
...
|
@@ -103,7 +103,7 @@ |
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
nav: function (n) {
|
|
|
nav(n) {
|
|
|
let activeObj = this.isActive
|
|
|
activeObj[activeObj['actived']] = 0
|
|
|
activeObj[n] = 1
|
...
|
...
|
@@ -113,7 +113,7 @@ |
|
|
this.page = n
|
|
|
this.$dispatch('page', this.page)
|
|
|
},
|
|
|
next: function () {
|
|
|
next() {
|
|
|
let activeObj = this.isActive
|
|
|
if (activeObj.actived % this.pageSize === 0) {
|
|
|
this.pageChunkIndex += 1
|
...
|
...
|
@@ -123,7 +123,7 @@ |
|
|
this.nav(activeObj.actived + 1)
|
|
|
}
|
|
|
},
|
|
|
prev: function () {
|
|
|
prev() {
|
|
|
let activeObj = this.isActive
|
|
|
if (activeObj.actived - 1 >= 1) {
|
|
|
this.nav(activeObj.actived - 1)
|
...
|
...
|
|