2929 </template >
3030 </el-table-column >
3131 </el-table >
32+ <el-row type =" flex" justify =" center" align =" middle" class =" pagination" >
33+ <el-pagination
34+ @size-change =" handleSizeChange"
35+ @current-change =" handleCurrentChange"
36+ :current-page =" pagination.current"
37+ :page-sizes =" [4,6,8,10]"
38+ :page-size =" pagination.size"
39+ layout =" total, sizes, prev, pager, next, jumper"
40+ :total =" pagination.total" >
41+ </el-pagination >
42+ </el-row >
3243 </section >
3344 </div >
3445</template >
3748export default {
3849 data () {
3950 return {
51+ pagination: { // 分页后的留言列表
52+ current: 1 , // 当前页
53+ total: null , // 记录条数
54+ size: 10 // 每页条数
55+ },
4056 loading: false , // 加载标识符
4157 score: [], // 学生成绩
4258 filter: null // 过滤参数
@@ -49,10 +65,11 @@ export default {
4965 methods: {
5066 getScore () {
5167 let studentId = this .$cookies .get (" cid" )
52- this .$axios (` /api/score/${ studentId} ` ).then (res => {
68+ this .$axios (` /api/score/${ this . pagination . current } / ${ this . pagination . size } / ${ studentId} ` ).then (res => {
5369 if (res .data .code == 200 ) {
5470 this .loading = false // 数据加载完成去掉遮罩
55- this .score = res .data .data
71+ this .score = res .data .data .records
72+ this .pagination = {... res .data .data }
5673 let mapVal = this .score .map ((element ,index ) => { // 通过map得到 filter:[{text,value}]形式的数组对象
5774 let newVal = {}
5875 newVal .text = element .answerDate
@@ -68,6 +85,16 @@ export default {
6885 }
6986 })
7087 },
88+ // 改变当前记录条数
89+ handleSizeChange (val ) {
90+ this .pagination .size = val
91+ this .getScore ()
92+ },
93+ // 改变当前页码,重新发送请求
94+ handleCurrentChange (val ) {
95+ this .pagination .current = val
96+ this .getScore ()
97+ },
7198 formatter (row , column ) {
7299 return row .address ;
73100 },
@@ -83,6 +110,9 @@ export default {
83110 </script >
84111
85112<style lang="scss" scoped>
113+ .pagination {
114+ padding-top : 20px ;
115+ }
86116.table {
87117 width : 980px ;
88118 margin : 0 auto ;
0 commit comments