mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-19 09:43:32 +00:00
perf: 修改平台和资产
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<div v-for="(item, index) in items" :key="item.name" style="display: flex;margin-top: 8px;">
|
<div v-for="(item, index) in items" :key="item.name" style="display: flex;margin-top: 8px;">
|
||||||
<el-input v-model="item.port" class="input-with-select" v-bind="$attrs">
|
<el-input v-model="item.port" class="input-with-select" v-bind="$attrs">
|
||||||
<el-select slot="prepend" v-model="item.name" @change="handleProtocolChange($event, item)">
|
<el-select slot="prepend" v-model="item.name" class="prepend" @change="handleProtocolChange($event, item)">
|
||||||
<el-option v-for="p of remainProtocols" :key="p.name" :label="p.name" :value="p.name" />
|
<el-option v-for="p of remainProtocols" :key="p.name" :label="p.name" :value="p.name" />
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<el-button v-if="showSetting" slot="append" icon="el-icon-setting" @click="onSettingClick(item)" />
|
||||||
</el-input>
|
</el-input>
|
||||||
<div style="display: flex; margin-left: 20px" class="input-button">
|
<div style="display: flex; margin-left: 20px" class="input-button">
|
||||||
<el-button
|
<el-button
|
||||||
@@ -43,6 +44,16 @@ export default {
|
|||||||
choices: {
|
choices: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => ([])
|
default: () => ([])
|
||||||
|
},
|
||||||
|
showSetting: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
onSettingClick: {
|
||||||
|
type: Function,
|
||||||
|
default: (item) => {
|
||||||
|
alert('Click setting: ' + item.name + ', port: ' + item.port)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -130,4 +141,8 @@ export default {
|
|||||||
height: 25px;
|
height: 25px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
.el-input-group__append .el-button {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
68
src/components/TableFormatters/ChoicesDisplayFormatter.vue
Normal file
68
src/components/TableFormatters/ChoicesDisplayFormatter.vue
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<template>
|
||||||
|
<el-tooltip v-if="shown" :disabled="!formatterArgs.hasTips" placement="bottom" effect="dark">
|
||||||
|
<div slot="content" v-html="tips" />
|
||||||
|
<span :class="classes">
|
||||||
|
<i v-if="formatterArgs.useIcon" :class="'fa ' + icon" />
|
||||||
|
<span v-if="formatterArgs.useText">{{ text }}</span>
|
||||||
|
</span>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import BaseFormatter from './base'
|
||||||
|
export default {
|
||||||
|
name: 'ChoicesDisplayFormatter',
|
||||||
|
extends: BaseFormatter,
|
||||||
|
props: {
|
||||||
|
formatterArgsDefault: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {
|
||||||
|
iconChoices: {
|
||||||
|
},
|
||||||
|
classChoices: {
|
||||||
|
},
|
||||||
|
hasTips: false,
|
||||||
|
useIcon: false,
|
||||||
|
useText: true,
|
||||||
|
getTips: ({ row, cellValue }) => {
|
||||||
|
return cellValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
formatterArgs: Object.assign(this.formatterArgsDefault, this.col.formatterArgs)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
key() {
|
||||||
|
return this.cellValue['value']
|
||||||
|
},
|
||||||
|
icon() {
|
||||||
|
return this.formatterArgs.iconChoices[this.key] || ''
|
||||||
|
},
|
||||||
|
classes() {
|
||||||
|
return this.formatterArgs.classChoices[this.key] || ''
|
||||||
|
},
|
||||||
|
text() {
|
||||||
|
return this.cellValue['label']
|
||||||
|
},
|
||||||
|
tips() {
|
||||||
|
return this.formatterArgs.getTips({ cellValue: this.cellValue, row: this.row })
|
||||||
|
},
|
||||||
|
shown() {
|
||||||
|
if (!this.formatterArgs.showFalse && !this.key) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@@ -13,6 +13,7 @@ import EditableInputFormatter from './EditableInputFormatter'
|
|||||||
import StatusFormatter from './StatusFormatter'
|
import StatusFormatter from './StatusFormatter'
|
||||||
import TagsFormatter from './TagsFormatter'
|
import TagsFormatter from './TagsFormatter'
|
||||||
import NestedObjectFormatter from './NestedObjectFormatter'
|
import NestedObjectFormatter from './NestedObjectFormatter'
|
||||||
|
import ChoicesDisplayFormatter from './ChoicesDisplayFormatter'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
DetailFormatter,
|
DetailFormatter,
|
||||||
@@ -29,7 +30,8 @@ export default {
|
|||||||
EditableInputFormatter,
|
EditableInputFormatter,
|
||||||
StatusFormatter,
|
StatusFormatter,
|
||||||
TagsFormatter,
|
TagsFormatter,
|
||||||
NestedObjectFormatter
|
NestedObjectFormatter,
|
||||||
|
ChoicesDisplayFormatter
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -47,5 +49,6 @@ export {
|
|||||||
EditableInputFormatter,
|
EditableInputFormatter,
|
||||||
StatusFormatter,
|
StatusFormatter,
|
||||||
TagsFormatter,
|
TagsFormatter,
|
||||||
NestedObjectFormatter
|
NestedObjectFormatter,
|
||||||
|
ChoicesDisplayFormatter
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,8 @@ import {
|
|||||||
DetailFormatter,
|
DetailFormatter,
|
||||||
ActionsFormatter,
|
ActionsFormatter,
|
||||||
TagsFormatter,
|
TagsFormatter,
|
||||||
NestedObjectFormatter
|
NestedObjectFormatter,
|
||||||
|
ChoicesDisplayFormatter
|
||||||
} from '@/components/TableFormatters'
|
} from '@/components/TableFormatters'
|
||||||
import $ from '@/utils/jquery-vendor'
|
import $ from '@/utils/jquery-vendor'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
@@ -66,7 +67,7 @@ export default {
|
|||||||
url: '/api/v1/assets/assets/',
|
url: '/api/v1/assets/assets/',
|
||||||
hasTree: true,
|
hasTree: true,
|
||||||
columns: [
|
columns: [
|
||||||
'name', 'ip', 'protocols',
|
'name', 'ip',
|
||||||
'category', 'type', 'platform',
|
'category', 'type', 'platform',
|
||||||
'labels', 'nodes',
|
'labels', 'nodes',
|
||||||
'is_active', 'connectivity',
|
'is_active', 'connectivity',
|
||||||
@@ -81,6 +82,12 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
columnsMeta: {
|
columnsMeta: {
|
||||||
|
type: {
|
||||||
|
formatter: ChoicesDisplayFormatter
|
||||||
|
},
|
||||||
|
category: {
|
||||||
|
formatter: ChoicesDisplayFormatter
|
||||||
|
},
|
||||||
hostname: {
|
hostname: {
|
||||||
formatter: DetailFormatter,
|
formatter: DetailFormatter,
|
||||||
formatterArgs: {
|
formatterArgs: {
|
||||||
|
@@ -34,7 +34,7 @@ export default {
|
|||||||
'name', 'category_type', 'charset'
|
'name', 'category_type', 'charset'
|
||||||
]],
|
]],
|
||||||
[this.$t('assets.Protocol'), [
|
[this.$t('assets.Protocol'), [
|
||||||
'protocols_enabled', 'protocols_default'
|
'protocols_enabled', 'protocols'
|
||||||
]],
|
]],
|
||||||
[this.$t('assets.Domain'), [
|
[this.$t('assets.Domain'), [
|
||||||
'domain_enabled', 'domain_default'
|
'domain_enabled', 'domain_default'
|
||||||
@@ -109,8 +109,12 @@ export default {
|
|||||||
disabled: false
|
disabled: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
protocols_default: {
|
protocols: {
|
||||||
...assetMeta.protocols,
|
...assetMeta.protocols,
|
||||||
|
el: {
|
||||||
|
choices: [],
|
||||||
|
showSetting: true
|
||||||
|
},
|
||||||
hidden: (formValue) => {
|
hidden: (formValue) => {
|
||||||
return !formValue['protocols_enabled']
|
return !formValue['protocols_enabled']
|
||||||
}
|
}
|
||||||
@@ -163,7 +167,7 @@ export default {
|
|||||||
|
|
||||||
const protocols = constraints['protocols'] || []
|
const protocols = constraints['protocols'] || []
|
||||||
this.fieldsMeta.protocols_enabled.el.disabled = protocols.length === 0
|
this.fieldsMeta.protocols_enabled.el.disabled = protocols.length === 0
|
||||||
this.fieldsMeta.protocols_default.el.choices = protocols
|
this.fieldsMeta.protocols.el.choices = protocols
|
||||||
|
|
||||||
if (updateForm) {
|
if (updateForm) {
|
||||||
updateForm({
|
updateForm({
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { GenericListPage } from '@/layout/components'
|
import { GenericListPage } from '@/layout/components'
|
||||||
|
import { ChoicesDisplayFormatter } from '@/components/TableFormatters'
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
GenericListPage
|
GenericListPage
|
||||||
@@ -22,6 +23,12 @@ export default {
|
|||||||
default: ['name', 'category', 'type', 'actions']
|
default: ['name', 'category', 'type', 'actions']
|
||||||
},
|
},
|
||||||
columnsMeta: {
|
columnsMeta: {
|
||||||
|
type: {
|
||||||
|
formatter: ChoicesDisplayFormatter
|
||||||
|
},
|
||||||
|
category: {
|
||||||
|
formatter: ChoicesDisplayFormatter
|
||||||
|
},
|
||||||
base: {
|
base: {
|
||||||
width: '140px'
|
width: '140px'
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user