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"
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>
<i class="fa fa-external-link" />
@@ -19,7 +19,7 @@
<AutoDataForm
class="data-form"
:form="form"
:disabled="iDisabled"
:disabled="disabled"
v-bind="config"
@submit="onSubmit"
/>
@@ -41,7 +41,7 @@ export default {
},
disabled: {
type: Boolean,
default: true
default: false
}
},
data() {
@@ -52,8 +52,7 @@ export default {
},
loading: true,
form: {},
iDisabled: this.disabled,
platformDetail: '#/console/assets/platforms/' + this.$route.query['platform'],
platformDetail: '#/console/assets/platforms/' + this.$route.query.platform,
config: {
hasSaveContinue: false,
hasButtons: !this.disabled,

View File

@@ -56,10 +56,13 @@ export default {
nodes: nodesInitial
}
Object.assign(this.initial, initial)
this.fieldsMeta.protocols.el.choices = this.platform['protocols']
if (this.platform.domain_enabled === false) {
this.fieldsMeta.domain.hidden = () => true
const hiddenCheckFields = ['protocols', 'domain']
for (const field of hiddenCheckFields) {
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>
<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>
<component :is="config.activeMenu" :object="TaskDetail" />
<component :is="config.activeMenu" :object="asset" />
</keep-alive>
</GenericDetailPage>
</template>
@@ -25,7 +30,7 @@ export default {
},
data() {
return {
TaskDetail: {},
asset: {},
config: {
activeMenu: 'Detail',
submenu: [
@@ -55,11 +60,12 @@ export default {
},
actions: {
updateCallback: () => {
const category = this.TaskDetail.category.value || 'host'
const category = this.asset.category.value || 'host'
const routerName = _.capitalize(category) + 'Update'
this.$router.push({
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() {
const vm = this
const onAction = (row, action) => {
const routeName = _.capitalize(row.category.value) + action
vm.$router.push({
let routeAction = action
if (action === 'Clone') {
routeAction = 'Create'
}
const routeName = _.capitalize(row.category.value) + routeAction
const route = {
name: routeName,
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 {
showPlatform: false,
@@ -109,15 +119,6 @@ export default {
sortable: 'custom',
width: '140px'
},
hardware_info: {
showOverflowTooltip: true
},
cpu_model: {
showOverflowTooltip: true
},
sn: {
showOverflowTooltip: true
},
comment: {
showOverflowTooltip: true
},
@@ -129,7 +130,7 @@ export default {
formatter: ActionsFormatter,
formatterArgs: {
onUpdate: ({ row }) => onAction(row, 'Update'),
onClone: ({ row }) => onAction(row, 'Create'),
onClone: ({ row }) => onAction(row, 'Clone'),
performDelete: ({ row }) => {
const id = row.id
const url = `/api/v1/assets/assets/${id}/`