import { Component, OnInit } from '@angular/core';
|
import { _HttpClient } from '@delon/theme';
|
import { NzModalSubject } from 'ng-zorro-antd';
|
import { FormGroup } from '@angular/forms';
|
|
@Component({
|
selector: 'app-sensor-unit',
|
templateUrl: './sensor-unit.component.html',
|
})
|
export class SensorUnitComponent implements OnInit {
|
public isSaving = false;
|
public validateForm: FormGroup;
|
public data: any;
|
constructor(
|
private subject: NzModalSubject,
|
private http: _HttpClient
|
) { }
|
|
ngOnInit() {
|
}
|
save($event, value, valid) {
|
$event.preventDefault();
|
if (valid) {
|
for (const i in this.validateForm.controls) {
|
this.validateForm.controls[ i ].disable();
|
}
|
this.isSaving = true;
|
Object.keys(value).forEach( (key: string) => {
|
// '_'为前缀的为自定义属性
|
if (!key.startsWith('_') && value[key] != null) {
|
this.data[key] = value[key];
|
}
|
} );
|
} else {
|
this.validate();
|
}
|
}
|
validate() {
|
for (const i in this.validateForm.controls) {
|
this.validateForm.controls[ i ].markAsDirty();
|
}
|
}
|
}
|