| | |
| | | }) |
| | | |
| | | export class DemoComponent implements OnInit { |
| | | constructor( |
| | | public http: HttpClient, |
| | | public dateSrv: DateService, |
| | | public router: Router, |
| | | public msgSrv: NzMessageService |
| | | ) { |
| | | this.query.timeType = this.typeOptions[1]; |
| | | this.time.format = this.query.timeType.format.toUpperCase(); |
| | | this.query.reportType = this.reportOptions[1].value; |
| | | } |
| | | [x: string]: any; |
| | | public query: any = {}; |
| | | public sensorOptions = []; |
| | |
| | | {value: 'line', label: '折线图'} |
| | | ]; |
| | | public monitorPointOptions = []; |
| | | public time: any = {}; |
| | | public items = [{ |
| | | id: 0, |
| | | monitorPoint: null, |
| | | monitorPointName: '', |
| | | monitorPointAddress: '', |
| | | mac: '', |
| | | deviceName: '', |
| | | device: null, |
| | | time: null, |
| | | deviceOptions: [] |
| | | }]; |
| | | |
| | | constructor( |
| | | public http: HttpClient, |
| | | public dateSrv: DateService, |
| | | public router: Router, |
| | | public msgSrv: NzMessageService |
| | | ) { |
| | | this.timeType = this.typeOptions[1]; |
| | | this.query.reportType = this.reportOptions[1].value; |
| | | } |
| | | |
| | | ngOnInit() { |
| | | this.http.get(environment.SERVER_BASH_URL + 'sensor/all').subscribe((res: any) => { |
| | |
| | | }); |
| | | } |
| | | |
| | | typeChange(searchText) { |
| | | this.typeOptions.forEach(types => { |
| | | if (types === searchText) { |
| | | this.time.format = types.format.toUpperCase(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | addItem() { |
| | | const id = (this.items.length > 0) ? this.items[this.items.length - 1].id + 1 : 0; |
| | | const index = this.items.push({ |
| | | id: id, |
| | | monitorPoint: null, |
| | | monitorPointName: '', |
| | | monitorPointAddress: '', |
| | | mac: '', |
| | | deviceName: '', |
| | | device: null, |
| | | time: null, |
| | | deviceOptions: [] |
| | | }); |
| | |
| | | |
| | | monitorPointChange(value, i) { |
| | | this.items[i].deviceOptions = []; |
| | | this.items[i].device = null; |
| | | if (value) { |
| | | this.monitorPointOptions.forEach(monitorPoint => { |
| | | if (monitorPoint.id === value) { |
| | | this.items[i].monitorPointName = monitorPoint.name; |
| | | this.items[i].monitorPointAddress = monitorPoint.address; |
| | | } |
| | | }); |
| | | this.http.get(environment.SERVER_BASH_URL + 'device/monitorPointId', {params: {monitorPointId: value}}).subscribe((res: any) => { |
| | | this.http.get(environment.SERVER_BASH_URL + 'device/monitorPointId', {params: {monitorPointId: value.id}}).subscribe((res: any) => { |
| | | if (res.code === 0) { |
| | | this.msgSrv.error(res.message); |
| | | } else { |
| | | this.items[i].deviceOptions = res.data; |
| | | this.items[i].mac = null; |
| | | } |
| | | }); |
| | | } else { |
| | | this.items[i].monitorPoint = null; |
| | | this.items[i].mac = null; |
| | | this.items[i].monitorPointName = ''; |
| | | this.items[i].monitorPointAddress = ''; |
| | | } |
| | | } |
| | | |
| | | deviceChange(value, i) { |
| | | if (value) { |
| | | this.items[i].deviceOptions.forEach(device => { |
| | | if (device.mac === value) { |
| | | this.items[i].deviceName = device.name; |
| | | } |
| | | }); |
| | | } else { |
| | | this.items[i].deviceName = ''; |
| | | } |
| | | } |
| | | |
| | |
| | | let item = this.items[i]; |
| | | let queryItem: any = {}; |
| | | if (item.monitorPoint && item.time) { |
| | | queryItem.formatTime = this.dateSrv.date_format(item.time, this.time.format); |
| | | for (var key in item) { |
| | | if (item[key]) { |
| | | queryItem[key] = item[key]; |
| | | } |
| | | } |
| | | queryItem.monitorPointId = queryItem.monitorPoint.id; |
| | | queryItem.monitorPointName = queryItem.monitorPoint.name; |
| | | queryItem.monitorPointAddress = queryItem.monitorPoint.address; |
| | | delete queryItem.monitorPoint; |
| | | if (queryItem.device) { |
| | | queryItem.mac = queryItem.device.mac; |
| | | queryItem.deviceName = queryItem.device.name; |
| | | delete queryItem.device; |
| | | } |
| | | queryItem.deviceCount = queryItem.deviceOptions.length; |
| | | delete queryItem.deviceOptions; |
| | | queryItem.formatTime = this.dateSrv.date_format(queryItem.time, this.timeType.format.toUpperCase()); |
| | | delete queryItem.time; |
| | | queryItems.push(queryItem); |
| | | } else { |
| | |
| | | break; |
| | | } |
| | | } |
| | | if (validate && query.timeType && query.reportType) { |
| | | if (validate && this.timeType && query.reportType) { |
| | | query.sensors = null; |
| | | if (query.sensorKey && query.sensorKey.length > 0) { |
| | | const sensors = []; |
| | |
| | | query.sensors = JSON.stringify(sensors); |
| | | } |
| | | query.items = JSON.stringify(queryItems); |
| | | query.timeTypes = JSON.stringify(query.timeType); |
| | | query.timeType = JSON.stringify(this.timeType); |
| | | this.router.navigate(['report'], {queryParams: query}); |
| | | } else { |
| | | this.msgSrv.error('请完善搜索项或删除查询条目'); |
| | | } |
| | | |
| | | } |
| | | } |