mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-28 15:55:24 +00:00
perf: 优化资产克隆时模版添加账号
This commit is contained in:
@@ -61,24 +61,11 @@ export default {
|
||||
cleanFormValue(values) {
|
||||
// Update 的时候
|
||||
const { id = '' } = this.$route.params
|
||||
const accounts = values?.accounts
|
||||
const query = this.$route.query || {}
|
||||
if (id) delete values['accounts']
|
||||
|
||||
if (values.nodes && values.nodes.length === 0) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@@ -133,7 +133,12 @@ export default {
|
||||
this.iVisible = false
|
||||
// 过滤掉添加里还没有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.$emit('onConfirm', this.accounts)
|
||||
},
|
||||
|
@@ -40,6 +40,8 @@ export default {
|
||||
formConfig: {
|
||||
initial: { secret_type: 'password' },
|
||||
url: '/api/v1/accounts/account-templates/',
|
||||
getUrl: '/api/v1/accounts/account-templates/',
|
||||
needGetObjectDetail: false,
|
||||
hasDetailInMsg: false,
|
||||
fields: [
|
||||
...templateFields(this)
|
||||
|
Reference in New Issue
Block a user