mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-17 07:42:41 +00:00
perf: 修改 平台详情
This commit is contained in:
@@ -51,30 +51,32 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
object: {
|
object: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => ({})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
fields: ['domain_enabled'],
|
fields: ['domain_enabled'],
|
||||||
quickActions: this.setQuickActions(),
|
quickActions: [],
|
||||||
url: `/api/v1/assets/platforms/${this.object.id}`,
|
url: `/api/v1/assets/platforms/${this.object.id}`,
|
||||||
detailFields: [
|
detailFields: [
|
||||||
'name', 'charset',
|
'name', 'charset', 'internal',
|
||||||
{
|
{
|
||||||
key: this.$t('assets.Type'),
|
key: this.$t('assets.Type'),
|
||||||
value: `${this.object.category?.label}/${this.object.type?.label}`
|
value: `${this.object.category?.label}/${this.object.type?.label}`
|
||||||
},
|
},
|
||||||
|
'su_method',
|
||||||
'comment'
|
'comment'
|
||||||
],
|
],
|
||||||
protocolChoices: null
|
protocolChoices: null,
|
||||||
|
constraints: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.getTypeConstraints()
|
await this.getTypeConstraints()
|
||||||
|
await this.setQuickActions()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateProtocols() {
|
updateProtocols() {
|
||||||
@@ -89,12 +91,10 @@ export default {
|
|||||||
const url = `/api/v1/assets/categories/constraints/?category=${category}&type=${type}`
|
const url = `/api/v1/assets/categories/constraints/?category=${category}&type=${type}`
|
||||||
const constraints = await this.$axios.get(url)
|
const constraints = await this.$axios.get(url)
|
||||||
this.protocolChoices = constraints['protocols']
|
this.protocolChoices = constraints['protocols']
|
||||||
|
this.constraints = constraints
|
||||||
},
|
},
|
||||||
setQuickActions() {
|
async setQuickActions() {
|
||||||
const vm = this
|
|
||||||
const { object } = this
|
const { object } = this
|
||||||
const suEnabledDisabled = ['database', 'device']
|
|
||||||
const domainEnabledDisabled = ['cloud', 'web']
|
|
||||||
const quickActions = [
|
const quickActions = [
|
||||||
{
|
{
|
||||||
title: this.$t('assets.DomainEnabled'),
|
title: this.$t('assets.DomainEnabled'),
|
||||||
@@ -102,10 +102,7 @@ export default {
|
|||||||
attrs: {
|
attrs: {
|
||||||
label: this.$t('common.Update'),
|
label: this.$t('common.Update'),
|
||||||
model: object['domain_enabled'],
|
model: object['domain_enabled'],
|
||||||
disabled: (
|
disabled: object['internal'] || this.constraints['domain_enabled'] === false
|
||||||
object.internal || !vm.$hasPerm('assets.change_platform') ||
|
|
||||||
domainEnabledDisabled.includes(object.category?.value)
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
callbacks: Object.freeze({
|
callbacks: Object.freeze({
|
||||||
change: (val) => {
|
change: (val) => {
|
||||||
@@ -119,24 +116,23 @@ export default {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: this.$t(`assets.AccountEnabled`),
|
title: this.$t(`assets.AccountEnabled`),
|
||||||
|
type: 'switch',
|
||||||
attrs: {
|
attrs: {
|
||||||
type: 'primary',
|
model: object['su_enabled'],
|
||||||
label: this.$t('common.Update'),
|
disabled: object['internal'] || this.constraints['su_enabled'] === false
|
||||||
disabled: (
|
|
||||||
suEnabledDisabled.includes(object.category?.value) || !object.su_enabled ||
|
|
||||||
object.internal || !vm.$hasPerm('assets.change_platform')
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
callbacks: Object.freeze({
|
callbacks: Object.freeze({
|
||||||
click: () => {
|
change: (val) => {
|
||||||
this.fields = ['su_enabled', 'su_method']
|
const data = { su_enabled: val }
|
||||||
this.visible = !this.visible
|
this.$axios.patch(
|
||||||
|
`/api/v1/assets/platforms/${object.id}/`, data).then(res => {
|
||||||
|
this.$message.success(this.$tc('common.updateSuccessMsg'))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
this.quickActions = quickActions
|
||||||
return quickActions
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user