perf: 修改 accounts 创建

This commit is contained in:
ibuler 2024-03-13 18:53:19 +08:00
parent 6b87a2ad31
commit dc94ff58c3
10 changed files with 35 additions and 17 deletions

View File

@ -2,6 +2,7 @@
<AutoDataForm <AutoDataForm
v-if="!loading" v-if="!loading"
ref="AutoDataForm" ref="AutoDataForm"
:class="addTemplate? '': 'account-add'"
v-bind="$data" v-bind="$data"
@submit="confirm" @submit="confirm"
/> />
@ -58,9 +59,8 @@ export default {
form: Object.assign({ 'on_invalid': 'error' }, this.account || {}), form: Object.assign({ 'on_invalid': 'error' }, this.account || {}),
encryptedFields: ['secret'], encryptedFields: ['secret'],
fields: [ fields: [
[this.$t('Asset'), ['assets']],
[this.$t('AccountTemplate'), ['template']], [this.$t('AccountTemplate'), ['template']],
[this.$t('Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username']], [this.$t('Basic'), ['assets', 'name', 'username', 'privileged', 'su_from', 'su_from_username']],
[this.$t('Secret'), [ [this.$t('Secret'), [
'secret_type', 'password', 'ssh_key', 'token', 'secret_type', 'password', 'ssh_key', 'token',
'access_key', 'passphrase', 'api_key' 'access_key', 'passphrase', 'api_key'
@ -145,5 +145,21 @@ export default {
} }
</script> </script>
<style scoped> <style lang='scss' scoped>
.account-add {
>>> .el-form-item {
margin-bottom: 5px;
.help-block {
margin-bottom: 5px;
}
}
>>> .form-group-header {
.hr-line-dashed {
margin: 5px 0;
}
h3 {
margin-bottom: 5px;
}
}
}
</style> </style>

View File

@ -53,7 +53,7 @@ export default {
title: { title: {
type: String, type: String,
default: function() { default: function() {
return this.$t('Add') return this.$t('AddAccount')
} }
} }
}, },

View File

@ -139,7 +139,7 @@ export default {
showAddDialog: false, showAddDialog: false,
showAddTemplateDialog: false, showAddTemplateDialog: false,
createAccountResults: [], createAccountResults: [],
accountCreateUpdateTitle: this.$t('Create'), accountCreateUpdateTitle: this.$t('AddAccount'),
iAsset: this.asset, iAsset: this.asset,
account: {}, account: {},
secretUrl: '', secretUrl: '',
@ -316,6 +316,7 @@ export default {
name: 'add', name: 'add',
title: this.$t('Create'), title: this.$t('Create'),
type: 'primary', type: 'primary',
icon: 'plus',
can: () => { can: () => {
return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot
}, },

View File

@ -1,7 +1,7 @@
<template> <template>
<el-form-item <el-form-item
v-show="_show" v-show="_show"
:class="'el-form-item-' + data.prop" :class="'el-form-item-' + data.prop + ' ' + data.attrs.class || ''"
:label="data.label" :label="data.label"
:prop="prop" :prop="prop"
:rules="_show && Array.isArray(data.rules) ? data.rules : []" :rules="_show && Array.isArray(data.rules) ? data.rules : []"

View File

@ -161,6 +161,7 @@ export default {
.el-form ::v-deep .el-form-item__content { .el-form ::v-deep .el-form-item__content {
width: 75%; width: 75%;
line-height: 35px;
} }
.mobile.el-form ::v-deep .el-form-item__content { .mobile.el-form ::v-deep .el-form-item__content {
@ -169,6 +170,7 @@ export default {
.el-form ::v-deep .el-form-item__label { .el-form ::v-deep .el-form-item__label {
padding: 0 30px 0 0; padding: 0 30px 0 0;
line-height: 35px;
} }
.el-form ::v-deep .el-form-item__error { .el-form ::v-deep .el-form-item__error {

View File

@ -151,7 +151,6 @@ export default {
}, },
actions() { actions() {
const actions = [...this.defaultActions, ...this.extraActions] const actions = [...this.defaultActions, ...this.extraActions]
console.log('Moreactions: ', this.defaultActions)
return cleanActions(actions, true, { return cleanActions(actions, true, {
selectedRows: this.selectedRows, selectedRows: this.selectedRows,
reloadTable: this.reloadTable reloadTable: this.reloadTable

View File

@ -1,6 +1,4 @@
{ {
"FieldRequiredError": "This field is required.", "FieldRequiredError": "This field is required.",
"SystemRoleHelpMsg": "System roles are roles that apply universally across all organizations within the platform. These roles allow you to define specific permissions and access levels for users across the entire system. Changes made to system roles will affect all organizations using the platform.", "ServerError": "An error occurred while processing your request. Please try again later."
"OrgRoleHelpMsg": "Organization roles are roles tailored to individual organizations within the platform. These roles are assigned when inviting users to join a particular organization and dictate their permissions and access levels within that organization. Unlike system roles, organization roles are customizable and apply only within the scope of the organization they are assigned to.",
"VirtualAccountHelpMsg": "Virtual accounts are specialized accounts with specific purposes when connecting assets."
} }

View File

@ -359,6 +359,7 @@ button, input, optgroup, select, textarea {
.el-form .el-form-item__content { .el-form .el-form-item__content {
font-size: 13px; font-size: 13px;
line-height: 35px;
} }
.el-tabs__item > span { .el-tabs__item > span {
@ -385,6 +386,7 @@ button, input, optgroup, select, textarea {
word-break: break-word; word-break: break-word;
} }
} }
.form-group-header { .form-group-header {
text-align: left; text-align: left;
} }

View File

@ -44,11 +44,11 @@ export default {
}, },
fields: [ fields: [
[this.$t('Basic'), [ [this.$t('Basic'), [
'name', 'category_type', 'charset', 'name', 'category_type'
'domain_enabled'
]], ]],
[this.$t('Config'), [ [this.$t('Config'), [
'protocols', 'su_enabled', 'su_method' 'protocols', 'su_enabled', 'su_method',
'domain_enabled', 'charset'
]], ]],
[this.$t('Automations'), ['automation']], [this.$t('Automations'), ['automation']],
[this.$t('Other'), ['comment']] [this.$t('Other'), ['comment']]
@ -174,7 +174,7 @@ export default {
} }
} }
>>> .itemMethodKey.el-form-item { >>> .item-method.el-form-item {
display: inline-block; display: inline-block;
width: 100%; width: 100%;
.el-form-item__content { .el-form-item__content {
@ -185,7 +185,7 @@ export default {
} }
} }
>>> .itemParamsKey.el-form-item { >>> .item-params.el-form-item {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: 20px; right: 20px;

View File

@ -130,7 +130,7 @@ export const setAutomations = (vm) => {
return !formValue[itemEnabledKey] || !formValue['ansible_enabled'] return !formValue[itemEnabledKey] || !formValue['ansible_enabled']
}) })
// 设置 enableMethod className // 设置 enableMethod className
_.set(autoFieldsMeta, `${itemMethodKey}.attrs.class`, 'itemMethodKey') _.set(autoFieldsMeta, `${itemMethodKey}.attrs.class`, 'item-method')
// 设置 enableParams Hidden // 设置 enableParams Hidden
_.set(autoFieldsMeta, `${itemParamsKey}.hidden`, (formValue) => { _.set(autoFieldsMeta, `${itemParamsKey}.hidden`, (formValue) => {
return !formValue[itemEnabledKey] || !formValue['ansible_enabled'] return !formValue[itemEnabledKey] || !formValue['ansible_enabled']
@ -148,7 +148,7 @@ export const setAutomations = (vm) => {
// 设置 enableParams label // 设置 enableParams label
_.set(autoFieldsMeta, `${itemParamsKey}.label`, '') _.set(autoFieldsMeta, `${itemParamsKey}.label`, '')
// 设置 enableParams className // 设置 enableParams className
_.set(autoFieldsMeta, `${itemParamsKey}.attrs.class`, 'itemParamsKey') _.set(autoFieldsMeta, `${itemParamsKey}.attrs.class`, 'item-params')
_.set(autoFieldsMeta, `${itemParamsKey}.component`, AutomationParamsSetting) _.set(autoFieldsMeta, `${itemParamsKey}.component`, AutomationParamsSetting)
_.set(autoFieldsMeta, `${itemParamsKey}.el.method`, initial[itemMethodKey]) _.set(autoFieldsMeta, `${itemParamsKey}.el.method`, initial[itemMethodKey])
// } // }