Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加在用户管理界面仅查看管理员的功能 #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/pages/admin/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ export default {
})
},
// 获取用户列表
getUserList (offset, limit, keyword) {
getUserList (offset, limit, keyword, onlyadmin) {
let params = {paging: true, offset, limit}
if (keyword) {
params.keyword = keyword
}
if (onlyadmin) {
params.onlyadmin = true
}
return ajax('admin/user', 'get', {
params: params
})
Expand Down
18 changes: 17 additions & 1 deletion src/pages/admin/views/general/User.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
</el-table-column>
</el-table>
<div class="panel-options">
<el-form label-width="120px" label-position="left">
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="Only Admin">
<el-switch
v-model="onlyadmin">
</el-switch>
</el-form-item>
</el-col>
</el-row>
</el-form>

<el-pagination
class="page"
layout="prev, pager, next"
Expand Down Expand Up @@ -268,6 +280,7 @@
uploadUsersPageSize: 15,
// 搜索关键字
keyword: '',
onlyadmin: false,
// 是否显示用户对话框
showUserDialog: false,
// 当前用户model
Expand Down Expand Up @@ -317,7 +330,7 @@
// 获取用户列表
getUserList (page) {
this.loadingTable = true
api.getUserList((page - 1) * this.pageSize, this.pageSize, this.keyword).then(res => {
api.getUserList((page - 1) * this.pageSize, this.pageSize, this.keyword, this.onlyadmin).then(res => {
this.loadingTable = false
this.total = res.data.data.total
this.userList = res.data.data.results
Expand Down Expand Up @@ -400,6 +413,9 @@
}
},
watch: {
'onlyadmin' () {
this.currentChange(1)
},
'keyword' () {
this.currentChange(1)
},
Expand Down
3 changes: 2 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ function downloadFile (url) {
}
let link = document.createElement('a')
link.href = window.URL.createObjectURL(new window.Blob([resp.data], {type: headers['content-type']}))
link.download = (headers['content-disposition'] || '').split('filename=')[1]
let filename = (headers['content-disposition'] || '').split('filename=')[1]
link.download = decodeURI(filename)
document.body.appendChild(link)
link.click()
link.remove()
Expand Down