Merge pull request #1 from jumpserver/jym_dev

[Update] 增加一些列表组件
This commit is contained in:
Orange 2020-03-22 21:01:17 +08:00 committed by GitHub
commit 89d7668814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 792 additions and 44 deletions

42
src/api/asset.js Normal file
View File

@ -0,0 +1,42 @@
import request from '@/utils/request'
export function getAdminUserList(data) {
return request({
url: '/api/v1/assets/admin-users/',
method: 'get',
params: data
})
}
export function getSystemUserList(data) {
return request({
url: '/api/v1/assets/system-users/',
method: 'get',
params: data
})
}
export function getDomainList(data) {
return request({
url: '/api/v1/assets/domains/',
method: 'get',
params: data
})
}
export function getLabelList(data) {
return request({
url: '/api/v1/assets/labels/',
method: 'get',
params: data
})
}
export function getCommandFilterList(data) {
return request({
url: '/api/v1/assets/cmd-filters/',
method: 'get',
params: data
})
}

View File

@ -15,13 +15,13 @@ const cn = {
'Users': '用户管理',
'UserList': '用户列表',
'UserGroupList': '用户组',
'assets': '资产管理',
'assetList': '资产列表',
'domainList': '网关列表',
'adminUserList': '管理用户',
'systemUserList': '系统用户',
'labelList': '标签管理',
'commandFilterList': '命令过滤',
'Assets': '资产管理',
'AssetList': '资产列表',
'DomainList': '网关列表',
'AdminUserList': '管理用户',
'SystemUserList': '系统用户',
'LabelList': '标签管理',
'CommandFilterList': '命令过滤',
'platformList': '平台列表',
'applications': '应用管理',
'perms': '权限管理',
@ -163,18 +163,18 @@ const cn = {
'gateway': '网关',
'date_created': '创建日期',
// 管理用户
'admin_user_list': '管理用户列表',
'admin_user_detail': '管理用户详情',
'create_admin_user': '创建管理用户',
'update_admin_user': '更新管理用户',
'AdminUserList': '管理用户列表',
'AdminUserDetail': '管理用户详情',
'AdminUserCreate': '创建管理用户',
'AdminUserUpdate': '更新管理用户',
'username': '用户名',
'replace_node_assets_admin_user_with_this': '替换资产的管理员',
'select_nodes': '选择节点',
// 系统用户
'system_user_list': '系统用户列表',
'create_system_user': '创建系统用户',
'update_system_user': '更新系统用户',
'system_user_detail': '系统用户详情',
'SystemUserList': '系统用户列表',
'SystemUserDetail': '系统用户详情',
'SystemUserCreate': '创建系统用户',
'SystemUserUpdate': '更新系统用户',
'protocol': '协议',
'login_mode': '登录模式',
'quick_update': '快速更新',

View File

@ -52,7 +52,7 @@ export const constantRoutes = [
{
path: '/users',
component: Layout,
redirect: '/users/list',
redirect: '/user/list',
name: 'Users',
meta: {
title: 'Users',
@ -102,46 +102,54 @@ export const constantRoutes = [
]
},
{
path: '/static/',
path: '/assets',
component: Layout,
redirect: '/asset/list',
name: 'assets',
meta: { title: 'assets', icon: 'user' },
meta: { title: 'Assets', icon: 'user' },
children: [
{
path: 'assets',
name: 'assetList',
component: () => import('@/views/table/index'),
meta: { title: 'assetList' }
path: 'asset/list',
name: 'AssetList',
component: () => import('@/views/assets/AssetList.vue'),
meta: { title: 'AssetList' }
},
{
path: 'domains',
name: 'domainList',
component: () => import('@/views/tree/index'),
meta: { title: 'domainList' }
path: 'domain/list',
name: 'DomainList',
component: () => import('@/views/assets/DomainList.vue'),
meta: { title: 'DomainList' }
},
{
path: 'admin-users',
name: 'adminUserList',
component: () => import('@/views/table/index'),
meta: { title: 'adminUserList' }
path: 'admin-user/list',
name: 'AdminUserList',
component: () => import('@/views/assets/AdminUserList'),
meta: { title: 'AdminUserList' }
},
{
path: 'system-users',
name: 'systemUserList',
component: () => import('@/views/tree/index'),
meta: { title: 'systemUserList' }
path: 'admin-user/detail/:id',
component: () => import('@/views/assets/AdminUserDetail.vue'), // Parent router-view
name: 'AdminUserDetail',
meta: { title: 'AdminUserDetail' },
hidden: true
},
{
path: 'labels',
name: 'labelList',
component: () => import('@/views/table/index'),
meta: { title: 'labelList' }
path: 'system-user/list',
name: 'SystemUserList',
component: () => import('@/views/assets/SystemUserList.vue'),
meta: { title: 'SystemUserList' }
},
{
path: 'command-filters',
name: 'commandFilterList',
component: () => import('@/views/tree/index'),
meta: { title: 'commandFilterList' }
path: 'label/list',
name: 'LabelList',
component: () => import('@/views/assets/LabelList.vue'),
meta: { title: 'LabelList' }
},
{
path: 'cmd-filter/list',
name: 'CommandFilterList',
component: () => import('@/views/assets/CommandFilterList.vue'),
meta: { title: 'CommandFilterList' }
},
{
path: 'platforms',

View File

@ -0,0 +1,13 @@
<template>
<h1>管理用户详情组件</h1>
</template>
<script>
export default {
name: 'AdminUserDetail'
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,132 @@
<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.asset')"
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')"
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 { getAdminUserList } from '@/api/asset'
import Tables from '@/layout/mixin/ListTables'
export default {
components: {
BackPlayground,
ListTables
},
mixins: [Tables],
data() {
return {
tableData: [],
listLoading: true
}
},
created() {
this.getAdminUser(this.current_page, this.page_size, this.offset)
},
methods: {
handleDetail: function(index, row) {
this.$router.push({ name: 'AdminUserDetail', params: { id: row.id }})
},
handleSizeChange(val) {
//
this.offset = (this.current_page - 1) * val
this.page_size = val
this.getAdminUser(this.current_page, val, this.offset)
},
handleCurrentChange(val) {
//
this.offset = (val - 1) * this.page_size
this.current_page = val
this.getAdminUser(val, this.page_size, this.offset)
},
getAdminUser(draw, limit, offset) {
this.listLoading = true
getAdminUserList({ draw, limit, offset }).then(response => {
this.tableData = response.results
this.total = response.count
this.listLoading = false
})
}
}
}
</script>
<style lang="less" scoped>
</style>

View File

@ -0,0 +1,13 @@
<template>
<h1>这是组件AssetList</h1>
</template>
<script>
export default {
name: 'AssetList'
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,132 @@
<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.rules')"
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.rules.length }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.system_user')"
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.system_users.length }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.comment')"
align="center"
header-align="center"
sortable
>
<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 { getCommandFilterList } from '@/api/asset'
import Tables from '@/layout/mixin/ListTables'
export default {
components: {
BackPlayground,
ListTables
},
mixins: [Tables],
data() {
return {
tableData: [],
listLoading: true
}
},
created() {
this.getCommandFilter(this.current_page, this.page_size, this.offset)
},
methods: {
handleDetail: function(index, row) {
this.$router.push({ name: 'LabelDetail', params: { id: row.id }})
},
handleSizeChange(val) {
//
this.offset = (this.current_page - 1) * val
this.page_size = val
this.getCommandFilter(this.current_page, val, this.offset)
},
handleCurrentChange(val) {
//
this.offset = (val - 1) * this.page_size
this.current_page = val
this.getCommandFilter(val, this.page_size, this.offset)
},
getCommandFilter(draw, limit, offset) {
this.listLoading = true
getCommandFilterList({ draw, limit, offset }).then(response => {
this.tableData = response.results
this.total = response.count
this.listLoading = false
})
}
}
}
</script>
<style lang="less" scoped>
</style>

View File

@ -0,0 +1,131 @@
<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.asset')"
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.asset_count }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.gateway')"
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.gateway_count }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.comment')"
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 { getDomainList } from '@/api/asset'
import Tables from '@/layout/mixin/ListTables'
export default {
components: {
BackPlayground,
ListTables
},
mixins: [Tables],
data() {
return {
tableData: [],
listLoading: true
}
},
created() {
this.getDomain(this.current_page, this.page_size, this.offset)
},
methods: {
handleDetail: function(index, row) {
this.$router.push({ name: 'DomainDetail', params: { id: row.id }})
},
handleSizeChange(val) {
//
this.offset = (this.current_page - 1) * val
this.page_size = val
this.getDomain(this.current_page, val, this.offset)
},
handleCurrentChange(val) {
//
this.offset = (val - 1) * this.page_size
this.current_page = val
this.getDomain(val, this.page_size, this.offset)
},
getDomain(draw, limit, offset) {
this.listLoading = true
getDomainList({ draw, limit, offset }).then(response => {
this.tableData = response.results
this.total = response.count
this.listLoading = false
})
}
}
}
</script>
<style lang="less" scoped>
</style>

View File

@ -0,0 +1,123 @@
<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.value')"
sortable
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.value }}</span>
</template>
</el-table-column>
<el-table-column
:label="this.$t('assets.asset')"
align="center"
header-align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.asset_count }}</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 { getLabelList } from '@/api/asset'
import Tables from '@/layout/mixin/ListTables'
export default {
components: {
BackPlayground,
ListTables
},
mixins: [Tables],
data() {
return {
tableData: [],
listLoading: true
}
},
created() {
this.getLabel(this.current_page, this.page_size, this.offset)
},
methods: {
handleDetail: function(index, row) {
this.$router.push({ name: 'LabelDetail', params: { id: row.id }})
},
handleSizeChange(val) {
//
this.offset = (this.current_page - 1) * val
this.page_size = val
this.getLabel(this.current_page, val, this.offset)
},
handleCurrentChange(val) {
//
this.offset = (val - 1) * this.page_size
this.current_page = val
this.getLabel(val, this.page_size, this.offset)
},
getLabel(draw, limit, offset) {
this.listLoading = true
getLabelList({ draw, limit, offset }).then(response => {
this.tableData = response.results
this.total = response.count
this.listLoading = false
})
}
}
}
</script>
<style lang="less" scoped>
</style>

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>

View File

@ -1,7 +1,7 @@
<template>
<BackPlayground :title="$t('route.userList')">
<BackPlayground :title="$t('route.UserList')">
<ListTables
:tablebotton="$t('users.createuser')"
:tablebotton="$t('assets.createuser')"
tableroute="UserEdit"
@SizeChange="handleSizeChange"
@CurrentChange="handleCurrentChange"