From 0e184df30a1d07a30d412e2d5fd91bc37711455d Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Wed, 10 Jan 2018 10:04:33 +0800 Subject: [PATCH] 安装用户 管理 --- src/app/routes/systems/account/account-edit/account-edit.component.ts | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/app/routes/systems/account/account-edit/account-edit.component.ts b/src/app/routes/systems/account/account-edit/account-edit.component.ts index 4964b13..01a6157 100644 --- a/src/app/routes/systems/account/account-edit/account-edit.component.ts +++ b/src/app/routes/systems/account/account-edit/account-edit.component.ts @@ -24,30 +24,33 @@ } ngOnInit() { + const account = this.account; this.validateForm = this.formBuilder.group({ - accountName: [this.account.accountName], - mobile: [this.account.mobile], - email: [this.account.email], - weixin: [this.account.weixin], - organizationId: [this.account.organizationId], - expireTime: [this.account.expireTime], - id: [this.account.id] + accountName: [account.accountName], + mobile: [account.mobile], + email: [account.email], + weixin: [account.weixin], + organizationId: [account.organizationId], + expireTime: [account.expireTime], + id: [account.id] }); - this.searchOptions = this.account.organization ? [this.account.organization] : []; + this.searchOptions = account.organization ? [account.organization] : []; } save() { - if (this.validateForm.valid) { - for (const i in this.validateForm.controls) { - this.validateForm.controls[i].disable(); + const validateForm = this.validateForm; + const controls = validateForm.controls; + if (validateForm.valid) { + for (const i in controls) { + controls[i].disable(); } - this.http.post(environment.SERVER_BASH_URL + '/account/account', this.validateForm.value).subscribe(() => { + this.http.post(environment.SERVER_BASH_URL + '/account/account', validateForm.value).subscribe(() => { this.subject.next('true'); this.close(); }); } else { - for (const i in this.validateForm.controls) { - this.validateForm.controls[i].markAsDirty(); + for (const i in controls) { + controls[i].markAsDirty(); } } } @@ -57,14 +60,15 @@ } check(accountName) { + const controlsAccountName = this.validateForm.controls.accountName; if (accountName) { this.http.get(environment.SERVER_BASH_URL + '/account/' + accountName).subscribe((res: any) => { if (res.data > 0) { - this.validateForm.controls.accountName.setErrors({unique: true}); + controlsAccountName.setErrors({unique: true}); } }); } else { - this.validateForm.controls.accountName.setErrors({required: true}); + controlsAccountName.setErrors({required: true}); } } @@ -78,4 +82,5 @@ } } } + } -- Gitblit v1.8.0