47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|||
|
|
import { FormBuilder,FormControl,FormGroup,Validators} from '@angular/forms';
|
||
|
|
|
||
|
|
@Component({
|
||
|
|
selector: 'app-user-management-modify',
|
||
|
|
templateUrl: './user-management-modify.component.html',
|
||
|
|
styleUrls: ['./user-management-modify.component.scss','../../../main.scss']
|
||
|
|
})
|
||
|
|
export class UserManagementModifyComponent implements OnInit {
|
||
|
|
validateForm: FormGroup;
|
||
|
|
|
||
|
|
constructor(
|
||
|
|
private fb: FormBuilder
|
||
|
|
) { }
|
||
|
|
|
||
|
|
ngOnInit() {
|
||
|
|
this.validateForm = this.fb.group({
|
||
|
|
real_name:[ null, [ Validators.required ] ],
|
||
|
|
loginId:[ null, [ Validators.required ] ],
|
||
|
|
password:[ null, [ Validators.required ] ],
|
||
|
|
identify_num:[ null],
|
||
|
|
email:[ null],
|
||
|
|
mobile:[ null],
|
||
|
|
});
|
||
|
|
}
|
||
|
|
submitForm(): void {
|
||
|
|
for (const i in this.validateForm.controls) {
|
||
|
|
this.validateForm.controls[ i ].markAsDirty();
|
||
|
|
this.validateForm.controls[ i ].updateValueAndValidity();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
updateConfirmValidator(): void {
|
||
|
|
/** wait for refresh value */
|
||
|
|
Promise.resolve().then(() => this.validateForm.controls.checkPassword.updateValueAndValidity());
|
||
|
|
}
|
||
|
|
|
||
|
|
confirmationValidator = (control: FormControl): { [ s: string ]: boolean } => {
|
||
|
|
if (!control.value) {
|
||
|
|
return { required: true };
|
||
|
|
} else if (control.value !== this.validateForm.controls.password.value) {
|
||
|
|
return { confirm: true, error: true };
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
}
|