perf: Enhance account actions with organization root checks

This commit is contained in:
w940853815 2025-04-10 14:43:55 +08:00 committed by w940853815
parent e19c0090de
commit 025487a5eb
2 changed files with 10 additions and 6 deletions

View File

@ -6,7 +6,7 @@
<i class="fa fa-check" />
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="item of iActions" :key="item.name" :command="item.name">
<el-dropdown-item v-for="item of iActions" :key="item.name" :command="item.name" :disabled="item.disabled">
{{ item.label }}
</el-dropdown-item>
</el-dropdown-menu>
@ -123,17 +123,20 @@ export default {
{
name: 'delete_remote',
label: this.$t('DeleteRemoteAccount'),
has: this.row.remote_present
has: this.row.remote_present,
disabled: this.$store.getters.currentOrgIsRoot
},
{
name: 'add_account',
label: this.$t('AddAccount'),
has: !this.row.present
has: !this.row.present,
disabled: this.$store.getters.currentOrgIsRoot
},
{
name: 'change_password_add',
label: this.$t('AddAccountAfterChangingPassword'),
has: !this.row.present
has: !this.row.present,
disabled: this.$store.getters.currentOrgIsRoot
}
]
return actions.filter(action => {

View File

@ -1,5 +1,6 @@
import { toSafeLocalDateStr } from '@/utils/time'
import { ActionsFormatter, DetailFormatter, DiscoverConfirmFormatter } from '@/components/Table/TableFormatters'
export const statusMap = {
pending: '0',
confirmed: '1',
@ -135,7 +136,7 @@ export const gatherAccountHeaderActions = (vm) => {
type: 'primary',
icon: 'fa fa-check',
can: ({ selectedRows }) => {
return selectedRows.length > 0 && vm.$hasPerm('accounts.add_account')
return selectedRows.length > 0 && vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot
},
callback: function({ selectedRows }) {
const ids = selectedRows.map(v => {
@ -157,7 +158,7 @@ export const gatherAccountHeaderActions = (vm) => {
type: 'primary',
icon: 'fa fa-exchange',
can: ({ selectedRows }) => {
return selectedRows.length > 0 && vm.$hasPerm('accounts.remove_account')
return selectedRows.length > 0 && vm.$hasPerm('accounts.remove_account') && !vm.$store.getters.currentOrgIsRoot
},
callback: function({ selectedRows }) {
vm.gatherAccounts = selectedRows