perf: 平台影响资产创建

This commit is contained in:
ibuler
2022-09-08 21:19:18 +08:00
parent ccfb7356eb
commit 0157c42c52
4 changed files with 36 additions and 27 deletions

View File

@@ -11,7 +11,7 @@
@open="onOpen" @open="onOpen"
v-on="$listeners" v-on="$listeners"
> >
<el-alert type="success"> <el-alert v-if="disabled" type="success">
继承自平台配置如需更改请更改平台中的配置 继承自平台配置如需更改请更改平台中的配置
<el-link :href="platformDetail" class="link-more" target="_blank">查看</el-link> <el-link :href="platformDetail" class="link-more" target="_blank">查看</el-link>
<i class="fa fa-external-link" /> <i class="fa fa-external-link" />
@@ -19,7 +19,7 @@
<AutoDataForm <AutoDataForm
class="data-form" class="data-form"
:form="form" :form="form"
:disabled="iDisabled" :disabled="disabled"
v-bind="config" v-bind="config"
@submit="onSubmit" @submit="onSubmit"
/> />
@@ -41,7 +41,7 @@ export default {
}, },
disabled: { disabled: {
type: Boolean, type: Boolean,
default: true default: false
} }
}, },
data() { data() {
@@ -52,8 +52,7 @@ export default {
}, },
loading: true, loading: true,
form: {}, form: {},
iDisabled: this.disabled, platformDetail: '#/console/assets/platforms/' + this.$route.query.platform,
platformDetail: '#/console/assets/platforms/' + this.$route.query['platform'],
config: { config: {
hasSaveContinue: false, hasSaveContinue: false,
hasButtons: !this.disabled, hasButtons: !this.disabled,

View File

@@ -56,10 +56,13 @@ export default {
nodes: nodesInitial nodes: nodesInitial
} }
Object.assign(this.initial, initial) Object.assign(this.initial, initial)
this.fieldsMeta.protocols.el.choices = this.platform['protocols'] const hiddenCheckFields = ['protocols', 'domain']
if (this.platform.domain_enabled === false) { for (const field of hiddenCheckFields) {
this.fieldsMeta.domain.hidden = () => true if (this.platform[field + '_enabled'] === false) {
this.fieldsMeta[field].hidden = () => true
}
} }
this.fieldsMeta.protocols.el.choices = this.platform['protocols']
} }
} }
} }

View File

@@ -1,7 +1,12 @@
<template> <template>
<GenericDetailPage :object.sync="TaskDetail" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners"> <GenericDetailPage
:object.sync="asset"
:active-menu.sync="config.activeMenu"
v-bind="config"
v-on="$listeners"
>
<keep-alive> <keep-alive>
<component :is="config.activeMenu" :object="TaskDetail" /> <component :is="config.activeMenu" :object="asset" />
</keep-alive> </keep-alive>
</GenericDetailPage> </GenericDetailPage>
</template> </template>
@@ -25,7 +30,7 @@ export default {
}, },
data() { data() {
return { return {
TaskDetail: {}, asset: {},
config: { config: {
activeMenu: 'Detail', activeMenu: 'Detail',
submenu: [ submenu: [
@@ -55,11 +60,12 @@ export default {
}, },
actions: { actions: {
updateCallback: () => { updateCallback: () => {
const category = this.TaskDetail.category.value || 'host' const category = this.asset.category.value || 'host'
const routerName = _.capitalize(category) + 'Update' const routerName = _.capitalize(category) + 'Update'
this.$router.push({ this.$router.push({
name: routerName, name: routerName,
params: { id: this.$route.params.id } params: { id: this.$route.params.id },
query: { platform: this.asset.platform.id }
}) })
} }
} }

View File

@@ -60,12 +60,22 @@ export default {
data() { data() {
const vm = this const vm = this
const onAction = (row, action) => { const onAction = (row, action) => {
const routeName = _.capitalize(row.category.value) + action let routeAction = action
vm.$router.push({ if (action === 'Clone') {
routeAction = 'Create'
}
const routeName = _.capitalize(row.category.value) + routeAction
const route = {
name: routeName, name: routeName,
params: { id: row.id }, params: { id: row.id },
...(action === 'Create' && { query: { clone_from: row.id }}) query: {}
}) }
if (action === 'Clone') {
route.query.clone_from = row.id
} else if (action === 'Update') {
route.query.platform = row.platform.id
}
vm.$router.push(route)
} }
return { return {
showPlatform: false, showPlatform: false,
@@ -109,15 +119,6 @@ export default {
sortable: 'custom', sortable: 'custom',
width: '140px' width: '140px'
}, },
hardware_info: {
showOverflowTooltip: true
},
cpu_model: {
showOverflowTooltip: true
},
sn: {
showOverflowTooltip: true
},
comment: { comment: {
showOverflowTooltip: true showOverflowTooltip: true
}, },
@@ -129,7 +130,7 @@ export default {
formatter: ActionsFormatter, formatter: ActionsFormatter,
formatterArgs: { formatterArgs: {
onUpdate: ({ row }) => onAction(row, 'Update'), onUpdate: ({ row }) => onAction(row, 'Update'),
onClone: ({ row }) => onAction(row, 'Create'), onClone: ({ row }) => onAction(row, 'Clone'),
performDelete: ({ row }) => { performDelete: ({ row }) => {
const id = row.id const id = row.id
const url = `/api/v1/assets/assets/${id}/` const url = `/api/v1/assets/assets/${id}/`