| | |
| | | styles: [] |
| | | }) |
| | | export class AdjustConfigComponent implements OnInit { |
| | | record:Device; |
| | | _dataValue:{[s:string]:number} = {}; |
| | | data:DeviceAdjustValue; |
| | | record: Device; |
| | | _dataValue: {[s: string]: number} = {}; |
| | | data: DeviceAdjustValue; |
| | | deviceVersionId: number; |
| | | isSaving = false; |
| | | grid: Grid<Sensor> = new Grid(null); |
| | |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | private sensorsService: SensorsService, |
| | | private adjustValueService:DeviceAdjustValueService, |
| | | private adjustValueService: DeviceAdjustValueService, |
| | | public msgSrv: NzMessageService, |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | if(this.record.deviceVersionId==null){ |
| | | if (this.record.deviceVersionId == null) { |
| | | swal(`请先选择设备型号`, '设备校准值到传感器类型由所属设备型号决定', 'info'); |
| | | this.subject.destroy(); |
| | | } |
| | |
| | | this.adjustValueService.getByDid(this.record.id), |
| | | this.sensorsService.getPageByVersionId(this.record.deviceVersionId) |
| | | ).subscribe( |
| | | ([adjustRes,sensorsRes]) => { |
| | | if(adjustRes!=null && adjustRes.code==1 && sensorsRes != null && sensorsRes.data != null){ |
| | | ([adjustRes, sensorsRes]) => { |
| | | if (adjustRes != null && adjustRes.code === 1 && sensorsRes != null && sensorsRes.data != null) { |
| | | this.data = { |
| | | deviceId:this.record.id, |
| | | value:{} |
| | | deviceId: this.record.id, |
| | | value: {} |
| | | }; |
| | | if(adjustRes.data!=null){ |
| | | if (adjustRes.data != null) { |
| | | // 存储修改前到值 |
| | | Object.assign(this._dataValue,adjustRes.data.value); |
| | | this.data['id'] =adjustRes.data.id; |
| | | Object.assign(this._dataValue, adjustRes.data.value); |
| | | this.data['id'] = adjustRes.data.id; |
| | | } |
| | | this.grid.initData(sensorsRes); |
| | | sensorsRes.data.forEach( |
| | | (item:Sensor) => { |
| | | this.data.value[item.sensorKey] = this._dataValue[item.sensorKey] == null?0:this._dataValue[item.sensorKey]; |
| | | (item: Sensor) => { |
| | | this.data.value[item.sensorKey] = this._dataValue[item.sensorKey] == null ? 0 : this._dataValue[item.sensorKey]; |
| | | } |
| | | ); |
| | | this.grid.refreshStatus(); |
| | |
| | | } |
| | | save($event) { |
| | | // $event.preventDefault(); |
| | | let isModify = Object.keys(this._dataValue).length != Object.keys(this.data.value).length; |
| | | if(!isModify){ |
| | | let isModify = Object.keys(this._dataValue).length !== Object.keys(this.data.value).length; |
| | | if (!isModify) { |
| | | isModify = Object.keys(this.data.value).some( |
| | | key => { |
| | | return this.data.value[key] !== this._dataValue[key]; |
| | | } |
| | | ); |
| | | } |
| | | debugger; |
| | | if(isModify){ |
| | | if (isModify) { |
| | | this.adjustValueService.save(this.data).subscribe( |
| | | (res:ResultBean<any>) =>{ |
| | | if(res!=null&&res.code==1){ |
| | | (res: ResultBean<any>) => { |
| | | if (res != null && res.code === 1) { |
| | | this.subject.destroy(); |
| | | this.msgSrv.success('校准值配置成功'); |
| | | } |
| | | } |
| | | ); |
| | | }else{ |
| | | } else { |
| | | this.subject.destroy(); |
| | | this.msgSrv.success('校准值配置未改变'); |
| | | } |