From 3517e796f650b8aed52165c1a5905456f54033ef Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Wed, 10 Jan 2018 14:31:40 +0800 Subject: [PATCH] 项目路径 配置,以适应可能的框架更新 --- src/app/routes/systems/organization/organization.component.ts | 227 ------ src/app/routes/users/installer/edit/edit.component.ts | 4 src/app/business/services/http/organization.service.ts | 17 src/app/routes/systems/account/account.component.ts | 2 src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.ts | 105 +++ src/app/business/pipe/tyep-handle.pipe.ts | 4 src/app/routes/devices/monitor-point/monitor-point.component.ts | 72 +- src/app/routes/systems/organization/organization-list/organization-list.component.ts | 212 ++++++ src/app/routes/routes.module.ts | 12 src/app/business/entity/grid.ts | 9 src/app/app.module.ts | 3 src/app/routes/sensors/sensors.module.ts | 18 src/app/routes/sensors/basic-info/basic-info.component.ts | 162 +++++ src/app/routes/devices/version/version.component.ts | 83 + src/app/business/entity/data.ts | 63 + src/app/routes/systems/organization/organization-edit/organization-edit.component.ts | 4 tsconfig.json | 4 src/app/business/services/http/version.service.ts | 17 src/app/business/services/util/date.service.ts | 0 src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.ts | 64 ++ src/app/routes/devices/devices.module.ts | 20 src/tsconfig.spec.json | 4 src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.html | 80 ++ src/app/business/services/http/sensors.service.ts | 39 + src/app/routes/systems/organization/organization-edit/organization-edit.component.html | 9 src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts | 118 +++ src/app/routes/devices/version/version-edit/version-edit.component.ts | 5 src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.html | 64 ++ src/app/routes/devices/version/version-edit/version-edit.component.html | 7 src/app/routes/systems/organization/organization.component.html | 71 -- src/app/routes/users/alarm-user/alarm-user.component.ts | 2 src/app/routes/devices/monitor-point/monitor-point.component.html | 2 src/app/business/services/http/monitor-point.service.ts | 6 src/app/business/services/util/example.service.ts | 45 + src/tsconfig.app.json | 4 src/app/routes/users/installer/installer.component.ts | 2 src/app/routes/systems/organization/organization-config/organization-config.component.html | 67 ++ src/app/shared/shared.module.ts | 13 src/app/routes/systems/organization/organization-list/organization-list.component.html | 66 ++ src/app/business/enum/types.enum.ts | 0 src/app/business/services/util/tools.service.ts | 0 /dev/null | 45 - src/app/business/services/http/areacode.service.ts | 2 src/app/routes/systems/systems.module.ts | 15 src/app/routes/systems/organization/organization-config/organization-config.component.ts | 24 src/app/routes/devices/version/version.component.html | 4 src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.html | 39 + src/app/routes/sensors/basic-info/basic-info.component.html | 69 ++ src/app/business/pipe/pipe.module.ts | 2 49 files changed, 1,433 insertions(+), 473 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5aeeadf..a5e4a7d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,3 +1,4 @@ +import { DateService } from '@business/services/util/date.service'; import { BrowserModule } from '@angular/platform-browser'; import { NgModule, LOCALE_ID, APP_INITIALIZER, Injector } from '@angular/core'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -9,7 +10,6 @@ import { AppComponent } from './app.component'; import { RoutesModule } from './routes/routes.module'; import { LayoutModule } from './layout/layout.module'; -import { DateService } from './core/services/date.service'; import { StartupService } from './core/services/startup.service'; import { DefaultInterceptor } from '@core/net/default.interceptor'; import { AlainAuthModule, SimpleInterceptor } from '@delon/auth'; @@ -20,6 +20,7 @@ import { registerLocaleData } from '@angular/common'; import localeZhHans from '@angular/common/locales/zh-Hans'; + registerLocaleData(localeZhHans); // AoT requires an exported function for factories diff --git a/src/app/business/entity/data.ts b/src/app/business/entity/data.ts new file mode 100644 index 0000000..2ea1eba --- /dev/null +++ b/src/app/business/entity/data.ts @@ -0,0 +1,63 @@ +import { Column } from '@business/entity/grid'; + + +export interface AreaNames { + provinceName?: string; + cityName?: string; + areaName?: string; +} +// ��������� +export interface Sensor { + description?: any|Column; + id?: any|Column; + key?: any|Column; + lower?: any|Column; + name?: any|Column; + unit?: any|Column; + upper?: any|Column; + } + +// ������ +export interface Organization { + address?: Column|any; + areaCode?: Column|any; + cityCode?: Column|any; + createTime?: Column|any; + description?: Column|any; + email?: Column|any; + expireTime?: Column|any; + id?: Column|any; + isDelete?: Column|any; + name?: Column|any; + provinceCode?: Column|any; + rank?: Column|any; + telephone?: Column|any; + areaNames?: AreaNames|any ; + } + + // ������������ + + export interface DeviceVersion { + createTime?: Column|any; + description?: Column|any; + id?: Column|any; + name?: Column|any; + version?: Column|any; + } + + // ��������� + export interface MonitorPoint { + address?: any|Column; + areaCode?: any|Column; + cityCode?: any|Column; + description?: any|Column; + id?: any|Column; + isDelete?: any|Column; + latitude?: any|Column; + longitude?: any|Column; + name?: any|Column; + organizationId?: any|Column; + provinceCode?: any|Column; + areaNames?: AreaNames|any ; + organization?: Organization; + } diff --git a/src/app/core/entity/grid.ts b/src/app/business/entity/grid.ts similarity index 94% rename from src/app/core/entity/grid.ts rename to src/app/business/entity/grid.ts index 3a1ac82..628fea5 100644 --- a/src/app/core/entity/grid.ts +++ b/src/app/business/entity/grid.ts @@ -1,11 +1,6 @@ -import { Column } from '@core/entity/grid'; -import { Types } from '@core/enum/types.enum'; +import { Types } from '@business/enum/types.enum'; -export interface AreaNames { - provinceName?: string; - cityName?: string; - areaName?: string; -} + export interface Column { text?: string; name?: string; diff --git a/src/app/core/enum/types.enum.ts b/src/app/business/enum/types.enum.ts similarity index 100% rename from src/app/core/enum/types.enum.ts rename to src/app/business/enum/types.enum.ts diff --git a/src/app/core/pipe/pipe.module.ts b/src/app/business/pipe/pipe.module.ts similarity index 82% rename from src/app/core/pipe/pipe.module.ts rename to src/app/business/pipe/pipe.module.ts index 069d891..c845221 100644 --- a/src/app/core/pipe/pipe.module.ts +++ b/src/app/business/pipe/pipe.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TyepHandlePipe } from './tyep-handle.pipe'; -import { DateService } from '@core/services/date.service'; +import { DateService } from '@business/services/util/date.service'; @NgModule({ imports: [ diff --git a/src/app/core/pipe/tyep-handle.pipe.ts b/src/app/business/pipe/tyep-handle.pipe.ts similarity index 89% rename from src/app/core/pipe/tyep-handle.pipe.ts rename to src/app/business/pipe/tyep-handle.pipe.ts index 47acc5f..6005cfc 100644 --- a/src/app/core/pipe/tyep-handle.pipe.ts +++ b/src/app/business/pipe/tyep-handle.pipe.ts @@ -4,8 +4,8 @@ import { Pipe, PipeTransform } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { NzDatePipe } from 'ng-zorro-antd/src/util/nz-date.pipe'; -import { DateService } from '@core/services/date.service'; -import { Column } from '@core/entity/grid'; +import { DateService } from '@business/services/util/date.service'; +import { Column } from '@business/entity/grid'; diff --git a/src/app/core/services/areacode.service.ts b/src/app/business/services/http/areacode.service.ts similarity index 95% rename from src/app/core/services/areacode.service.ts rename to src/app/business/services/http/areacode.service.ts index cb0670e..51254b2 100644 --- a/src/app/core/services/areacode.service.ts +++ b/src/app/business/services/http/areacode.service.ts @@ -1,4 +1,3 @@ -import { environment } from './../../../environments/environment.prod'; import { Injectable } from '@angular/core'; import { _HttpClient } from '@delon/theme/services/http/http.client'; // Statics @@ -7,6 +6,7 @@ import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/map'; import { Observable } from 'rxjs/Observable'; +import { environment } from 'environments/environment'; @Injectable() export class AreacodeService { diff --git a/src/app/routes/devices/monitor-point/monitor-point.service.ts b/src/app/business/services/http/monitor-point.service.ts similarity index 85% rename from src/app/routes/devices/monitor-point/monitor-point.service.ts rename to src/app/business/services/http/monitor-point.service.ts index 89045e4..2dc0c02 100644 --- a/src/app/routes/devices/monitor-point/monitor-point.service.ts +++ b/src/app/business/services/http/monitor-point.service.ts @@ -1,11 +1,11 @@ -import { ExampleService } from './../../../core/services/example.service'; +import { PageBean } from '@business/entity/grid'; +import { ExampleService } from '@business/services/util/example.service'; import { _HttpClient } from '@delon/theme'; -import { environment } from './../../../../environments/environment.prod'; +import { environment } from 'environments/environment'; import { RouteConfigLoadStart } from '@angular/router'; import { Injectable } from '@angular/core'; import { equal } from 'assert'; import { Observable } from 'rxjs/Observable'; -import { PageBean } from '@core/entity/grid'; @Injectable() export class MonitorPointService { diff --git a/src/app/routes/systems/organization/organization.service.ts b/src/app/business/services/http/organization.service.ts similarity index 66% rename from src/app/routes/systems/organization/organization.service.ts rename to src/app/business/services/http/organization.service.ts index 85b97ba..da161a8 100644 --- a/src/app/routes/systems/organization/organization.service.ts +++ b/src/app/business/services/http/organization.service.ts @@ -1,15 +1,20 @@ -import { ExampleService } from './../../../core/services/example.service'; +import { Organization } from '@business/entity/data'; +import { ExampleService } from '@business/services/util/example.service'; import { _HttpClient } from '@delon/theme'; -import { environment } from './../../../../environments/environment'; +import { environment } from 'environments/environment'; import { RouteConfigLoadStart } from '@angular/router'; import { Injectable } from '@angular/core'; import { equal } from 'assert'; import { Observable } from 'rxjs/Observable'; -import { PageBean } from '@core/entity/grid'; +import { PageBean } from '@business/entity/grid'; @Injectable() export class OrganizationService { + handle: 'list'|'config' = 'list'; + + data: Organization; + title: '������������'|'������������' = '������������'; private urls = { edit: environment.SERVER_BASH_URL + '/organization/page-list', save: environment.SERVER_BASH_URL + '/organization/add-or-modify', @@ -21,8 +26,12 @@ if (queryText != null && queryText !== '') { example.or().andLike({name: 'name', value: '%' + queryText + '%'}); } + let orderByClause = ''; + if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { + orderByClause = page.getOrderByClause(); + } const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, - queryParams: example.getSqlParam(), orderByClause: page.getOrderByClause()}; + queryParams: example.getSqlParam(), orderByClause: orderByClause}; return this.http.get(this.urls.edit, param); } public save(data: any): Observable<any> { diff --git a/src/app/business/services/http/sensors.service.ts b/src/app/business/services/http/sensors.service.ts new file mode 100644 index 0000000..af04f91 --- /dev/null +++ b/src/app/business/services/http/sensors.service.ts @@ -0,0 +1,39 @@ +import { ExampleService } from '@business/services/util/example.service'; +import { _HttpClient } from '@delon/theme'; +import { environment } from 'environments/environment'; +import { RouteConfigLoadStart } from '@angular/router'; +import { Injectable } from '@angular/core'; +import { equal } from 'assert'; +import { Observable } from 'rxjs/Observable'; +import { PageBean } from '@business/entity/grid'; + +@Injectable() +export class SensorsService { + private urls = { + edit: environment.SERVER_BASH_URL + '/sensor/page-list', + save: environment.SERVER_BASH_URL + '/sensor/add-or-modify', + delete: environment.SERVER_BASH_URL + '/sensor/delete-by-ids' +}; +constructor(private http: _HttpClient) { } + public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { + const example = new ExampleService(); + if (queryText != null && queryText !== '') { + example.or().andLike({name: 'name', value: '%' + queryText + '%'}); + example.or().andEqualTo({name: 'version', value: queryText}); + } + let orderByClause = ''; + if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { + orderByClause = page.getOrderByClause(); + } + const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, + queryParams: example.getSqlParam(), orderByClause: orderByClause}; + return this.http.get(this.urls.edit, param); +} +public save(data: any): Observable<any> { + return this.http.post(this.urls.save, data); +} +public delete(...ids: number[]): Observable<any> { + return this.http.post(this.urls.delete, ids); +} + +} diff --git a/src/app/routes/devices/version/version.service.ts b/src/app/business/services/http/version.service.ts similarity index 63% rename from src/app/routes/devices/version/version.service.ts rename to src/app/business/services/http/version.service.ts index b94059e..8bc27ae 100644 --- a/src/app/routes/devices/version/version.service.ts +++ b/src/app/business/services/http/version.service.ts @@ -1,11 +1,11 @@ -import { ExampleService } from './../../../core/services/example.service'; +import { ExampleService } from '@business/services/util/example.service'; +import { PageBean } from '@business/entity/grid'; import { _HttpClient } from '@delon/theme'; -import { environment } from './../../../../environments/environment'; +import { environment } from 'environments/environment'; import { RouteConfigLoadStart } from '@angular/router'; import { Injectable } from '@angular/core'; import { equal } from 'assert'; import { Observable } from 'rxjs/Observable'; -import { PageBean } from '@core/entity/grid'; @Injectable() @@ -13,7 +13,9 @@ private urls = { edit: environment.SERVER_BASH_URL + '/device-version/page-list', save: environment.SERVER_BASH_URL + '/device-version/add-or-modify', - delete: environment.SERVER_BASH_URL + '/device-version/delete-by-ids' + delete: environment.SERVER_BASH_URL + '/device-version/delete-by-ids', + getSensorIds: environment.SERVER_BASH_URL + '/device-version/get-sensor-ids', + versionSensorConfig: environment.SERVER_BASH_URL + '/device-version/version-sensor-config' }; constructor(private http: _HttpClient) { } public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { @@ -32,4 +34,11 @@ public delete(...ids: number[]): Observable<any> { return this.http.post(this.urls.delete, ids); } + public getSensorIds(deviceVersionId: number): Observable< number []> { + return this.http.get(this.urls.getSensorIds, {deviceVersionId: deviceVersionId}); + } + public versionSensorConfig(deviceVersionId: number, sensorIds: number[]): Observable<any> { + const url = this.urls.versionSensorConfig + '/' + deviceVersionId; + return this.http.post(url, sensorIds); + } } diff --git a/src/app/core/services/date.service.ts b/src/app/business/services/util/date.service.ts similarity index 100% rename from src/app/core/services/date.service.ts rename to src/app/business/services/util/date.service.ts diff --git a/src/app/business/services/util/example.service.ts b/src/app/business/services/util/example.service.ts new file mode 100644 index 0000000..e1427dd --- /dev/null +++ b/src/app/business/services/util/example.service.ts @@ -0,0 +1,45 @@ + +import { Injectable } from '@angular/core'; + +export class Criteria { + private static CONDITION_SPLIT = '||'; + private conditions: string[] = []; + public getConditions(): string[] { + return this.conditions; + } + + public addCondition(condition: string, colName:string, ...values: any[]){ + const split = Criteria.CONDITION_SPLIT; // '||' + this.conditions.push(condition+split + colName + split + values.join(split)); + } + public andLike(col: { name: string, value: any}): Criteria{ + this.addCondition('andLike', col.name, col.value); + return this; + } + public andEqualTo(col: { name: string, value: any}): Criteria{ + this.addCondition('andEqualTo', col.name, col.value); + return this; + } +} + +@Injectable() +export class ExampleService { + private static OR_SPLIT = 'or|'; + private static CRITERIA_SPLIT = '|||'; + private criterion: Criteria[] = []; + + public getSqlParam(): string { + let whereSql = ''; + for (const cri of this.criterion){ + const conditions = cri.getConditions(); + whereSql += ExampleService.OR_SPLIT + conditions.join(ExampleService.CRITERIA_SPLIT); + } + return encodeURI(whereSql); + } + constructor() { } + public or() { + const cri = new Criteria(); + this.criterion.push(cri); + return cri; + } +} diff --git a/src/app/core/services/tools.service.ts b/src/app/business/services/util/tools.service.ts similarity index 100% rename from src/app/core/services/tools.service.ts rename to src/app/business/services/util/tools.service.ts diff --git a/src/app/core/services/example.service.ts b/src/app/core/services/example.service.ts deleted file mode 100644 index 9d32660..0000000 --- a/src/app/core/services/example.service.ts +++ /dev/null @@ -1,45 +0,0 @@ - -import { Injectable } from '@angular/core'; - -export class Criteria{ - private static CONDITION_SPLIT = '||'; - private conditions: string[] = []; - public getConditions(): string[]{ - return this.conditions; - } - - public addCondition(condition: string,colName:string,...values: any[]){ - const split = Criteria.CONDITION_SPLIT; // '||' - this.conditions.push(condition+split+colName+split+ values.join(split)); - } - public andLike(col: { name: string, value: any}): Criteria{ - this.addCondition('andLike',col.name,col.value); - return this; - } - public andEqualTo(col: { name: string, value: any}): Criteria{ - this.addCondition('andEqualTo',col.name,col.value); - return this; - } -} - -@Injectable() -export class ExampleService { - private static OR_SPLIT = "or|"; - private static CRITERIA_SPLIT = "|||"; - private criterion: Criteria[]=[]; - - public getSqlParam():string{ - let whereSql = ''; - for(let cri of this.criterion){ - const conditions = cri.getConditions(); - whereSql += ExampleService.OR_SPLIT+conditions.join(ExampleService.CRITERIA_SPLIT); - } - return encodeURI(whereSql); - } - constructor() { } - public or(){ - const cri = new Criteria(); - this.criterion.push(cri); - return cri; - } -} diff --git a/src/app/routes/devices/devices.module.ts b/src/app/routes/devices/devices.module.ts index e65f3b7..9ad3e5b 100644 --- a/src/app/routes/devices/devices.module.ts +++ b/src/app/routes/devices/devices.module.ts @@ -1,6 +1,8 @@ -import { MonitorPointService } from 'app/routes/devices/monitor-point/monitor-point.service'; - -import { ToolsService } from './../../core/services/tools.service'; +import { SensorsService } from '@business/services/http/sensors.service'; +import { OrganizationService } from '@business/services/http/organization.service'; +import { MonitorPointService } from '@business/services/http/monitor-point.service'; +import { VersionService } from '@business/services/http/version.service'; +import { AreacodeService } from '@business/services/http/areacode.service'; import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { BasicInfoComponent } from './basic-info/basic-info.component'; @@ -8,15 +10,15 @@ import { MonitorPointComponent } from './monitor-point/monitor-point.component'; import {RouterModule, Routes} from '@angular/router'; import { SharedModule } from '@shared/shared.module'; -import { VersionService } from 'app/routes/devices/version/version.service'; import { Version } from '@angular/compiler/src/util'; import { _HttpClient } from '@delon/theme/services/http/http.client'; -import { PipeModule } from '@core/pipe/pipe.module'; +import { PipeModule } from '@business/pipe/pipe.module'; import { FormBuilder } from '@angular/forms'; import { VersionEditComponent } from './version/version-edit/version-edit.component'; import { MonitorPointEditComponent } from './monitor-point/monitor-point-edit/monitor-point-edit.component'; +import { VersionSensorConfigComponent } from './version/version-sensor-config/version-sensor-config.component'; -const COMPONENTS_NOROUNT = [ VersionEditComponent, MonitorPointEditComponent ]; +const COMPONENTS_NOROUNT = [ VersionEditComponent, MonitorPointEditComponent, VersionSensorConfigComponent ]; const routes: Routes = [ { @@ -41,9 +43,11 @@ BasicInfoComponent, VersionComponent, MonitorPointComponent, - ...COMPONENTS_NOROUNT + ...COMPONENTS_NOROUNT ], - providers: [ToolsService, VersionService, MonitorPointService, _HttpClient, FormBuilder], + providers: [OrganizationService, VersionService, + SensorsService, AreacodeService, MonitorPointService, + _HttpClient, FormBuilder], entryComponents: COMPONENTS_NOROUNT }) export class DevicesModule { } diff --git a/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.html b/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.html index ad9f119..e01c902 100644 --- a/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.html +++ b/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.html @@ -1,3 +1,77 @@ -<p> - monitor-point-edit works! -</p> +<div class="modal-header"> + <div class="modal-title">{{ data.id != null ? '������' : '������'}} - ������</div> +</div> +<form [formGroup]="validateForm" (ngSubmit)="save($event,validateForm.value,validateForm.valid)" nz-form [nzType]="'horizontal'"> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label nz-form-item-required>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="7" nzHasFeedback> + <nz-input formControlName="name" maxlength="20" [nzPlaceHolder]="'���������������'"> + </nz-input> + </div> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label nz-form-item-required>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="6" nzHasFeedback> + <nz-select formControlName="organizationId" [nzPlaceHolder]="'������ ������(������������������)'" + nzAllowClear [nzFilter]="false" nzShowSearch + formControlName="organizationId" (nzSearchChange)="OrgSelectChange($event)" [nzNotFoundContent]="'������������'" > + <nz-option *ngFor="let option of orgOptions" [nzLabel]="option.name" [nzValue]="option.id" [nzDisabled]="option.disabled"> + </nz-option> + </nz-select> + </div> + </div> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label nz-form-item-required>���/���/���</label> + </div> + <div nz-form-control nz-col [nzSpan]="7" nzHasFeedback> + <nz-cascader [class.class123]="true" (nzChange)="setAreaCodes($event)" formControlName="_areas" (nzLoad)="areaLazyLoad($event)" + [nzPlaceHolder]="'������ ���/���/���'" > + </nz-cascader> + </div> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������������</label> + </div> + <div nz-form-control nz-col [nzSpan]="9" nzHasFeedback> + <nz-input formControlName="address" maxlength="20" + [nzPlaceHolder]="'������������(���)������������120���'"> + </nz-input> + </div> + </div> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="5" nzHasFeedback> + <nz-input-number [ngStyle]="{'width': '100%' }" formControlName="longitude" [nzMin]="-180" [nzMax]="180" [nzStep]="0.000001"> + </nz-input-number> + </div> + <div nz-form-control nz-col [nzSpan]="2" nzHasFeedback></div> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="5" nzHasFeedback> + <nz-input-number [ngStyle]="{'width': '100%' }" formControlName="latitude" [nzMin]="-90" [nzMax]="90" [nzStep]="0.000001"> + </nz-input-number> + </div> + </div> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="16" nzHasFeedback> + <nz-input formControlName="description" maxlength="100"></nz-input> + </div> + </div> + <div class="modal-footer"> + <button nz-button type="button" (click)="close()">������</button> + <button nz-button [nzType]="'primary'" [nzLoading]="isSaving"> + <span> + ������ + <span *ngIf="isSaving">���</span> + </span> + </button> + </div> +</form> diff --git a/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts b/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts index a99f4d1..9ca1b95 100644 --- a/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts +++ b/src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts @@ -1,4 +1,11 @@ +import { MonitorPoint } from '@business/entity/data'; +import { PageBean } from '@business/entity/grid'; +import { OrganizationService } from '@business/services/http//organization.service'; +import { AreacodeService } from '@business/services/http/areacode.service'; import { Component, OnInit } from '@angular/core'; +import { NzMessageService, NzModalSubject } from 'ng-zorro-antd'; +import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; +import { CascaderOption } from 'ng-zorro-antd/src/cascader/nz-cascader.component'; @Component({ selector: 'app-monitor-point-edit', @@ -7,9 +14,116 @@ }) export class MonitorPointEditComponent implements OnInit { - constructor() { } + orgOptions = []; + + data: MonitorPoint; + isSaving = false; + validateForm: FormGroup; + constructor( + private subject: NzModalSubject, + private formBuilder: FormBuilder, + private areacodeService: AreacodeService, + private organizationService: OrganizationService + ) { } ngOnInit() { + const data = this.data; + const areaNames = data.areaNames; + let _areas = null; + if (areaNames != null) { + _areas = { + label: Object.values(areaNames).join('/'), + value: data.areaCode + }; + } + this.OrgSelectChange(null); + const validates: MonitorPoint|object = { + name: [data.name, [Validators.required] ], + organizationId: [data.organizationId, [Validators.required]], + longitude: [data.longitude], + latitude: [data.latitude], + address: [data.address ], + _areas: [_areas, [Validators.required]], + description: [data.description ] + }; + this.validateForm = this.formBuilder.group( + validates + ); } - + close() { + this.subject.destroy(); + } + save($event, value, valid) { + $event.preventDefault(); + if (valid) { + for (const i in this.validateForm.controls) { + this.validateForm.controls[ i ].disable(); + } + this.isSaving = true; + Object.keys(value).forEach( (key: string) => { + // '_'������������������������������ + if (!key.startsWith('_') && value[key] != null) { + this.data[key] = value[key]; + } + } ); + this.subject.next( this ); + }else { + this.validate(); + } + } + validate() { + for (const i in this.validateForm.controls) { + this.validateForm.controls[ i ].markAsDirty(); + } + } + 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; + } + } + setAreaCodes(codes: string[]) { + this.data.provinceCode = codes[0]; + this.data.cityCode = codes[1]; + this.data.areaCode = codes[2]; + } + OrgSelectChange(text) { + const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; + this.organizationService.getPagingList(pageBean, text).subscribe( + (res: PageBean) => { + if (res != null && res.data != null) { + this.orgOptions = res.data; + } + const organization = this.data.organization; + if (organization != null && text == null) { + const num: number = this.orgOptions.filter( + (item: any) => { + return item.id === organization.id; + } + ).length; + if ( num === 0 ) { + this.orgOptions.push(organization); + } + } + } + ); + } } diff --git a/src/app/routes/devices/monitor-point/monitor-point.component.html b/src/app/routes/devices/monitor-point/monitor-point.component.html index b580411..fd431c6 100644 --- a/src/app/routes/devices/monitor-point/monitor-point.component.html +++ b/src/app/routes/devices/monitor-point/monitor-point.component.html @@ -54,7 +54,7 @@ <td nz-td> <a (click)="addOrModify(row)">������</a> <span nz-table-divider></span> - <nz-popconfirm [nzTitle]="'���������������������������?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > + <nz-popconfirm [nzTitle]="'������������������'+grid.title+'���?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > <a nz-popconfirm>������</a> </nz-popconfirm> </td> diff --git a/src/app/routes/devices/monitor-point/monitor-point.component.ts b/src/app/routes/devices/monitor-point/monitor-point.component.ts index e1a6b84..db33f86 100644 --- a/src/app/routes/devices/monitor-point/monitor-point.component.ts +++ b/src/app/routes/devices/monitor-point/monitor-point.component.ts @@ -1,33 +1,19 @@ -import { DataType, AreaNames } from './../../../core/entity/grid'; +import { AreaNames, MonitorPoint } from '@business/entity/data'; import { Version, ValueTransformer } from '@angular/compiler/src/util'; import { Subject } from 'rxjs/Subject'; -import { ToolsService } from '@core/services/tools.service'; import { Component, OnInit } from '@angular/core'; import { NzMessageService, NzModalService } from 'ng-zorro-antd'; import { ModalHelper } from '@delon/theme'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../../environments/environment'; -import { DateService } from '@core/services/date.service'; -import { VersionService } from 'app/routes/devices/version/version.service'; -import { Types } from '@core/enum/types.enum'; -import { Column, Grid, PageBean } from '@core/entity/grid'; +import { environment } from 'environments/environment'; +import { VersionService } from '@business/services/http/version.service'; +import { Types } from '@business/enum/types.enum'; +import { Column, Grid, PageBean, DataType } from '@business/entity/grid'; import { filter } from 'rxjs/operators/filter'; import { MonitorPointEditComponent } from 'app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component'; -import { MonitorPointService } from 'app/routes/devices/monitor-point/monitor-point.service'; +import { MonitorPointService } from '@business/services/http/monitor-point.service'; -interface MonitorPoint { - address?: any|Column; - areaCode?: any|Column; - cityCode?: any|Column; - description?: any|Column; - id?: any|Column; - isDelete?: any|Column; - latitude?: any|Column; - longitude?: any|Column; - name?: any|Column; - organizationId?: any|Column; - provinceCode?: any|Column; -} + @Component({ selector: 'app-monitor-point', templateUrl: './monitor-point.component.html', @@ -36,19 +22,36 @@ export class MonitorPointComponent implements OnInit { - private organization: MonitorPoint; + private monitorPoint: MonitorPoint; grid: Grid<MonitorPoint> = new Grid(null); queryMap = { text: '���������������', value: ''}; queryTextStream: Subject<string> = new Subject<string>(); private initPage() { - this.organization = { + this.monitorPoint = { name: { text: '������', - width: '120px' + width: '300px' + }, + address: { + text: '������', + width: '300px', + format: (value: any, col: Column, row: any) => { + value = value == null ? '' : value ; + if (row['areaNames'] != null) { + return row['areaNames']['provinceName'] + row['areaNames']['cityName'] + row['areaNames']['areaName'] + value; + } else { + return value; + } + + } + }, + description: { + text: '������', + width: '300px' } }; - this.grid.title = '������������'; - this.grid.setColumns(this.organization); + this.grid.title = '���������'; + this.grid.setColumns(this.monitorPoint); this.grid.pageSize = 10; } constructor( @@ -99,13 +102,12 @@ if ( d != null) { Object.assign(data, d); } - const cols = this.organization; - this.modalHelper.static(MonitorPointEditComponent, { cols , data }).subscribe( + this.modalHelper.static(MonitorPointEditComponent, { data }).subscribe( ( ret: { data: any, close: Function} ) => { // ������������ if (ret.data['index'] != null ) { const index: number = ret.data['index'] ; - const origData = this.grid.getData()[index]; + const origData = this.grid.data[index]; const isModified = Object.keys(origData).some( (key: string) => { return ret.data[key] !== origData[key]; @@ -114,7 +116,7 @@ // ������������ if (!isModified) { ret.close(); - this.msgSrv.success('���������������������������'); + this.msgSrv.success(this.grid.title + '���������������������'); return; } } @@ -123,7 +125,7 @@ if (res.code === 1) { this.load(); ret.close(); - this.msgSrv.success('���������������������'); + this.msgSrv.success(this.grid.title + '���������������'); } } ); @@ -135,7 +137,7 @@ ( res: any) => { if (res.code === 1) { this.load(); - this.msgSrv.success('���������������������������'); + this.msgSrv.success(this.grid.title + '���������������'); } } ); @@ -172,10 +174,4 @@ } this.load(); } - - reset(ls: any[]) { - for (const item of ls) item.value = false; - this.load(true); - } - } diff --git a/src/app/routes/devices/version/version-edit/version-edit.component.html b/src/app/routes/devices/version/version-edit/version-edit.component.html index 7f8f399..950ab4c 100644 --- a/src/app/routes/devices/version/version-edit/version-edit.component.html +++ b/src/app/routes/devices/version/version-edit/version-edit.component.html @@ -15,7 +15,7 @@ </label> </div> <div nz-form-control nz-col [nzSpan]="3" nzHasFeedback> - <nz-input-number formControlName="{{ cols.version.name }}" [nzMin]="1" [nzMax]="100" [nzStep]="1"> + <nz-input-number style="width: 100%;" formControlName="{{ cols.version.name }}" [nzMin]="1" [nzMax]="100" [nzStep]="1"> </nz-input-number> </div> </div> @@ -23,10 +23,11 @@ <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> <label nz-form-item-required>{{ cols.createTime.text }}</label> </div> - <div nz-form-control nz-col [nzSpan]="7" nzHasFeedback> - <nz-datepicker nzSize="large" style="width: 90%;" formControlName="{{ cols.createTime.name }}" nzShowTime [nzPlaceHolder]="'������������'" + <div nz-form-control nz-col [nzSpan]="6" nzHasFeedback> + <nz-datepicker nzSize="large" style="width: 100%;" formControlName="{{ cols.createTime.name }}" nzShowTime [nzPlaceHolder]="'������������'" [nzFormat]="'YYYY-MM-DD HH:mm:ss'" ></nz-datepicker> </div> + <div nz-form-control nz-col [nzSpan]="1" nzHasFeedback></div> <div nz-form-label nz-col [nzSpan]="4"> <label>{{ cols.description.text }}</label> </div> diff --git a/src/app/routes/devices/version/version-edit/version-edit.component.ts b/src/app/routes/devices/version/version-edit/version-edit.component.ts index 2137673..9624084 100644 --- a/src/app/routes/devices/version/version-edit/version-edit.component.ts +++ b/src/app/routes/devices/version/version-edit/version-edit.component.ts @@ -1,7 +1,7 @@ +import { DeviceVersion } from '@business/entity/data'; import { Component, OnInit } from '@angular/core'; import { NzMessageService, NzModalSubject } from 'ng-zorro-antd'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { DeviceVersion } from 'app/routes/devices/version/version.component'; @Component({ selector: 'app-version-edit', @@ -21,6 +21,9 @@ ) { } ngOnInit() { + if (this.data.createTime == null) { + this.data.createTime = new Date().getTime(); + } const validates: DeviceVersion = { name: [this.data.name, [Validators.required] ], version: [this.data.version == null ? 1 : this.data.version, [Validators.required] ], diff --git a/src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.html b/src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.html new file mode 100644 index 0000000..8ad08af --- /dev/null +++ b/src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.html @@ -0,0 +1,39 @@ +<div class="modal-header"> + <div class="modal-title">���������������</div> +</div> +<nz-table #nzTable [nzDataSource]="grid.data" [nzPageSize]="8" + [nzLoading]="grid.loading" [nzShowTotal]="true" > + <thead nz-thead> + <tr> + <th nz-th [nzCheckbox]="true"> + <label nz-checkbox [(ngModel)]="grid.allChecked" [nzIndeterminate]="grid.indeterminate" (ngModelChange)="grid.checkAll($event)"></label> + </th> + <th nz-th *ngFor="let col of grid.columns" [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}"> + <span>{{ col.text }}</span> + <nz-table-sort *ngIf="col.isSort" [(nzValue)]="col.sort" (nzValueChange)="sort(col.name,$event)"></nz-table-sort> + </th> + </tr> + </thead> + <tbody nz-tbody> + <tr nz-tbody-tr *ngFor="let row of nzTable.data"> + <td nz-td [nzCheckbox]="true"> + <label nz-checkbox [(ngModel)]="row.checked" (ngModelChange)="grid.refreshStatus($event)"></label> + </td> + <td nz-td *ngFor="let col of grid.columns" [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}"> + <span [ngSwitch]="col.type"> + <!-- ������������������������������������ --> + <span *ngSwitchDefault> {{ row[col.name]|tyepHandle:col:row }} </span> + <!-- ������������������������������������ --> + </span> + </td> + </tr> + </tbody> +</nz-table> +<div class="modal-footer"> + <button nz-button type="button" (click)="close()">������</button> + <button nz-button [nzType]="'primary'" (click)="save($event)" [nzLoading]="isSaving"> + <span > + ������<span *ngIf="isSaving" >���</span> + </span> + </button> +</div> diff --git a/src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.ts b/src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.ts new file mode 100644 index 0000000..db44f3c --- /dev/null +++ b/src/app/routes/devices/version/version-sensor-config/version-sensor-config.component.ts @@ -0,0 +1,105 @@ +import { NzModalSubject } from 'ng-zorro-antd'; +import { Component, OnInit } from '@angular/core'; +import { SensorsService } from '@business/services/http/sensors.service'; +import { PageBean, Grid } from '@business/entity/grid'; +import { Sensor } from '@business/entity/data'; +import { Subject } from 'rxjs/Subject'; + +@Component({ + selector: 'app-version-sensor-config', + templateUrl: './version-sensor-config.component.html', + styles: [] +}) +export class VersionSensorConfigComponent implements OnInit { + deviceVersionId: number; + selectedSensorIds: number[]; + isSaving = false; + grid: Grid<Sensor> = new Grid(null); + private initPage() { + const sensor: Sensor = { + name: { + text: '������', + width: '200px' + }, + key: { + text: '������', + width: '60px' + }, + lower: { + text: '���������', + width: '90px' + }, + upper: { + text: '���������', + width: '90px' + }, + unit: { + text: '������', + width: '100px' + }, + description: { + text: '������' + } + }; + this.grid.title = '���������'; + this.grid.setColumns(sensor); + this.grid.pageSize = 0; + } + constructor( + private subject: NzModalSubject, + private sensorsService: SensorsService, + ) { } + + ngOnInit() { + this.initPage(); + this.load(); + } + load() { + // ������������������ExpressionChangedAfterItHasBeenCheckedError + setTimeout(() => { + this.grid.loading = true; + }, 1); + this.sensorsService.getPagingList(this.grid, null).subscribe( + (res: PageBean) => { + this.grid.loading = true; + if (res != null && res.data != null) { + this.grid.initData(res); + this.grid.data.map( + (row: any) => { + row['checked'] = this.selectedSensorIds.filter( + (id: number) => { + return row.id === id; + } + ).length > 0; + } + ); + this.grid.refreshStatus(); + setTimeout(() => { + this.grid.loading = false; + }, 1); + } + } + ); + } + close() { + this.subject.destroy(); + } + save($event, value, valid) { + $event.preventDefault(); + this.subject.next( this ); + } + + sort(field: string, value: string) { + // ������������field + this.grid.sorts = this.grid.sorts.filter( + (fn: string) => { + return fn !== field; + } + ); + // ������value������null������������������������������filed + if (value != null) { + this.grid.sorts.push(field); + } + this.load(); + } +} diff --git a/src/app/routes/devices/version/version.component.html b/src/app/routes/devices/version/version.component.html index 9832a1e..31d2d18 100644 --- a/src/app/routes/devices/version/version.component.html +++ b/src/app/routes/devices/version/version.component.html @@ -54,9 +54,11 @@ <td nz-td> <a (click)="addOrModify(row)">������</a> <span nz-table-divider></span> - <nz-popconfirm [nzTitle]="'���������������������������?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > + <nz-popconfirm [nzTitle]="'������������������'+grid.title+'���?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > <a nz-popconfirm>������</a> </nz-popconfirm> + <span nz-table-divider></span> + <a (click)="configSensor(row)">���������������</a> </td> </tr> </tbody> diff --git a/src/app/routes/devices/version/version.component.ts b/src/app/routes/devices/version/version.component.ts index 304d9e7..6e970b7 100644 --- a/src/app/routes/devices/version/version.component.ts +++ b/src/app/routes/devices/version/version.component.ts @@ -1,26 +1,20 @@ -import { DataType } from './../../../core/entity/grid'; +import { VersionSensorConfigComponent } from './version-sensor-config/version-sensor-config.component'; +import { DataType } from '@business/entity/grid'; +import { DeviceVersion, Sensor } from '@business/entity/data'; import { Version } from '@angular/compiler/src/util'; import { Subject } from 'rxjs/Subject'; -import { ToolsService } from '@core/services/tools.service'; +import { ToolsService } from '@business/services/util/tools.service'; import { Component, OnInit } from '@angular/core'; import { NzMessageService, NzModalService } from 'ng-zorro-antd'; import { ModalHelper } from '@delon/theme'; import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../../environments/environment'; -import { DateService } from '@core/services/date.service'; -import { VersionService } from 'app/routes/devices/version/version.service'; -import { Types } from '@core/enum/types.enum'; -import { Column, Grid, PageBean } from '@core/entity/grid'; -import { filter } from 'rxjs/operators/filter'; +import { DateService } from '@business/services/util/date.service'; +import { VersionService } from '@business/services/http/version.service'; +import { Types } from '@business/enum/types.enum'; +import { Column, Grid, PageBean } from '@business/entity/grid'; import { VersionEditComponent } from 'app/routes/devices/version/version-edit/version-edit.component'; -export interface DeviceVersion { - createTime?: Column|any; - description?: Column|any; - id?: Column|any; - name?: Column|any; - version?: Column|any; -} + @Component({ selector: 'app-version', templateUrl: './version.component.html', @@ -115,7 +109,7 @@ if (res.code === 1) { this.load(); ret.close(); - this.msgSrv.success('���������������������������'); + this.msgSrv.success(this.grid.title + '���������������'); } } ); @@ -127,7 +121,7 @@ ( res: any) => { if (res.code === 1) { this.load(); - this.msgSrv.success('���������������������������'); + this.msgSrv.success(this.grid.title + '���������������'); } } ); @@ -164,10 +158,55 @@ } this.load(); } + configSensor(data) { + const deviceVersionId = data.id; + this.versionService.getSensorIds(deviceVersionId).subscribe( + (selectedSensorIds: number[]) => { + this.modalHelper.static(VersionSensorConfigComponent, { deviceVersionId, selectedSensorIds }).subscribe( + ( ret: { grid: Grid<Sensor>, close: Function} ) => { + // ������������id + const selectedIds = ret.grid.data.filter( + (r: any) => { + return r['checked'] === true; + } + ).map( + (r: any) => { + return r['id']; + } + ); + // ������������������������������ + let isModified = selectedIds.length !== selectedSensorIds.length; + // ��������������������������� + if (!isModified) { + isModified = !selectedIds.every( + (id: number) => { + // console.log('id:' + id); + const result = selectedSensorIds.some( + (sid: number) => { + return id === sid ; + } + ); + // console.log('result:' + result); + return result; + } + ); + } + if ( !isModified ) { + this.msgSrv.success(this.grid.title + '������������������'); + ret.close(); + return ; + } + this.versionService.versionSensorConfig(deviceVersionId, selectedIds).subscribe( + ( res: any) => { + if (res.code === 1) { + ret.close(); + this.msgSrv.success(this.grid.title + '���������������'); + } + } + ); + }); + } + ); - reset(ls: any[]) { - for (const item of ls) item.value = false; - this.load(true); - } - + } } diff --git a/src/app/routes/routes.module.ts b/src/app/routes/routes.module.ts index ea7da38..53906ae 100644 --- a/src/app/routes/routes.module.ts +++ b/src/app/routes/routes.module.ts @@ -4,14 +4,24 @@ import { RouterModule } from '@angular/router'; import { SharedModule } from '@shared/shared.module'; import { environment } from '../../environments/environment'; - import { routes } from './routes'; import { DashboardV1Component } from './dashboard/v1/v1.component'; import { DashboardAnalysisComponent } from './dashboard/analysis/analysis.component'; import { DashboardMonitorComponent } from './dashboard/monitor/monitor.component'; import { DashboardWorkplaceComponent } from './dashboard/workplace/workplace.component'; import { CoreModule } from '@core/core.module'; +// region: zorro modules +// Statics +import 'rxjs/add/observable/throw'; +// Operators +import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/debounceTime'; +import 'rxjs/add/operator/distinctUntilChanged'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/toPromise'; +import 'rxjs/add/operator/filter'; @NgModule({ imports: [ SharedModule, diff --git a/src/app/routes/sensors/basic-info/basic-info.component.html b/src/app/routes/sensors/basic-info/basic-info.component.html index f7a2791..fd431c6 100644 --- a/src/app/routes/sensors/basic-info/basic-info.component.html +++ b/src/app/routes/sensors/basic-info/basic-info.component.html @@ -1,3 +1,66 @@ -<p> - sensor basic-info works! -</p> +<pro-header [title]="grid.title"></pro-header> +<nz-card [nzBordered]="false"> + <div class="mb-md"> + <button nz-button (click)="addOrModify()" [nzType]="'primary'" [nzSize]="'large'"> + <i class="anticon anticon-plus"></i><span>������</span> + </button> + <ng-container *ngIf="grid.selectedIndexs.length > 0"> + <button nz-button [nzSize]="'large'" (click)="deleteSelected()">������������</button> + </ng-container> + <nz-input [ngStyle]="{'width': '280px','float':'right'}" [(ngModel)]="queryMap.value" name="" [nzPlaceHolder]="queryMap.text" + (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> + </div> + <div class="mb-md"> + <nz-alert *ngIf="grid.selectedIndexs.length > 0" [nzType]="'info'" [nzShowIcon]="true"> + <span alert-body> + ���������<strong class="text-primary">{{grid.selectedIndexs.length}}</strong>��� + </span> + </nz-alert> + </div> + <nz-table #nzTable + [nzAjaxData]="grid.data" + [nzTotal]="grid.total" + [(nzPageIndex)]="grid.pageIndex" + [(nzPageSize)]="grid.pageSize" + [nzLoading]="grid.loading" + [nzShowTotal]="true" + (nzPageIndexChange)="load()"> + <thead nz-thead> + <tr> + <th nz-th [nzCheckbox]="true"> + <label nz-checkbox [(ngModel)]="grid.allChecked" [nzIndeterminate]="grid.indeterminate" (ngModelChange)="grid.checkAll($event)"></label> + </th> + <th nz-th *ngFor="let col of grid.columns" + [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}" > + <span>{{ col.text }}</span> + <nz-table-sort *ngIf="col.isSort" [(nzValue)]="col.sort" (nzValueChange)="sort(col.name,$event)"></nz-table-sort> + </th> + <th nz-th><span>������</span></th> + </tr> + </thead> + <tbody nz-tbody> + <tr nz-tbody-tr *ngFor="let row of nzTable.data"> + <td nz-td [nzCheckbox]="true"> + <label nz-checkbox [(ngModel)]="row.checked" (ngModelChange)="grid.refreshStatus($event)"></label> + </td> + <td nz-td *ngFor="let col of grid.columns" + [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}"> + <span [ngSwitch]="col.type"> + <!-- ������������������������������������ --> + <span *ngSwitchDefault> {{ row[col.name]|tyepHandle:col:row }} </span> + <!-- ������������������������������������ --> + </span> + </td> + <td nz-td> + <a (click)="addOrModify(row)">������</a> + <span nz-table-divider></span> + <nz-popconfirm [nzTitle]="'������������������'+grid.title+'���?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > + <a nz-popconfirm>������</a> + </nz-popconfirm> + </td> + </tr> + </tbody> + </nz-table> + </nz-card> + + diff --git a/src/app/routes/sensors/basic-info/basic-info.component.ts b/src/app/routes/sensors/basic-info/basic-info.component.ts index 434f272..e53d4f6 100644 --- a/src/app/routes/sensors/basic-info/basic-info.component.ts +++ b/src/app/routes/sensors/basic-info/basic-info.component.ts @@ -1,4 +1,14 @@ +import { NzModalService, NzMessageService } from 'ng-zorro-antd'; +import { PageBean } from '@business/entity/grid'; +import { Sensor } from '@business/entity/data'; +import { ModalHelper } from '@delon/theme'; +import { SensorsService } from '@business/services/http/sensors.service'; +import { Column, Grid } from '@business/entity/grid'; import { Component, OnInit } from '@angular/core'; +import { Subject } from 'rxjs/Subject'; +import { SensorEditComponent } from './sensor-edit/sensor-edit.component'; + + @Component({ selector: 'app-basic-info', @@ -7,9 +17,159 @@ }) export class BasicInfoComponent implements OnInit { - constructor() { } + + grid: Grid<Sensor> = new Grid(null); + queryMap = { text: '���������������', value: ''}; + queryTextStream: Subject<string> = new Subject<string>(); + private initPage() { + const sensor: Sensor = { + name: { + text: '������', + width: '200px' + }, + key: { + text: '������', + width: '60px' + }, + lower: { + text: '���������', + width: '90px' + }, + upper: { + text: '���������', + width: '90px' + }, + unit: { + text: '������', + width: '100px' + }, + description: { + text: '������' + } + }; + this.grid.title = '���������'; + this.grid.setColumns(sensor); + this.grid.pageSize = 10; + } + constructor( + private sensorsService: SensorsService, + + private confirmServ: NzModalService, + public msgSrv: NzMessageService, + private modalHelper: ModalHelper, + ) {} ngOnInit() { + this.initPage(); + this.queryTextStream + .debounceTime(500) + .distinctUntilChanged() + .subscribe(queryText => { + this.load(); + }); + } + queryTextChanged($event) { + this.queryTextStream.next(this.queryMap.value); + } + load(reload: boolean = false) { + if (reload) { + this.grid.pageIndex = 1 ; + } + // ������������������ExpressionChangedAfterItHasBeenCheckedError + setTimeout(() => { + this.grid.loading = true; + }, 1); + this.sensorsService.getPagingList(this.grid, this.queryMap.value).subscribe( + (res: PageBean) => { + this.grid.loading = true; + if (res != null && res.data != null) { + this.grid.initData(res); + this.grid.refreshStatus(); + setTimeout(() => { + this.grid.loading = false; + }, 1); + } + } + ); + } + +// rowData���null��������������� + addOrModify(d) { + const data = {}; + if ( d != null) { + Object.assign(data, d); + } + this.modalHelper.static(SensorEditComponent, { data }).subscribe( + ( ret: { data: any, close: Function} ) => { + // ������������ + if (ret.data['index'] != null ) { + const index: number = ret.data['index'] ; + const origData = this.grid.getData()[index]; + const isModified = Object.keys(origData).some( + (key: string) => { + return ret.data[key] !== origData[key]; + } + ); + // ������������ + if (!isModified) { + ret.close(); + this.msgSrv.success(this.grid.title + '���������������������'); + return; + } + } + this.sensorsService.save(ret.data).subscribe( + ( res: any) => { + if (res.code === 1) { + this.load(); + ret.close(); + this.msgSrv.success(this.grid.title + '���������������'); + } + } + ); + }); + } + + delete(...id: number[]) { + this.sensorsService.delete( ...id ).subscribe( + ( res: any) => { + if (res.code === 1) { + this.load(); + this.msgSrv.success(this.grid.title + '���������������'); + } + } + ); + } + + deleteSelected() { + this.confirmServ.confirm({ + title: '������������', + content: '������������������������������������������������', + okText: '������', + cancelText: '������' + }).on('onOk', () => { + if (this.grid.selectedIndexs != null && this.grid.selectedIndexs.length > 0) { + const ids = this.grid.selectedIndexs.map( + (index: number) => { + const id = this.grid.data[index].id; + return Number.parseInt(id); + } + ); + this.delete( ...ids ); + } + }); + } + sort(field: string, value: string) { + // ������������field + this.grid.sorts = this.grid.sorts.filter( + (fn: string) => { + return fn !== field; + } + ); + // ������value������null������������������������������filed + if ( value != null ) { + this.grid.sorts.push(field); + } + this.load(); } } diff --git a/src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.html b/src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.html new file mode 100644 index 0000000..0147609 --- /dev/null +++ b/src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.html @@ -0,0 +1,64 @@ +<div class="modal-header"> + <div class="modal-title">{{ data.id != null ? '������' : '������'}} - ������</div> +</div> +<form [formGroup]="validateForm" (ngSubmit)="save($event,validateForm.value,validateForm.valid)" nz-form [nzType]="'horizontal'"> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label nz-form-item-required>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="10" nzHasFeedback> + <nz-input formControlName="name" maxlength="20" [nzPlaceHolder]="'������'"> + </nz-input> + </div> + </div> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label nz-form-item-required>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="5" nzHasFeedback> + <nz-input formControlName="key" maxlength="20" [nzPlaceHolder]="'������'"> + </nz-input> + </div> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="7" nzHasFeedback> + <nz-input formControlName="unit" maxlength="20" [nzPlaceHolder]="'������'"> + </nz-input> + </div> + </div> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="5" nzHasFeedback> + <nz-input-number [ngStyle]="{'width': '100%' }" formControlName="lower" > + </nz-input-number> + </div> + <div nz-form-control nz-col [nzSpan]="2" nzHasFeedback></div> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="5" nzHasFeedback> + <nz-input-number [ngStyle]="{'width': '100%' }" formControlName="upper" > + </nz-input-number> + </div> + </div> + <div nz-form-item nz-row class="mb-sm"> + <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> + <label>������</label> + </div> + <div nz-form-control nz-col [nzSpan]="16" nzHasFeedback> + <nz-input formControlName="description" maxlength="100"></nz-input> + </div> + </div> + <div class="modal-footer"> + <button nz-button type="button" (click)="close()">������</button> + <button nz-button [nzType]="'primary'" [nzLoading]="isSaving"> + <span> + ������ + <span *ngIf="isSaving">���</span> + </span> + </button> + </div> +</form> \ No newline at end of file diff --git a/src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.ts b/src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.ts new file mode 100644 index 0000000..4d06e27 --- /dev/null +++ b/src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.ts @@ -0,0 +1,64 @@ +import { NzModalSubject } from 'ng-zorro-antd'; +import { Sensor } from '@business/entity/data'; +import { Component, OnInit } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { SensorsService } from '@business/services/http/sensors.service'; + +@Component({ + selector: 'app-sensor-edit', + templateUrl: './sensor-edit.component.html', + styles: [] +}) +export class SensorEditComponent implements OnInit { + data: Sensor; + isSaving = false; + validateForm: FormGroup; + constructor( + private subject: NzModalSubject, + private formBuilder: FormBuilder, + private organizationService: SensorsService + ) { } + + ngOnInit() { + const data = this.data; + const validates: Sensor = { + name: [data.name, [Validators.required] ], + key: [data.key, [Validators.required] ], + lower: [data.lower ], + upper: [data.upper ], + unit: [data.unit ], + description: [data.description ] + }; + this.validateForm = this.formBuilder.group( + validates + ); + } + close() { + this.subject.destroy(); + } + save($event, value, valid) { + $event.preventDefault(); + if (valid) { + for (const i in this.validateForm.controls) { + this.validateForm.controls[ i ].disable(); + } + this.isSaving = true; + Object.keys(value).forEach( (key: string) => { + // '_'������������������������������ + if (!key.startsWith('_') && value[key] != null) { + this.data[key] = value[key]; + } + } ); + this.subject.next( this ); + }else { + this.validate(); + } + } + validate() { + for (const i in this.validateForm.controls) { + this.validateForm.controls[ i ].markAsDirty(); + } + } + + +} diff --git a/src/app/routes/sensors/sensors.module.ts b/src/app/routes/sensors/sensors.module.ts index 73e08a1..440d5e9 100644 --- a/src/app/routes/sensors/sensors.module.ts +++ b/src/app/routes/sensors/sensors.module.ts @@ -1,7 +1,13 @@ +import { SensorsService } from '@business/services/http/sensors.service'; import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { BasicInfoComponent } from './basic-info/basic-info.component'; import {RouterModule, Routes} from '@angular/router'; +import { PipeModule } from '@business/pipe/pipe.module'; +import { SharedModule } from '@shared/shared.module'; +import { _HttpClient } from '@delon/theme/services/http/http.client'; +import { FormBuilder } from '@angular/forms'; +import { SensorEditComponent } from './basic-info/sensor-edit/sensor-edit.component'; const routes: Routes = [ { @@ -11,12 +17,20 @@ ] } ]; - +const COMPONENTS_NOROUNT = [SensorEditComponent]; @NgModule({ imports: [ + // ������������������������������������ + PipeModule, CommonModule, + SharedModule, RouterModule.forChild(routes) ], - declarations: [BasicInfoComponent] + declarations: [ + BasicInfoComponent, + SensorEditComponent + ], + providers: [SensorsService, _HttpClient, FormBuilder], + entryComponents: COMPONENTS_NOROUNT }) export class SensorsModule { } diff --git a/src/app/routes/systems/account/account.component.ts b/src/app/routes/systems/account/account.component.ts index 69ff1db..74a47ba 100644 --- a/src/app/routes/systems/account/account.component.ts +++ b/src/app/routes/systems/account/account.component.ts @@ -3,7 +3,7 @@ import {ModalHelper} from '@delon/theme'; import {HttpClient} from '@angular/common/http'; import {environment} from '../../../../environments/environment'; -import {DateService} from '../../../core/services/date.service'; +import {DateService} from '@business/services/util/date.service'; import {AccountEditComponent} from './account-edit/account-edit.component'; @Component({ selector: 'app-account', diff --git a/src/app/routes/systems/organization/organization-config/organization-config.component.html b/src/app/routes/systems/organization/organization-config/organization-config.component.html new file mode 100644 index 0000000..a4c3222 --- /dev/null +++ b/src/app/routes/systems/organization/organization-config/organization-config.component.html @@ -0,0 +1,67 @@ +<form> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <p>111111111111111111111111111<br/> + 222222222222222222222222222<br/> + 333333333333333333333333333<br/> + </p> + <footer-toolbar errorCollect> + <button nz-button type="button" (click)="backToList()">������</button> + <button nz-button [nzType]="'primary'" [nzLoading]="isSaving"> + <span> + ������ + <span *ngIf="isSaving">���</span> + </span> + </button> + </footer-toolbar> +</form> diff --git a/src/app/routes/systems/organization/organization-config/organization-config.component.ts b/src/app/routes/systems/organization/organization-config/organization-config.component.ts new file mode 100644 index 0000000..f9fdffa --- /dev/null +++ b/src/app/routes/systems/organization/organization-config/organization-config.component.ts @@ -0,0 +1,24 @@ +import { Organization } from '@business/entity/data'; +import { Component, OnInit } from '@angular/core'; +import { OrganizationService } from '@business/services/http/organization.service'; + +@Component({ + selector: 'app-organization-config', + templateUrl: './organization-config.component.html', + styles: [] +}) +export class OrganizationConfigComponent implements OnInit { + organization: Organization; + constructor( + private organizationService: OrganizationService + ) { + console.log(this.organizationService.data); + } + + ngOnInit() { + } + backToList() { + this.organizationService.handle = 'list'; + this.organizationService.title = '������������'; + } +} diff --git a/src/app/routes/systems/organization/organization-edit/organization-edit.component.html b/src/app/routes/systems/organization/organization-edit/organization-edit.component.html index 7830d63..b945e8e 100644 --- a/src/app/routes/systems/organization/organization-edit/organization-edit.component.html +++ b/src/app/routes/systems/organization/organization-edit/organization-edit.component.html @@ -14,7 +14,7 @@ <label>������</label> </div> <div nz-form-control nz-col [nzSpan]="4" nzHasFeedback> - <nz-select style="width: 120px;" formControlName="rank" [nzPlaceHolder]="'������ ������'"> + <nz-select style="width:100%;" formControlName="rank" [nzPlaceHolder]="'������ ������'"> <nz-option *ngFor="let option of rankOptions" [nzLabel]="option.label" [nzValue]="option.value" [nzDisabled]="option.disabled"> </nz-option> </nz-select> @@ -58,15 +58,16 @@ <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> <label nz-form-item-required>������������</label> </div> - <div nz-form-control nz-col [nzSpan]="7" nzHasFeedback> - <nz-datepicker nzSize="large" style="width: 90%;" formControlName="createTime" nzShowTime [nzPlaceHolder]="'������������'" + <div nz-form-control nz-col [nzSpan]="6" nzHasFeedback> + <nz-datepicker nzSize="large" style="width:100%;" formControlName="createTime" nzShowTime [nzPlaceHolder]="'������������'" [nzFormat]="'YYYY-MM-DD HH:mm:ss'" ></nz-datepicker> </div> + <div nz-form-control nz-col [nzSpan]="1" nzHasFeedback></div> <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> <label nz-form-item-required>������������</label> </div> <div nz-form-control nz-col [nzSpan]="7" nzHasFeedback> - <nz-datepicker nzSize="large" style="width: 90%;" formControlName="expireTime" nzShowTime [nzPlaceHolder]="'������������'" + <nz-datepicker nzSize="large" style="width:100%;" formControlName="expireTime" nzShowTime [nzPlaceHolder]="'������������'" [nzFormat]="'YYYY-MM-DD HH:mm:ss'" ></nz-datepicker> </div> </div> diff --git a/src/app/routes/systems/organization/organization-edit/organization-edit.component.ts b/src/app/routes/systems/organization/organization-edit/organization-edit.component.ts index 03a2dd4..24427f4 100644 --- a/src/app/routes/systems/organization/organization-edit/organization-edit.component.ts +++ b/src/app/routes/systems/organization/organization-edit/organization-edit.component.ts @@ -1,5 +1,5 @@ -import { Organization } from './../organization.component'; -import { AreacodeService } from './../../../../core/services/areacode.service'; +import { Organization } from '@business/entity/data'; +import { AreacodeService } from '@business/services/http/areacode.service'; import { Component, OnInit } from '@angular/core'; import { NzMessageService, NzModalSubject } from 'ng-zorro-antd'; import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'; diff --git a/src/app/routes/systems/organization/organization-list/organization-list.component.html b/src/app/routes/systems/organization/organization-list/organization-list.component.html new file mode 100644 index 0000000..ead90fe --- /dev/null +++ b/src/app/routes/systems/organization/organization-list/organization-list.component.html @@ -0,0 +1,66 @@ +<nz-card [nzBordered]="false"> + <div class="mb-md"> + <button nz-button (click)="addOrModify()" [nzType]="'primary'" [nzSize]="'large'"> + <i class="anticon anticon-plus"></i><span>������</span> + </button> + <ng-container *ngIf="grid.selectedIndexs.length > 0"> + <button nz-button [nzSize]="'large'" (click)="deleteSelected()">������������</button> + </ng-container> + <nz-input [ngStyle]="{'width': '280px','float':'right'}" [(ngModel)]="queryMap.value" name="" [nzPlaceHolder]="queryMap.text" + (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> + </div> + <div class="mb-md"> + <nz-alert *ngIf="grid.selectedIndexs.length > 0" [nzType]="'info'" [nzShowIcon]="true"> + <span alert-body> + ���������<strong class="text-primary">{{grid.selectedIndexs.length}}</strong>��� + </span> + </nz-alert> + </div> + <nz-table #nzTable + [nzAjaxData]="grid.data" + [nzTotal]="grid.total" + [(nzPageIndex)]="grid.pageIndex" + [(nzPageSize)]="grid.pageSize" + [nzLoading]="grid.loading" + [nzShowTotal]="true" + (nzPageIndexChange)="load()"> + <thead nz-thead> + <tr> + <th nz-th [nzCheckbox]="true"> + <label nz-checkbox [(ngModel)]="grid.allChecked" [nzIndeterminate]="grid.indeterminate" (ngModelChange)="grid.checkAll($event)"></label> + </th> + <th nz-th *ngFor="let col of grid.columns" + [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}" > + <span>{{ col.text }}</span> + <nz-table-sort *ngIf="col.isSort" [(nzValue)]="col.sort" (nzValueChange)="sort(col.name,$event)"></nz-table-sort> + </th> + <th nz-th><span>������</span></th> + </tr> + </thead> + <tbody nz-tbody> + <tr nz-tbody-tr *ngFor="let row of nzTable.data"> + <td nz-td [nzCheckbox]="true"> + <label nz-checkbox [(ngModel)]="row.checked" (ngModelChange)="grid.refreshStatus($event)"></label> + </td> + <td nz-td *ngFor="let col of grid.columns" + [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}"> + <span [ngSwitch]="col.type"> + <!-- ������������������������������������ --> + <span *ngSwitchDefault> {{ row[col.name]|tyepHandle:col:row }} </span> + <!-- ������������������������������������ --> + </span> + </td> + <td nz-td> + <a (click)="config(row)">������</a> + <span nz-table-divider></span> + <a (click)="addOrModify(row)">������</a> + <span nz-table-divider></span> + <nz-popconfirm [nzTitle]="'������������������'+grid.title+'���?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > + <a nz-popconfirm>������</a> + </nz-popconfirm> + </td> + </tr> + </tbody> + </nz-table> + </nz-card> + diff --git a/src/app/routes/systems/organization/organization-list/organization-list.component.ts b/src/app/routes/systems/organization/organization-list/organization-list.component.ts new file mode 100644 index 0000000..24e80c5 --- /dev/null +++ b/src/app/routes/systems/organization/organization-list/organization-list.component.ts @@ -0,0 +1,212 @@ +import { Router } from '@angular/router'; +import { ModalHelper } from '@delon/theme'; +import { NzModalService, NzMessageService } from 'ng-zorro-antd'; +import { OrganizationService } from '@business/services/http/organization.service'; +import { Grid, Column, PageBean } from '@business/entity/grid'; +import { Organization } from '@business/entity/data'; +import { Component, OnInit } from '@angular/core'; +import { Subject } from 'rxjs/Subject'; +import { Types } from '@business/enum/types.enum'; +import { OrganizationEditComponent } from 'app/routes/systems/organization/organization-edit/organization-edit.component'; + +@Component({ + selector: 'app-organization-list', + templateUrl: './organization-list.component.html', + styles: [] +}) +export class OrganizationListComponent implements OnInit { + private organization: Organization; + grid: Grid<Organization> = new Grid(null); + queryMap = { text: '���������������', value: ''}; + queryTextStream: Subject<string> = new Subject<string>(); + private initPage() { + this.organization = { + name: { + text: '������', + width: '120px' + }, + rank: { + text: '������', + width: '80px', + format: (value: any, col: Column, row: any) => { + const item = [ + { value: 0, label: '������' }, + { value: 1, label: '������������' }, + { value: 2, label: '���������' }, + { value: 3, label: '������������' }, + { value: 4, label: '���������' }, + { value: 5, label: '���������' } + ].filter( (rankItem: {value: number, label: string }) => { + return rankItem.value === value; + }); + return item != null && item.length === 1 ? item[0].label : ''; + } + }, + telephone: { + text: '������', + width: '120px' + }, + address: { + text: '������', + width: '300px', + format: (value: any, col: Column, row: any) => { + value = value == null ? '' : value ; + if (row['areaNames'] != null) { + return row['areaNames']['provinceName'] + row['areaNames']['cityName'] + row['areaNames']['areaName'] + value; + } else { + return value; + } + + } + }, + createTime: { + text: '������������', + width: '100px', + type: { + name: Types.Date, + format: 'YYYY-MM-DD HH:mm:ss' + }, + isSort: true + }, + expireTime: { + text: '������������', + width: '100px', + type: { + name: Types.Date, + format: 'YYYY-MM-DD HH:mm:ss' + }, + isSort: true + } + }; + this.grid.title = '������'; + this.grid.setColumns(this.organization); + this.grid.pageSize = 10; + } + constructor( + private organizationService: OrganizationService, + + private confirmServ: NzModalService, + public msgSrv: NzMessageService, + private modalHelper: ModalHelper, + private router: Router, + ) {} + + ngOnInit() { + this.initPage(); + this.queryTextStream + .debounceTime(500) + .distinctUntilChanged() + .subscribe(queryText => { + this.load(); + }); + } + queryTextChanged($event) { + this.queryTextStream.next(this.queryMap.value); + } + load(reload: boolean = false) { + if (reload) { + this.grid.pageIndex = 1 ; + } + // ������������������ExpressionChangedAfterItHasBeenCheckedError + setTimeout(() => { + this.grid.loading = true; + }, 1); + this.organizationService.getPagingList(this.grid, this.queryMap.value).subscribe( + (res: PageBean) => { + this.grid.loading = true; + if (res != null && res.data != null) { + this.grid.initData(res); + this.grid.refreshStatus(); + setTimeout(() => { + this.grid.loading = false; + }, 1); + } + } + ); + } + +// rowData���null��������������� + addOrModify(d) { + const data = {}; + if ( d != null) { + Object.assign(data, d); + } + const cols = this.organization; + this.modalHelper.static(OrganizationEditComponent, { cols , data }).subscribe( + ( ret: { data: any, close: Function} ) => { + // ������������ + if (ret.data['index'] != null ) { + const index: number = ret.data['index'] ; + const origData = this.grid.getData()[index]; + const isModified = Object.keys(origData).some( + (key: string) => { + return ret.data[key] !== origData[key]; + } + ); + // ������������ + if (!isModified) { + ret.close(); + this.msgSrv.success('���������������������������'); + return; + } + } + this.organizationService.save(ret.data).subscribe( + ( res: any) => { + if (res.code === 1) { + this.load(); + ret.close(); + this.msgSrv.success('���������������������'); + } + } + ); + }); + } + + delete(...id: number[]) { + this.organizationService.delete( ...id ).subscribe( + ( res: any) => { + if (res.code === 1) { + this.load(); + this.msgSrv.success('���������������������������'); + } + } + ); + } + + deleteSelected() { + this.confirmServ.confirm({ + title: '������������', + content: '������������������������������������������������', + okText: '������', + cancelText: '������' + }).on('onOk', () => { + if (this.grid.selectedIndexs != null && this.grid.selectedIndexs.length > 0) { + const ids = this.grid.selectedIndexs.map( + (index: number) => { + const id = this.grid.data[index].id; + return Number.parseInt(id); + } + ); + this.delete( ...ids ); + } + }); + } + sort(field: string, value: string) { + // ������������field + this.grid.sorts = this.grid.sorts.filter( + (fn: string) => { + return fn !== field; + } + ); + // ������value������null������������������������������filed + if ( value != null ) { + this.grid.sorts.push(field); + } + this.load(); + } + config(row) { + this.organizationService.handle = 'config' ; + this.organizationService.data = row; + this.organizationService.title = '������������'; + } +} diff --git a/src/app/routes/systems/organization/organization.component.html b/src/app/routes/systems/organization/organization.component.html index ed0b257..bee33d6 100644 --- a/src/app/routes/systems/organization/organization.component.html +++ b/src/app/routes/systems/organization/organization.component.html @@ -1,65 +1,8 @@ -<pro-header [title]="grid.title"></pro-header> -<nz-card [nzBordered]="false"> - <div class="mb-md"> - <button nz-button (click)="addOrModify()" [nzType]="'primary'" [nzSize]="'large'"> - <i class="anticon anticon-plus"></i><span>������</span> - </button> - <ng-container *ngIf="grid.selectedIndexs.length > 0"> - <button nz-button [nzSize]="'large'" (click)="deleteSelected()">������������</button> - </ng-container> - <nz-input [ngStyle]="{'width': '280px','float':'right'}" [(ngModel)]="queryMap.value" name="" [nzPlaceHolder]="queryMap.text" - (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> - </div> - <div class="mb-md"> - <nz-alert *ngIf="grid.selectedIndexs.length > 0" [nzType]="'info'" [nzShowIcon]="true"> - <span alert-body> - ���������<strong class="text-primary">{{grid.selectedIndexs.length}}</strong>��� - </span> - </nz-alert> - </div> - <nz-table #nzTable - [nzAjaxData]="grid.data" - [nzTotal]="grid.total" - [(nzPageIndex)]="grid.pageIndex" - [(nzPageSize)]="grid.pageSize" - [nzLoading]="grid.loading" - [nzShowTotal]="true" - (nzPageIndexChange)="load()"> - <thead nz-thead> - <tr> - <th nz-th [nzCheckbox]="true"> - <label nz-checkbox [(ngModel)]="grid.allChecked" [nzIndeterminate]="grid.indeterminate" (ngModelChange)="grid.checkAll($event)"></label> - </th> - <th nz-th *ngFor="let col of grid.columns" - [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}" > - <span>{{ col.text }}</span> - <nz-table-sort *ngIf="col.isSort" [(nzValue)]="col.sort" (nzValueChange)="sort(col.name,$event)"></nz-table-sort> - </th> - <th nz-th><span>������</span></th> - </tr> - </thead> - <tbody nz-tbody> - <tr nz-tbody-tr *ngFor="let row of nzTable.data"> - <td nz-td [nzCheckbox]="true"> - <label nz-checkbox [(ngModel)]="row.checked" (ngModelChange)="grid.refreshStatus($event)"></label> - </td> - <td nz-td *ngFor="let col of grid.columns" - [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}"> - <span [ngSwitch]="col.type"> - <!-- ������������������������������������ --> - <span *ngSwitchDefault> {{ row[col.name]|tyepHandle:col:row }} </span> - <!-- ������������������������������������ --> - </span> - </td> - <td nz-td> - <a (click)="addOrModify(row)">������</a> - <span nz-table-divider></span> - <nz-popconfirm [nzTitle]="'���������������������������?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > - <a nz-popconfirm>������</a> - </nz-popconfirm> - </td> - </tr> - </tbody> - </nz-table> - </nz-card> +<pro-header [title]="organizationService.title"></pro-header> +<nz-card [nzBordered]="false" [nzNoHovering]="true"> + <ng-template #body> + <app-organization-list *ngIf="organizationService.handle=='list'"></app-organization-list> + <app-organization-config *ngIf="organizationService.handle=='config'"></app-organization-config> + </ng-template> +</nz-card> diff --git a/src/app/routes/systems/organization/organization.component.ts b/src/app/routes/systems/organization/organization.component.ts index 5aa3a9a..d417498 100644 --- a/src/app/routes/systems/organization/organization.component.ts +++ b/src/app/routes/systems/organization/organization.component.ts @@ -1,36 +1,7 @@ -import { DataType, AreaNames } from './../../../core/entity/grid'; -import { Version, ValueTransformer } from '@angular/compiler/src/util'; -import { Subject } from 'rxjs/Subject'; -import { ToolsService } from '@core/services/tools.service'; +import { OrganizationService } from '@business/services/http/organization.service'; import { Component, OnInit } from '@angular/core'; -import { NzMessageService, NzModalService } from 'ng-zorro-antd'; -import { ModalHelper } from '@delon/theme'; -import { HttpClient } from '@angular/common/http'; -import { environment } from '../../../../environments/environment'; -import { DateService } from '@core/services/date.service'; -import { VersionService } from 'app/routes/devices/version/version.service'; -import { Types } from '@core/enum/types.enum'; -import { Column, Grid, PageBean } from '@core/entity/grid'; -import { filter } from 'rxjs/operators/filter'; -import { OrganizationEditComponent } from './organization-edit/organization-edit.component'; -import { OrganizationService } from 'app/routes/systems/organization/organization.service'; -export interface Organization { - address?: Column|any; - areaCode?: Column|any; - cityCode?: Column|any; - createTime?: Column|any; - description?: Column|any; - email?: Column|any; - expireTime?: Column|any; - id?: Column|any; - isDelete?: Column|any; - name?: Column|any; - provinceCode?: Column|any; - rank?: Column|any; - telephone?: Column|any; - areaNames?: AreaNames|any ; -} + @Component({ selector: 'app-organization', @@ -38,198 +9,10 @@ styles: [] }) export class OrganizationComponent implements OnInit { - - private organization: Organization; - grid: Grid<Organization> = new Grid(null); - queryMap = { text: '���������������', value: ''}; - queryTextStream: Subject<string> = new Subject<string>(); - private initPage() { - this.organization = { - name: { - text: '������', - width: '120px' - }, - rank: { - text: '������', - width: '80px', - format: (value: any, col: Column, row: any) => { - const item = [ - { value: 0, label: '������' }, - { value: 1, label: '������������' }, - { value: 2, label: '���������' }, - { value: 3, label: '������������' }, - { value: 4, label: '���������' }, - { value: 5, label: '���������' } - ].filter( (rankItem: {value: number, label: string }) => { - return rankItem.value === value; - }); - return item != null && item.length === 1 ? item[0].label : ''; - } - }, - telephone: { - text: '������', - width: '180px' - }, - address: { - text: '������', - width: '300px', - format: (value: any, col: Column, row: any) => { - value = value == null ? '' : value ; - if (row['areaNames'] != null) { - return row['areaNames']['provinceName'] + row['areaNames']['cityName'] + row['areaNames']['areaName'] + value; - } else { - return value; - } - - } - }, - createTime: { - text: '������������', - width: '100px', - type: { - name: Types.Date, - format: 'YYYY-MM-DD HH:mm:ss' - }, - isSort: true - }, - expireTime: { - text: '������������', - width: '100px', - type: { - name: Types.Date, - format: 'YYYY-MM-DD HH:mm:ss' - }, - isSort: true - } - }; - this.grid.title = '������������'; - this.grid.setColumns(this.organization); - this.grid.pageSize = 10; + ngOnInit(): void { + } constructor( - private organizationService: OrganizationService, - - private confirmServ: NzModalService, - public msgSrv: NzMessageService, - private modalHelper: ModalHelper, + private organizationService: OrganizationService ) {} - - ngOnInit() { - this.initPage(); - this.queryTextStream - .debounceTime(500) - .distinctUntilChanged() - .subscribe(queryText => { - this.load(); - }); - } - queryTextChanged($event) { - this.queryTextStream.next(this.queryMap.value); - } - load(reload: boolean = false) { - if (reload) { - this.grid.pageIndex = 1 ; - } - // ������������������ExpressionChangedAfterItHasBeenCheckedError - setTimeout(() => { - this.grid.loading = true; - }, 1); - this.organizationService.getPagingList(this.grid, this.queryMap.value).subscribe( - (res: PageBean) => { - this.grid.loading = true; - if (res != null && res.data != null) { - this.grid.initData(res); - this.grid.refreshStatus(); - setTimeout(() => { - this.grid.loading = false; - }, 1); - } - } - ); - } - -// rowData���null��������������� - addOrModify(d) { - const data = {}; - if ( d != null) { - Object.assign(data, d); - } - const cols = this.organization; - this.modalHelper.static(OrganizationEditComponent, { cols , data }).subscribe( - ( ret: { data: any, close: Function} ) => { - // ������������ - if (ret.data['index'] != null ) { - const index: number = ret.data['index'] ; - const origData = this.grid.getData()[index]; - const isModified = Object.keys(origData).some( - (key: string) => { - return ret.data[key] !== origData[key]; - } - ); - // ������������ - if (!isModified) { - ret.close(); - this.msgSrv.success('���������������������������'); - return; - } - } - this.organizationService.save(ret.data).subscribe( - ( res: any) => { - if (res.code === 1) { - this.load(); - ret.close(); - this.msgSrv.success('���������������������'); - } - } - ); - }); - } - - delete(...id: number[]) { - this.organizationService.delete( ...id ).subscribe( - ( res: any) => { - if (res.code === 1) { - this.load(); - this.msgSrv.success('���������������������������'); - } - } - ); - } - - deleteSelected() { - this.confirmServ.confirm({ - title: '������������', - content: '������������������������������������������������', - okText: '������', - cancelText: '������' - }).on('onOk', () => { - if (this.grid.selectedIndexs != null && this.grid.selectedIndexs.length > 0) { - const ids = this.grid.selectedIndexs.map( - (index: number) => { - const id = this.grid.data[index].id; - return Number.parseInt(id); - } - ); - this.delete( ...ids ); - } - }); - } - sort(field: string, value: string) { - // ������������field - this.grid.sorts = this.grid.sorts.filter( - (fn: string) => { - return fn !== field; - } - ); - // ������value������null������������������������������filed - if ( value != null ) { - this.grid.sorts.push(field); - } - this.load(); - } - - reset(ls: any[]) { - for (const item of ls) item.value = false; - this.load(true); - } } diff --git a/src/app/routes/systems/systems.module.ts b/src/app/routes/systems/systems.module.ts index 7c14ab3..7404c54 100644 --- a/src/app/routes/systems/systems.module.ts +++ b/src/app/routes/systems/systems.module.ts @@ -5,15 +5,16 @@ import { CommonModule } from '@angular/common'; import { RouterModule, Routes } from '@angular/router'; import { SharedModule } from '@shared/shared.module'; - import { AccountComponent } from './account/account.component'; import { AccountEditComponent } from './account/account-edit/account-edit.component'; import { OrganizationComponent } from './organization/organization.component'; -import { PipeModule } from '@core/pipe/pipe.module'; +import { PipeModule } from '@business/pipe/pipe.module'; import { OrganizationEditComponent } from './organization/organization-edit/organization-edit.component'; -import { ToolsService } from '@core/services/tools.service'; -import { OrganizationService } from 'app/routes/systems/organization/organization.service'; -import { AreacodeService } from '@core/services/areacode.service'; +import { ToolsService } from '@business/services/util/tools.service'; +import { OrganizationService } from '@business/services/http/organization.service'; +import { AreacodeService } from '@business/services/http/areacode.service'; +import { OrganizationConfigComponent } from './organization/organization-config/organization-config.component'; +import { OrganizationListComponent } from './organization/organization-list/organization-list.component'; const routes: Routes = [ { @@ -39,7 +40,9 @@ ...COMPONENTS_NOROUNT, AccountComponent, AccountEditComponent, - OrganizationComponent + OrganizationComponent, + OrganizationConfigComponent, + OrganizationListComponent ], providers: [ToolsService, OrganizationService, _HttpClient, FormBuilder, AreacodeService], entryComponents: COMPONENTS_NOROUNT diff --git a/src/app/routes/users/alarm-user/alarm-user.component.ts b/src/app/routes/users/alarm-user/alarm-user.component.ts index 1c0996f..a447e3c 100644 --- a/src/app/routes/users/alarm-user/alarm-user.component.ts +++ b/src/app/routes/users/alarm-user/alarm-user.component.ts @@ -3,7 +3,7 @@ import {ModalHelper} from '@delon/theme'; import {HttpClient} from '@angular/common/http'; import {environment} from '../../../../environments/environment'; -import {DateService} from '../../../core/services/date.service'; +import {DateService} from '@business/services/util/date.service'; import {AlarmUserEditComponent} from './alarm-user-edit/alarm-user-edit.component'; @Component({ diff --git a/src/app/routes/users/installer/edit/edit.component.ts b/src/app/routes/users/installer/edit/edit.component.ts index 6509fe4..f02cabf 100644 --- a/src/app/routes/users/installer/edit/edit.component.ts +++ b/src/app/routes/users/installer/edit/edit.component.ts @@ -2,8 +2,8 @@ import {Component, OnInit} from '@angular/core'; import {ModalHelper} from '@delon/theme'; import {HttpClient} from '@angular/common/http'; -import {environment} from '../../../../../environments/environment'; -import {DateService} from '../../../../core/services/date.service'; +import {environment} from 'environments/environment'; +import {DateService} from '@business/services/util/date.service'; import {FormGroup, FormBuilder, FormControl, Validators} from '@angular/forms'; @Component({ diff --git a/src/app/routes/users/installer/installer.component.ts b/src/app/routes/users/installer/installer.component.ts index f59a364..94a17cb 100644 --- a/src/app/routes/users/installer/installer.component.ts +++ b/src/app/routes/users/installer/installer.component.ts @@ -4,7 +4,7 @@ import {HttpClient} from '@angular/common/http'; import {UserInstallerEditComponent} from './edit/edit.component'; import {environment} from '../../../../environments/environment'; -import {DateService} from '../../../core/services/date.service'; +import {DateService} from '@business/services/util/date.service'; @Component({ selector: 'app-installer', diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 7bf1fa4..f2d4422 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -16,19 +16,6 @@ import { TranslateModule } from '@ngx-translate/core'; import { I18NService } from '@core/i18n/i18n.service'; -// region: zorro modules -// Statics -import 'rxjs/add/observable/throw'; - -// Operators -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/debounceTime'; -import 'rxjs/add/operator/distinctUntilChanged'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/switchMap'; -import 'rxjs/add/operator/toPromise'; -import 'rxjs/add/operator/filter'; - import { // LoggerModule, // NzLocaleModule, diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 29f6da9..de2e6ef 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -9,7 +9,9 @@ "@shared": [ "app/shared" ], "@shared/*": [ "app/shared/*" ], "@core": [ "app/core/" ], - "@core/*": [ "app/core/*" ] + "@core/*": [ "app/core/*" ], + "@business": [ "app/business/" ], + "@business/*": [ "app/business/*" ] } }, "exclude": [ diff --git a/src/tsconfig.spec.json b/src/tsconfig.spec.json index f460cf7..34d8bf6 100644 --- a/src/tsconfig.spec.json +++ b/src/tsconfig.spec.json @@ -13,7 +13,9 @@ "@shared": [ "app/shared" ], "@shared/*": [ "app/shared/*" ], "@core": [ "app/core/" ], - "@core/*": [ "app/core/*" ] + "@core/*": [ "app/core/*" ], + "@business": [ "app/business/" ], + "@business/*": [ "app/business/*" ] } }, "files": [ diff --git a/tsconfig.json b/tsconfig.json index 55ffe6b..448f1bd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,9 @@ "@shared": [ "app/shared" ], "@shared/*": [ "app/shared/*" ], "@core": [ "app/core/" ], - "@core/*": [ "app/core/*" ] + "@core/*": [ "app/core/*" ], + "@business": [ "app/business/" ], + "@business/*": [ "app/business/*" ] } } } -- Gitblit v1.8.0