Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {
AbstractControl,
FormBuilder,
FormControl,
FormGroup,
Validators
} from '@angular/forms';
import {SystemService} from '../../system.service';
import {NzMessageService} from 'ng-zorro-antd';
@Component({
selector: 'smart-role',
templateUrl: './role.component.html',
styles: []
})
export class RoleComponent implements OnInit {
@Output() add = new EventEmitter<any>();
title = '新增角色';
isVisible = false;
validateForm: FormGroup;
constructor(private fb: FormBuilder, private message: NzMessageService,
private systemSer: SystemService) {
}
ngOnInit() {
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
status: [null, [Validators.required]],
comments: [null, [Validators.required]],
});
}
showModal(): void {
this.isVisible = true;
}
handleCancel(): void {
this.isVisible = false;
}
handleOk(): void {
for (const i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
this.systemSer.addRole(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.add.emit();
this.message.info('新增成功');
}
}
);
}
}