[Update] 增加系统用户列表组件

This commit is contained in:
jym503558564 2020-03-22 11:26:10 +08:00
parent 5db2301b5d
commit 4b0b46d23f
5 changed files with 174 additions and 12 deletions

View File

@ -8,3 +8,11 @@ export function getAdminUserList(data) {
}) })
} }
export function getSystemUserList(data) {
return request({
url: '/api/v1/assets/system-users/',
method: 'get',
params: data
})
}

View File

@ -19,7 +19,7 @@ const cn = {
'AssetList': '资产列表', 'AssetList': '资产列表',
'DomainList': '网关列表', 'DomainList': '网关列表',
'AdminUserList': '管理用户', 'AdminUserList': '管理用户',
'systemUserList': '系统用户', 'SystemUserList': '系统用户',
'labelList': '标签管理', 'labelList': '标签管理',
'commandFilterList': '命令过滤', 'commandFilterList': '命令过滤',
'platformList': '平台列表', 'platformList': '平台列表',
@ -171,10 +171,10 @@ const cn = {
'replace_node_assets_admin_user_with_this': '替换资产的管理员', 'replace_node_assets_admin_user_with_this': '替换资产的管理员',
'select_nodes': '选择节点', 'select_nodes': '选择节点',
// 系统用户 // 系统用户
'system_user_list': '系统用户列表', 'SystemUserList': '系统用户列表',
'create_system_user': '创建系统用户', 'SystemUserDetail': '系统用户详情',
'update_system_user': '更新系统用户', 'SystemUserCreate': '创建系统用户',
'system_user_detail': '系统用户详情', 'SystemUserUpdate': '更新系统用户',
'protocol': '协议', 'protocol': '协议',
'login_mode': '登录模式', 'login_mode': '登录模式',
'quick_update': '快速更新', 'quick_update': '快速更新',

View File

@ -121,7 +121,7 @@ export const constantRoutes = [
meta: { title: 'DomainList' } meta: { title: 'DomainList' }
}, },
{ {
path: 'admin-user', path: 'admin-user/list',
name: 'AdminUserList', name: 'AdminUserList',
component: () => import('@/views/assets/AdminUserList'), component: () => import('@/views/assets/AdminUserList'),
meta: { title: 'AdminUserList' } meta: { title: 'AdminUserList' }
@ -134,10 +134,10 @@ export const constantRoutes = [
hidden: true hidden: true
}, },
{ {
path: 'system-users', path: 'system-user/list',
name: 'systemUserList', name: 'SystemUserList',
component: () => import('@/views/tree/index'), component: () => import('@/views/assets/SystemUserList.vue'),
meta: { title: 'systemUserList' } meta: { title: 'SystemUserList' }
}, },
{ {
path: 'labels', path: 'labels',

View File

@ -107,13 +107,13 @@ export default {
// //
this.offset = (this.current_page - 1) * val this.offset = (this.current_page - 1) * val
this.page_size = val this.page_size = val
this.getAdminUserList(this.current_page, val, this.offset) this.getAdminUser(this.current_page, val, this.offset)
}, },
handleCurrentChange(val) { handleCurrentChange(val) {
// //
this.offset = (val - 1) * this.page_size this.offset = (val - 1) * this.page_size
this.current_page = val this.current_page = val
this.getAdminUserList(val, this.page_size, this.offset) this.getAdminUser(val, this.page_size, this.offset)
}, },
getAdminUser(draw, limit, offset) { getAdminUser(draw, limit, offset) {
this.listLoading = true this.listLoading = true

View File

@ -0,0 +1,154 @@
<template>
<BackPlayground :title="$t('route.AdminUserList')">
<ListTables
:tablebotton="$t('assets.AdminUserCreate')"
tableroute="UserEdit"
@SizeChange="handleSizeChange"
@CurrentChange="handleCurrentChange"
>
<el-table
v-loading="listLoading"
:data="tableData"
stripe
border
class="userTable"
>
<el-table-column
type="selection"
width="55"
align="center"
header-align="center"
/>
<el-table-column
:label="this.$t('assets.name')"
sortable
align="center"
header-align="center"
>
<template slot-scope="scope">
<el-button type="text" size="small" style="font-size:14px" @click="handleDetail(scope.$index, scope.row)">{{ scope.row.name }}</el-button>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.username')"
sortable
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.protocol')"
sortable
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.protocol }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.login_mode')"
sortable
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.login_mode_display }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.asset')"
sortable
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.assets_amount }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.comment')"
sortable
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.comment }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.action')"
align="center"
header-align="center"
>
<template slot-scope="scope">
<el-button
size="mini"
type="primary"
@click="handleEdit(scope.$index, scope.row)"
>{{ $t('assets.update') }}</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)"
>{{ $t('assets.delete') }}</el-button>
</template>
</el-table-column>
</el-table>
</ListTables>
</BackPlayground>
</template>
<script>
import { ListTables, BackPlayground } from '@/layout/components'
import { getSystemUserList } from '@/api/asset'
import Tables from '@/layout/mixin/ListTables'
export default {
components: {
BackPlayground,
ListTables
},
mixins: [Tables],
data() {
return {
tableData: [],
listLoading: true
}
},
created() {
this.getSystemUser(this.current_page, this.page_size, this.offset)
},
methods: {
handleDetail: function(index, row) {
this.$router.push({ name: 'SystemUserDetail', params: { id: row.id }})
},
handleSizeChange(val) {
//
this.offset = (this.current_page - 1) * val
this.page_size = val
this.getSystemUser(this.current_page, val, this.offset)
},
handleCurrentChange(val) {
//
this.offset = (val - 1) * this.page_size
this.current_page = val
this.getSystemUser(val, this.page_size, this.offset)
},
getSystemUser(draw, limit, offset) {
this.listLoading = true
getSystemUserList({ draw, limit, offset }).then(response => {
this.tableData = response.results
this.total = response.count
this.listLoading = false
})
}
}
}
</script>
<style lang="less" scoped>
</style>