| | |
| | | * @memberof QueryComponent |
| | | */ |
| | | public timeUnitOptions = [ |
| | | {label: '某年', value: TimeUnits.MONTH}, |
| | | {label: '某月', value: TimeUnits.DAY}, |
| | | {label: '某日', value: TimeUnits.HOUR}, |
| | | {label: '某时', value: TimeUnits.MINUTE}, |
| | | {label: '年', value: TimeUnits.MONTH}, |
| | | {label: '月', value: TimeUnits.DAY}, |
| | | {label: '日', value: TimeUnits.HOUR}, |
| | | {label: '时', value: TimeUnits.MINUTE}, |
| | | ]; |
| | | public timeUnit: {label: string, value: TimeUnits} = this.timeUnitOptions[2]; |
| | | // 默认时间为昨天,今天无数据 |
| | |
| | | // 监测项目 tree click 事件 |
| | | this.treeClickStream.debounceTime(1).subscribe( event => { |
| | | const data = event.node.data; |
| | | console.log(data); |
| | | // console.log(data); |
| | | if (data.id === -1) { |
| | | const children = data.children; |
| | | // 全选状态 |
| | |
| | | this.reloadSensorNames(); |
| | | } |
| | | private reloadSensorNames(): void { |
| | | this._sensorNames = ''; |
| | | this.sensorOptions[0].children.forEach( |
| | | sensor => { |
| | | const hasSensor = Object.keys(this._sensors).some( |
| | | id => Number(id) === Number(sensor.id) |
| | | ); |
| | | if (hasSensor) { |
| | | this._sensorNames += sensor.name + ','; |
| | | // 异步提升展现速度 |
| | | setTimeout(() => { |
| | | this._sensorNames = ''; |
| | | const sensorNameList = Object.keys(this._sensors).map( |
| | | id => { |
| | | const sensor = this.sensorOptions[0].children.find(item => { |
| | | return Number(id) === Number(item.id) ; |
| | | }); |
| | | return sensor.name; |
| | | } |
| | | } |
| | | ); |
| | | ); |
| | | this._sensorNames = sensorNameList.join(', '); |
| | | }, 1); |
| | | } |
| | | public setTimeUnit(val: {label: string, value: TimeUnits} ) { |
| | | switch (val.value) { |
| | |
| | | this.reloadChartTitle(); |
| | | // 清空数据 |
| | | this.grid.data = []; |
| | | console.log(lineChartCriteria); |
| | | this.http.post(environment.SERVER_BASH_URL + '/report/line-chart', lineChartCriteria).subscribe( |
| | | (res: ResultBean<{[key: string]: Array<Array<number>>}>) => { |
| | | if (res.code === 1) { |
| | |
| | | weight = !!value ? weight : weight + 1; |
| | | } |
| | | // 四舍五入,保留2位 |
| | | return !!value ? String(Math.round(value * 100) / 100) : '-'; |
| | | return value != null ? String(Math.round(value * 100) / 100) : '-'; |
| | | } |
| | | ); |
| | | this.grid.data.push({sensor: sensor, data: sensorData, weight: weight}); |
| | |
| | | public sensorTableFocus(index) { |
| | | this.sensorTableFocusIndex = index; |
| | | } |
| | | |
| | | public sensorTableBlur(index) { |
| | | this.sensorTableFocusIndex = -1; |
| | | } |
| | | public sensorSelectVisible = false; |
| | | public treeMouseOverOccur = false; |
| | | public onTreeMouseOver(event) { |
| | | this.treeMouseOverOccur = true; |
| | | } |
| | | public onTreeMouseOut(event) { |
| | | this.treeMouseOverOccur = false; |
| | | setTimeout(() => { |
| | | if (!this.treeMouseOverOccur) { |
| | | this.sensorSelectVisible = false; |
| | | } |
| | | }, 900); |
| | | } |
| | | } |
| | | |
| | | |