mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-20 10:46:35 +00:00
feat: 支持 json m2m field
This commit is contained in:
77
src/components/FormFields/JSONManyToManySelect.vue
Normal file
77
src/components/FormFields/JSONManyToManySelect.vue
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-radio-group v-model="iValue.type">
|
||||||
|
<el-radio v-for="tp of types" :key="tp.name" :label="tp.name">
|
||||||
|
{{ tp.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
<Select2 v-if="iValue.type === 'ids'" v-model="ids" v-bind="select2" />
|
||||||
|
<div>
|
||||||
|
<DataTable v-model="iAttrs" :config="tableConfig" class="attr-list" />
|
||||||
|
<div class="actions">
|
||||||
|
<el-button size="mini" type="primary">
|
||||||
|
{{ $t('common.Add') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button size="mini" type="success">
|
||||||
|
{{ $t('common.TemplateAdd') }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Select2 from './Select2.vue'
|
||||||
|
import DataTable from '@/components/DataTable/index.vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'JSONManyToManySelect',
|
||||||
|
components: { DataTable, Select2 },
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {
|
||||||
|
return {
|
||||||
|
type: 'all'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
select2: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
attrs: {
|
||||||
|
type: Array,
|
||||||
|
default: () => {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
iValue: Object.assign({ type: 'all' }, this.value),
|
||||||
|
ids: [],
|
||||||
|
iAttrs: [],
|
||||||
|
types: [
|
||||||
|
{ name: 'all', label: '全部' },
|
||||||
|
{ name: 'ids', label: '指定' },
|
||||||
|
{ name: 'attrs', label: '属性选择' }
|
||||||
|
],
|
||||||
|
tableConfig: {
|
||||||
|
columns: [
|
||||||
|
{ prop: 'name', label: '属性名' },
|
||||||
|
{ prop: 'match', label: '匹配' },
|
||||||
|
{ prop: 'value', label: '属性值' }
|
||||||
|
],
|
||||||
|
hasPagination: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.attr-list {
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
</style>
|
@@ -15,6 +15,7 @@ import UploadSecret from './UploadSecret'
|
|||||||
import WeekCronSelect from './WeekCronSelect'
|
import WeekCronSelect from './WeekCronSelect'
|
||||||
import NestedObjectSelect2 from './NestedObjectSelect2'
|
import NestedObjectSelect2 from './NestedObjectSelect2'
|
||||||
import DatetimeRangePicker from './DatetimeRangePicker'
|
import DatetimeRangePicker from './DatetimeRangePicker'
|
||||||
|
import JSONManyToManySelect from './JSONManyToManySelect'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Text,
|
Text,
|
||||||
@@ -33,7 +34,8 @@ export default {
|
|||||||
UploadSecret,
|
UploadSecret,
|
||||||
WeekCronSelect,
|
WeekCronSelect,
|
||||||
NestedObjectSelect2,
|
NestedObjectSelect2,
|
||||||
DatetimeRangePicker
|
DatetimeRangePicker,
|
||||||
|
JSONManyToManySelect
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -53,5 +55,6 @@ export {
|
|||||||
UploadSecret,
|
UploadSecret,
|
||||||
WeekCronSelect,
|
WeekCronSelect,
|
||||||
NestedObjectSelect2,
|
NestedObjectSelect2,
|
||||||
DatetimeRangePicker
|
DatetimeRangePicker,
|
||||||
|
JSONManyToManySelect
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<GenericCreateUpdatePage
|
<GenericCreateUpdatePage
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:initial="initial"
|
|
||||||
:fields-meta="fieldsMeta"
|
:fields-meta="fieldsMeta"
|
||||||
|
:initial="initial"
|
||||||
:url="url"
|
:url="url"
|
||||||
v-bind="$data"
|
v-bind="$data"
|
||||||
/>
|
/>
|
||||||
@@ -10,10 +10,9 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { GenericCreateUpdatePage } from '@/layout/components'
|
import { GenericCreateUpdatePage } from '@/layout/components'
|
||||||
|
import { JSONManyToManySelect } from '@/components/FormFields'
|
||||||
import rules from '@/components/DataForm/rules'
|
import rules from '@/components/DataForm/rules'
|
||||||
import {
|
import { cleanFormValueForHandleUserAssetAccount } from '../../common'
|
||||||
cleanFormValueForHandleUserAssetAccount
|
|
||||||
} from '../../common'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CommandFilterAclCreateUpdate',
|
name: 'CommandFilterAclCreateUpdate',
|
||||||
@@ -38,7 +37,28 @@ export default {
|
|||||||
createSuccessNextRoute: { name: 'CommandFilterAclList' },
|
createSuccessNextRoute: { name: 'CommandFilterAclList' },
|
||||||
fieldsMeta: {
|
fieldsMeta: {
|
||||||
users: {
|
users: {
|
||||||
fields: ['username_group']
|
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')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
username: 'username',
|
||||||
|
label: this.$t('common.Username')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
assets: {
|
assets: {
|
||||||
fields: ['name_group', 'address_group']
|
fields: ['name_group', 'address_group']
|
||||||
|
@@ -4,26 +4,25 @@
|
|||||||
{{ $t('assets.InAssetDetail') }}
|
{{ $t('assets.InAssetDetail') }}
|
||||||
</el-link>
|
</el-link>
|
||||||
<div v-else class="accounts">
|
<div v-else class="accounts">
|
||||||
<el-table :data="accounts" style="width: 100%">
|
<DataTable :config="iTableConfig" />
|
||||||
<el-table-column :label="$tc('assets.Name')" prop="name" />
|
<!-- <el-table :data="accounts" style="width: 100%">-->
|
||||||
<el-table-column :label="$tc('assets.Username')" prop="username" />
|
<!-- <el-table-column :label="$tc('assets.Privileged')" prop="privileged">-->
|
||||||
<el-table-column :label="$tc('assets.Privileged')" prop="privileged">
|
<!-- <template v-slot="scope">-->
|
||||||
<template v-slot="scope">
|
<!-- <i :class="scope.row['privileged'] ? 'fa-check' : ''" class="fa text-primary" />-->
|
||||||
<i :class="scope.row['privileged'] ? 'fa-check' : ''" class="fa text-primary" />
|
<!-- </template>-->
|
||||||
</template>
|
<!-- </el-table-column>-->
|
||||||
</el-table-column>
|
<!-- <el-table-column :label="$tc('common.TemplateAdd')" prop="template">-->
|
||||||
<el-table-column :label="$tc('common.TemplateAdd')" prop="template">
|
<!-- <template v-slot="scope">-->
|
||||||
<template v-slot="scope">
|
<!-- <i :class="scope.row['template'] ? 'fa-check' : ''" class="fa text-primary" />-->
|
||||||
<i :class="scope.row['template'] ? 'fa-check' : ''" class="fa text-primary" />
|
<!-- </template>-->
|
||||||
</template>
|
<!-- </el-table-column>-->
|
||||||
</el-table-column>
|
<!-- <el-table-column :label="$tc('common.Actions')" align="right" class-name="buttons" fixed="right" width="135">-->
|
||||||
<el-table-column :label="$tc('common.Actions')" align="right" class-name="buttons" fixed="right" width="135">
|
<!-- <template v-slot="scope">-->
|
||||||
<template v-slot="scope">
|
<!-- <el-button icon="el-icon-minus" size="mini" type="danger" @click="removeAccount(scope.row)" />-->
|
||||||
<el-button icon="el-icon-minus" size="mini" type="danger" @click="removeAccount(scope.row)" />
|
<!-- <el-button :disabled="scope.row.template" icon="el-icon-edit" size="mini" type="primary" @click="onEditClick(scope.row)" />-->
|
||||||
<el-button :disabled="scope.row.template" icon="el-icon-edit" size="mini" type="primary" @click="onEditClick(scope.row)" />
|
<!-- </template>-->
|
||||||
</template>
|
<!-- </el-table-column>-->
|
||||||
</el-table-column>
|
<!-- </el-table>-->
|
||||||
</el-table>
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<el-button size="mini" type="primary" @click="onAddClick">
|
<el-button size="mini" type="primary" @click="onAddClick">
|
||||||
{{ $t('common.Add') }}
|
{{ $t('common.Add') }}
|
||||||
@@ -50,12 +49,14 @@
|
|||||||
<script>
|
<script>
|
||||||
import AccountTemplateDialog from './AccountTemplateDialog'
|
import AccountTemplateDialog from './AccountTemplateDialog'
|
||||||
import AddAccountDialog from './AddAccountDialog'
|
import AddAccountDialog from './AddAccountDialog'
|
||||||
|
import DataTable from '@/components/DataTable/index.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AssetAccounts',
|
name: 'AssetAccounts',
|
||||||
components: {
|
components: {
|
||||||
AccountTemplateDialog,
|
AccountTemplateDialog,
|
||||||
AddAccountDialog
|
AddAccountDialog,
|
||||||
|
DataTable
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
platform: {
|
platform: {
|
||||||
@@ -79,7 +80,27 @@ export default {
|
|||||||
account: {},
|
account: {},
|
||||||
initial: false,
|
initial: false,
|
||||||
addAccountDialogVisible: false,
|
addAccountDialogVisible: false,
|
||||||
templateDialogVisible: false
|
templateDialogVisible: false,
|
||||||
|
iTableConfig: {
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
prop: 'name',
|
||||||
|
label: this.$tc('assets.Name')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'username',
|
||||||
|
label: this.$tc('assets.Username')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'privileged',
|
||||||
|
label: this.$tc('assets.Privileged'),
|
||||||
|
formatter: (row) => {
|
||||||
|
return row.privileged ? this.$tc('common.Yes') : this.$tc('common.No')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
hasPagination: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
Reference in New Issue
Block a user