|  |  | 
 |  |  |   styles: [] | 
 |  |  | }) | 
 |  |  | export class DeviceEditComponent implements OnInit { | 
 |  |  |   public monitorPoints:any [] = []; | 
 |  |  |   public deviceVersions:any [] = []; | 
 |  |  |   public operateUsers:any [] = []; | 
 |  |  |   public monitorPoints: any [] = []; | 
 |  |  |   public deviceVersions: any [] = []; | 
 |  |  |   public operateUsers: any [] = []; | 
 |  |  |   public isSaving = false; | 
 |  |  |   constructor( | 
 |  |  |     private subject: NzModalSubject, | 
 |  |  |     private formBuilder: FormBuilder, | 
 |  |  |     private monitorPointService:MonitorPointService, | 
 |  |  |     private versionService:VersionService, | 
 |  |  |     private operateUserService:OperateUserService | 
 |  |  |     private monitorPointService: MonitorPointService, | 
 |  |  |     private versionService: VersionService, | 
 |  |  |     private operateUserService: OperateUserService | 
 |  |  |   ) { } | 
 |  |  |   data:Device; | 
 |  |  |   validateForm:FormGroup; | 
 |  |  |   data: Device; | 
 |  |  |   validateForm: FormGroup; | 
 |  |  |   ngOnInit() { | 
 |  |  |     const data = this.data; | 
 |  |  |     this.monitorPointChange(null); | 
 |  |  | 
 |  |  |     if (this.data.createTime == null) { | 
 |  |  |         this.data.createTime = new Date().getTime(); | 
 |  |  |     } | 
 |  |  |     const validates:Device = { | 
 |  |  |          name:[data.name,[Validators.required]], | 
 |  |  |          mac:[data.mac,[Validators.required]], | 
 |  |  |          deviceVersionId:[data.deviceVersionId], | 
 |  |  |          monitorPointId:[data.monitorPointId], | 
 |  |  |          operateUserId:[data.operateUserId], | 
 |  |  |          address:[data.address], | 
 |  |  |          id:[data.id], | 
 |  |  |          longitude:[data.longitude], | 
 |  |  |          latitude:[data.latitude], | 
 |  |  |          createTime:[data.createTime], | 
 |  |  |          installTime:[data.installTime] | 
 |  |  |     const validates: Device = { | 
 |  |  |          name: [data.name, [Validators.required]], | 
 |  |  |          mac: [data.mac, [Validators.required]], | 
 |  |  |          deviceVersionId: [data.deviceVersionId], | 
 |  |  |          monitorPointId: [data.monitorPointId], | 
 |  |  |          operateUserId: [data.operateUserId], | 
 |  |  |          address: [data.address], | 
 |  |  |          id: [data.id], | 
 |  |  |          longitude: [data.longitude], | 
 |  |  |          latitude: [data.latitude], | 
 |  |  |          createTime: [data.createTime], | 
 |  |  |          installTime: [data.installTime] | 
 |  |  |     }; | 
 |  |  |     this.validateForm = this.formBuilder.group( | 
 |  |  |       validates | 
 |  |  |     ); | 
 |  |  |   } | 
 |  |  |   close(){ | 
 |  |  |   close() { | 
 |  |  |      this.subject.destroy(); | 
 |  |  |    } | 
 |  |  |    save($event, value, valid){ | 
 |  |  |    save($event, value, valid) { | 
 |  |  |     $event.preventDefault(); | 
 |  |  |     if(valid){ | 
 |  |  |     if (valid) { | 
 |  |  |       this.isSaving = true; | 
 |  |  |       this.data = value; | 
 |  |  |       this.subject.next( this ); | 
 |  |  |     }else{ | 
 |  |  |     } else { | 
 |  |  |         ToolsService.markAsDirty(this.validateForm); | 
 |  |  |     } | 
 |  |  |    } | 
 |  |  |    monitorPointChange(text){ | 
 |  |  |    monitorPointChange(text) { | 
 |  |  |     const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; | 
 |  |  |     this.monitorPointService.getPagingList(pageBean, text).subscribe( | 
 |  |  |       (res: PageBean) => { | 
 |  |  | 
 |  |  |                       return item.id === monitorPoint.id; | 
 |  |  |                    } | 
 |  |  |                ); | 
 |  |  |                if ( hasSelectedValue ) { | 
 |  |  |                if ( !hasSelectedValue ) { | 
 |  |  |                   this.monitorPoints.push(monitorPoint); | 
 |  |  |                } | 
 |  |  |            } | 
 |  |  |       } | 
 |  |  |    ); | 
 |  |  |    } | 
 |  |  |    deviceVersionChange(text){ | 
 |  |  |    deviceVersionChange(text) { | 
 |  |  |     const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; | 
 |  |  |     this.versionService.getPagingList(pageBean, text).subscribe( | 
 |  |  |       (res: PageBean) => { | 
 |  |  | 
 |  |  |                       return item.id === deviceVersion.id; | 
 |  |  |                    } | 
 |  |  |                ); | 
 |  |  |                if ( hasSelectedValue ) { | 
 |  |  |                   this.monitorPoints.push(deviceVersion); | 
 |  |  |                if ( !hasSelectedValue ) { | 
 |  |  |                   this.deviceVersions.push(deviceVersion); | 
 |  |  |                } | 
 |  |  |            } | 
 |  |  |       } | 
 |  |  |    ); | 
 |  |  |    } | 
 |  |  |    operateUserChange(text){ | 
 |  |  |    operateUserChange(text) { | 
 |  |  |     const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; | 
 |  |  |     this.operateUserService.getPagingList(pageBean, text).subscribe( | 
 |  |  |       (res: PageBean) => { | 
 |  |  | 
 |  |  |                       return item.id === operateUser.id; | 
 |  |  |                    } | 
 |  |  |                ); | 
 |  |  |                if ( hasSelectedValue ) { | 
 |  |  |                   this.monitorPoints.push(operateUser); | 
 |  |  |                if ( !hasSelectedValue ) { | 
 |  |  |                   this.operateUsers.push(operateUser); | 
 |  |  |                } | 
 |  |  |            } | 
 |  |  |       } |