From a3f48ec919bdc973dd36420678b2282f234ccd3f Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Fri, 13 Jul 2018 14:36:57 +0800
Subject: [PATCH] updates
---
src/app/routes/reports/query2/query2.component.ts | 849 +++++++++++++++++++++++++++++++++
src/app/routes/reports/query2/query2.component.html | 230 +++++++++
src/app/routes/reports/query2/query2.component.less | 414 ++++++++++++++++
3 files changed, 1,493 insertions(+), 0 deletions(-)
diff --git a/src/app/routes/reports/query2/query2.component.html b/src/app/routes/reports/query2/query2.component.html
new file mode 100644
index 0000000..150b578
--- /dev/null
+++ b/src/app/routes/reports/query2/query2.component.html
@@ -0,0 +1,230 @@
+
+<div nz-row [nzGutter]="24" style="padding-top: 25px">
+ <div nz-col nzXs="24" nzSm="24" nzMd="24" nzLg="24">
+ <nz-card [nzLoading]="loading" [nzBordered]="false" nzTitle="������������������" [nzBodyStyle]="{'padding.px': 24}" class="sales-card" style="min-height: 482px;">
+ <ng-template #extra>
+ <div class="sales-card-extra">
+ <div class="sales-type-radio">
+ <nz-radio-group [(ngModel)]="salesType" (ngModelChange)="changeSaleType()" [nzSize]="'large'">
+ <label nz-radio-button [nzValue]="'1'"><span>PM2.5</span></label>
+ <label nz-radio-button [nzValue]="'2'"><span>PM10</span></label>
+ <label nz-radio-button [nzValue]="'3'"><span>SO2</span></label>
+ <label nz-radio-button [nzValue]="'4'"><span>NO3</span></label>
+ <label nz-radio-button [nzValue]="'5'"><span>O3</span></label>
+ <label nz-radio-button [nzValue]="'6'"><span>CO</span></label>
+ </nz-radio-group>
+ </div>
+ </div>
+ </ng-template>
+ <ng-template #body>
+ <h4 class="margin:8px 0 32px 0;">������������������</h4>
+
+ <nz-table #keyTable [nzDataSource]="data.searchData" [nzPageSize]="5" nzSize="small">
+ <thead nz-thead>
+ <tr>
+ <th nz-th><span>������</span></th>
+ <th nz-th><span>������������</span></th>
+ <th nz-th class="text-right">
+ <span>������������ mg/m3</span>
+ <nz-table-sort (nzValueChange)="sort('count',$event)"></nz-table-sort>
+ </th>
+ </tr>
+ </thead>
+ <tbody nz-tbody>
+ <tr nz-tbody-tr *ngFor="let i of keyTable.data">
+ <td nz-td>{{i.index}}</td>
+ <td nz-td><a (click)="msg.success(i.point)">{{i.point}}</a></td>
+ <td nz-td class="text-right">{{i.value}}</td>
+ </tr>
+ </tbody>
+ </nz-table>
+ </ng-template>
+ </nz-card>
+ </div>
+</div>
+
+<nz-card [nzBordered]="false">
+ <form nz-form [nzLayout]="'inline'">
+ <div nz-row [nzGutter]="24">
+ <div nz-col [nzSpan]="6" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div [ngStyle]="{'width': '100px'}" nz-form-label>
+ <label>������������</label>
+ </div>
+ <div nz-form-control class="flex-1">
+ <nz-popover [nzPlacement]="'bottomLeft'" [(nzVisible)]="sensorSelectVisible" [nzTrigger]="'click'">
+ <nz-input [nzType]="'input'" nz-popover [ngModel]="sensorNames" style="cursor:pointer;"
+ name="sensorNames" [nzReadonly]="true"
+ [nzPlaceHolder]="'���������������������'">
+ <ng-template #suffix>
+ <i class="anticon anticon-down ng-star-inserted ant-cascader-picker-arrow" style="right: 1px;"></i>
+ </ng-template>
+ </nz-input>
+ <ng-template #nzTemplate>
+ <div style="position: relative; width: 240px; height: 240px;" (mouseover) = "onTreeMouseOver($event)" (mouseout) = "onTreeMouseOut($event)">
+ <div style="position: absolute; left: -16px; width: 272px; height: 256px; overflow-y :auto; top: -8px;">
+ <nz-tree [nzNodes]="sensorOptions" (nzActivate)="onTreeClickSelect($event)"
+ (nzDeactivate)="onTreeClickSelect($event)" [nzCheckable]="true" (nzCheck)="onSensorSelect($event)"></nz-tree>
+ </div>
+ </div>
+ </ng-template>
+ </nz-popover>
+ </div>
+ </div>
+ </div>
+ <div nz-col [nzSpan]="4" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div [ngStyle]="{'width': '128px'}" nz-form-label>
+ <label>������</label>
+ </div>
+ <div nz-form-control class="flex-1">
+ <nz-select name="timeUnit" [(ngModel)]="timeUnit" [nzPlaceHolder]="'������ ������������'" (ngModelChange)="setTimeUnit($event)" [nzNotFoundContent]="'������������'">
+ <nz-option *ngFor="let option of timeUnitOptions" [nzLabel]="option.label" [nzValue]="option">
+ </nz-option>
+ </nz-select>
+ </div>
+ </div>
+ </div>
+ <div nz-col [nzSpan]="7" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div [ngStyle]="{'width': '128px'}" nz-form-label>
+ <label>������������</label>
+ </div>
+ <div nz-form-control class="flex-1">
+ <nz-select name="deviceDimension" style="width: 100%;" [(ngModel)]="deviceDimension" nzAllowClear [nzPlaceHolder]="'������ '+ dimensionItem.label +'(������������������)'"
+ nzShowSearch (nzSearchChange)="dimensionsChange($event)" [nzNotFoundContent]="'������������'">
+ <nz-option *ngFor="let option of dimensionOptions" [nzLabel]="option.name" [nzValue]="option">
+ </nz-option>
+ </nz-select>
+ </div>
+ </div>
+ </div>
+ <div nz-col [nzSpan]="5" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div nz-form-label>
+ <label>������:</label>
+ </div>
+ <div *ngIf="timeUnit.value!='MONTH'; else elseBlock" nz-form-control class="flex-1">
+ <nz-datepicker [ngStyle]="{'width': '100%'}" name="actualTime" [(ngModel)]="actualTime" [nzAllowClear]="false" [nzShowTime]="_timeType.showTime"
+ [nzMode]="_timeType.mode" [nzFormat]="_timeType.dateFormat" [nzPlaceHolder]="'������������'">
+ </nz-datepicker>
+ </div>
+ <ng-template #elseBlock>
+ <div nz-form-control class="flex-1">
+ <nz-select name="actualYear" [(ngModel)]="actualYear" [nzPlaceHolder]="'������ ������������'" (ngModelChange)="setTimeUnit($event)" [nzNotFoundContent]="'������������'">
+ <nz-option *ngFor="let option of actualYearOptions" [nzLabel]="option + ' ���'" [nzValue]="option">
+ </nz-option>
+ </nz-select>
+ </div>
+ </ng-template>
+ </div>
+ </div>
+ <div nz-col [nzSpan]="2" class="mb-md">
+ <button nz-button [nzType]="'primary'" (click)="loadGrid()">
+ <i class="anticon anticon-search"></i>
+ <span>������</span>
+ </button>
+ </div>
+ </div>
+ </form>
+</nz-card>
+<nz-card>
+ <div nz-row [nzGutter]="16">
+ <div nz-col [ngStyle]="{'display':isChartCollapse ? 'none' : 'block' }" [nzMd]="24">
+ <div echarts style="margin-top: 12px;" [options]="chartOption" [loading]="chartLoading" class="line-chart" (chartInit)="onChartInit($event)"></div>
+ </div>
+ <div *ngIf="isChartCollapse" style="width:100%; text-align:center;">
+ <span style="font-size:18px; font-weight: bold;">{{ _chartTitleTemp }}</span>
+ </div>
+ <div *ngIf="!!echartsIntance&&!isChartCollapse" class="chart-switch-select">
+ <nz-dropdown>
+ <a class="ant-dropdown-link" nz-dropdown>
+ <p class="display-3 text-primary">������������
+ <i class="anticon anticon-down"></i>
+ </p>
+ </a>
+ <ul style="cursor:pointer; max-height: 260px; overflow:auto;" nz-menu>
+ <li [ngClass]="{'ant-dropdown-menu-item-selected':chartSelectedIndex==m}" *ngFor="let item of grid.data,index as m" (click)="switchSensor(m)"
+ nz-menu-item>
+ {{item.sensor.name}}
+ <i *ngIf="chartSelectedIndex==m" class="anticon anticon-check-circle-o"></i>
+ </li>
+ </ul>
+ </nz-dropdown>
+ </div>
+ <a *ngIf="!!echartsIntance" style="position: absolute; right: 0; top: -10px;" class="pl-sm" (click)="toggleChartCollapse()">
+ ������
+ <i class="anticon" [class.anticon-down]="isChartCollapse" [class.anticon-up]="!isChartCollapse"></i>
+ </a>
+ </div>
+</nz-card>
+<!--<nz-card>-->
+ <!--<div nz-row [nzGutter]="16">-->
+ <!--<div nz-col [nzMd]="24">-->
+ <!--<div style="width:100%; text-align:center;">-->
+ <!--<span style="font-size:18px; font-weight: bold;">{{ _tableTitleTemp }}</span>-->
+ <!--</div>-->
+ <!--</div>-->
+ <!--</div>-->
+ <!--<div nz-row [nzGutter]="16">-->
+ <!--<div nz-col [nzMd]="24">-->
+ <!--<nz-table #nzTable [nzScroll]="{ x:tableWidth,y:350 }" [nzDataSource]="grid.data" [nzIsPagination]="false" [nzLoading]="grid.loading">-->
+ <!--<ng-template #nzFixedHeader>-->
+ <!--<thead nz-thead>-->
+ <!--<tr>-->
+ <!--<th nz-th [nzWidth]="'160px'" [ngStyle]="{'position': 'relative', 'text-align':'center', 'left':sensorNameScrollLeft+'px'}">-->
+ <!--<span>������������</span>-->
+ <!--</th>-->
+ <!--<th nz-th [nzWidth]="'80px'" *ngFor="let col of grid.columns" [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}">-->
+ <!--<span>{{ col.text }}</span>-->
+ <!--</th>-->
+ <!--</tr>-->
+ <!--</thead>-->
+ <!--</ng-template>-->
+ <!--<tbody nz-tbody>-->
+ <!--<tr nz-tbody-tr style="cursor:pointer;" *ngFor="let row of nzTable.data,index as i" (click)="switchSensor(i)" (mouseover)="sensorTableFocus(i)"-->
+ <!--(mouseout)="sensorTableBlur(i)" [ngClass]="{'table-tr-bgcolor-focus': i === sensorTableFocusIndex,'table-tr-bgcolor-blur': i !== sensorTableFocusIndex}">-->
+ <!--<td nz-td class='sensor-name' [ngStyle]="{'background-color': '#FFF'}">-->
+ <!--<span>-->
+ <!--<span>{{ row.sensor.name+'('+row.sensor.unit+')' }}</span> -->
+ <!--<i *ngIf="chartSelectedIndex==i" class="anticon anticon-line-chart"></i>-->
+ <!--</span>-->
+ <!--</td>-->
+ <!--<td nz-td *ngFor="let col of grid.columns,index as n" [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}">-->
+ <!--<span [ngSwitch]="col.type">-->
+ <!--<!– ������������������������������������ –>-->
+ <!--<span title="{{ row.data[n]|tyepHandle:col:row }}" style="width:100%; display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;"-->
+ <!--*ngSwitchDefault> {{ row.data[n]|tyepHandle:col:row }} </span>-->
+ <!--<!– ������������������������������������ –>-->
+ <!--</span>-->
+ <!--</td>-->
+ <!--</tr>-->
+ <!--</tbody>-->
+ <!--</nz-table>-->
+ <!---->
+ <!--<div *ngIf="grid.data.length>0" [ngClass]="{'table-scroll':true,'table-scroll-box-shadow': sensorNameScrollLeft>2 }" style="position: absolute; top:0;">-->
+ <!--<nz-table #nzTable [nzDataSource]="grid.data" [nzIsPagination]="false">-->
+ <!--<thead nz-thead>-->
+ <!--<tr>-->
+ <!--<th nz-th [nzWidth]="'160px'" style="text-align:center; position:relative; display:block; z-index:9;">-->
+ <!--<span>������������</span>-->
+ <!--</th>-->
+ <!--</tr>-->
+ <!--</thead>-->
+ <!--<tbody nz-tbody [ngStyle]="{'top':sensorNameScrollTop+'px'}" style="position: relative; z-index:7; display:block;">-->
+ <!--<tr nz-tbody-tr style="cursor:pointer;" *ngFor="let row of nzTable.data,index as i" (mouseover)="sensorTableFocus(i)" (mouseout)="sensorTableBlur(i)"-->
+ <!--[ngClass]="{'table-tr-bgcolor-focus': i === sensorTableFocusIndex,'table-tr-bgcolor-blur': i !== sensorTableFocusIndex}"-->
+ <!--(click)="switchSensor(i)">-->
+ <!--<td nz-td class='sensor-name' [ngStyle]="{'width':'160px','text-align': 'center'}">-->
+ <!--<span>-->
+ <!--<span>{{ row.sensor.name+'('+row.sensor.unit+')' }}</span> -->
+ <!--<i *ngIf="chartSelectedIndex==i" class="anticon anticon-line-chart"></i>-->
+ <!--</span>-->
+ <!--</td>-->
+ <!--</tr>-->
+ <!--</tbody>-->
+ <!--</nz-table>-->
+ <!--</div>-->
+ <!--</div>-->
+ <!--</div>-->
+<!--</nz-card>-->
diff --git a/src/app/routes/reports/query2/query2.component.less b/src/app/routes/reports/query2/query2.component.less
new file mode 100644
index 0000000..35c32a4
--- /dev/null
+++ b/src/app/routes/reports/query2/query2.component.less
@@ -0,0 +1,414 @@
+@import '~@delon/theme/styles/antd/themes/default.less';
+@import '~@delon/abc/utils/utils.less';
+
+:host ::ng-deep {
+ .page-header {
+ display: flex;
+ .avatar {
+ flex: 0 1 72px;
+ margin-bottom: 8px;
+ .ant-avatar {
+ border-radius: 72px;
+ display: block;
+ width: 72px;
+ height: 72px;
+ }
+ }
+ .desc {
+ position: relative;
+ top: 4px;
+ margin-left: 24px;
+ flex: 1 1 auto;
+ color: @text-color-secondary;
+ line-height: 22px;
+ .desc-title {
+ font-size: 20px;
+ line-height: 28px;
+ font-weight: 500;
+ color: @heading-color;
+ margin-bottom: 12px;
+ }
+ }
+ }
+
+ .page-extra {
+ .clearfix();
+ float: right;
+ & > div {
+ padding: 0 32px;
+ position: relative;
+ float: left;
+ & > p:first-child {
+ color: @text-color-secondary;
+ font-size: @font-size-base;
+ line-height: 22px;
+ margin-bottom: 4px;
+ }
+ & > p {
+ color: @heading-color;
+ font-size: 30px;
+ line-height: 38px;
+ margin: 0;
+ & > span {
+ color: @text-color-secondary;
+ font-size: 20px;
+ }
+ }
+ &:after {
+ background-color: @border-color-split;
+ position: absolute;
+ top: 8px;
+ right: 0;
+ width: 1px;
+ height: 40px;
+ content: "";
+ }
+ }
+ & > div:last-child {
+ padding-right: 0;
+ &:after {
+ display: none;
+ }
+ }
+ }
+
+ .project-list {
+ .ant-card-meta-description {
+ color: @text-color-secondary;
+ height: 44px;
+ line-height: 22px;
+ overflow: hidden;
+ }
+ .card-title {
+ font-size: 0;
+ a {
+ color: @heading-color;
+ margin-left: 12px;
+ line-height: 24px;
+ height: 24px;
+ display: inline-block;
+ vertical-align: top;
+ font-size: @font-size-base;
+ &:hover {
+ color: @primary-color;
+ }
+ }
+ }
+
+ .project-grid {
+ width: 33.33%;
+ }
+
+ .project-item {
+ display: flex;
+ margin-top: 8px;
+ overflow: hidden;
+ font-size: 12px;
+ height: 20px;
+ line-height: 20px;
+ .textOverflow();
+ a {
+ color: @text-color-secondary;
+ display: inline-block;
+ flex: 1 1 0;
+ .textOverflow();
+ &:hover {
+ color: @primary-color;
+ }
+ }
+ .datetime {
+ color: @disabled-color;
+ flex: 0 0 auto;
+ float: right;
+ }
+ }
+ }
+
+ .activities {
+ padding: 0 24px 8px;
+ .username {
+ color: @text-color;
+ }
+ .event {
+ font-weight: normal;
+ }
+ }
+
+ .members {
+ a {
+ display: block;
+ margin: 12px 0;
+ line-height: 24px;
+ height: 24px;
+ .textOverflow();
+ .member {
+ font-size: @font-size-base;
+ color: @text-color;
+ line-height: 24px;
+ max-width: 100px;
+ vertical-align: top;
+ margin-left: 12px;
+ transition: all .3s;
+ display: inline-block;
+ .textOverflow();
+ }
+ &:hover {
+ span {
+ color: @primary-color;
+ }
+ }
+ }
+ }
+
+ .datetime {
+ color: @disabled-color;
+ }
+
+ .links {
+ padding: 20px 0 8px 24px;
+ font-size: 0;
+ > a {
+ color: rgba(0, 0, 0, 0.65);
+ display: inline-block;
+ font-size: 14px;
+ margin-bottom: 13px;
+ width: 25%;
+ }
+ }
+
+ @media screen and (max-width: @screen-xl) and (min-width: @screen-lg) {
+ .active-card {
+ margin-bottom: 24px;
+ }
+ .members {
+ margin-bottom: 0;
+ }
+ .page-extra {
+ margin-left: -44px;
+ & > div {
+ padding: 0 16px;
+ }
+ }
+ }
+
+ @media screen and (max-width: @screen-lg) {
+ .active-card {
+ margin-bottom: 24px;
+ }
+ .members {
+ margin-bottom: 0;
+ }
+ .page-extra {
+ float: none;
+ margin-right: 0;
+ & > div {
+ padding: 0 16px;
+ text-align: left;
+ &:after {
+ display: none;
+ }
+ }
+ }
+ }
+
+ @media screen and (max-width: @screen-md) {
+ .page-extra {
+ margin-left: -16px;
+ }
+ }
+
+ @media screen and (max-width: @screen-sm) {
+ .page-header {
+ display: block;
+ .desc {
+ margin-left: 0;
+ }
+ }
+ .page-extra {
+ & > div {
+ float: none;
+ }
+ }
+ }
+
+ @media screen and (max-width: @screen-xs) {
+ .project-list {
+ .project-grid {
+ width: 100%;
+ }
+ }
+ }
+
+
+
+ .icon-group {
+ transition: color 0.32s;
+ color: @text-color-secondary;
+ cursor: pointer;
+ margin-left: 16px;
+ &:hover {
+ color: @text-color;
+ }
+ }
+
+ .rank-list {
+ padding: 0px 32px 32px 72px;
+ ul {
+ margin-top: 25px;
+ }
+ li {
+ zoom: 1;
+ margin-top: 16px;
+ display: flex;
+ justify-content: space-between;
+ .icon {
+ background-color: #f5f5f5;
+ border-radius: 20px;
+ display: inline-block;
+ font-size: 12px;
+ font-weight: 600;
+ margin-right: 24px;
+ height: 20px;
+ line-height: 20px;
+ width: 20px;
+ text-align: center;
+ }
+ .active {
+ background-color: #314659;
+ color: #fff;
+ }
+ }
+ }
+
+ .sales-extra {
+ display: inline-block;
+ margin-right: 24px;
+ a {
+ margin-left: 24px;
+ }
+ }
+
+ .sales-card {
+ .bar {
+ padding: 0px 0px 32px 32px;
+ }
+ .rank {
+ padding: 0 32px 32px 72px;
+ }
+ .ant-tabs-tab {
+ padding-top: 16px;
+ padding-bottom: 14px;
+ line-height: 24px;
+ }
+
+ .ant-tabs-extra-content {
+ padding-right: 24px;
+ line-height: 55px;
+ }
+
+ .ant-card-head {
+ position: relative;
+ }
+ }
+
+ .sales-card-extra {
+ height: 68px;
+ }
+
+ .sales-type-radio {
+ position: absolute;
+ left: 24px;
+ bottom: 15px;
+ }
+
+ .offline-card {
+ .ant-tabs-ink-bar {
+ bottom: auto;
+ }
+ .ant-tabs-bar {
+ border-bottom: none;
+ }
+ .ant-tabs-nav-container-scrolling {
+ padding-left: 40px;
+ padding-right: 40px;
+ }
+ .ant-tabs-tab-prev-icon:before {
+ position: relative;
+ left: 6px;
+ }
+ .ant-tabs-tab-next-icon:before {
+ position: relative;
+ right: 6px;
+ }
+ }
+
+ .trend-text {
+ margin-left: 8px;
+ color: @heading-color;
+ }
+
+ @media screen and (max-width: @screen-lg) {
+ .sales-extra {
+ display: none;
+ }
+
+ .rank-list {
+ li {
+ span:first-child {
+ margin-right: 8px;
+ }
+ }
+ }
+ }
+
+ @media screen and (max-width: @screen-md) {
+ .rank-title {
+ margin-top: 16px;
+ }
+
+ .sales-card .bar {
+ padding: 16px;
+ }
+ }
+
+ @media screen and (max-width: @screen-sm) {
+ .sales-extra-wrap {
+ display: none;
+ }
+
+ .sales-card {
+ .ant-tabs-content {
+ padding-top: 30px;
+ }
+ }
+ }
+
+ .ant-table-pagination {
+ margin-bottom: 0;
+ }
+}
+
+.line-chart {
+ height: 100%;
+}
+.table-tr-bgcolor-focus {
+ background-color: #ecf6fd;
+}
+.table-tr-bgcolor-blur {
+ background-color: #fff;
+}
+.table-scroll {
+ z-index: 9;
+ height: auto;
+ max-height: 388px;
+ overflow: hidden;
+}
+.table-scroll-box-shadow {
+ -moz-box-shadow: 4px 0 2px rgba(0, 0, 0, 0.1); /* ������ Firefox */
+ box-shadow: 4px 0 2px rgba(0, 0, 0, 0.1);
+}
+.chart-switch-select {
+ position: absolute;
+ right: 8%;
+ top: 2%;
+}
diff --git a/src/app/routes/reports/query2/query2.component.ts b/src/app/routes/reports/query2/query2.component.ts
new file mode 100644
index 0000000..df0a741
--- /dev/null
+++ b/src/app/routes/reports/query2/query2.component.ts
@@ -0,0 +1,849 @@
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { _HttpClient } from '@delon/theme';
+import { Sensor, Device, DataCondition, MonitorPoint, Organization, LineChartCriteria } from '@business/entity/data';
+import { TimeUnits, AreaRange, ResultCode, DeviceDimension } from '@business/enum/types.enum';
+import { SensorsService } from '@business/services/http/sensors.service';
+import { PageBean, ResultBean, Grid } from '@business/entity/grid';
+import { NzTreeComponent } from 'ng-tree-antd';
+import * as moment from 'moment';
+import { ExampleService } from '@business/services/util/example.service';
+import { DeviceService } from '@business/services/http/device.service';
+import { CascaderOption } from 'ng-zorro-antd/src/cascader/nz-cascader.component';
+import { AreacodeService } from '@business/services/http/areacode.service';
+import { MonitorPointService } from '@business/services/http/monitor-point.service';
+import { NzMessageService } from 'ng-zorro-antd';
+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-query2',
+ templateUrl: './query2.component.html',
+ styleUrls: ['./query2.component.less']
+})
+export class Query2Component implements OnInit {
+
+ data: any = {};
+
+ // aqi������������
+ private aqiSort = {
+ e1: 1,
+ e2: 2,
+ e10: 3,
+ e11: 4,
+ e15: 5,
+ e16: 6
+ };
+
+ public tableWidth = 2800;
+ // private tableWidthOption = {
+ // 'MONTH': 1400,
+ // 'DAY': 2800,
+ // 'HOUR': 2100,
+ // 'MINUTE': 5000
+ // };
+ public expandForm: boolean; // ��������� ������������
+ // public sensors: any[] = [];
+ public sensorOptions: any[] = [];
+ /**
+ * ���������������������������������
+ * ���������������������������������������������������������������������
+ * @memberof QueryComponent
+ */
+ public timeUnitOptions = [
+ {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];
+ // ���������������������������������������
+ public actualTime: Date = moment().subtract(1, 'days').toDate();
+ public actualYearOptions: number [];
+ public isCollapse = false;
+ public isChartCollapse = false;
+ // ������������
+ public _areas: { label: string, value: string }[] = new Array();
+ public grid: Grid<{sensor: Sensor, data: string [], weight?: number}> = new Grid();
+ // public grid.data: {sensor: Sensor, data: string [], weight?: number} [] = [];
+ // ������������������������������������������
+ 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������,������������������
+ private _sensors: {[key: string]: string} = {};
+ private _sensorNames: string;
+ get sensorNames(): string {
+ return this._sensorNames;
+ }
+ public toggleCollapse() {
+ this.isCollapse = !this.isCollapse;
+ }
+ public toggleChartCollapse() {
+ // ���������������
+ if (this.isChartCollapse && !!this.echartsIntance) {
+ this.reloadChart();
+ this.switchSensor(this.chartSelectedIndex);
+ // this.chartLoading = false;
+ }
+ this.isChartCollapse = !this.isChartCollapse;
+ }
+ public deviceOptions: Device[] = [];
+ public dataCondition: DataCondition = {areaRangeId: 320583, areaRange: AreaRange.AREA, deviceDimension: DeviceDimension.NONE};
+
+ public dimensionOptions: MonitorPoint[] = [];
+
+ get actualYear(): number {
+ return this.actualTime.getFullYear();
+ }
+ set actualYear(year) {
+ this.actualTime.setFullYear(Number(year));
+ }
+ dimensionsChange(text?: string) {
+ switch (this.dimensionItem.value) {
+ case DeviceDimension.MONITORPOINT:
+ this.monitorPointsChange(text); break;
+ case DeviceDimension.PROFESSION:
+ this.professionsChange(text); break;
+ }
+ }
+ professionsChange(text?: string) {
+ this.http.get<ResultBean<any[]>>('profession/getall').subscribe(
+ result => {
+ if (!!result.code) {
+ this.dimensionOptions = result.data;
+ }
+ }
+ );
+ }
+ monitorPointsChange(text?: string) {
+ const pageBean: PageBean = { pageIndex: 0, pageSize: 20 };
+ const example = new ExampleService();
+ let areaName = '';
+ switch (this._areas.length) {
+ case 1:
+ areaName = 'provinceCode'; break;
+ case 2:
+ areaName = 'cityCode'; break;
+ case 3:
+ areaName = 'areaCode'; break;
+ }
+ if (!!text) {
+ example.or().andLike({ name: 'name', value: '%' + text + '%' })
+ .andEqualTo({ name: areaName, value: Number(this._areas.slice(-1).pop().value) });
+ } else {
+ example.or()
+ .andEqualTo({ name: areaName, value: Number(this._areas.slice(-1).pop().value) });
+ }
+ this.monitorPointService.getPageByExample(pageBean, example).subscribe(
+ (res: PageBean) => {
+ if (!!res && !!res.data) {
+ this.dimensionOptions = res.data;
+ }
+ }
+ );
+ }
+ devicesChange(text?: string) {
+ if (!!this.deviceDimension) {
+ const example = new ExampleService();
+ const deviceDimensionProperty =
+ this.dimensionItem.value === DeviceDimension.MONITORPOINT ? 'monitorPointId' : 'professionId';
+ if (!!text) {
+ example.or().andEqualTo({ name: deviceDimensionProperty, value: this.deviceDimension.id })
+ .andLike({name: 'text', value: text});
+ } else {
+ example.or().andEqualTo({ name: deviceDimensionProperty, value: this.deviceDimension.id });
+ }
+ this.deviceService.getPageByExample(null, example).subscribe(
+ (res: PageBean) => {
+ if (!!res && !!res.data) {
+ this.deviceOptions = res.data;
+ }
+ }
+ );
+ } else {
+ this.deviceOptions = [];
+ }
+ }
+ /**
+ * ������������
+ */
+ public chartLoading: boolean;
+ public chartOption;
+ public echartsIntance;
+ public chartSelectedIndex = 0;
+ public onChartInit(e): void {
+ this.echartsIntance = e;
+ }
+ /**
+ * ������ sensor ������������������������
+ * @param sensorKeys
+ */
+ private mockSelectSensors(sensorKeys: string[]) {
+ // ������������ aqi 6���������
+ // Object.keys(this.aqiSort)
+ sensorKeys.forEach( key => {
+ const sensor = this.sensorOptions[0].children.find(
+ sen => sen.sensorKey === key
+ )
+ if (!!sensor) {
+ sensor['halfChecked'] = false;
+ sensor['checked'] = true;
+ const event = {node: {data: sensor}};
+ this.onSensorSelect(event);
+ }
+ });
+ }
+ constructor(
+ private http: _HttpClient,
+ private sensorsService: SensorsService,
+ private deviceService: DeviceService,
+ private areacodeService: AreacodeService,
+ private monitorPointService: MonitorPointService,
+ private msg: NzMessageService,
+ private dateService: DateService,
+ ) { }
+ ngOnInit() {
+ const searchData = [];
+ for (let i = 0; i < 50; i += 1) {
+ searchData.push({
+ index: i + 1,
+ point: `������������-${i}`,
+ value: Math.floor(Math.random() * 100)
+ });
+ }
+
+ this.data = {
+ searchData: searchData
+ };
+
+ 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(
+ (res: PageBean) => {
+ this.sensorOptions.push({id: -1, name: '������', isExpanded: true, children: res.data});
+ this.mockSelectSensors(Object.keys(this.aqiSort));
+ }
+ );
+ this.actualYearOptions = this.newArray(this.actualYear - 9, 10).map(item => Number(item)).reverse();
+ // ��������� ���������
+ this.http.get('organization/get-my-org').subscribe(
+ (res: ResultBean<Organization>) => {
+ if (res.code === ResultCode.SUCCESS) {
+ const org = res.data;
+ const areas = new Array(3);
+ if (!!org.areaNames) {
+ const areaNames = org.areaNames;
+ Object.keys(areaNames).forEach(
+ key => {
+ const value = areaNames[key];
+ if ( value != null) {
+ switch (key) {
+ case 'provinceName' :
+ areas[0] = {label : value, value: org.provinceCode }; break;
+ case 'cityName' :
+ areas[1] = {label : value, value: org.cityCode }; break;
+ case 'areaName' :
+ areas[2] = {label : value, value: org.areaCode }; break;
+ }
+ }
+ }
+ );
+ } else {
+ for (let i = 0; i < areas.length; i++) {
+ switch (i) {
+ case 0:
+ areas[0] = {label : '���������', value: 320000 }; break;
+ case 1:
+ areas[1] = {label : '���������', value: 320500 }; break;
+ case 2:
+ areas[2] = {label : '���������', value: 320583 }; break;
+ }
+ }
+ }
+ this.setAreasData(areas);
+ }
+ }
+ );
+ this.dimensionItem = this.dimensions[0];
+ // this.dimensionsChange();
+ }
+ public get sensorsLength(): number {
+ return this.sensorOptions.length > 0 ? this.sensorOptions[0].children.length : 0;
+ }
+ public get sensorsSelect(): number {
+ return Object.keys(this._sensors).length;
+ }
+ public areaLazyLoad(event: { option: CascaderOption, index: number, resolve: (children: CascaderOption[]) => void, reject: () => void }) {
+ const index = event['index'];
+ const option = event.option;
+ switch (index) {
+ case -1:
+ this.areacodeService.getProvinces().subscribe(
+ (res: { label: string, value: string }[]) => {
+ event.resolve(res);
+ }
+ ); break;
+ case 0:
+ this.areacodeService.getCities(option.value).subscribe(
+ (res: { label: string, value: string }[]) => {
+ event.resolve(res);
+ }
+ ); break;
+ case 1:
+ this.areacodeService.getAreas(option.value).subscribe(
+ (res: { label: string, value: string }[]) => {
+ event.resolve(res);
+ }
+ ); break;
+ }
+ }
+ // ��������������������� ��������� ��� ������������������������
+ public setAreasData(areas: {label: string, value: string}[] ) {
+ let isChanged = false;
+ isChanged = areas.some( (item , index: number) => {
+ // this._areas[index] ���null ������ ������������������
+ return this._areas.length < areas.length
+ || !this._areas[index]
+ || this._areas[index].value !== item.value;
+ });
+ if ( isChanged ) {
+ this._areas = areas;
+ this.deviceDimension = null;
+ if (this.dimensionItem.value === DeviceDimension.MONITORPOINT) {
+ this.dimensionsChange();
+ }
+ }
+ }
+
+ // ��������� ������ ������������, ������ ���������������������������null ������������������������������
+ public dimensionItem: {label: string, value: DeviceDimension};
+ public dimensions: {label: string, value: DeviceDimension}[] = [
+ {label: '������������', value: DeviceDimension.MONITORPOINT},
+ {label: '������������', value: DeviceDimension.PROFESSION}
+ ];
+ public get otherDimensions(): {label: string, value: DeviceDimension}[] {
+ return this.dimensions.filter(
+ item => {
+ return item.value !== this.dimensionItem.value;
+ }
+ );
+ }
+ public selectDimension(option: {label: string, value: DeviceDimension}) {
+ this.dimensionItem = option;
+ this.dimensionsChange();
+ this._deviceDimension = null;
+ // ������������������
+ this.device = null;
+ this.deviceOptions = null;
+ }
+ public _deviceDimension: {id: number, name: string};
+ get deviceDimension(): {id: number, name: string} {
+ return this._deviceDimension;
+ }
+ set deviceDimension(value) {
+ if (!!value) {
+ // ������ ������������������
+ if (this._deviceDimension !== value) {
+ this._deviceDimension = value; // ���������������������������������������������������������
+ this._device = null; // ���������������
+ this.devicesChange();
+ }
+ // ������null ������������������������������
+ } else {
+ this._deviceDimension = null;
+ this.device = null;
+ this.deviceOptions = null;
+ }
+
+ }
+ // ��������� ������ ������������
+ public _device: Device;
+ set device(val: Device) {
+ this._device = val;
+
+ }
+ get device(): Device {
+ return this._device;
+ }
+
+
+ /**
+ * ������ ���������������
+ *
+ * @readonly
+ * @type {string}
+ * @memberof QueryComponent
+ */
+ private treeClickStream: Subject<any> = new Subject<any>();
+ public onTreeClickSelect(event): void {
+ this.treeClickStream.next(event);
+ }
+ public onSensorSelect(event): void {
+ debugger;
+ const data = event.node.data;
+ if (data.id === -1 && data.halfChecked === false) {
+ if (!!data.checked) {
+ this.sensorOptions[0].children.forEach(
+ sensor => {
+ this._sensors [sensor.id] = sensor.sensorKey;
+ }
+ );
+ } else {
+ this._sensors = {};
+ }
+ } else {
+ if (!!data.checked) {
+ this._sensors [data.id] = data.sensorKey;
+ } else {
+ delete this._sensors[data.id];
+ }
+ }
+ 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) {
+ // YYYY-MM-DD HH:mm:ss
+ case TimeUnits.MONTH:
+ this._timeType.dateFormat = 'YYYY���';
+ // this._timeType.dateFormat = 'YYYY-MM';
+ // this._timeType.mode = 'month';
+ // this._timeType.endShowTime = null;
+ break;
+ case TimeUnits.DAY:
+ this._timeType.dateFormat = 'YYYY���MM���';
+ this._timeType.mode = 'month';
+ this._timeType.showTime = false;
+ break;
+ case TimeUnits.HOUR:
+ this._timeType.dateFormat = 'YYYY���MM���DD���';
+ this._timeType.mode = 'day';
+ this._timeType.showTime = false;
+ break;
+ case TimeUnits.MINUTE:
+ this._timeType.dateFormat = 'YYYY���MM���DD��� HH���';
+ this._timeType.mode = 'day';
+ this._timeType.showTime = {
+ nzHideDisabledOptions: true,
+ nzDisabledHours: () => {
+ return [];
+ },
+ nzDisabledMinutes: (h) => {
+ return this.newArray(60).slice(1).map(
+ item => Number(item)
+ );
+ },
+ nzDisabledSeconds: () => {
+ return this.newArray(60).slice(1).map(
+ item => Number(item)
+ );
+ }
+ };
+ break;
+ }
+ }
+ private newArray = (startOrLen: number, len?: number, prefix?: string, suffix?: string) => {
+ const result = [];
+ const s = !!len ? startOrLen : 0;
+ len = !!len ? len : startOrLen;
+ suffix = !!suffix ? suffix : '';
+ prefix = !!prefix ? prefix : '';
+ for (let i = s; result.length < len; i++) {
+ result.push(prefix + i + suffix);
+ }
+ return result;
+ }
+ public loadGrid(): void {
+ // ������������
+ const sensors = Object.values(this._sensors);
+ debugger;
+ if ( sensors.length === 0 ) {
+ this.msg.error(' ������������ ������������');
+ return ;
+ }
+ this.grid.loading = true;
+ 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;
+ // ���������������
+ const dimValue: number = !!this._deviceDimension ? this._deviceDimension.id : null;
+ const devValue: number = !!this._device ? this._device.id : null;
+ const areasData = [ devValue, dimValue, Number(this._areas.slice(-1).pop().value)];
+ if (!!this.deviceDimension) {
+ this.dataCondition.dimensionValue = this._deviceDimension.id;
+ this.dataCondition.deviceDimension = this.dimensionItem.value;
+ }
+ for (let index = 0 ; index < areasData.length ; index++) {
+ const item = areasData[index];
+ if ( item !== null ) {
+ this.dataCondition.areaRangeId = item;
+ switch (index) {
+ case 0: this.dataCondition.areaRange = AreaRange.DEVICE; break;
+ case 1:
+ // ������������������
+ if (this.dimensionItem.value === DeviceDimension.MONITORPOINT) {
+ this.dataCondition.areaRange = AreaRange.MONITORPOINT;
+ // ���������������
+ } else {
+ // ������������������������
+ this.switchAreas();
+ // ���������������������
+ this.dataCondition.areaRangeId = areasData.slice(-1).pop();
+ } break;
+ case 2:
+ this.switchAreas();
+ break;
+ }
+ break;
+ }
+ }
+ const dataConditions = [this.dataCondition];
+ const lineChartCriteria: LineChartCriteria = {
+ sensorKeys: sensors,
+ timePeriod: {startTime: start , endTime: end, timeUnits: this.timeUnit.value },
+ dataConditions: dataConditions
+ };
+ const timePeriod = lineChartCriteria.timePeriod;
+ switch (timePeriod.timeUnits) {
+ case TimeUnits.MONTH:
+ this.grid.columns = this.newArray(1, 12, null, '���').map(
+ item => {
+ return {text: item};
+ }
+ ); break;
+ case TimeUnits.DAY:
+ const mo = moment(lineChartCriteria.timePeriod.startTime);
+ const days = mo.endOf('month').date();
+ this.grid.columns = this.newArray(1, days, null, '���').map(
+ item => {
+ return {text: item};
+ }
+ ); break;
+ case TimeUnits.HOUR:
+ this.grid.columns = this.newArray(0, 24, null, '���').map(
+ item => {
+ return {text: item};
+ }
+ ); break;
+ case TimeUnits.MINUTE:
+ this.grid.columns = this.newArray(0, 60, null, '���').map(
+ item => {
+ return {text: item};
+ }
+ ); break;
+ }
+ // ���������������������������������
+ this.tableWidth = this.grid.columns.length * 80 + 160;
+ this.reloadChart();
+ // ������������������
+ this.reloadChartTitle();
+ // ������������
+ this.grid.data = [];
+ console.log(lineChartCriteria);
+ this.http.post('/report/line-chart', lineChartCriteria).subscribe(
+ (res: ResultBean<{[key: string]: Array<Array<number>>}>) => {
+ if (res.code === 1) {
+ const data = res.data;
+ if (!!data) {
+ const sensorKeys = Object.keys(data);
+ // aqi������������������������������������ ���������
+ sensorKeys.forEach(
+ key => {
+ const sensor = (<Array<Sensor>>this.sensorOptions[0].children).
+ find(item => {
+ return item.sensorKey === key;
+ });
+ let weight = this.aqiSort[key];
+ weight = !!weight ? weight : 101;
+ // this.gridSensors.push(sensor);
+ const sensorData = data[key][0].map(
+ value => {
+ if (weight > 100) {
+ // pair.value ���null,������������
+ weight = !!value ? weight : weight + 1;
+ }
+ // ���������������������2���
+ return value != null ? String(Math.round(value * 100) / 100) : '-';
+ }
+ );
+ this.grid.data.push({sensor: sensor, data: sensorData, weight: weight});
+ }
+ );
+ }
+ this.grid.data.sort( (a, b) => a.weight - b.weight );
+ this.grid.loading = false;
+ this.switchSensor(0);
+ }
+ }
+ );
+ $('.ant-table-body').scroll(
+ () => {
+ this.sensorNameScrollLeft = $('.ant-table-body').scrollLeft();
+ this.sensorNameScrollTop = -$('.ant-table-body').scrollTop();
+ }
+ );
+ }
+ private switchAreas(): void {
+ switch (this._areas.length ) {
+ case 1: this.dataCondition.areaRange = AreaRange.PROVINCE; break;
+ case 2: this.dataCondition.areaRange = AreaRange.CITY; break;
+ case 3: this.dataCondition.areaRange = AreaRange.AREA; break;
+ }
+ }
+ private reloadChart(): void {
+ const timeList = this.grid.columns.map(item => item.text);
+ if (!!this.echartsIntance) {
+ this.chartOption = null;
+ this.echartsIntance.clear();
+ }
+ // let series = null;
+ // if ( this.chartSelectedIndex < this.grid.data.length ) {
+ // series = [{type: 'line', data: this.grid.data[this.chartSelectedIndex]}];
+ // }
+
+ this.initOpton({ xAxis : [{data : timeList}]});
+ this.chartLoading = true;
+ }
+ private initOpton(opt: {[key: string]: object}) {
+ const defaultOption = {
+ title: {
+ left: 'center'
+ },
+ tooltip : {
+ trigger: 'axis',
+ axisPointer: {
+ type: 'cross',
+ label: {
+ backgroundColor: '#6a7985'
+ }
+ }
+ },
+ legend: {
+ data: []
+ },
+ toolbox: {
+ feature: {
+ saveAsImage: {}
+ }
+ },
+ grid: {
+ left: '3%',
+ right: '4%',
+ bottom: '3%',
+ containLabel: true
+ },
+ xAxis : [
+ {
+ type : 'category',
+ boundaryGap : false
+ }
+ ],
+ yAxis : [
+ {
+ type : 'value'
+ }
+ ],
+ series : [
+ ]
+ };
+ $.extend(true, defaultOption, opt);
+ this.chartOption = defaultOption;
+ }
+ public get sensorUnit() {
+ return this.grid.data[this.chartSelectedIndex].sensor.unit;
+ }
+ // ������������������ ������������
+ public _chartTitleTemp = '';
+ public _tableTitleTemp = '';
+ public reloadChartTitle(): void {
+ const names = ['������', '������', '������', '������', '������'];
+ switch ( this.dataCondition.areaRange ) {
+ case AreaRange.MONITORPOINT :
+ names[0] = '������������';
+ names[1] = this._deviceDimension.name; break;
+ case AreaRange.DEVICE :
+ names[0] = '������';
+ names[1] = this._device.name; break;
+ default :
+ names[0] = '';
+ names[1] = this._areas.map( item => item.label).join('/');
+ break;
+ }
+ // ������������
+ if (!!this._deviceDimension) {
+ switch (this.dataCondition.deviceDimension) {
+ case DeviceDimension.PROFESSION :
+ names[2] = '[' + this._deviceDimension.name + ']';
+ break;
+ default :
+ names[2] = '';
+ break;
+ }
+ } else {
+ names[2] = '';
+ }
+
+ names[3] = moment(this.actualTime).format(this._timeType.dateFormat);
+ if ( this.grid.data.length > this.chartSelectedIndex) {
+ names[4] = this.grid.data[this.chartSelectedIndex].sensor.name;
+ }
+ const title = names.join(' ') + ' ������';
+ if (title.trim() !== this._chartTitleTemp.trim()) {
+ this._chartTitleTemp = title;
+ }
+ const tableTile = names.slice(0, -1).join(' ') + ' ������������';
+ if (tableTile.trim() !== this._tableTitleTemp.trim()) {
+ this._tableTitleTemp = tableTile;
+ }
+ }
+ 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._chartTitleTemp
+ },
+ yAxis : [
+ {
+ name : '���������' + this.sensorUnit
+ }
+ ],
+ series: series
+ });
+ this.chartLoading = false;
+ }, 600);
+ }
+ private getPeriodDate(value: Date , type?: 'start'|'end' ): Date {
+ let month = 0;
+ let day = 1;
+ let hour = 0;
+ let minute = 0;
+ let second = 0;
+ let millisecond = 0;
+ if ('end' === type) {
+ month = 11;
+ day = 31;
+ hour = 23;
+ minute = 59;
+ second = 59;
+ millisecond = 999;
+ }
+ const mo = moment(value);
+ switch ( this.timeUnit.value ) {
+ case TimeUnits.MONTH:
+ mo.month(month).date(day).hour(hour).minute(minute).second(second).millisecond(millisecond); break;
+ case TimeUnits.DAY:
+ mo.date(day).hour(hour).minute(minute).second(second).millisecond(millisecond); break;
+ case TimeUnits.HOUR:
+ mo.hour(hour).minute(minute).second(second).millisecond(millisecond); break;
+ case TimeUnits.MINUTE:
+ mo.minute(minute).second(second).millisecond(millisecond); break;
+ // case TimeUnits.MINUTE:
+ // mo.second(second).millisecond(millisecond); break;
+ }
+ return mo.toDate();
+ }
+ public sensorTableFocusIndex = -1;
+ 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);
+ }
+
+
+ sort(sortName, sortValue) {
+ this.data.searchData = [
+ ...(<any[]>this.data.searchData).sort((a, b) => {
+ if (a[sortName] > b[sortName]) {
+ return (sortValue === 'ascend') ? 1 : -1;
+ } else if (a[sortName] < b[sortName]) {
+ return (sortValue === 'ascend') ? -1 : 1;
+ } else {
+ return 0;
+ }
+ })
+ ];
+ }
+}
+
+
--
Gitblit v1.8.0