From 8ab24e9123c8b1cee08ba905aced0bd314c5bcd8 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Tue, 27 Mar 2018 12:02:21 +0800 Subject: [PATCH] 去除监控项目 请选择标题 --- src/app/routes/reports/query/query.component.ts | 78 ++++++++++++++++++++++++++++++++------- 1 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/app/routes/reports/query/query.component.ts b/src/app/routes/reports/query/query.component.ts index b113d75..b878e2c 100644 --- a/src/app/routes/reports/query/query.component.ts +++ b/src/app/routes/reports/query/query.component.ts @@ -16,6 +16,7 @@ import * as $ from 'jquery'; import { DateService } from '@business/services/util/date.service'; import { zip } from 'rxjs/observable/zip'; +import { Subject } from 'rxjs/Subject'; @Component({ selector: 'app-query', @@ -48,10 +49,10 @@ * @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]; // ��������������������������������������� @@ -165,6 +166,46 @@ ) { } ngOnInit() { this.initPage(); + // ������������ tree click ������ + this.treeClickStream.debounceTime(1).subscribe( event => { + const data = event.node.data; + // console.log(data); + if (data.id === -1) { + const children = data.children; + // ������������ + if (!data.halfChecked && data.checked) { + // ��������������� + data['checked'] = false; + data['halfChecked'] = false; + children.forEach(element => { + element['checked'] = false; + }); + this._sensors = {}; + // ������ ������ ������������ + }else { + // ������������ + children.forEach(element => { + element['checked'] = true; + this._sensors [element.id] = element.sensorKey; + }); + data['checked'] = true; + data['halfChecked'] = false; + } + }else { + const parentData = event.node.parent.data; + data['checked'] = !data['checked']; + if (data['checked']) { + this._sensors [data.id] = data.sensorKey; + } else { + delete this._sensors [data.id]; + } + const length = Object.keys(this._sensors).length; + parentData['halfChecked'] = length > 0 + && this.sensorOptions[0].children.length > length; + parentData['checked'] = !parentData['halfChecked'] && length !== 0; + } + this.reloadSensorNames(); + }); } private initPage() { this.sensorsService.getPagingList(null, null).subscribe( @@ -292,6 +333,10 @@ * @type {string} * @memberof QueryComponent */ + private treeClickStream: Subject<any> = new Subject<any>(); + public onTreeClickSelect(event): void { + this.treeClickStream.next(event); + } public onSensorSelect(event): void { const data = event.node.data; if (data.id === -1 && data.halfChecked === false) { @@ -311,17 +356,22 @@ delete this._sensors[data.id]; } } - 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 + ','; + this.reloadSensorNames(); + } + private reloadSensorNames(): void { + // ������������������������ + 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) { -- Gitblit v1.8.0