mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-29 21:28:52 +00:00
perf: 修改 m2m placeholder
This commit is contained in:
@@ -46,6 +46,10 @@ export default {
|
||||
attrs: {
|
||||
type: Array,
|
||||
default: () => ([])
|
||||
},
|
||||
resource: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -86,8 +90,8 @@ export default {
|
||||
iValue: Object.assign({ type: 'all' }, this.value),
|
||||
ids: this.value.ids || [],
|
||||
types: [
|
||||
{ name: 'all', label: '全部' },
|
||||
{ name: 'ids', label: '指定' },
|
||||
{ name: 'all', label: '全部' + this.resource },
|
||||
{ name: 'ids', label: '指定' + this.resource },
|
||||
{ name: 'attrs', label: '属性选择' }
|
||||
],
|
||||
tableConfig: {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
|
||||
import rules from '@/components/DataForm/rules'
|
||||
import { cleanFormValueForHandleUserAssetAccount } from '../common'
|
||||
import { userJSONSelectMeta } from '@/views/users/const'
|
||||
import { assetJSONSelectMeta } from '@/views/assets/const'
|
||||
|
||||
export default {
|
||||
name: 'AclCreateUpdate',
|
||||
@@ -16,24 +18,19 @@ export default {
|
||||
return {
|
||||
initial: {},
|
||||
fields: [
|
||||
[this.$t('common.Basic'), ['name', 'priority']],
|
||||
[this.$t('common.Basic'), ['name']],
|
||||
[this.$t('acl.users'), ['users']],
|
||||
[this.$t('acl.host'), ['assets']],
|
||||
[this.$t('acl.account'), ['accounts']],
|
||||
[this.$t('acl.action'), ['action', 'reviewers']],
|
||||
[this.$t('common.Other'), ['is_active', 'comment']]
|
||||
[this.$t('common.Other'), ['priority', 'is_active', 'comment']]
|
||||
],
|
||||
fieldsMeta: {
|
||||
priority: {
|
||||
rules: [rules.Required]
|
||||
},
|
||||
assets: {
|
||||
fields: ['name_group', 'address_group']
|
||||
},
|
||||
users: {
|
||||
fields: ['username_group'],
|
||||
fieldsMeta: {}
|
||||
},
|
||||
assets: assetJSONSelectMeta(this),
|
||||
users: userJSONSelectMeta(this),
|
||||
accounts: {
|
||||
fields: ['username_group']
|
||||
},
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
|
||||
<script>
|
||||
import { GenericCreateUpdatePage } from '@/layout/components'
|
||||
import { JSONManyToManySelect } from '@/components/FormFields'
|
||||
import AccountFormatter from '@/views/perms/AssetPermission/components/AccountFormatter.vue'
|
||||
import rules from '@/components/DataForm/rules'
|
||||
import { userJSONSelectMeta } from '@/views/users/const'
|
||||
import { assetJSONSelectMeta } from '@/views/assets/const'
|
||||
|
||||
export default {
|
||||
name: 'CommandFilterAclCreateUpdate',
|
||||
@@ -36,54 +37,8 @@ export default {
|
||||
url: '/api/v1/acls/command-filter-acls/',
|
||||
createSuccessNextRoute: { name: 'CommandFilterAclList' },
|
||||
fieldsMeta: {
|
||||
users: {
|
||||
component: JSONManyToManySelect,
|
||||
el: {
|
||||
value: [],
|
||||
select2: {
|
||||
ajax: {
|
||||
url: '/api/v1/users/users/?fields_size=mini',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name + '(' + item.username + ')', value: item.id }
|
||||
}
|
||||
}
|
||||
},
|
||||
attrs: [
|
||||
{
|
||||
name: 'name',
|
||||
label: this.$t('common.Name')
|
||||
},
|
||||
{
|
||||
name: 'username',
|
||||
label: this.$t('common.Username')
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
assets: {
|
||||
component: JSONManyToManySelect,
|
||||
el: {
|
||||
value: [],
|
||||
select2: {
|
||||
ajax: {
|
||||
url: '/api/v1/assets/assets/?fields_size=mini',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name + '(' + item.address + ')', value: item.id }
|
||||
}
|
||||
}
|
||||
},
|
||||
attrs: [
|
||||
{
|
||||
name: 'name',
|
||||
label: this.$t('common.Name')
|
||||
},
|
||||
{
|
||||
username: 'address',
|
||||
label: this.$t('assets.Address')
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
users: userJSONSelectMeta(this),
|
||||
assets: assetJSONSelectMeta(this),
|
||||
accounts: {
|
||||
component: AccountFormatter,
|
||||
el: {
|
||||
|
||||
@@ -1,26 +1,3 @@
|
||||
export const UserAssetAccountFieldInitial = {
|
||||
users: {
|
||||
username_group: '*'
|
||||
},
|
||||
assets: {
|
||||
name_group: '*',
|
||||
address_group: '*'
|
||||
},
|
||||
accounts: {
|
||||
username_group: '*'
|
||||
}
|
||||
}
|
||||
|
||||
export function afterGetFormValueForHandleUserAssetAccount(formValue) {
|
||||
// users
|
||||
formValue.users.username_group = formValue.users.username_group.toString()
|
||||
// assets
|
||||
formValue.assets.name_group = formValue.assets.name_group.toString()
|
||||
formValue.assets.address_group = formValue.assets.address_group.toString()
|
||||
// accounts
|
||||
formValue.accounts.username_group = formValue.accounts.username_group.toString()
|
||||
return formValue
|
||||
}
|
||||
|
||||
export function cleanFormValueForHandleUserAssetAccount(value) {
|
||||
// users
|
||||
|
||||
@@ -2,7 +2,7 @@ import i18n from '@/i18n/i18n'
|
||||
import ProtocolSelector from '@/components/FormFields/ProtocolSelector'
|
||||
import AssetAccounts from '@/views/assets/Asset/AssetCreateUpdate/components/AssetAccounts'
|
||||
import rules from '@/components/DataForm/rules'
|
||||
import { Select2 } from '@/components/FormFields'
|
||||
import { JSONManyToManySelect, Select2 } from '@/components/FormFields'
|
||||
import { message } from '@/utils/message'
|
||||
|
||||
export const filterSelectValues = (values) => {
|
||||
@@ -138,3 +138,48 @@ export const assetFieldsMeta = (vm) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const assetJSONSelectMeta = (vm) => {
|
||||
return {
|
||||
component: JSONManyToManySelect,
|
||||
el: {
|
||||
value: [],
|
||||
resource: vm.$t('assets.Asset'),
|
||||
select2: {
|
||||
ajax: {
|
||||
url: '/api/v1/assets/assets/?fields_size=mini',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name + '(' + item.address + ')', value: item.id }
|
||||
}
|
||||
}
|
||||
},
|
||||
attrs: [
|
||||
{
|
||||
name: 'name',
|
||||
label: vm.$t('common.Name')
|
||||
},
|
||||
{
|
||||
username: 'address',
|
||||
label: vm.$t('assets.Address')
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getAssetSelect2Meta() {
|
||||
return {
|
||||
component: Select2,
|
||||
el: {
|
||||
value: [],
|
||||
select2: {
|
||||
ajax: {
|
||||
url: '/api/v1/assets/assets/?fields_size=mini',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name + '(' + item.address + ')', value: item.id }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
29
src/views/users/const.js
Normal file
29
src/views/users/const.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { JSONManyToManySelect } from '@/components/FormFields'
|
||||
|
||||
export const userJSONSelectMeta = (vm) => {
|
||||
return {
|
||||
component: JSONManyToManySelect,
|
||||
el: {
|
||||
value: [],
|
||||
resource: vm.$t('users.Users'),
|
||||
select2: {
|
||||
ajax: {
|
||||
url: '/api/v1/users/users/?fields_size=mini',
|
||||
transformOption: (item) => {
|
||||
return { label: item.name + '(' + item.username + ')', value: item.id }
|
||||
}
|
||||
}
|
||||
},
|
||||
attrs: [
|
||||
{
|
||||
name: 'name',
|
||||
label: vm.$t('common.Name')
|
||||
},
|
||||
{
|
||||
name: 'username',
|
||||
label: vm.$t('common.Username')
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user