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