You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
884 B
44 lines
884 B
// 组件通用配置
|
|
import {AbstractControl, FormGroup, ValidatorFn} from '@angular/forms';
|
|
|
|
export abstract class Commons {
|
|
// 页面高度=屏幕的高度/2
|
|
height = 'height:' + screen.height / 2 + 'px';
|
|
|
|
|
|
/**
|
|
* 表单组
|
|
*/
|
|
abstract form(): FormGroup;
|
|
|
|
/**
|
|
* 获取单个表单控件
|
|
* @param key formControlName
|
|
*/
|
|
getValue(key) {
|
|
return this.form().get(key);
|
|
}
|
|
|
|
/**
|
|
* 检查确认密码
|
|
*/
|
|
checkPwd(): ValidatorFn {
|
|
return (control: AbstractControl): {} => {
|
|
|
|
const check = {
|
|
required: true,
|
|
pwd: true
|
|
};
|
|
if (this.form()) {
|
|
check.required = control.value.length === 0;
|
|
check.pwd = !check.required && control.value !== this.getValue('password').value;
|
|
}
|
|
|
|
if (check.required || check.pwd) {
|
|
return check;
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|