mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-20 02:31:43 +00:00
fix: 修复资产账号不能更新问题
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<GenericCreateUpdateForm v-if="!loading" v-bind="$data" @afterRemoteMeta="afterGetRemoteMeta" />
|
<AutoDataForm
|
||||||
|
v-bind="$data"
|
||||||
|
@submit="confirm"
|
||||||
|
@afterRemoteMeta="afterGetRemoteMeta"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { GenericCreateUpdateForm } from '@/layout/components'
|
import AutoDataForm from '@/components/AutoDataForm'
|
||||||
import { UpdateToken } from '@/components/FormFields'
|
import { UpdateToken } from '@/components/FormFields'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AccountCreateForm',
|
name: 'AccountCreateForm',
|
||||||
components: {
|
components: {
|
||||||
GenericCreateUpdateForm
|
AutoDataForm
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
platform: {
|
platform: {
|
||||||
@@ -22,17 +25,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const url = '/api/v1/assets/accounts/'
|
|
||||||
return {
|
return {
|
||||||
url,
|
|
||||||
loading: true,
|
loading: true,
|
||||||
initial: {},
|
usernameChanged: false,
|
||||||
getUrl: () => url,
|
url: '/api/v1/assets/accounts/',
|
||||||
|
form: this.account || {},
|
||||||
fields: [
|
fields: [
|
||||||
[this.$t('common.Basic'), ['name', 'username', 'privileged']],
|
[this.$t('common.Basic'), ['name', 'username', 'privileged']],
|
||||||
[this.$t('assets.Secret'), ['secret_type', 'secret', 'ssh_key', 'token', 'api_key', 'passphrase']],
|
[this.$t('assets.Secret'), ['secret_type', 'secret', 'ssh_key', 'token', 'api_key', 'passphrase']],
|
||||||
[this.$t('common.Other'), ['push_now', 'comment']]
|
[this.$t('common.Other'), ['push_now', 'comment']]
|
||||||
],
|
],
|
||||||
|
defaultPrivilegedAccounts: ['root', 'administrator'],
|
||||||
fieldsMeta: {
|
fieldsMeta: {
|
||||||
name: {
|
name: {
|
||||||
on: {
|
on: {
|
||||||
@@ -100,25 +103,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hasReset: true,
|
hasSaveContinue: false
|
||||||
hasSaveContinue: false,
|
|
||||||
cleanFormValue(values) {
|
|
||||||
const secretType = values.secret_type || ''
|
|
||||||
if (secretType !== 'password') {
|
|
||||||
values.secret = values[secretType]
|
|
||||||
delete values[secretType]
|
|
||||||
}
|
|
||||||
|
|
||||||
return values
|
|
||||||
},
|
|
||||||
onSubmit: this.confirm
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async created() {
|
|
||||||
try {
|
|
||||||
this.initial = await this.account
|
|
||||||
} finally {
|
|
||||||
this.loading = false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -128,14 +113,19 @@ export default {
|
|||||||
this.platform.protocols?.forEach(p => {
|
this.platform.protocols?.forEach(p => {
|
||||||
secretTypes.push(...p['secret_types'])
|
secretTypes.push(...p['secret_types'])
|
||||||
})
|
})
|
||||||
if (!this.initial.secret_type) {
|
if (!this.form.secret_type) {
|
||||||
this.initial.secret_type = secretTypes[0]
|
this.form.secret_type = secretTypes[0]
|
||||||
}
|
}
|
||||||
this.fieldsMeta.secret_type.options = choices.filter(item => {
|
this.fieldsMeta.secret_type.options = choices.filter(item => {
|
||||||
return secretTypes.indexOf(item.value) > -1
|
return secretTypes.indexOf(item.value) > -1
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
confirm(form) {
|
confirm(form) {
|
||||||
|
const secretType = form.secret_type || ''
|
||||||
|
if (secretType !== 'password') {
|
||||||
|
form.secret = form[secretType]
|
||||||
|
delete form[secretType]
|
||||||
|
}
|
||||||
if (this.account?.name) {
|
if (this.account?.name) {
|
||||||
this.$emit('edit', form)
|
this.$emit('edit', form)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user