/
table1.vue
82 lines (80 loc) · 1.65 KB
/
table1.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
<template>
<div>
<h1>服务端分页以及自定义序号</h1>
<iviewTablePage
:columns="columns12"
:data="data6"
:total='total'
:loading='loading'
:current='current'
:page-size='pageSize'
show-sizer
@on-change='handleChangeSize'
@on-page-size-change='handlePageChangeSize'>
</iviewTablePage>
</div>
</template>
<script>
import iviewTablePage from 'iview-table-page'
import $ from './utils'
export default {
components: { iviewTablePage },
data () {
return {
columns12: [
{
type: 'index',
width: 60,
align: 'center',
indexMethod: row => {
// 序号逻辑
return (
row._index + 1 + this.pageSize * this.current - this.pageSize
)
}
},
{
title: '姓名',
key: 'name'
}
],
data6: [],
loading: false,
total: 0,
current: 1,
pageSize: 10
}
},
methods: {
getData () {
if (this.loading) return
this.loading = true
$.ajax({
method: 'get',
url: '/data/list/' + this.current + '/' + this.pageSize
}).then(res => {
setTimeout(() => {
this.data6 = res.data.data.list
this.total = res.data.data.total
this.loading = false
}, 1000)
})
},
handleChangeSize (val) {
this.current = val
this.$nextTick(() => {
this.getData()
})
},
handlePageChangeSize (val) {
this.pageSize = val
this.$nextTick(() => {
this.getData()
})
}
},
mounted () {
this.getData()
}
}
</script>