perf: update pam account

This commit is contained in:
ibuler 2025-01-23 14:01:54 +08:00
parent 369247d987
commit 5645d253e5
9 changed files with 116 additions and 94 deletions

View File

@ -1,6 +1,5 @@
<template v-if="iVisible"> <template v-if="iVisible">
<Drawer <Drawer
:has-footer="true"
:title="title" :title="title"
:visible="iVisible" :visible="iVisible"
class="drawer" class="drawer"

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<ListTable <DrawerListTable
ref="ListTable" ref="ListTable"
:detail-drawer="detailDrawer" :detail-drawer="detailDrawer"
:header-actions="headerActions" :header-actions="headerActions"
@ -22,22 +22,13 @@
<AccountCreateUpdate <AccountCreateUpdate
v-if="showAddDialog" v-if="showAddDialog"
:account="account" :account="account"
:add-template="addTemplate"
:asset="iAsset" :asset="iAsset"
:title="accountCreateUpdateTitle" :title="accountCreateUpdateTitle"
:visible.sync="showAddDialog" :visible.sync="showAddDialog"
@add="addAccountSuccess" @add="addAccountSuccess"
@bulk-create-done="showBulkCreateResult($event)" @bulk-create-done="showBulkCreateResult($event)"
/> />
<AccountCreateUpdate
v-if="showAddTemplateDialog"
:account="account"
:add-template="true"
:asset="iAsset"
:title="accountCreateByTemplateTitle"
:visible.sync="showAddTemplateDialog"
@add="addAccountSuccess"
@bulk-create-done="showBulkCreateResult($event)"
/>
<ResultDialog <ResultDialog
v-if="showResultDialog" v-if="showResultDialog"
:result="createAccountResults" :result="createAccountResults"
@ -67,19 +58,19 @@ import UpdateSecretInfo from './UpdateSecretInfo.vue'
import ResultDialog from './BulkCreateResultDialog.vue' import ResultDialog from './BulkCreateResultDialog.vue'
import AccountCreateUpdate from './AccountCreateUpdate.vue' import AccountCreateUpdate from './AccountCreateUpdate.vue'
import PasswordHistoryDialog from './PasswordHistoryDialog.vue' import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
import ListTable from '@/components/Table/DrawerListTable/index.vue' import DrawerListTable from '@/components/Table/DrawerListTable/index.vue'
import AccountBulkUpdateDialog from '@/components/Apps/AccountListTable/AccountBulkUpdateDialog.vue' import AccountBulkUpdateDialog from '@/components/Apps/AccountListTable/AccountBulkUpdateDialog.vue'
export default { export default {
name: 'AccountListTable', name: 'AccountListTable',
components: { components: {
AccountBulkUpdateDialog,
ResultDialog,
ListTable,
UpdateSecretInfo,
ViewSecret, ViewSecret,
ResultDialog,
DrawerListTable,
UpdateSecretInfo,
AccountCreateUpdate, AccountCreateUpdate,
PasswordHistoryDialog PasswordHistoryDialog,
AccountBulkUpdateDialog
}, },
props: { props: {
url: { url: {
@ -147,6 +138,7 @@ export default {
data() { data() {
const vm = this const vm = this
return { return {
addTemplate: false,
currentAccountColumn: {}, currentAccountColumn: {},
showPasswordHistoryDialog: false, showPasswordHistoryDialog: false,
showViewSecretDialog: false, showViewSecretDialog: false,
@ -156,8 +148,6 @@ export default {
showAddTemplateDialog: false, showAddTemplateDialog: false,
detailDrawer: () => import('@/views/accounts/Account/AccountDetail/index.vue'), detailDrawer: () => import('@/views/accounts/Account/AccountDetail/index.vue'),
createAccountResults: [], createAccountResults: [],
accountCreateUpdateTitle: this.$t('AddAccount'),
accountCreateByTemplateTitle: this.$t('AddAccountByTemplate'),
iAsset: this.asset, iAsset: this.asset,
account: {}, account: {},
secretUrl: '', secretUrl: '',
@ -179,7 +169,10 @@ export default {
name: { name: {
width: '120px', width: '120px',
formatterArgs: { formatterArgs: {
can: () => vm.$hasPerm('accounts.view_account') can: () => vm.$hasPerm('accounts.view_account'),
getDrawerTitle({ row }) {
return `${row.username}@${row.asset.name}`
}
} }
}, },
secret: { secret: {
@ -204,11 +197,6 @@ export default {
) )
} }
}, },
asset: {
formatter: row => {
return <span>{row.asset.name}</span>
}
},
platform: { platform: {
label: this.$t('Platform'), label: this.$t('Platform'),
width: '120px', width: '120px',
@ -288,6 +276,7 @@ export default {
setTimeout(() => { setTimeout(() => {
vm.iAsset = this.asset vm.iAsset = this.asset
vm.account = {} vm.account = {}
vm.addTemplate = false
vm.showAddDialog = true vm.showAddDialog = true
}) })
} }
@ -304,7 +293,8 @@ export default {
setTimeout(() => { setTimeout(() => {
vm.iAsset = this.asset vm.iAsset = this.asset
vm.account = {} vm.account = {}
vm.showAddTemplateDialog = true vm.showAddDialog = true
vm.addTemplate = true
}) })
} }
}, },
@ -384,6 +374,15 @@ export default {
} }
} }
}, },
computed: {
accountCreateUpdateTitle() {
if (this.addTemplate) {
return this.$t('AddAccountByTemplate')
} else {
return this.$t('AddAccount')
}
}
},
watch: { watch: {
url(iNew) { url(iNew) {
this.$set(this.tableConfig, 'url', iNew) this.$set(this.tableConfig, 'url', iNew)

View File

@ -115,6 +115,10 @@ export default {
} }
.page-submenu { .page-submenu {
.el-tabs__header {
padding: 0 15px;
}
.el-tabs__item.is-top { .el-tabs__item.is-top {
padding: 0 10px; padding: 0 10px;
} }

View File

@ -63,37 +63,25 @@ export default {
resource: { resource: {
type: String, type: String,
default: '' default: ''
},
getDrawerTitle: {
type: Function,
default: null
} }
}, },
data() { data() {
return { return {
title: '',
action: '',
visible: false, visible: false,
drawerVisible: false, drawerVisible: false,
drawerComponent: '', drawerComponent: ''
action: ''
} }
}, },
computed: { computed: {
...mapGetters(['inDrawer']), ...mapGetters(['inDrawer']),
drawerTitle() { drawerTitle() {
let title = this.title return this.getDefaultTitle()
if (!title && this.resource) {
title = this.resource
}
if (!title) {
title = this.$route.meta?.title
title = title.replace('List', '').replace('列表', '')
title = _.trimEnd(title, 's')
}
if (!title) {
title = this.$t('NoTitle')
}
let action = this.action
if (action === 'clone') {
action = 'create'
}
title = toSentenceCase(action) + this.$t('WordSep') + title.toLowerCase()
return title
}, },
iHeaderActions() { iHeaderActions() {
const actions = this.headerActions const actions = this.headerActions
@ -137,12 +125,31 @@ export default {
} }
if (!val) { if (!val) {
this.drawerVisible = false this.drawerVisible = false
console.log('Start reload table')
this.reloadTable() this.reloadTable()
} }
} }
}, },
methods: { methods: {
getDefaultTitle() {
let title = this.title
if (!title && this.resource) {
title = this.resource
}
if (!title) {
title = this.$route.meta?.title
title = title.replace('List', '').replace('列表', '')
title = _.trimEnd(title, 's')
}
if (!title) {
title = this.$t('NoTitle')
}
let action = this.action
if (action === 'clone') {
action = 'create'
}
title = toSentenceCase(action) + this.$t('WordSep') + title.toLowerCase()
return title
},
getDefaultDrawer(action) { getDefaultDrawer(action) {
const route = this.$route.name const route = this.$route.name
const actionRouteName = route.replace('List', toSentenceCase(action)) const actionRouteName = route.replace('List', toSentenceCase(action))
@ -167,7 +174,7 @@ export default {
return component return component
} }
}, },
showDrawer(action) { async showDrawer(action) {
this.action = action this.action = action
if (action === 'create') { if (action === 'create') {
this.drawerComponent = this.createDrawer this.drawerComponent = this.createDrawer
@ -183,7 +190,10 @@ export default {
if (!this.drawerComponent) { if (!this.drawerComponent) {
this.drawerComponent = this.getDefaultDrawer(action) this.drawerComponent = this.getDefaultDrawer(action)
} }
console.log('Show drawer', this.drawerComponent) if (this.getDrawerTitle) {
const actionMeta = await this.$store.getters['common/drawerActionMeta']
this.title = this.getDrawerTitle({ action, ...actionMeta })
}
this.drawerVisible = true this.drawerVisible = true
}, },
onCreate(meta) { onCreate(meta) {
@ -197,7 +207,6 @@ export default {
}) })
}, },
reloadTable() { reloadTable() {
console.log('Reload table ....')
if (this.reloadOrderQuery) { if (this.reloadOrderQuery) {
this.iTableConfig.url = setUrlParam(this.iTableConfig.url, 'order', this.reloadOrderQuery) this.iTableConfig.url = setUrlParam(this.iTableConfig.url, 'order', this.reloadOrderQuery)
} }

View File

@ -46,7 +46,10 @@ export default {
removeColorOnClick: false, removeColorOnClick: false,
beforeClick: () => { beforeClick: () => {
}, },
getTitle({ col, row, cellValue }) { getTitle({ row, cellValue }) {
return cellValue || row.name
},
getDrawerTitle({ row, cellValue }) {
return cellValue || row.name return cellValue || row.name
}, },
getIcon({ col, row, cellValue }) { getIcon({ col, row, cellValue }) {
@ -124,13 +127,14 @@ export default {
this.$cookie.set(route.name, route.query.tab, 1) this.$cookie.set(route.name, route.query.tab, 1)
this.$route.query.tab = route.query.tab this.$route.query.tab = route.query.tab
} }
this.$store.dispatch('common/setDrawerActionMeta', { const payload = {
action: 'detail', action: 'detail',
row: this.row, row: this.row,
col: this.col, col: this.col,
id: route.params.id id: route.params.id || this.row.id
}).then(() => { }
this.drawerTitle = this.iTitle this.$store.dispatch('common/setDrawerActionMeta', payload).then(() => {
this.drawerTitle = this.formatterArgs.getDrawerTitle(payload)
this.drawerVisible = true this.drawerVisible = true
}) })
}, },

View File

@ -99,7 +99,6 @@ export default {
return this.activeTab return this.activeTab
}, },
set(item) { set(item) {
console.log('SEt active tab', item)
this.activeTab = item this.activeTab = item
this.$emit('update:activeMenu', item) this.$emit('update:activeMenu', item)
} }

View File

@ -62,6 +62,9 @@ export default {
methods: { methods: {
addAccountSuccess() { addAccountSuccess() {
this.$store.commit('common/reload') this.$store.commit('common/reload')
},
getPageTitle({ row }) {
return `${row.username}@${row.asset.name}`
} }
} }
} }

View File

@ -9,7 +9,7 @@
<script> <script>
import AssetTreeTable from '@/components/Apps/AssetTreeTable/index.vue' import AssetTreeTable from '@/components/Apps/AssetTreeTable/index.vue'
import AccountListTable from '@/components/Apps/AccountListTable/AccountList.vue' import AccountListTable from '@/components/Apps/AccountListTable/AccountList.vue'
import { DetailFormatter, AccountConnectFormatter } from '@/components/Table/TableFormatters' import { AccountConnectFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
export default { export default {
name: 'AssetAccountList', name: 'AssetAccountList',
@ -32,7 +32,7 @@ export default {
formatterArgs: { formatterArgs: {
drawer: true, drawer: true,
can: this.$hasPerm('assets.view_asset'), can: this.$hasPerm('assets.view_asset'),
getTitle: ({ row }) => row.asset.name, getTitle: ({ row }) => row.asset.name + row.asset.id,
getRoute: ({ row }) => ({ getRoute: ({ row }) => ({
name: 'AssetDetail', name: 'AssetDetail',
params: { id: row.asset.id }, params: { id: row.asset.id },
@ -65,47 +65,47 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.asset-table ::v-deep .row-clicked, .asset-user-table ::v-deep .row-background-color { .asset-table ::v-deep .row-clicked, .asset-user-table ::v-deep .row-background-color {
background-color: #f5f7fa; background-color: #f5f7fa;
}
.asset-table {
&:hover {
cursor: pointer;
} }
.asset-table { & ::v-deep .table-content {
&:hover { margin-left: 21px;
cursor: pointer;
}
& ::v-deep .table-content {
margin-left: 21px;
}
& ::v-deep .el-table__row {
height: 40px;
& > td {
padding: 0;
}
}
} }
.noDataR { & ::v-deep .el-table__row {
width: 100%; height: 40px;
height: 40vh;
& > td {
padding: 0;
}
}
}
.noDataR {
width: 100%;
height: 40vh;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
flex-direction: column;
.hintWrap {
color: #D4D6E6;
display: flex; display: flex;
align-items: center; align-items: flex-start;
justify-content: center; justify-content: center;
font-size: 18px;
flex-direction: column; flex-direction: column;
.hintWrap {
color: #D4D6E6;
display: flex;
align-items: flex-start;
justify-content: center;
flex-direction: column;
}
} }
}
.asset-user-table { .asset-user-table {
padding-left: 20px; padding-left: 20px;
} }
</style> </style>

View File

@ -1,5 +1,10 @@
<template> <template>
<GenericDetailPage :active-menu.sync="config.activeMenu" :object.sync="user" v-bind="config" v-on="$listeners"> <GenericDetailPage
:active-menu.sync="config.activeMenu"
:object.sync="user"
v-bind="config"
v-on="$listeners"
>
<keep-alive> <keep-alive>
<component :is="config.activeMenu" :object="user" /> <component :is="config.activeMenu" :object="user" />
</keep-alive> </keep-alive>