From ba6f868ccc79328594f42d85ea34ca254e5d51d8 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Sat, 24 Mar 2018 23:05:43 +0800
Subject: [PATCH] grid 冻结 功能 延迟bug修复

---
 src/app/routes/analysis/query/query.component.ts |   46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/src/app/routes/analysis/query/query.component.ts b/src/app/routes/analysis/query/query.component.ts
index 3f41f21..ec9e65e 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,7 @@
     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;
      @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������,������������������
@@ -79,6 +79,7 @@
      public toggleChartCollapse() {
           // ���������������
          if (this.isChartCollapse && !!this.echartsIntance) {
+            this.reloadChart();
             this.switchSensor(this.chartSelectedIndex);
             // this.chartLoading = false;
          }        
@@ -320,8 +321,7 @@
             }
         );
     }
-    public setTimeUnit(val: {label: string, value: TimeUnits} ) {
-        this.tableWidth = this.tableWidthOption[val.value];
+    public setTimeUnit(val: {label: string, value: TimeUnits} ) {       
         switch (val.value) {
             // YYYY-MM-DD HH:mm:ss
             case TimeUnits.MONTH:
@@ -381,7 +381,7 @@
             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');
@@ -443,8 +443,12 @@
                 return {text: item};
             }
           ); break;
-      }      
+      }   
+        // ���������������������������������
+        this.tableWidth =  this.grid.columns.length * 80 + 160;   
       this.reloadChart();
+      // ������������
+      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) {
@@ -467,7 +471,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});
@@ -482,7 +487,7 @@
       );
         $('.ant-table-body').scroll(
             () => {
-                this.sensorNameScrollLeft =  $('.ant-table-body').scrollLeft() + 'px';
+                this.sensorNameScrollLeft =  $('.ant-table-body').scrollLeft();
             }
         );
     }
@@ -548,6 +553,8 @@
     public get sensorUnit() {
         return this.grid.data[this.chartSelectedIndex].sensor.unit;
     }
+    // ������������������ ������������
+    public _chartTitleTemp: string;
     public get chartTitle(): string {
         const names = ['������', '������', '������', '������'];
         switch ( this.dataCondition.areaRange ) {
@@ -563,12 +570,15 @@
             break;
         }
         names[2] = moment(this.actualTime).format(this._timeType.dateFormat);
-        names[3] = this.grid.data[this.chartSelectedIndex].sensor.name;
+        if ( this.grid.data.length > this.chartSelectedIndex) {
+            names[3] = this.grid.data[this.chartSelectedIndex].sensor.name;
+        }        
         return names.join('  ') + '  ������';
     }
     public switchSensor(index: number): void {
         this.chartSelectedIndex = index;
         this.chartLoading = true; 
+        this._chartTitleTemp = this.chartTitle;
         setTimeout(() => {
             const series = [{type: 'line', data: this.grid.data[index].data}];
             this.echartsIntance.setOption({
@@ -615,7 +625,13 @@
         }
         return mo.toDate();
     }
-
+    public sensorTableFocusIndex = -1;
+    public sensorTableFocus(index) {
+        this.sensorTableFocusIndex = index;
+    }
+    public sensorTableBlur(index) {
+        this.sensorTableFocusIndex = -1;
+    }
 }
 
 

--
Gitblit v1.8.0