diff --git a/src/components/Apps/AccountListTable/AccountList.vue b/src/components/Apps/AccountListTable/AccountList.vue index 5914d8b76..21bc81efd 100644 --- a/src/components/Apps/AccountListTable/AccountList.vue +++ b/src/components/Apps/AccountListTable/AccountList.vue @@ -162,6 +162,7 @@ export default { account: {}, secretUrl: '', quickFilters: accountQuickFilters, + tabDeactivated: false, tableConfig: { url: this.url, permissions: { @@ -205,15 +206,7 @@ export default { }, asset: { formatter: row => { - const to = { - name: 'AssetDetail', - params: { id: row.asset.id } - } - if (vm.$hasPerm('assets.view_asset')) { - return {row.asset.name} - } else { - return {row.asset.name} - } + return {row.asset.name} } }, platform: { @@ -254,9 +247,9 @@ export default { formatter: ActionsFormatter, formatterArgs: { hasUpdate: false, // can set function(row, value) - hasDelete: false, // can set function(row, value) + hasDelete: true, // can set function(row, value) hasClone: false, - canClone: true, + canDelete: () => vm.$hasPerm('accounts.delete_account'), moreActionsTitle: this.$t('More'), extraActions: accountOtherActions(this) } @@ -319,7 +312,7 @@ export default { name: 'TestSelected', title: this.$t('TestSelected'), type: 'primary', - icon: 'fa-link', + icon: 'verify', can: ({ selectedRows }) => { return selectedRows.length > 0 && ['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 && @@ -399,12 +392,12 @@ export default { }, activated() { // 由于组件嵌套较深,有可能导致 Error in activated hook: "TypeError: Cannot read properties of undefined (reading 'getList')" 的问题 - setTimeout(() => { - this.refresh() - }, 300) + if (this.tabDeactivated) { + setTimeout(() => this.refresh(), 300) + } }, deactivated() { - this.deactive = true + this.tabDeactivated = true }, methods: { setActions() { @@ -417,31 +410,6 @@ export default { actionColumn.formatterArgs.extraActions.push(item) } } - if (this.hasDeleteAction) { - this.tableConfig.columnsMeta.actions.formatterArgs.extraActions.push( - { - name: 'Delete', - title: this.$t('Delete'), - can: this.$hasPerm('accounts.delete_account'), - type: 'primary', - callback: ({ row }) => { - const msg = this.$t('AccountDeleteConfirmMsg') - this.$confirm(msg, this.$tc('Info'), { - type: 'warning', - confirmButtonClass: 'el-button--danger', - beforeClose: async(action, instance, done) => { - if (action !== 'confirm') return done() - this.$axios.delete(`/api/v1/accounts/accounts/${row.id}/`).then(() => { - done() - this.$refs.ListTable.reloadTable() - this.$message.success(this.$tc('DeleteSuccessMsg')) - }) - } - }) - } - } - ) - } }, onUpdateAuthDone(account) { Object.assign(this.account, account) diff --git a/src/components/Apps/AccountListTable/const.js b/src/components/Apps/AccountListTable/const.js index 6011cea84..192178af8 100644 --- a/src/components/Apps/AccountListTable/const.js +++ b/src/components/Apps/AccountListTable/const.js @@ -30,6 +30,7 @@ export const accountOtherActions = (vm) => [ title: vm.$t('View'), can: vm.$hasPerm('accounts.view_accountsecret'), type: 'primary', + order: 1, callback: ({ row }) => { // debugger vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/` @@ -58,9 +59,28 @@ export const accountOtherActions = (vm) => [ }) } }, + { + name: 'Clone', + title: vm.$t('Duplicate'), + can: vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot, + callback: ({ row }) => { + const data = { + ...vm.asset, + ...row.asset + } + vm.account = row + vm.iAsset = data + vm.showAddDialog = false + vm.accountCreateUpdateTitle = vm.$t('DuplicateAccount') + setTimeout(() => { + vm.showAddDialog = true + }) + } + }, { name: 'Test', title: vm.$t('验证密文'), + divided: true, can: ({ row }) => !vm.$store.getters.currentOrgIsRoot && vm.$hasPerm('accounts.verify_account') && @@ -104,10 +124,11 @@ export const accountOtherActions = (vm) => [ }, { name: 'CopyToOther', - title: '复制到其他资产', + title: vm.$t('CopyToOther'), type: 'primary', divided: true, callback: ({ row }) => { + vm.accountCreateUpdateTitle = vm.$t('CopyToOther') vm.$route.query.flag = 'copy' vm.iAsset = vm.asset vm.account = row @@ -116,19 +137,15 @@ export const accountOtherActions = (vm) => [ }, { name: 'MoveToOther', - title: '移动到其他资产', + title: vm.$t('MoveToOther'), type: 'primary', callback: ({ row }) => { + vm.accountCreateUpdateTitle = vm.$t('MoveToOther') vm.$route.query.flag = 'move' vm.iAsset = vm.asset vm.account = row vm.showAddDialog = true } - }, - { - name: 'Clone', - title: vm.$t('Duplicate'), - divided: true } ] @@ -186,7 +203,7 @@ export const accountQuickFilters = [ { label: '弱密码', filter: { - risk: 'week_password' + risk: 'weak_password' } }, { diff --git a/src/components/Table/ListTable/index.vue b/src/components/Table/ListTable/index.vue index 71d1a66ac..a9fa76b65 100644 --- a/src/components/Table/ListTable/index.vue +++ b/src/components/Table/ListTable/index.vue @@ -100,7 +100,7 @@ export default { extraQuery: extraQuery, actionInit: this.headerActions.has === false, initQuery: {}, - filterExpand: localStorage.getItem('filterExpand') === '1' + filterExpand: localStorage.getItem('filterExpand') !== '0' } }, computed: { diff --git a/src/components/Table/TableFormatters/SecretViewerFormatter.vue b/src/components/Table/TableFormatters/SecretViewerFormatter.vue index cba49a342..0a1a40d0d 100644 --- a/src/components/Table/TableFormatters/SecretViewerFormatter.vue +++ b/src/components/Table/TableFormatters/SecretViewerFormatter.vue @@ -1,6 +1,6 @@