mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-25 22:36:23 +00:00
[Update] 修改授权列表组件页面
This commit is contained in:
23
src/components/ListTable/formatters/LengthFormatter.vue
Normal file
23
src/components/ListTable/formatters/LengthFormatter.vue
Normal file
@@ -0,0 +1,23 @@
|
||||
<template>
|
||||
<span>{{ getCellValueLength }}</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BaseFormatter from './base'
|
||||
export default {
|
||||
name: 'LengthFormatter',
|
||||
extends: BaseFormatter,
|
||||
computed: {
|
||||
getCellValueLength() {
|
||||
if (this.cellValue instanceof Array) {
|
||||
return this.cellValue.length
|
||||
}
|
||||
return this.cellValue
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@@ -19,7 +19,7 @@ export default {
|
||||
default: () => ({})
|
||||
},
|
||||
cellValue: {
|
||||
type: [String, Boolean, Number, Object],
|
||||
type: [String, Boolean, Number, Object, Array],
|
||||
default: null
|
||||
},
|
||||
tableData: {
|
||||
|
@@ -2,4 +2,5 @@ export { default as DetailFormatter } from './DetailFormatter'
|
||||
export { default as DisplayFormatter } from './DisplayFormatter'
|
||||
export { default as BooleanFormatter } from './ChoicesFormatter'
|
||||
export { default as ActionsFormatter } from './ActionsFormatter'
|
||||
export { default as LengthFormatter } from './LengthFormatter'
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<script>
|
||||
import { GenericListPage } from '@/layout/components'
|
||||
import { DetailFormatter, ActionsFormatter, BooleanFormatter } from '@/components/ListTable/formatters/index'
|
||||
import { LengthFormatter } from '@/components/ListTable/formatters/index'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -14,59 +14,23 @@ export default {
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/perms/asset-permissions/',
|
||||
columns: [
|
||||
{
|
||||
prop: 'name',
|
||||
label: this.$t('common.name'),
|
||||
formatter: DetailFormatter,
|
||||
sortable: true,
|
||||
route: 'AssetPermissionDetail'
|
||||
columns: ['name', 'users', 'user_groups', 'assets', 'nodes', 'system_users', 'is_active', 'actions'],
|
||||
columnsMeta: {
|
||||
users: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'users.length',
|
||||
label: this.$t('perms.user')
|
||||
user_groups: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'user_groups.length',
|
||||
label: this.$t('perms.userGroup')
|
||||
assets: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'assets.length',
|
||||
label: this.$t('perms.asset')
|
||||
nodes: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'nodes.length',
|
||||
label: this.$t('perms.node')
|
||||
},
|
||||
{
|
||||
prop: 'system_users.length',
|
||||
label: this.$t('perms.systemUser')
|
||||
},
|
||||
{
|
||||
prop: 'is_active',
|
||||
label: this.$t('perms.validity'),
|
||||
formatter: BooleanFormatter,
|
||||
align: 'center',
|
||||
width: '80px'
|
||||
},
|
||||
{
|
||||
prop: 'id',
|
||||
label: this.$tc('Action'),
|
||||
align: 'center',
|
||||
formatter: ActionsFormatter,
|
||||
width: '200px',
|
||||
actions: {
|
||||
performDelete: ({ row, col }) => {
|
||||
const id = row.id
|
||||
const url = `/api/v1/perms/asset-permissions/${id}/`
|
||||
return this.$axios.delete(url)
|
||||
}
|
||||
}
|
||||
system_users: {
|
||||
formatter: LengthFormatter
|
||||
}
|
||||
],
|
||||
tableActions: {
|
||||
hasEdit: true,
|
||||
editRoute: '404'
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
|
@@ -4,8 +4,7 @@
|
||||
|
||||
<script>
|
||||
import { GenericListPage } from '@/layout/components'
|
||||
import { DetailFormatter, ActionsFormatter, BooleanFormatter } from '@/components/ListTable/formatters/index'
|
||||
|
||||
import { LengthFormatter } from '@/components/ListTable/formatters/index'
|
||||
export default {
|
||||
components: {
|
||||
GenericListPage
|
||||
@@ -14,52 +13,21 @@ export default {
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/perms/database-app-permissions/',
|
||||
columns: [
|
||||
{
|
||||
prop: 'name',
|
||||
label: this.$t('perms.name'),
|
||||
formatter: DetailFormatter,
|
||||
sortable: true,
|
||||
route: 'DatabaseAppPermissionDetail'
|
||||
columns: ['name', 'users', 'user_groups', 'database_apps', 'system_users', 'is_valid', 'actions'],
|
||||
columnsMeta: {
|
||||
users: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'users.length',
|
||||
label: this.$t('perms.user')
|
||||
user_groups: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'user_groups.length',
|
||||
label: this.$t('perms.userGroup')
|
||||
database_apps: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'database_apps.length',
|
||||
label: this.$t('perms.DatabaseApp')
|
||||
},
|
||||
{
|
||||
prop: 'system_users.length',
|
||||
label: this.$t('perms.systemUser')
|
||||
},
|
||||
{
|
||||
prop: 'is_valid',
|
||||
label: this.$t('perms.validity'),
|
||||
formatter: BooleanFormatter,
|
||||
align: 'center',
|
||||
width: '80px'
|
||||
},
|
||||
{
|
||||
prop: 'id',
|
||||
label: this.$tc('Action'),
|
||||
align: 'center',
|
||||
formatter: ActionsFormatter,
|
||||
width: '200px',
|
||||
actions: {
|
||||
performDelete: ({ row, col }) => {
|
||||
const id = row.id
|
||||
const url = `/api/v1/perms/database-app-permissions/${id}/`
|
||||
return this.$axios.delete(url)
|
||||
}
|
||||
}
|
||||
system_users: {
|
||||
formatter: LengthFormatter
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasBulkDelete: false,
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
<script>
|
||||
import { GenericListPage } from '@/layout/components'
|
||||
import { DetailFormatter, ActionsFormatter, BooleanFormatter } from '@/components/ListTable/formatters/index'
|
||||
import { LengthFormatter } from '@/components/ListTable/formatters/index'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -14,52 +14,21 @@ export default {
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/perms/remote-app-permissions/',
|
||||
columns: [
|
||||
{
|
||||
prop: 'name',
|
||||
label: this.$t('perms.name'),
|
||||
formatter: DetailFormatter,
|
||||
sortable: true,
|
||||
route: 'RemoteAppPermissionDetail'
|
||||
columns: ['name', 'users', 'user_groups', 'remote_apps', 'system_users', 'is_valid', 'actions'],
|
||||
columnsMeta: {
|
||||
users: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'users.length',
|
||||
label: this.$t('perms.user')
|
||||
user_groups: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'user_groups.length',
|
||||
label: this.$t('perms.userGroup')
|
||||
remote_apps: {
|
||||
formatter: LengthFormatter
|
||||
},
|
||||
{
|
||||
prop: 'remote_apps.length',
|
||||
label: this.$t('perms.RemoteApp')
|
||||
},
|
||||
{
|
||||
prop: 'system_users.length',
|
||||
label: this.$t('perms.systemUser')
|
||||
},
|
||||
{
|
||||
prop: 'is_valid',
|
||||
label: this.$t('perms.validity'),
|
||||
formatter: BooleanFormatter,
|
||||
align: 'center',
|
||||
width: '80px'
|
||||
},
|
||||
{
|
||||
prop: 'id',
|
||||
label: this.$tc('Action'),
|
||||
align: 'center',
|
||||
formatter: ActionsFormatter,
|
||||
width: '200px',
|
||||
actions: {
|
||||
performDelete: ({ row, col }) => {
|
||||
const id = row.id
|
||||
const url = `/api/v1/perms/database-app-permissions/${id}/`
|
||||
return this.$axios.delete(url)
|
||||
}
|
||||
}
|
||||
system_users: {
|
||||
formatter: LengthFormatter
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasBulkDelete: false,
|
||||
|
Reference in New Issue
Block a user