From 4f3f8d3a0365b329d9baba2365e12aeed31a3231 Mon Sep 17 00:00:00 2001 From: Bai Date: Tue, 26 May 2020 11:54:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E6=94=B9?= =?UTF-8?q?=E5=AF=86=E8=AE=A1=E5=88=92=E6=9B=B4=E6=96=B0api=20url=E7=9A=84?= =?UTF-8?q?=E5=90=8E=E7=BC=80/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue index 19fe55f59..080d3b642 100644 --- a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue +++ b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue @@ -13,7 +13,7 @@ export default { }, data() { return { - url: '/api/v1/xpack/change-auth-plan/plan/', + url: '/api/v1/xpack/change-auth-plan/plan', fields: [ [this.$t('xpack.Basic'), ['name']], [this.$t('xpack.Asset'), ['username', 'assets', 'nodes']], From 9573164a0360446df66a6f59460d722ee0093ba8 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 27 May 2020 10:37:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Update]=20=E6=94=B9=E5=AF=86=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=88=9B=E5=BB=BA/=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEpassword=5Frules=20type=E4=B8=BAgroup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChangeAuthPlanCreateUpdate.vue | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue index 080d3b642..66d02d080 100644 --- a/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue +++ b/src/views/xpack/ChangeAuthPlan/ChangeAuthPlanCreateUpdate.vue @@ -13,18 +13,20 @@ export default { }, data() { return { - url: '/api/v1/xpack/change-auth-plan/plan', + url: '/api/v1/xpack/change-auth-plan/plan/', fields: [ [this.$t('xpack.Basic'), ['name']], [this.$t('xpack.Asset'), ['username', 'assets', 'nodes']], - [this.$t('xpack.ChangeAuthPlan.PasswordStrategy'), ['password_strategy', 'password', 'password_rules_length']], + [this.$t('xpack.ChangeAuthPlan.PasswordStrategy'), ['password_strategy', 'password', 'password_rules']], [this.$t('xpack.Timer'), ['is_periodic', 'crontab', 'interval']], [this.$t('xpack.Other'), ['comment']] ], initial: { password_strategy: 'custom', - password_rules_length: 20, is_periodic: true, + password_rules: { + length: 20 + }, interval: 24 }, fieldsMeta: { @@ -42,14 +44,14 @@ export default { password: { hidden: (formValue) => { return formValue.password_strategy !== 'custom' - } + }, + rules: [ + { required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError'), trigger: 'blur' } + ] }, - password_rules_length: { - type: 'input', - label: this.$t('xpack.ChangeAuthPlan.PasswordLength'), - hidden: (formValue) => { - return ['random_one', 'random_all'].indexOf(formValue.password_strategy) === -1 - } + password_rules: { + type: 'group', + items: this.generatePasswordRulesItemsFields() }, nodes: { label: this.$t('xpack.Node'), @@ -92,22 +94,23 @@ export default { }, helpText: '(单位: 时)' } - }, - cleanFormValue(values) { - if (['random_one', 'random_all'].indexOf(values.password_strategy) !== -1) { - const password_rules = {} - const password_rules_prefix = 'password_rules_' - for (const key of Object.keys(values)) { - if (key.startsWith(password_rules_prefix)) { - password_rules[key.slice(password_rules_prefix.length)] = values[key] - delete values[key] - } - } - values['password_rules'] = password_rules - } - return values } } + }, + methods: { + generatePasswordRulesItemsFields() { + const itemsFields = [] + const items = [ + { id: 'length', prop: 'length', label: this.$t('xpack.ChangeAuthPlan.PasswordLength') } + ] + items.forEach((item, index, array) => { + itemsFields.push({ + id: item.id, prop: item.prop, el: {}, attrs: {}, type: 'input', label: item.label, required: true, + hidden: (formValue) => { return ['random_one', 'random_all'].indexOf(formValue.password_strategy) === -1 } + }) + }) + return itemsFields + } } }