From 4e4cae085739fd5e72e047d368351bfd6ceaf4e3 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Sun, 25 Mar 2018 12:20:40 +0800
Subject: [PATCH] grid 冻结列 上下滚动实现

---
 src/app/routes/analysis/query/query.component.ts |   54 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/src/app/routes/analysis/query/query.component.ts b/src/app/routes/analysis/query/query.component.ts
index 3d63222..fca727c 100644
--- a/src/app/routes/analysis/query/query.component.ts
+++ b/src/app/routes/analysis/query/query.component.ts
@@ -33,12 +33,12 @@
         e16: 6
     };
     public tableWidth = 2800;
-    private tableWidthOption = {
-        'MONTH': 1400,
-        'DAY': 2800,
-        'HOUR': 2100,
-        'MINUTE': 5000
-    };
+    // private tableWidthOption = {
+    //     'MONTH': 1400,
+    //     'DAY': 2800,
+    //     'HOUR': 2100,
+    //     'MINUTE': 5000
+    // };
     public expandForm: boolean; // ��������� ������������
     // public sensors: any[] = [];
     public sensorOptions: any[] = [];    
@@ -64,7 +64,8 @@
     public  grid: Grid<{sensor: Sensor, data: string [], weight?: number}> = new Grid();
     // public grid.data: {sensor: Sensor, data: string [], weight?: number} [] = [];
     //  ������������������������������������������
-    public sensorNameScrollLeft = '0px';
+    public sensorNameScrollLeft = 0;
+    public sensorNameScrollTop = 0;
      @ViewChild(NzTreeComponent)  private tree: NzTreeComponent;
      private _timeType: {showTime: boolean|{[key: string]: Function|boolean}, mode:  'month' | 'day', dateFormat: string  } = {showTime: false, mode: 'day', dateFormat: 'YYYY���MM���DD���'};
      // ���key-value������,������������������
@@ -262,6 +263,7 @@
               // ������ ������������������
              if (this._monitorPoint !== value) {
                 this._monitorPoint = value; // ���������������������������������������������������������
+                this._device = null; // ���������������
                 this.devicesChange();
              }
              // ������null ������������������������������
@@ -381,14 +383,12 @@
             return ;
         }
        this.grid.loading = true;
-       this.sensorNameScrollLeft = '0px';
+       this.sensorNameScrollLeft = 0;
        this.grid.data = [];
        const start: Date = this.getPeriodDate(this.actualTime , 'start');
        const end: Date = this.getPeriodDate(this.actualTime , 'end');
        this.dataCondition['actualTime'] = null;
        this.dataCondition['timeUnits'] = this.timeUnit.value;
-       // ���������������������������������
-       this.tableWidth = this.tableWidthOption[this.timeUnit.value];
        // ���������������
        const mptValue: number = !!this._monitorPoint ? this._monitorPoint.id : null;
        const devValue: number = !!this._device ? this._device.id : null;
@@ -445,8 +445,14 @@
                 return {text: item};
             }
           ); break;
-      }      
+      }   
+        // ���������������������������������
+        this.tableWidth =  this.grid.columns.length * 80 + 160;   
       this.reloadChart();
+      // ������������������
+      this.reloadChartTitle();
+      // ������������
+      this.grid.data = [];
       this.http.post(environment.SERVER_BASH_URL + '/report/line-chart', lineChartCriteria).subscribe(
         (res: ResultBean<{[key: string]: Array<Array<PairData>>}>) => {
            if (res.code === 1) {
@@ -469,7 +475,8 @@
                                     // pair.value ���null,������������
                                     weight = !!pair.value ? weight : weight + 1;
                                 }
-                                return !!pair.value ? String(Math.round(pair.value)) : '-';
+                                // ���������������������2���
+                                return !!pair.value ? String(Math.round(pair.value * 100) / 100) : '-';
                            }
                        );
                        this.grid.data.push({sensor: sensor, data: sensorData, weight: weight});
@@ -484,7 +491,8 @@
       );
         $('.ant-table-body').scroll(
             () => {
-                this.sensorNameScrollLeft =  $('.ant-table-body').scrollLeft() + 'px';
+                this.sensorNameScrollLeft =  $('.ant-table-body').scrollLeft();
+                this.sensorNameScrollTop =   -$('.ant-table-body').scrollTop();
             }
         );
     }
@@ -550,7 +558,9 @@
     public get sensorUnit() {
         return this.grid.data[this.chartSelectedIndex].sensor.unit;
     }
-    public get chartTitle(): string {
+    // ������������������ ������������
+    public _chartTitleTemp = '';
+    public reloadChartTitle(): void {
         const names = ['������', '������', '������', '������'];
         switch ( this.dataCondition.areaRange ) {
             case AreaRange.MONITORPOINT :
@@ -568,16 +578,20 @@
         if ( this.grid.data.length > this.chartSelectedIndex) {
             names[3] = this.grid.data[this.chartSelectedIndex].sensor.name;
         }        
-        return names.join('  ') + '  ������';
+        const title = names.join('  ') + '  ������';
+        if (title.trim() !== this._chartTitleTemp.trim()) {
+             this._chartTitleTemp = title;
+        }
     }
     public switchSensor(index: number): void {
         this.chartSelectedIndex = index;
         this.chartLoading = true; 
+          this.reloadChartTitle();      
         setTimeout(() => {
             const series = [{type: 'line', data: this.grid.data[index].data}];
             this.echartsIntance.setOption({
                 title: {
-                        text: this.chartTitle
+                        text: this._chartTitleTemp
                 },
                 yAxis : [
                     {
@@ -619,7 +633,13 @@
         }
         return mo.toDate();
     }
-
+    public sensorTableFocusIndex = -1;
+    public sensorTableFocus(index) {
+        this.sensorTableFocusIndex = index;
+    }
+    public sensorTableBlur(index) {
+        this.sensorTableFocusIndex = -1;
+    }
 }
 
 

--
Gitblit v1.8.0