Compare commits

...

2 Commits

4 changed files with 45 additions and 104 deletions

View File

@ -134,10 +134,6 @@ export default {
updatePageCount(newPageSize) { updatePageCount(newPageSize) {
this.pageCount = Math.floor(this.dataCount / newPageSize); this.pageCount = Math.floor(this.dataCount / newPageSize);
this.pageCount += this.dataCount % newPageSize == 0 ? 0 : 1; this.pageCount += this.dataCount % newPageSize == 0 ? 0 : 1;
},
//
updateRows(newPageIndex) {
}, },
// //
updatePageBtn(newPageIndex){ updatePageBtn(newPageIndex){
@ -155,7 +151,9 @@ export default {
this.pageBtn.push({text: '...', index: newPageIndex}) this.pageBtn.push({text: '...', index: newPageIndex})
} }
// //
for(let i = newPageIndex - 2; i <= newPageIndex + 2; i++){ const numleft = (newPageIndex - 2) < 2 ? newPageIndex - 2 : 2;
const numright = (newPageIndex + 2) < this.pageCount ? 2 : (this.pageCount - newPageIndex - 1);
for(let i = newPageIndex - numleft; i <= newPageIndex + numright; i++){
this.pageBtn.push({text: `${i}`, index: i}) this.pageBtn.push({text: `${i}`, index: i})
} }
//21 //21
@ -174,7 +172,7 @@ export default {
this.updatePageCount(newVal) this.updatePageCount(newVal)
// //
this.currentPageIndex = 1 this.currentPageIndex = 1
this.updateRows(this.currentPageIndex) this.$emit('pageChanged',{pageIndex:this.currentPageIndex,pageSize:newVal})
this.updatePageBtn(this.currentPageIndex) this.updatePageBtn(this.currentPageIndex)
}, },
immediate: true immediate: true
@ -182,7 +180,7 @@ export default {
// //
'currentPageIndex': { 'currentPageIndex': {
handler(newVal) { handler(newVal) {
this.updateRows(newVal) this.$emit('pageChanged',{pageIndex:newVal,pageSize:this.pageSize})
this.updatePageBtn(newVal) this.updatePageBtn(newVal)
}, },
immediate: true immediate: true

View File

@ -17,11 +17,15 @@ const getUserInfo = async () => await request.get('/api/User/UserInfo')
//获取用户列表(分页) //获取用户列表(分页)
const getUserList = async (pageIndex,pageSize,desc) => await request.get(`/api/Admin/UserList?pageIndex=${pageIndex}&pageSize=${pageSize}&desc=${desc}`) const getUserList = async (pageIndex,pageSize,desc) => await request.get(`/api/Admin/UserList?pageIndex=${pageIndex}&pageSize=${pageSize}&desc=${desc}`)
//获取用户数量
const getUserCount = async () => await request.get('/api/Admin/UserCount')
export default { export default {
login, login,
register, register,
SendValidateCode, SendValidateCode,
getAllConfig, getAllConfig,
getUserInfo, getUserInfo,
getUserList getUserList,
getUserCount
} }

View File

@ -61,13 +61,24 @@ const routes = [
path: 'test', path: 'test',
component: () => import('@/views/layout/Users.vue'), component: () => import('@/views/layout/Users.vue'),
meta: { meta: {
title: '用户管理', title: '充值中心',
icon: 'inbox', icon: 'inbox',
showInMenu: true, showInMenu: true,
showInUser:false, showInUser:false,
isHome:false isHome:false
} }
}, },
{
path: 'api',
component: () => import('@/views/layout/Dashboard.vue'),
meta: {
title: 'API管理',
icon: 'home',
showInMenu: true,
showInUser:false,
isHome:true
}
},
] ]
} }
] ]

View File

@ -2,8 +2,8 @@
<div class="main-wrapper"> <div class="main-wrapper">
<div class="row"> <div class="row">
<div class="col"> <div class="col" v-if="isLoaded">
<DataTable :title="'员工信息表'" :headers="tableHeaders" :rows="tableData" :data-count="dataCount"/> <DataTable :title="'用户管理'" :headers="tableHeaders" :rows="tableData" :data-count="dataCount" @pageChanged="pageChangedHandle"/>
</div> </div>
</div> </div>
</div> </div>
@ -16,113 +16,41 @@ export default {
components: { DataTable }, components: { DataTable },
data() { data() {
return { return {
dataCount:11, dataCount:0,
isLoaded:false,
tableHeaders: [ tableHeaders: [
{ text: "名字", value: "name", width: "155px" }, { text: "编号", value: "id", width: "155px" },
{ text: "位置", value: "position", width: "214px" }, { text: "用户名", value: "userName", width: "214px" },
{ text: "办公室", value: "office", width: "48px" }, { text: "邮箱", value: "email", width: "48px" },
{ text: "年龄", value: "age", width: "29px" }, { text: "余额", value: "balance", width: "29px" },
{ text: "开始日期", value: "startDate", width: "82px" }, { text: "状态", value: "isBan", width: "82px",type:"state"},
{ text: "工资", value: "salary", width: "103px" }, { text: "角色", value: "roles", width: "103px" },
], { text: "创建时间", value: "created", width: "103px" },
tableData: [
{
name: "佐藤爱理",
position: "会计",
office: "东京",
age: 33,
startDate: "2008/11/28",
salary: "162,700 元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
{
name: "安吉莉卡·拉莫斯",
position: "首席执行官 CEO",
office: "伦敦",
age: 47,
startDate: "2009/10/09",
salary: "1,200,000 美元",
},
// ...
], ],
tableData: [],
}; };
}, },
methods: { methods: {
async loadUserList(pageIndex = 1, pageSize = 10, desc = false){ async loadUserList(pageIndex = 1, pageSize = 10, desc = false){
try{ try{
const res = await this.$api.getUserList(pageIndex,pageSize,desc) const res = await this.$api.getUserList(pageIndex,pageSize,desc)
console.log(res) if(res.code == '1000'){
this.tableData = res.data
}
}catch(e){ }catch(e){
this.$alert('用户列表数据加载失败!','danger') this.$alert('用户列表数据加载失败!','danger')
console.error(e) console.error(e)
} }
},
async pageChangedHandle(newval){
console.log(newval)
await this.loadUserList(newval.pageIndex,newval.pageSize,false)
} }
}, },
mounted(){ async mounted(){
this.loadUserList() await this.loadUserList()
this.dataCount = (await this.$api.getUserCount()).data
this.isLoaded = true
} }
}; };
</script> </script>