Browse Source

[完善]新增单位名称不允许出现空格

非煤矿山灾害智能感知和预警系统
邵佳豪 2 years ago
parent
commit
f2782a1fcc
  1. 5
      src/app/home/basic-info/add-unit/add-unit.component.html
  2. 4
      src/app/home/basic-info/add-unit/add-unit.component.scss
  3. 6
      src/app/home/basic-info/add-unit/add-unit.component.ts
  4. 2
      src/app/home/basic-info/unit-details/unit-details.component.ts

5
src/app/home/basic-info/add-unit/add-unit.component.html

@ -4,8 +4,11 @@
<nz-form-label [nzSm]="7" [nzXs]="24" nzRequired nzFor="单位名称">单位名称</nz-form-label> <nz-form-label [nzSm]="7" [nzXs]="24" nzRequired nzFor="单位名称">单位名称</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-input-group> <nz-input-group>
<input nz-input type="text" formControlName="unitname" placeholder="请输入单位名称" /> <input nz-input type="text" formControlName="unitname" placeholder="请输入单位名称" (ngModelChange)="xxx()"/>
</nz-input-group> </nz-input-group>
<div class="error-message"
*ngIf="validateForm.controls['unitname'].invalid && !validateForm.controls['unitname'].errors.required">
(单位名称不能使用空格)</div>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>

4
src/app/home/basic-info/add-unit/add-unit.component.scss

@ -0,0 +1,4 @@
.error-message{
color: red;
font-size: 14px;
}

6
src/app/home/basic-info/add-unit/add-unit.component.ts

@ -17,7 +17,7 @@ export class AddUnitComponent implements OnInit {
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { } constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
ngOnInit(): void { ngOnInit(): void {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
unitname: [null, [Validators.required]], unitname: [null, [Validators.required, Validators.pattern("[^\\s\\r\\n]{1,100}")]],
person: [null], person: [null],
phone: [null], phone: [null],
addr: [null], addr: [null],
@ -31,5 +31,7 @@ export class AddUnitComponent implements OnInit {
this.modal.destroy({ data: 'this the result data' }); this.modal.destroy({ data: 'this the result data' });
} }
xxx(){
console.log(this.validateForm.controls['unitname'])
}
} }

2
src/app/home/basic-info/unit-details/unit-details.component.ts

@ -1483,7 +1483,6 @@ export class UnitDetailsComponent implements OnInit {
getAllOrganization() { getAllOrganization() {
let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId
let params = { let params = {
// OrganizationId: organizationId || '',
ContainsChildren: "true", ContainsChildren: "true",
PageNumber: 1, PageNumber: 1,
PageSize: 9999 PageSize: 9999
@ -1491,6 +1490,7 @@ export class UnitDetailsComponent implements OnInit {
this.http.get('/api/Organizations', { this.http.get('/api/Organizations', {
params: params params: params
}).subscribe((data: any) => { }).subscribe((data: any) => {
console.log('组织机构', data.items)
data.items.forEach(element => { data.items.forEach(element => {
if (element.id == organizationId) { if (element.id == organizationId) {
element.parentId = null element.parentId = null

Loading…
Cancel
Save