perf: 修改<工作台-我的资产>页面;修改<控制台-用户详情>页面;修改<GrantedSystemUsersShowFormatter>为<GrantedAccountShowFormatter>组件;

This commit is contained in:
Bai
2022-12-01 12:09:43 +08:00
parent 179c420e9d
commit 41d07fd670
5 changed files with 34 additions and 34 deletions

View File

@@ -3,7 +3,7 @@
</template> </template>
<script type="text/jsx"> <script type="text/jsx">
import { DetailFormatter, SystemUserFormatter } from '@/components/TableFormatters' import { DetailFormatter, AccountShowFormatter } from '@/components/TableFormatters'
import TreeTable from '../TreeTable' import TreeTable from '../TreeTable'
export default { export default {
@@ -35,7 +35,7 @@ export default {
getShowUrl: { getShowUrl: {
type: Function, type: Function,
default({ row, col }) { default({ row, col }) {
return this.tableUrl.replace('/assets/', `/assets/${row.id}/system-users/?cache_policy=1`) return this.tableUrl.replace('/assets/', `/assets/${row.id}/accounts/?cache_policy=1`)
} }
} }
}, },
@@ -59,8 +59,8 @@ export default {
hasTree: true, hasTree: true,
columns: [ columns: [
{ {
prop: 'hostname', prop: 'name',
label: this.$t('assets.Hostname'), label: this.$t('assets.Name'),
formatter: DetailFormatter, formatter: DetailFormatter,
sortable: true, sortable: true,
formatterArgs: { formatterArgs: {
@@ -69,16 +69,16 @@ export default {
showOverflowTooltip: true showOverflowTooltip: true
}, },
{ {
prop: 'ip', prop: 'address',
label: this.$t('assets.IP'), label: this.$t('assets.Address'),
width: '140px', width: '140px',
sortable: 'custom' sortable: 'custom'
}, },
{ {
prop: 'systemUsers', prop: 'accounts',
label: this.$t('assets.SystemUsers'), label: this.$t('assets.Account'),
align: 'center', align: 'center',
formatter: SystemUserFormatter, formatter: AccountShowFormatter,
formatterArgs: { formatterArgs: {
getUrl: this.getShowUrl.bind(this) getUrl: this.getShowUrl.bind(this)
}, },

View File

@@ -1,6 +1,6 @@
<template> <template>
<span v-if="!systemUsers"><a style="color: #1c84c6;" @click="showSystemUser">{{ this.$t('common.Show') }}</a></span> <span v-if="!accounts"><a style="color: #1c84c6;" @click="showAccount">{{ this.$t('common.Show') }}</a></span>
<span v-else>{{ systemUsers.toString() }}</span> <span v-else>{{ accounts.toString() }}</span>
</template> </template>
<script> <script>
@@ -20,15 +20,15 @@ export default {
}, },
data() { data() {
return { return {
systemUsers: null accounts: null
} }
}, },
methods: { methods: {
async showSystemUser() { async showAccount() {
const formatterArgs = Object.assign(this.formatterArgsDefault, this.col.formatterArgs) const formatterArgs = Object.assign(this.formatterArgsDefault, this.col.formatterArgs)
const url = formatterArgs.getUrl({ row: this.row, col: this.col }) const url = formatterArgs.getUrl({ row: this.row, col: this.col })
const data = await this.$axios.get(url) const data = await this.$axios.get(url)
this.systemUsers = data.map((item) => item.name) this.accounts = data.map((item) => item.name)
} }
} }
} }

View File

@@ -5,7 +5,7 @@ import ChoicesFormatter from './ChoicesFormatter'
import ActionsFormatter from './ActionsFormatter' import ActionsFormatter from './ActionsFormatter'
import DeleteActionFormatter from './DeleteActionFormatter' import DeleteActionFormatter from './DeleteActionFormatter'
import DateFormatter from './DateFormatter' import DateFormatter from './DateFormatter'
import SystemUserFormatter from './GrantedSystemUsersShowFormatter' import AccountShowFormatter from './GrantedAccountShowFormatter'
import ShowKeyCopyFormatter from './ShowKeyCopyFormatter' import ShowKeyCopyFormatter from './ShowKeyCopyFormatter'
import DialogDetailFormatter from './DialogDetailFormatter' import DialogDetailFormatter from './DialogDetailFormatter'
import EditableInputFormatter from './EditableInputFormatter' import EditableInputFormatter from './EditableInputFormatter'
@@ -20,7 +20,7 @@ export default {
ActionsFormatter, ActionsFormatter,
DeleteActionFormatter, DeleteActionFormatter,
DateFormatter, DateFormatter,
SystemUserFormatter, AccountShowFormatter,
ShowKeyCopyFormatter, ShowKeyCopyFormatter,
DialogDetailFormatter, DialogDetailFormatter,
ArrayFormatter, ArrayFormatter,
@@ -37,7 +37,7 @@ export {
ActionsFormatter, ActionsFormatter,
DeleteActionFormatter, DeleteActionFormatter,
DateFormatter, DateFormatter,
SystemUserFormatter, AccountShowFormatter,
ShowKeyCopyFormatter, ShowKeyCopyFormatter,
DialogDetailFormatter, DialogDetailFormatter,
ArrayFormatter, ArrayFormatter,

View File

@@ -10,7 +10,7 @@
<script> <script>
import GenericTreeListPage from '@/layout/components/GenericTreeListPage' import GenericTreeListPage from '@/layout/components/GenericTreeListPage'
import { SystemUserFormatter, DialogDetailFormatter } from '@/components/TableFormatters' import { AccountShowFormatter, DialogDetailFormatter } from '@/components/TableFormatters'
export default { export default {
components: { components: {
GenericTreeListPage GenericTreeListPage
@@ -22,22 +22,22 @@ export default {
showMenu: false, showMenu: false,
showRefresh: true, showRefresh: true,
showAssets: false, showAssets: false,
url: '/api/v1/perms/users/assets/', url: '/api/v1/perms/my/users/assets/',
nodeUrl: '/api/v1/perms/users/nodes/', nodeUrl: '/api/v1/perms/my/users/nodes/',
// ?assets=0不显示资产. =1显示资产 // ?assets=0不显示资产. =1显示资产
treeUrl: '/api/v1/perms/users/nodes/children/tree/?cache_policy=2', treeUrl: '/api/v1/perms/users/my/nodes/children/tree/?cache_policy=2',
callback: { callback: {
refresh: () => {}, refresh: () => {},
onSelected: function(event, treeNode) { onSelected: function(event, treeNode) {
if (treeNode.meta.type === 'node') { if (treeNode.meta.type === 'node') {
const currentNodeId = treeNode.meta.data.id const currentNodeId = treeNode.meta.data.id
this.tableConfig.url = `/api/v1/perms/users/nodes/${currentNodeId}/assets/?cache_policy=1` this.tableConfig.url = `/api/v1/perms/users/my/nodes/${currentNodeId}/assets/?cache_policy=1`
} }
}.bind(this) }.bind(this)
} }
}, },
tableConfig: { tableConfig: {
url: '/api/v1/perms/users/assets/', url: '/api/v1/perms/users/my/assets/',
hasTree: true, hasTree: true,
columns: ['name', 'address', 'platform', 'category', 'accounts', 'type', 'comment', 'actions'], columns: ['name', 'address', 'platform', 'category', 'accounts', 'type', 'comment', 'actions'],
columnsShow: { columnsShow: {
@@ -91,19 +91,19 @@ export default {
}, },
sortable: true sortable: true
}, },
ip: { address: {
sortable: 'custom', sortable: 'custom',
width: '150px' width: '150px'
}, },
system_users: { accounts: {
showOverflowTooltip: true, showOverflowTooltip: true,
align: 'center', align: 'center',
label: this.$t('assets.SystemUsers'), label: this.$t('assets.Account'),
width: '120px', width: '120px',
formatter: SystemUserFormatter, formatter: AccountShowFormatter,
formatterArgs: { formatterArgs: {
getUrl: ({ row }) => { getUrl: ({ row }) => {
return `/api/v1/perms/users/assets/${row.id}/system-users/?cache_policy=1` return `/api/v1/perms/users/my/assets/${row.id}/accounts/?cache_policy=1`
} }
} }
}, },

View File

@@ -46,12 +46,12 @@ export default {
name: 'UserGrantedAssets', name: 'UserGrantedAssets',
hidden: () => !vm.$hasPerm('perms.view_userassets') hidden: () => !vm.$hasPerm('perms.view_userassets')
}, },
{ // {
title: this.$t('users.tabs.grantedAccounts'), // title: this.$t('users.tabs.grantedAccounts'),
name: 'UserGrantedAccounts', // name: 'UserGrantedAccounts',
// Todo: perms.view_useraccounts // // Todo: perms.view_useraccounts
hidden: () => !vm.$hasPerm('perms.view_userassets') // hidden: () => !vm.$hasPerm('perms.view_userassets')
}, // },
{ {
title: this.$t('users.tabs.assetPermissionRules'), title: this.$t('users.tabs.assetPermissionRules'),
name: 'UserAssetPermissionRules', name: 'UserAssetPermissionRules',