mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-29 00:05:31 +00:00
perf: 优化资产克隆时模版添加账号
This commit is contained in:
@@ -61,24 +61,11 @@ export default {
|
|||||||
cleanFormValue(values) {
|
cleanFormValue(values) {
|
||||||
// Update 的时候
|
// Update 的时候
|
||||||
const { id = '' } = this.$route.params
|
const { id = '' } = this.$route.params
|
||||||
const accounts = values?.accounts
|
|
||||||
const query = this.$route.query || {}
|
|
||||||
if (id) delete values['accounts']
|
if (id) delete values['accounts']
|
||||||
|
|
||||||
if (values.nodes && values.nodes.length === 0) {
|
if (values.nodes && values.nodes.length === 0) {
|
||||||
delete values['nodes']
|
delete values['nodes']
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accounts && accounts.length !== 0) {
|
|
||||||
accounts.forEach(i => {
|
|
||||||
if (i.hasOwnProperty('id')) {
|
|
||||||
// 克隆资产时 template 为 false
|
|
||||||
i.template = !query.hasOwnProperty('clone_from')
|
|
||||||
}
|
|
||||||
return i
|
|
||||||
})
|
|
||||||
}
|
|
||||||
console.log('values[\'accounts\']', values['accounts'])
|
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -133,7 +133,12 @@ export default {
|
|||||||
this.iVisible = false
|
this.iVisible = false
|
||||||
// 过滤掉添加里还没有id的账号
|
// 过滤掉添加里还没有id的账号
|
||||||
const hasIdAccounts = this.accounts.filter(i => i?.id).map(item => item.id)
|
const hasIdAccounts = this.accounts.filter(i => i?.id).map(item => item.id)
|
||||||
const newAddAccounts = this.accountsSelected.filter(i => !hasIdAccounts.includes(i.id))
|
const newAddAccounts = this.accountsSelected.filter(i => {
|
||||||
|
if (!hasIdAccounts.includes(i.id)) {
|
||||||
|
i.template = true
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
})
|
||||||
this.accounts.push(...newAddAccounts)
|
this.accounts.push(...newAddAccounts)
|
||||||
this.$emit('onConfirm', this.accounts)
|
this.$emit('onConfirm', this.accounts)
|
||||||
},
|
},
|
||||||
|
@@ -40,6 +40,8 @@ export default {
|
|||||||
formConfig: {
|
formConfig: {
|
||||||
initial: { secret_type: 'password' },
|
initial: { secret_type: 'password' },
|
||||||
url: '/api/v1/accounts/account-templates/',
|
url: '/api/v1/accounts/account-templates/',
|
||||||
|
getUrl: '/api/v1/accounts/account-templates/',
|
||||||
|
needGetObjectDetail: false,
|
||||||
hasDetailInMsg: false,
|
hasDetailInMsg: false,
|
||||||
fields: [
|
fields: [
|
||||||
...templateFields(this)
|
...templateFields(this)
|
||||||
|
Reference in New Issue
Block a user