From 40951bf70651c38d09a3b1f5eaddde8faa9e8c06 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Fri, 23 Mar 2018 16:28:52 +0800 Subject: [PATCH] 查看数据bug修复,修改密码功能开发 --- src/app/routes/systems/account/account.component.ts | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 58 insertions(+), 1 deletions(-) diff --git a/src/app/routes/systems/account/account.component.ts b/src/app/routes/systems/account/account.component.ts index 92c5346..8f4f93c 100644 --- a/src/app/routes/systems/account/account.component.ts +++ b/src/app/routes/systems/account/account.component.ts @@ -5,6 +5,8 @@ import {environment} from '../../../../environments/environment'; import { DateService } from '../../../business/services/util/date.service'; import {AccountEditComponent} from './account-edit/account-edit.component'; +import { FormBuilder, Validators, FormControl, FormGroup } from '@angular/forms'; +import { ResultBean } from '@business/entity/grid'; @Component({ selector: 'app-account', templateUrl: './account.component.html', @@ -37,7 +39,8 @@ private confirmServ: NzModalService, public dateSrv: DateService, public msgSrv: NzMessageService, - private modalHelper: ModalHelper + private modalHelper: ModalHelper, + private fb: FormBuilder ) { } @@ -60,6 +63,12 @@ ngOnInit() { this.load(); + // ������������������ + this.resetPwdForm = this.fb.group({ + accountName : [ null, [ Validators.email ] ], + password : [ null, [ Validators.required ] ], + checkPassword : [ null, [ Validators.required, this.confirmationValidator ] ] + }); } edit(account?: any) { @@ -140,5 +149,53 @@ if (date) { return this.dateSrv.date_format(date, 'YYYY-MM-DD'); } + } + public resetPwdWindowIsVisible = false; + public isResetPwdLoading = false; + public resetPwdForm: FormGroup; + public showResetPwdWindow(account) { + this.resetPwdWindowIsVisible = true; + this.resetPwdForm = this.fb.group({ + id : [ account.id ], + accountName : [ account.accountName], + password : [ null, [ Validators.required ] ], + checkPassword : [ null, [ Validators.required, this.confirmationValidator ] ] + }); + } + public resetPwdCancel() { + this.resetPwdWindowIsVisible = false; + } + public resetPwdOk() { + for (const i in this.resetPwdForm.controls) { + this.resetPwdForm.controls[ i ].markAsDirty(); + } + if (this.resetPwdForm.valid) { + this.isResetPwdLoading = true; + const data = this.resetPwdForm.value; + data['accountName'] = null; + this.http.post(environment.SERVER_BASH_URL + '/account/account', data).subscribe((res: ResultBean<any>) => { + if ( res.code === 1 && res.data === 1 ) { + this.isResetPwdLoading = false; + this.resetPwdWindowIsVisible = false; + this.msgSrv.success('���������������������'); + } + }); + } + } + confirmationValidator = (control: FormControl): { [s: string]: boolean } => { + if (!control.value) { + return { required: true }; + } else if (control.value !== this.resetPwdForm.controls[ 'password' ].value) { + return { confirm: true, error: true }; + } + } + getFormControl(name) { + return this.resetPwdForm.controls[ name ]; + } + updateConfirmValidator() { + /** wait for refresh value */ + setTimeout(_ => { + this.resetPwdForm.controls[ 'checkPassword' ].updateValueAndValidity(); + }); } } -- Gitblit v1.8.0