mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-18 23:07:41 +00:00
perf: 修改账号创建更新
This commit is contained in:
parent
8a836faa25
commit
6bcf8b1b15
@ -47,7 +47,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
platform: {},
|
platform: {},
|
||||||
changePlatformID: '',
|
initing: false,
|
||||||
|
// 在 meta 中,可能改变 platform id
|
||||||
|
platformID: this.$route.query.platform || '',
|
||||||
meta: {},
|
meta: {},
|
||||||
iConfig: {},
|
iConfig: {},
|
||||||
defaultConfig: {
|
defaultConfig: {
|
||||||
@ -95,11 +97,18 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async init() {
|
async init() {
|
||||||
|
// 更改平台时,就不重新 loading 了
|
||||||
|
this.$log.debug('Initing asset base upcate create', this.initing)
|
||||||
|
if (this.initing) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.initing = true
|
||||||
try {
|
try {
|
||||||
await this.genConfig()
|
await this.genConfig()
|
||||||
await this.setInitial()
|
await this.setInitial()
|
||||||
await this.setPlatformConstrains()
|
await this.setPlatformConstrains()
|
||||||
} finally {
|
} finally {
|
||||||
|
this.initing = false
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -107,9 +116,9 @@ export default {
|
|||||||
const { addFields, addFieldsMeta, defaultConfig } = this
|
const { addFields, addFieldsMeta, defaultConfig } = this
|
||||||
defaultConfig.fieldsMeta = assetFieldsMeta(this, this.$route.query.type)
|
defaultConfig.fieldsMeta = assetFieldsMeta(this, this.$route.query.type)
|
||||||
let url = this.url
|
let url = this.url
|
||||||
const { id = '', platform } = this.$route.query
|
const id = this.$route.params.id
|
||||||
if (platform && !id) {
|
if (!id) {
|
||||||
url = setUrlParam(url, 'platform', platform)
|
url = setUrlParam(url, 'platform', this.platformID)
|
||||||
}
|
}
|
||||||
// 过滤类型为:null, undefined 的元素
|
// 过滤类型为:null, undefined 的元素
|
||||||
defaultConfig.fields = defaultConfig.fields.filter(Boolean)
|
defaultConfig.fields = defaultConfig.fields.filter(Boolean)
|
||||||
@ -134,9 +143,9 @@ export default {
|
|||||||
},
|
},
|
||||||
async setInitial() {
|
async setInitial() {
|
||||||
const { defaultConfig } = this
|
const { defaultConfig } = this
|
||||||
const { node, platform } = this.$route.query
|
const { node } = this.$route.query
|
||||||
const nodesInitial = node ? [node] : []
|
const nodesInitial = node ? [node] : []
|
||||||
const platformId = this.changePlatformID || this.$route.query.platform || (platform || 'Linux')
|
const platformId = this.platformID || 'Linux'
|
||||||
const url = `/api/v1/assets/platforms/${platformId}/`
|
const url = `/api/v1/assets/platforms/${platformId}/`
|
||||||
this.platform = await this.$axios.get(url)
|
this.platform = await this.$axios.get(url)
|
||||||
const initial = {
|
const initial = {
|
||||||
@ -165,13 +174,6 @@ export default {
|
|||||||
const protocolChoices = this.iConfig.fieldsMeta.protocols.el.choices
|
const protocolChoices = this.iConfig.fieldsMeta.protocols.el.choices
|
||||||
protocolChoices.splice(0, protocolChoices.length, ...protocols)
|
protocolChoices.splice(0, protocolChoices.length, ...protocols)
|
||||||
this.iConfig.fieldsMeta.accounts.el.platform = platform
|
this.iConfig.fieldsMeta.accounts.el.platform = platform
|
||||||
const hiddenCheckFields = ['protocols', 'domain']
|
|
||||||
|
|
||||||
for (const field of hiddenCheckFields) {
|
|
||||||
if (platform[field + '_enabled'] === false) {
|
|
||||||
this.iConfig.fieldsMeta[field].hidden = () => true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,8 @@ export default {
|
|||||||
const query = {
|
const query = {
|
||||||
platform: row.platform.id,
|
platform: row.platform.id,
|
||||||
type: row.type.value,
|
type: row.type.value,
|
||||||
category: row.category.value
|
category: row.category.value,
|
||||||
|
action: action
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action === 'clone') {
|
if (action === 'clone') {
|
||||||
|
@ -26,12 +26,12 @@ export const filterSelectValues = (values) => {
|
|||||||
return selects
|
return selects
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePlatformProtocols(vm, platformType, updateForm, isPlatformChanged = false) {
|
function updatePlatformProtocols(vm, platformType, updateForm, platformChanged = false) {
|
||||||
setTimeout(() => vm.init().then(() => {
|
setTimeout(() => vm.init().then(() => {
|
||||||
const isCreate = vm?.$route?.meta.action === 'create' && vm?.$route?.query.clone_from === undefined
|
const isCreate = vm.$route.query.action === 'create' && vm?.$route?.query.clone_from === undefined
|
||||||
const need_modify = isCreate || isPlatformChanged
|
const needModify = isCreate || platformChanged
|
||||||
const platformProtocols = vm.platform.protocols
|
const platformProtocols = vm.platform.protocols
|
||||||
if (!need_modify) return
|
if (!needModify) return
|
||||||
if (platformType === 'website') {
|
if (platformType === 'website') {
|
||||||
const setting = Array.isArray(platformProtocols) ? platformProtocols[0].setting : platformProtocols.setting
|
const setting = Array.isArray(platformProtocols) ? platformProtocols[0].setting : platformProtocols.setting
|
||||||
updateForm({
|
updateForm({
|
||||||
@ -99,21 +99,15 @@ export const assetFieldsMeta = (vm, platformType) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
change: ([event], updateForm) => {
|
change: _.debounce(([event], updateForm) => {
|
||||||
const pk = event.pk
|
const pk = event.pk
|
||||||
const url = window.location.href
|
vm.platformID = pk
|
||||||
vm.changePlatformID = pk
|
|
||||||
if (url.includes('clone')) {
|
|
||||||
updatePlatformProtocols(vm, platformType, updateForm, true)
|
updatePlatformProtocols(vm, platformType, updateForm, true)
|
||||||
} else {
|
}, 200),
|
||||||
vm.$nextTick(() => {
|
input: _.debounce(([event], updateForm) => {
|
||||||
updatePlatformProtocols(vm, platformType, updateForm, true)
|
// 初始化的时候,mounted 中没有这个逻辑
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
input: ([event], updateForm) => {
|
|
||||||
updatePlatformProtocols(vm, platformType, updateForm)
|
updatePlatformProtocols(vm, platformType, updateForm)
|
||||||
}
|
}, 200)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
domain: {
|
domain: {
|
||||||
@ -125,6 +119,9 @@ export const assetFieldsMeta = (vm, platformType) => {
|
|||||||
ajax: {
|
ajax: {
|
||||||
url: '/api/v1/assets/domains/'
|
url: '/api/v1/assets/domains/'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
hidden: () => {
|
||||||
|
return vm.platform.domain_enabled === false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
|
Loading…
Reference in New Issue
Block a user