mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-16 15:19:25 +00:00
perf: 修改账号创建
This commit is contained in:
@@ -13,7 +13,7 @@ import { UpdateToken, UploadSecret } from '@/components/FormFields'
|
||||
import Select2 from '@/components/FormFields/Select2'
|
||||
import AssetSelect from '@/components/AssetSelect'
|
||||
import { encryptPassword } from '@/utils/crypto'
|
||||
import { RequiredChange, Required } from '@/components/DataForm/rules'
|
||||
import { Required, RequiredChange } from '@/components/DataForm/rules'
|
||||
|
||||
export default {
|
||||
name: 'AccountCreateForm',
|
||||
@@ -63,7 +63,7 @@ export default {
|
||||
'secret_type', 'secret', 'ssh_key', 'token',
|
||||
'api_key', 'passphrase'
|
||||
]],
|
||||
[this.$t('common.Other'), ['push_now', 'strategy', 'is_active', 'comment']]
|
||||
[this.$t('common.Other'), ['push_now', 'on_exist', 'is_active', 'comment']]
|
||||
],
|
||||
fieldsMeta: {
|
||||
assets: {
|
||||
@@ -77,7 +77,7 @@ export default {
|
||||
return this.platform || this.asset
|
||||
}
|
||||
},
|
||||
strategy: {
|
||||
on_exist: {
|
||||
rules: [Required],
|
||||
label: this.$t('ops.RunasPolicy'),
|
||||
helpText: this.$t('accounts.BulkCreateStrategy'),
|
||||
|
@@ -63,6 +63,9 @@ export default {
|
||||
dateEnd: extraQuery.date_to
|
||||
}, this.headerActions.datePicker)
|
||||
}
|
||||
if (this.$route.query.order) {
|
||||
extraQuery['order'] = this.$route.query.order
|
||||
}
|
||||
return {
|
||||
selectedRows: [],
|
||||
init: false,
|
||||
|
@@ -137,11 +137,16 @@ export default {
|
||||
handleConfirm() {
|
||||
this.iVisible = false
|
||||
// 过滤掉添加里还没有id的账号
|
||||
const hasIdAccounts = this.accounts.filter(i => i?.id).map(item => item.id)
|
||||
const templates = this.accounts.filter(i => i?.template).map(item => item.template)
|
||||
const newAddAccounts = this.accountsSelected.filter(i => {
|
||||
if (!hasIdAccounts.includes(i.id)) {
|
||||
i.template = true
|
||||
return i
|
||||
return templates.indexOf(i.id) === -1
|
||||
}).map(item => {
|
||||
return {
|
||||
template: item.id,
|
||||
name: item.name,
|
||||
username: item.username,
|
||||
secret_type: item.secret_type.value,
|
||||
privileged: item.privileged
|
||||
}
|
||||
})
|
||||
this.accounts.push(...newAddAccounts)
|
||||
@@ -168,7 +173,7 @@ export default {
|
||||
})
|
||||
if (status) {
|
||||
this.$refs.dataTable.$refs.dataTable.toggleRowSelection(row, false)
|
||||
this.$message.error(this.$t('accounts.SameTypeAccountTip'))
|
||||
this.$message.error(this.$tc('accounts.SameTypeAccountTip'))
|
||||
}
|
||||
return status
|
||||
},
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<el-table-column :label="$tc('common.Actions')" align="right" class-name="buttons" fixed="right" width="135">
|
||||
<template v-slot="scope">
|
||||
<el-button icon="el-icon-minus" size="mini" type="danger" @click="removeAccount(scope.row)" />
|
||||
<el-button icon="el-icon-edit" size="mini" type="primary" @click="onEditClick(scope.row)" />
|
||||
<el-button :disabled="scope.row.template" icon="el-icon-edit" size="mini" type="primary" @click="onEditClick(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -22,7 +22,7 @@
|
||||
<el-button size="mini" type="primary" @click="onAddClick">
|
||||
{{ $t('common.Add') }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="success" :disabled="!$hasPerm('accounts.view_accounttemplate')" @click="onAddFromTemplateClick">
|
||||
<el-button :disabled="!$hasPerm('accounts.view_accounttemplate')" size="mini" type="success" @click="onAddFromTemplateClick">
|
||||
{{ $t('common.TemplateAdd') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
@@ -15,8 +15,8 @@
|
||||
/>
|
||||
<AccountTemplateDialog
|
||||
v-if="templateDialogVisible"
|
||||
:show-create="false"
|
||||
:asset="object"
|
||||
:show-create="false"
|
||||
:visible.sync="templateDialogVisible"
|
||||
@onConfirm="onConfirm"
|
||||
/>
|
||||
@@ -73,7 +73,7 @@ export default {
|
||||
methods: {
|
||||
onConfirm(data) {
|
||||
data = data?.map(i => {
|
||||
i.template = true
|
||||
i.template = i.id
|
||||
i.asset = this.object.id
|
||||
return i
|
||||
})
|
||||
|
Reference in New Issue
Block a user