fix: 修改授权规则列表 accounts popover 显示优化

This commit is contained in:
Bai
2023-02-15 15:56:25 +08:00
committed by Jiangjie.Bai
parent 1e474b25f3
commit 041801a319
4 changed files with 33 additions and 15 deletions

View File

@@ -13,6 +13,7 @@ import { GenericCreateUpdatePage } from '@/layout/components'
import AssetSelect from '@/components/AssetSelect' import AssetSelect from '@/components/AssetSelect'
import { getDayFuture } from '@/utils/common' import { getDayFuture } from '@/utils/common'
import AccountFormatter from './components/AccountFormatter' import AccountFormatter from './components/AccountFormatter'
import { AllAccount } from '../const'
export default { export default {
name: 'AccountFormatter', name: 'AccountFormatter',
@@ -35,7 +36,7 @@ export default {
date_expired: getDayFuture(36500, new Date()).toISOString(), date_expired: getDayFuture(36500, new Date()).toISOString(),
nodes: nodesInitial, nodes: nodesInitial,
assets: assetsInitial, assets: assetsInitial,
accounts: ['@ALL'] accounts: [AllAccount]
}, },
fields: [ fields: [
[this.$t('common.Basic'), ['name']], [this.$t('common.Basic'), ['name']],

View File

@@ -18,7 +18,7 @@ import AssetTreeTable from '@/components/AssetTreeTable'
import PermBulkUpdateDialog from './components/PermBulkUpdateDialog' import PermBulkUpdateDialog from './components/PermBulkUpdateDialog'
import AmountFormatter from '@/components/TableFormatters/AmountFormatter' import AmountFormatter from '@/components/TableFormatters/AmountFormatter'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { AssetPermissionListPageSearchConfigOptions } from '../const' import { AccountLabelMapper, AssetPermissionListPageSearchConfigOptions } from '../const'
export default { export default {
components: { components: {
@@ -121,7 +121,7 @@ export default {
formatter: AmountFormatter, formatter: AmountFormatter,
formatterArgs: { formatterArgs: {
getItem(item) { getItem(item) {
return item return AccountLabelMapper[item] || item
}, },
routeQuery: { routeQuery: {
activeTab: 'AssetPermissionAccount' activeTab: 'AssetPermissionAccount'

View File

@@ -20,6 +20,13 @@
<script> <script>
import { TagInput } from '@/components/FormFields' import { TagInput } from '@/components/FormFields'
import {
AllAccount,
SPECAccount,
SameUSER,
ManualINPUT,
AccountLabelMapper
} from '@/views/perms/const'
export default { export default {
components: { components: {
@@ -32,29 +39,27 @@ export default {
} }
}, },
data() { data() {
const ALL = '@ALL'
const SPEC = '@SPEC'
const choices = [ const choices = [
{ {
label: this.$t('perms.AllAccounts'), label: AccountLabelMapper[AllAccount],
value: ALL value: AllAccount
}, },
{ {
label: this.$t('perms.SpecifyAccounts'), label: AccountLabelMapper[SPECAccount],
value: SPEC value: SPECAccount
}, },
{ {
label: this.$t('perms.ManualInput'), label: AccountLabelMapper[ManualINPUT],
value: '@INPUT' value: ManualINPUT
}, },
{ {
label: this.$t('perms.SameAccount'), label: AccountLabelMapper[SameUSER],
value: '@USER' value: SameUSER
} }
] ]
return { return {
ALL: ALL, ALL: AllAccount,
SPEC: SPEC, SPEC: SPECAccount,
choices: choices, choices: choices,
choicesSelected: [], choicesSelected: [],
defaultChoices: [this.ALL], defaultChoices: [this.ALL],

View File

@@ -40,3 +40,15 @@ export const AssetPermissionListPageSearchConfigOptions = [
] ]
} }
] ]
export const AllAccount = '@ALL'
export const SPECAccount = '@SPEC'
export const SameUSER = '@USER'
export const ManualINPUT = '@INPUT'
export const AccountLabelMapper = {
[AllAccount]: i18n.t('perms.AllAccounts'),
[SPECAccount]: i18n.t('perms.SpecifyAccounts'),
[SameUSER]: i18n.t('perms.SameAccount'),
[ManualINPUT]: i18n.t('perms.ManualInput')
}