forked from bailicangdu/vue2-manage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminList.vue
More file actions
116 lines (112 loc) · 3.31 KB
/
adminList.vue
File metadata and controls
116 lines (112 loc) · 3.31 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
<div class="fillcontain">
<head-top></head-top>
<div class="table_container">
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
prop="user_name"
label="姓名"
width="180">
</el-table-column>
<el-table-column
prop="create_time"
label="注册日期"
width="220">
</el-table-column>
<el-table-column
prop="city"
label="地址"
width="180">
</el-table-column>
<el-table-column
prop="admin"
label="权限">
</el-table-column>
</el-table>
<div class="Pagination" style="text-align: left;margin-top: 10px;">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-size="20"
layout="total, prev, pager, next"
:total="count">
</el-pagination>
</div>
</div>
</div>
</template>
<script>
import headTop from '../components/headTop'
import {adminList, adminCount} from '@/api/getData'
export default {
data(){
return {
tableData: [],
currentRow: null,
offset: 0,
limit: 20,
count: 0,
currentPage: 1,
}
},
components: {
headTop,
},
created(){
this.initData();
},
methods: {
async initData(){
try{
const countData = await adminCount();
if (countData.status == 1) {
this.count = countData.count;
}else{
throw new Error('获取数据失败');
}
this.getAdmin();
}catch(err){
console.log('获取数据失败', err);
}
},
handleSizeChange(val) {
console.log(`每页 ${val} 条`);
},
handleCurrentChange(val) {
this.currentPage = val;
this.offset = (val - 1)*this.limit;
this.getAdmin()
},
async getAdmin(){
try{
const res = await adminList({offset: this.offset, limit: this.limit});
if (res.status == 1) {
this.tableData = [];
res.data.forEach(item => {
const tableItem = {
create_time: item.create_time,
user_name: item.user_name,
admin: item.admin,
city: item.city,
}
this.tableData.push(tableItem)
})
}else{
throw new Error(res.message)
}
}catch(err){
console.log('获取数据失败', err);
}
}
},
}
</script>
<style lang="less">
@import '../style/mixin';
.table_container{
padding: 20px;
}
</style>