From f320f1970e5d80a423f377fb3253628bd1e7f5bf Mon Sep 17 00:00:00 2001 From: 沈斌 <bluelazysb@hotmail.com> Date: Thu, 08 Mar 2018 15:10:46 +0800 Subject: [PATCH] Merge branch 'develop' of ssh://121.40.92.176:29418/screen-frontend into develop --- src/app/routes/devices/devices.module.ts | 8 src/app/business/services/http/device-adjust-value.service.ts | 8 src/app/business/services/http/sensors.service.ts | 12 src/app/routes/users/installer/edit/edit.component.ts | 16 src/app/routes/users/users.module.ts | 2 src/app/business/services/http/organization.service.ts | 2 src/app/routes/analysis/analysis.module.ts | 4 src/app/routes/systems/account/account.component.ts | 10 src/app/routes/devices/monitor-point/monitor-point-edit/monitor-point-edit.component.ts | 2 src/app/routes/devices/version/version-edit/version-edit.component.ts | 2 src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts | 2 src/app/business/services/http/login.service.ts | 20 src/app/routes/map/coordinates-picker/coordinates-picker.component.ts | 72 +- src/app/routes/devices/basic-info/device-edit/device-edit.component.ts | 54 +- src/app/routes/users/alarm-user/alarm-user.component.ts | 8 src/app/routes/devices/monitor-point/monitor-point.component.ts | 6 src/app/routes/dashboard/v1/v1.component.ts | 2 src/app/business/services/http/device.service.ts | 6 src/app/routes/map/coordinates-picker/coordinates-picker.service.ts | 12 src/app/business/services/http/alarm-config.service.ts | 24 src/app/business/services/http/monitor-point.service.ts | 33 + src/app/business/services/util/example.service.ts | 10 src/app/routes/systems/organization/organization-list/organization-list.component.ts | 8 src/app/routes/devices/basic-info/basic-info.component.ts | 40 src/app/business/entity/token.ts | 8 src/app/business/entity/grid.ts | 4 src/app/routes/map/map.module.ts | 4 src/app/routes/users/installer/installer.component.ts | 6 tslint.json | 2 src/app/routes/systems/organization/organization-config/organization-config.component.html | 2 src/app/core/i18n/i18n.service.ts | 2 src/app/business/enum/patterns.enum.ts | 2 src/app/business/enum/types.enum.ts | 15 src/app/business/services/util/tools.service.ts | 20 src/app/business/entity/data.ts | 46 +- src/app/routes/systems/organization/organization-edit/organization-edit.component.ts | 2 src/app/routes/analysis/query/query.component.ts | 339 ++++++++++++++-- src/app/routes/systems/systems.module.ts | 2 src/app/routes/systems/organization/organization-config/organization-config.component.ts | 139 +++--- src/app/core/net/default.interceptor.ts | 11 src/app/routes/routes-routing.module.ts | 2 src/app/routes/passport/login/login.component.ts | 44 - src/app/business/services/http/version.service.ts | 2 src/app/routes/devices/basic-info/basic-info.component.html | 2 src/app/routes/devices/basic-info/adjust-config/adjust-config.component.ts | 41 - src/app/app.component.ts | 20 src/app/routes/analysis/query/query.component.html | 154 +++++- src/app/routes/sensors/basic-info/sensor-edit/sensor-edit.component.ts | 2 48 files changed, 794 insertions(+), 440 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 90c68af..00faf0f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -20,7 +20,7 @@ private settings: SettingsService, private router: Router, private titleSrv: TitleService, - private loginService:LoginService) { + private loginService: LoginService) { } ngOnInit() { @@ -32,24 +32,24 @@ ) .subscribe(() => { // ��������������������������������� - let cdkOverlayContainer = $('.cdk-overlay-container'); - if(cdkOverlayContainer!=null&&cdkOverlayContainer.children().length>1){ + const cdkOverlayContainer = $('.cdk-overlay-container'); + if (cdkOverlayContainer != null && cdkOverlayContainer.children().length > 1) { cdkOverlayContainer.children('div:first-child').nextAll().each( - function(index,element){ - if($(element).hasClass('cdk-overlay-backdrop-showing')){ - $(element).remove(); - }else{ - $(element).empty(); + function(index, el) { + if ($(el).hasClass('cdk-overlay-backdrop-showing')) { + $(el).remove(); + } else { + $(el).empty(); } } ); } // ������������������������ - if($('.ant-modal-close').length>0){ + if ($('.ant-modal-close').length > 0) { $('.ant-modal-close').click(); } // ������������������������ - if($('.ant-select-open').length>0){ + if ($('.ant-select-open').length > 0) { $('.ant-select-open').click(); } }); diff --git a/src/app/business/entity/data.ts b/src/app/business/entity/data.ts index 38e3557..b963553 100644 --- a/src/app/business/entity/data.ts +++ b/src/app/business/entity/data.ts @@ -34,7 +34,7 @@ provinceCode?: Column|any; rank?: Column|any; telephone?: Column|any; - areaNames?: AreaNames|any ; + areaNames?: AreaNames; } // ������������ @@ -77,14 +77,14 @@ export interface AlarmConfigValue { alarmMode: AlarmMode; - alarmLevels:{[key: string]:AlarmSensorLevel}; + alarmLevels: {[key: string]: AlarmSensorLevel}; } export interface AlarmSensorLevel { enable: boolean|any []; increment: number []|any[]; - degressEnable:boolean|any []; + degressEnable: boolean|any []; degression: number []|any []; } export interface Device { @@ -117,15 +117,15 @@ deviceId?: number|any[]; id?: number|any[]; updateTime?: number|any[]; - value?:{[s:string] : number}|any[]; + value?: {[s: string]: number}|any[]; } -export interface CoorPicker{ - longitude:number;// ������ - latitude:number;// ������ - address:string; - describe:string; - name:string; +export interface CoorPicker { + longitude: number; // ������ + latitude: number; // ������ + address: string; + describe: string; + name: string; } export interface UserContext { @@ -134,18 +134,18 @@ organizationId: number; username: string; } -export interface TimePeriod{ - startTime:number;//������������ - endTime:number;//������������ +export interface TimePeriod { + startTime: Date; // ������������ + endTime: Date; // ������������ } -export interface DataCondition{ - timeUnits:TimeUnits;//������ - actualTime:number;//������������ - areaRange:AreaRange;//������������ - areaRangeId:number;//���������������ID +export interface DataCondition { + timeUnits?: TimeUnits; // ������ + actualTime?: Date; // ������������ + areaRange?: AreaRange; // ������������ + areaRangeId?: number; // ���������������ID } -export interface LineChartCriteria{ - sensorKey:String; - timePeriod:TimePeriod; - dataConditions:DataCondition[]; -} \ No newline at end of file +export interface LineChartCriteria { + sensorKey: String; + timePeriod: TimePeriod; + dataConditions: DataCondition[]; +} diff --git a/src/app/business/entity/grid.ts b/src/app/business/entity/grid.ts index f4f5501..9b6440d 100644 --- a/src/app/business/entity/grid.ts +++ b/src/app/business/entity/grid.ts @@ -111,8 +111,8 @@ return arr; } } -export interface ResultBean<T>{ +export interface ResultBean<T> { code?: number; data?: T; message?: string; -} \ No newline at end of file +} diff --git a/src/app/business/entity/token.ts b/src/app/business/entity/token.ts index 44cf4b1..5ddcfef 100644 --- a/src/app/business/entity/token.ts +++ b/src/app/business/entity/token.ts @@ -1,4 +1,4 @@ -export interface Authorization{ - token:string; - refreshToken:string; -} \ No newline at end of file +export interface Authorization { + token: string; + refreshToken: string; +} diff --git a/src/app/business/enum/patterns.enum.ts b/src/app/business/enum/patterns.enum.ts index 5772b61..fcce4b5 100644 --- a/src/app/business/enum/patterns.enum.ts +++ b/src/app/business/enum/patterns.enum.ts @@ -1,3 +1,3 @@ -export enum patterns{ +export enum patterns { num = '(\\-?)\\d+(\\.\\d+)?' } diff --git a/src/app/business/enum/types.enum.ts b/src/app/business/enum/types.enum.ts index 55d7143..7dda4d5 100644 --- a/src/app/business/enum/types.enum.ts +++ b/src/app/business/enum/types.enum.ts @@ -2,12 +2,15 @@ Date, Json } export enum AlarmStyle { - //��������������������������������� - weixin='weixin',email='email',sms='sms',voice='voice' + // ��������������������������������� + weixin= 'weixin', email= 'email', sms= 'sms', voice= 'voice' } -export enum TimeUnits{ - YEAR='YEAR',MONTH='MONTH',DAY='DAY',HOUR='HOUR',MINUTE='MINUTE' +export enum TimeUnits { + YEAR= 'YEAR', MONTH= 'MONTH', DAY= 'DAY', HOUR= 'HOUR', MINUTE= 'MINUTE' } export enum AreaRange { - PROVINCE='PROVINCE',CITY='CITY',AREA='AREA',MONITORPOINT='MONITORPOINT',DEVICE='DEVICE' -} \ No newline at end of file + PROVINCE= 'PROVINCE', CITY= 'CITY', AREA= 'AREA', MONITORPOINT= 'MONITORPOINT', DEVICE= 'DEVICE' +} +export enum ResultCode { + SUCCESS= 1, FAIL= 0 +} diff --git a/src/app/business/services/http/alarm-config.service.ts b/src/app/business/services/http/alarm-config.service.ts index 9fd4271..7e3cd14 100644 --- a/src/app/business/services/http/alarm-config.service.ts +++ b/src/app/business/services/http/alarm-config.service.ts @@ -3,7 +3,7 @@ import { environment } from '@env/environment'; import { Observable } from 'rxjs/Observable'; import { ResultBean } from '@business/entity/grid'; -import { AlarmConfig, AlarmConfigValue,AlarmSensorLevel, AlarmMode } from '@business/entity/data'; +import { AlarmConfig, AlarmConfigValue, AlarmSensorLevel, AlarmMode } from '@business/entity/data'; @Injectable() export class AlarmConfigService { @@ -14,13 +14,13 @@ constructor( private http: _HttpClient) { } - public generateAlarmConfig(sensors: {sensorKey:string} [],alarmConfig?: AlarmConfig): AlarmConfig{ - const _alarmConfig : AlarmConfig = alarmConfig==null || alarmConfig.value == null ? {value:{ - alarmLevels:null, - alarmMode:null - }}: alarmConfig; + public generateAlarmConfig(sensors: {sensorKey: string} [], alarmConfig?: AlarmConfig): AlarmConfig { + const _alarmConfig: AlarmConfig = alarmConfig == null || alarmConfig.value == null ? {value: { + alarmLevels: null, + alarmMode: null + }} : alarmConfig; let alarmLevels = _alarmConfig.value.alarmLevels; - alarmLevels = alarmLevels ==null ?{} :alarmLevels; + alarmLevels = alarmLevels == null ? {} : alarmLevels; sensors.forEach( sensor => { const key = sensor.sensorKey; @@ -28,14 +28,14 @@ alarmLevels[key] == null ? { enable: false, - increment: [0,0,0], + increment: [0, 0, 0], degressEnable: false, - degression: [0,0,0] + degression: [0, 0, 0] } : alarmLevels[key]; } ); _alarmConfig.value.alarmLevels = alarmLevels; - //������������ + // ������������ let alarmMode = _alarmConfig.value.alarmMode; alarmMode = alarmMode == null ? { enable: false, @@ -46,8 +46,8 @@ _alarmConfig.value.alarmMode = alarmMode; return _alarmConfig; } - public getByOid(oid:number):Observable<ResultBean<AlarmConfig>>{ - return this.http.get(this.urls.getByOid,{organizationId:oid}); + public getByOid(oid: number): Observable<ResultBean<AlarmConfig>> { + return this.http.get(this.urls.getByOid, {organizationId: oid}); } public save(data: any): Observable<ResultBean<any>> { return this.http.post(this.urls.save, data); diff --git a/src/app/business/services/http/device-adjust-value.service.ts b/src/app/business/services/http/device-adjust-value.service.ts index abf2f97..e18142a 100644 --- a/src/app/business/services/http/device-adjust-value.service.ts +++ b/src/app/business/services/http/device-adjust-value.service.ts @@ -11,15 +11,15 @@ getByDid: environment.SERVER_BASH_URL + 'device-adjust/get-by-did', save: environment.SERVER_BASH_URL + 'device-adjust/add-or-modify', }; - constructor(private http:_HttpClient) { } + constructor(private http: _HttpClient) { } /** * * @param did ������ID */ - public getByDid(did:number):Observable<ResultBean<DeviceAdjustValue>>{ - return this.http.get(this.urls.getByDid,{deviceId:did}); + public getByDid(did: number): Observable<ResultBean<DeviceAdjustValue>> { + return this.http.get(this.urls.getByDid, {deviceId: did}); } - public save(data:DeviceAdjustValue): Observable<any> { + public save(data: DeviceAdjustValue): Observable<any> { return this.http.post(this.urls.save, data); } } diff --git a/src/app/business/services/http/device.service.ts b/src/app/business/services/http/device.service.ts index 9771877..750e277 100644 --- a/src/app/business/services/http/device.service.ts +++ b/src/app/business/services/http/device.service.ts @@ -13,10 +13,10 @@ save: environment.SERVER_BASH_URL + 'device/add-or-modify', delete: environment.SERVER_BASH_URL + 'device/delete-by-ids' }; - public getListUrl (){ + public getListUrl () { return this.urls.list; } - public getSqlParams(queryText:string){ + public getSqlParams(queryText: string) { const example = new ExampleService(); if (queryText != null && queryText !== '') { example.or().andLike({name: 'name', value: '%' + queryText + '%'}); @@ -28,7 +28,7 @@ delete(...ids: number[]): Observable< ResultBean<any> > { return this.http.post(this.urls.delete, ids); } - public save(data:Device): Observable<any> { + public save(data: Device): Observable<any> { return this.http.post(this.urls.save, data); } } diff --git a/src/app/business/services/http/login.service.ts b/src/app/business/services/http/login.service.ts index 60fd4af..82db473 100644 --- a/src/app/business/services/http/login.service.ts +++ b/src/app/business/services/http/login.service.ts @@ -8,24 +8,24 @@ @Injectable() export class LoginService { - public authorization:Authorization; - public userContext:UserContext; + public authorization: Authorization; + public userContext: UserContext; private urls = { - login:environment.SERVER_BASH_URL+'auth/login', - userContext:environment.SERVER_BASH_URL+'user-context', + login: environment.SERVER_BASH_URL + 'auth/login', + userContext: environment.SERVER_BASH_URL + 'user-context', }; - constructor(private http:HttpClient) { } - public validate(username:string,password:string):Observable<Authorization>{ - return this.http.post(this.urls.login,{username:username,password:password,mode:"Web"}).map( - (res:any) => { + constructor(private http: HttpClient) { } + public validate(username: string, password: string): Observable<Authorization> { + return this.http.post(this.urls.login, {username: username, password: password, mode: 'Web'}).map( + (res: any) => { this.authorization = res; return res; } ); } - public loadUserContext():void{ + public loadUserContext(): void { this.http.get(this.urls.userContext).subscribe( - (res:UserContext) => { + (res: UserContext) => { this.userContext = res; return res; } diff --git a/src/app/business/services/http/monitor-point.service.ts b/src/app/business/services/http/monitor-point.service.ts index 90a65d2..aaf013e 100644 --- a/src/app/business/services/http/monitor-point.service.ts +++ b/src/app/business/services/http/monitor-point.service.ts @@ -15,7 +15,7 @@ list: environment.SERVER_BASH_URL + '/monitor-point/page-list', save: environment.SERVER_BASH_URL + '/monitor-point/add-or-modify', delete: environment.SERVER_BASH_URL + '/monitor-point/delete-by-ids', - getOne:environment.SERVER_BASH_URL + '/monitor-point/get-by-id' + getOne: environment.SERVER_BASH_URL + '/monitor-point/get-by-id' }; constructor(private http: _HttpClient) { } public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { @@ -24,20 +24,39 @@ example.or().andLike({name: 'name', value: '%' + queryText + '%'}); } let orderByClause = ''; - if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { - orderByClause = page.getOrderByClause(); - } + if (!!page) { + if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { + orderByClause = page.getOrderByClause(); + } + } else { + page = {pageIndex: 0, pageSize: 20}; + } const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, queryParams: example.getSqlParam(), orderByClause: orderByClause}; return this.http.get(this.urls.list, param); -} + } + public getPageByExample(page: PageBean, example: ExampleService): Observable<PageBean> { + let orderByClause = ''; + const _queryParams = !!example ? example.getSqlParam() : ''; + if (!!page) { + if ( page.getOrderByClause != null && page.getOrderByClause instanceof Function) { + orderByClause = page.getOrderByClause(); + } + } else { + page = {pageIndex: 0, pageSize: 20}; + } + + const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, + queryParams: _queryParams, orderByClause: orderByClause}; + return this.http.get(this.urls.list, 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); } -public getEntity(id:number):Observable<ResultBean<MonitorPoint>>{ - return this.http.get(this.urls.getOne,{id:id}); +public getEntity(id: number): Observable<ResultBean<MonitorPoint>> { + return this.http.get(this.urls.getOne, {id: id}); } } diff --git a/src/app/business/services/http/organization.service.ts b/src/app/business/services/http/organization.service.ts index 479e611..6f3ff0b 100644 --- a/src/app/business/services/http/organization.service.ts +++ b/src/app/business/services/http/organization.service.ts @@ -12,7 +12,7 @@ @Injectable() export class OrganizationService { handle: 'list'|'config' = 'list'; - config: {pageBean: PageBean,resultBean: ResultBean<AlarmConfig>}; + config: {pageBean: PageBean, resultBean: ResultBean<AlarmConfig>}; data: Organization; title: '������������'|'������������' = '������������'; private urls = { diff --git a/src/app/business/services/http/sensors.service.ts b/src/app/business/services/http/sensors.service.ts index 08c4e3a..1c18e3e 100644 --- a/src/app/business/services/http/sensors.service.ts +++ b/src/app/business/services/http/sensors.service.ts @@ -13,7 +13,7 @@ list: 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', - listByVersionId:environment.SERVER_BASH_URL + '/sensor/list-by-vid', + listByVersionId: environment.SERVER_BASH_URL + '/sensor/list-by-vid', }; constructor(private http: _HttpClient) { } public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { @@ -23,19 +23,19 @@ example.or().andEqualTo({name: 'version', value: queryText}); } let orderByClause = ''; - if(!!page){ + if (!!page) { if (page.getOrderByClause != null && page.getOrderByClause instanceof Function) { orderByClause = page.getOrderByClause(); } - }else{ - page = {pageSize:0,pageIndex:0}; + } else { + page = {pageSize: 0, pageIndex: 0}; } const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, queryParams: example.getSqlParam(), orderByClause: orderByClause}; return this.http.get(this.urls.list, param); } -public getPageByVersionId(versionId:number): Observable<PageBean> { - return this.http.get(this.urls.listByVersionId,{versionId:versionId}); +public getPageByVersionId(versionId: number): Observable<PageBean> { + return this.http.get(this.urls.listByVersionId, {versionId: versionId}); } public save(data: any): Observable<any> { return this.http.post(this.urls.save, data); diff --git a/src/app/business/services/http/version.service.ts b/src/app/business/services/http/version.service.ts index da3387b..8a5861a 100644 --- a/src/app/business/services/http/version.service.ts +++ b/src/app/business/services/http/version.service.ts @@ -29,7 +29,7 @@ orderByClause = page.getOrderByClause(); } const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, - queryParams: example.getSqlParam(), orderByClause:orderByClause}; + queryParams: example.getSqlParam(), orderByClause: orderByClause}; return this.http.get(this.urls.list, param); } public save(data: any): Observable<any> { diff --git a/src/app/business/services/util/example.service.ts b/src/app/business/services/util/example.service.ts index e1427dd..032634a 100644 --- a/src/app/business/services/util/example.service.ts +++ b/src/app/business/services/util/example.service.ts @@ -8,15 +8,15 @@ return this.conditions; } - public addCondition(condition: string, colName:string, ...values: any[]){ + public addCondition(condition: string, colName: string, ...values: any[]) { const split = Criteria.CONDITION_SPLIT; // '||' - this.conditions.push(condition+split + colName + split + values.join(split)); + this.conditions.push(condition + split + colName + split + values.join(split)); } - public andLike(col: { name: string, value: any}): Criteria{ + 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{ + public andEqualTo(col: { name: string, value: any}): Criteria { this.addCondition('andEqualTo', col.name, col.value); return this; } @@ -30,7 +30,7 @@ public getSqlParam(): string { let whereSql = ''; - for (const cri of this.criterion){ + for (const cri of this.criterion) { const conditions = cri.getConditions(); whereSql += ExampleService.OR_SPLIT + conditions.join(ExampleService.CRITERIA_SPLIT); } diff --git a/src/app/business/services/util/tools.service.ts b/src/app/business/services/util/tools.service.ts index affe82f..3facff7 100644 --- a/src/app/business/services/util/tools.service.ts +++ b/src/app/business/services/util/tools.service.ts @@ -3,25 +3,25 @@ @Injectable() export class ToolsService { - public static markAsDirty(controlSet:FormGroup|FormArray){ + public static markAsDirty(controlSet: FormGroup|FormArray) { const controls = controlSet.controls; Object.values(controls).forEach( - (control:AbstractControl) => { - if(control instanceof FormGroup || control instanceof FormArray){ + (control: AbstractControl) => { + if (control instanceof FormGroup || control instanceof FormArray) { ToolsService.markAsDirty(control); - }else{ + } else { control.markAsDirty(); } } - ) + ); } - public static removePrivate(obj:object){ + public static removePrivate(obj: object) { Object.keys(obj).forEach( - (key:string) => { - if(key.startsWith('_')){ + (key: string) => { + if (key.startsWith('_')) { delete obj[key]; - }else{ - if(obj[key] instanceof Object){ + } else { + if (obj[key] instanceof Object) { ToolsService.removePrivate(obj[key]); } } diff --git a/src/app/core/i18n/i18n.service.ts b/src/app/core/i18n/i18n.service.ts index 5ddd4c6..cf17dd2 100644 --- a/src/app/core/i18n/i18n.service.ts +++ b/src/app/core/i18n/i18n.service.ts @@ -10,7 +10,7 @@ private _default = 'zh-CN'; - //������������������ ��������� by fx + // ������������������ ��������� by fx private _langs = [ { code: 'zh-CN', text: '������' }, { code: 'en', text: 'English' } diff --git a/src/app/core/net/default.interceptor.ts b/src/app/core/net/default.interceptor.ts index 5d7b2e0..e18e15a 100644 --- a/src/app/core/net/default.interceptor.ts +++ b/src/app/core/net/default.interceptor.ts @@ -28,7 +28,7 @@ private handleData(event: HttpResponse<any> | HttpErrorResponse): Observable<any> { // ��������������� `throw` ������������������ `_HttpClient` ��� `end()` ������ - this.injector.get(_HttpClient).end(); + // this.injector.get(_HttpClient).end(); // ��������������������������������� switch (event.status) { case 200: @@ -52,7 +52,12 @@ this.goTo(`/${event.status}`); break; } - return of(event); + // ��������������������� httpclient ������������ + if (event instanceof HttpErrorResponse) { + return ErrorObservable.create(event); + } else { + return of(event); + } } intercept(req: HttpRequest<any>, next: HttpHandler): @@ -68,7 +73,7 @@ url: url }); return next.handle(newReq).pipe( - mergeMap((event: any) => { + mergeMap((event: any) => { // ������������������������������������������������������������������������������������������������HTTP������������������200������������������ if (event instanceof HttpResponse && event.status === 200) return this.handleData(event); diff --git a/src/app/routes/analysis/analysis.module.ts b/src/app/routes/analysis/analysis.module.ts index f61ca5e..eef181a 100644 --- a/src/app/routes/analysis/analysis.module.ts +++ b/src/app/routes/analysis/analysis.module.ts @@ -1,3 +1,5 @@ +import { MonitorPointService } from '@business/services/http/monitor-point.service'; +import { AreacodeService } from '@business/services/http/areacode.service'; import { SensorsService } from '@business/services/http/sensors.service'; import { PipeModule } from '@business/pipe/pipe.module'; import { NgModule } from '@angular/core'; @@ -23,6 +25,6 @@ RouterModule.forChild(routes) ], declarations: [QueryComponent], - providers:[SensorsService] + providers: [SensorsService, AreacodeService, MonitorPointService] }) export class AnalysisModule { } diff --git a/src/app/routes/analysis/query/query.component.html b/src/app/routes/analysis/query/query.component.html index 97a90da..8d782a2 100644 --- a/src/app/routes/analysis/query/query.component.html +++ b/src/app/routes/analysis/query/query.component.html @@ -3,49 +3,131 @@ <div nz-col [nzXs]="20" [nzSm]="8" class="header-info"> <p class="text-grey-dark">������������������</p> <nz-dropdown> - <a class="ant-dropdown-link" nz-dropdown> - <p class="display-2">{{ lineChartSensorName }}<i class="anticon anticon-down"></i></p> - </a> - <ul style="height:280px;overflow:auto;" nz-menu> - <li style="width:200px;cursor:pointer;" *ngFor="let sensor of sensorList" - (click) = "lineChartCriteria.sensorKey=sensor.sensorKey" nz-menu-item> - <p> - {{sensor.name}} + <a class="ant-dropdown-link" nz-dropdown> + <p class="display-2">{{ lineChartSensorName }} + <i class="anticon anticon-down"></i> </p> - </li> - </ul> + </a> + <ul style="height:280px; overflow:auto;" nz-menu> + <li style="width:200px; cursor:pointer;" *ngFor="let sensor of sensorList" (click)="lineChartCriteria.sensorKey=sensor.sensorKey" + nz-menu-item> + <p> + {{sensor.name}} + </p> + </li> + </ul> </nz-dropdown> <em></em> </div> <div nz-col [nzXs]="20" [nzSm]="8" class="header-info"> - <p class="text-grey-dark">���������������������</p> - <nz-dropdown> - <a class="ant-dropdown-link" nz-dropdown> - <p class="display-2">{{ timePeriodUnitName }}<i class="anticon anticon-down"></i></p> - </a> - <ul nz-menu> - <li style="width:60px;cursor:pointer;" *ngFor="let item of timeUnits" - (click)="timePeriodUnitValue = item.value" nz-menu-item> - <p> - {{item.label}} - </p> - </li> - </ul> + <p class="text-grey-dark">���������������������</p> + <nz-dropdown> + <a class="ant-dropdown-link" nz-dropdown> + <p class="display-2">{{ timePeriodUnitName }} + <i class="anticon anticon-down"></i> + </p> + </a> + <ul nz-menu> + <li style="width:60px; cursor:pointer;" *ngFor="let item of timeUnits" (click)="timePeriodUnitValue = item.value" nz-menu-item> + <p> + {{item.label}} + </p> + </li> + </ul> </nz-dropdown> <em></em> </div> - <div nz-col [nzSm]="8" class="header-info"> - <p class="text-grey-dark">���������������������</p> - <nz-datepicker style="width: 42%;" - [(ngModel)]="lineChartCriteria.timePeriod.startTime" - [nzDisabledDate]="_disabledStartDate" - nzShowTime="{{ !!timeType.timePickerOption?timeType.timePickerOption:false }}" [nzMode]="timeType.mode" [nzFormat]="timeType.dateFormat" [nzPlaceHolder]="'Start date'"></nz-datepicker> - <span>-</span> - <nz-datepicker style="width: 42%;" - [nzDisabledDate]="_disabledEndDate" - [(ngModel)]="lineChartCriteria.timePeriod.endTime" - nzShowTime="{{ !!timeType.timePickerOption?timeType.timePickerOption:false }}" [nzMode]="timeType.mode" [nzFormat]="timeType.dateFormat" [nzPlaceHolder]="'End date'"></nz-datepicker> + <div *ngIf="_timePeriodUnitValue!='YEAR'; else elseBlock" nz-col [nzSm]="8" class="header-info"> + <p class="text-grey-dark">���������������������</p> + <nz-datepicker style="width: 42%;" [(ngModel)]="lineChartCriteria.timePeriod.startTime" [nzDisabledDate]="_disabledStartDate" + nzShowTime="{{ !!timeType.timePickerOption?timeType.timePickerOption:false }}" [nzMode]="timeType.mode" [nzFormat]="timeType.dateFormat" + [nzPlaceHolder]="'Start date'"></nz-datepicker> + <span>-</span> + <nz-datepicker style="width: 42%;" [nzDisabledDate]="_disabledEndDate" [(ngModel)]="lineChartCriteria.timePeriod.endTime" + nzShowTime="{{ !!timeType.timePickerOption?timeType.timePickerOption:false }}" [nzMode]="timeType.mode" [nzFormat]="timeType.dateFormat" + [nzPlaceHolder]="'End date'"></nz-datepicker> </div> - <input type="button" value="text" width="100px;" (click)="_isSameDay"/> + <ng-template #elseBlock> + <div nz-col [nzSm]="8" class="header-info"> + <p class="text-grey-dark">���������������������</p> + <nz-input-number style="width: 42%;" [(ngModel)]="startYear" [nzMin]="minStartYear" [nzMax]="maxStartYear" [nzStep]="1" [nzAllowClear]="false"></nz-input-number> + <span>-</span> + <nz-input-number style="width: 42%;" [(ngModel)]="endYear" [nzMin]="minEndYear" [nzMax]="maxEndYear" [nzStep]="1" [nzAllowClear]="false"></nz-input-number> + </div> + </ng-template> </div> -</nz-card> \ No newline at end of file +</nz-card> +<nz-card [nzBordered]="true" title="������������"> + <form> + <div nz-row [nzGutter]="16"> + <div nz-col nzMd="6" nzSm="12" nzXs="24"> + <div nz-form-item nz-row> + <div nz-form-label nz-col><label>���������</label></div> + <div nz-form-control nz-col nzHasFeedback> + <nz-cascader [class.class123]="true" (nzChange)="setAreaCodes($event)" (nzLoad)="areaLazyLoad($event)" + [nzPlaceHolder]="'������ ���/���/���'" + [nzAllowClear]="false" + [nzChangeOnSelect] ="true" + [(ngModel)]="_areas" name="_areas"> + </nz-cascader> + </div> + </div> + </div> + <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> + <div nz-form-item nz-row> + <div nz-form-label nz-col><label>���������</label></div> + <div nz-form-control nz-col nzHasFeedback> + <nz-select + name="_monitorPoint" + style="width: 100%;" (click)="monitorPointChange(null)" + [ngModel]="_monitorPoint" + nzAllowClear + (ngModelChange)="setMonitorPoint($event)" + [nzPlaceHolder]="'������ ���������(������������������)'" + nzShowSearch (nzSearchChange)="monitorPointChange($event)" [nzNotFoundContent]="'������������'" > + <nz-option *ngFor="let option of monitorPoints" [nzLabel]="option.name" [nzValue]="option.id"> + </nz-option> + </nz-select> + </div> + + </div> + </div> + <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> + <div nz-form-item nz-row> + <div nz-form-label nz-col><label>������</label></div> + <div nz-form-control nz-col nzHasFeedback> + 11111111111111111 + </div> + + </div> + </div> + </div> + <div style="margin-top: 20px;" nz-row [nzGutter]="16"> + <div nz-col nzMd="6" nzSm="12" nzXs="24"> + <div nz-form-item nz-row> + <div nz-form-label nz-col><label>������������</label></div> + <div nz-form-control nz-col nzHasFeedback> + 222222222 + </div> + + </div> + </div> + <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> + <div nz-form-item nz-row> + <div nz-form-label nz-col><label>������������</label></div> + <div nz-form-control nz-col nzHasFeedback> + 2222222222 + </div> + </div> + </div> + <div nz-col [nzMd]="{span:6, offset:3}" nzSm="12" nzXs="24"> + <div nz-form-item nz-row> + <div nz-form-label nz-col><label>������</label></div> + <div nz-form-control nz-col nzHasFeedback> + 2222222222 + </div> + </div> + </div> + </div> + </form> +</nz-card> diff --git a/src/app/routes/analysis/query/query.component.ts b/src/app/routes/analysis/query/query.component.ts index fea1e49..268f91a 100644 --- a/src/app/routes/analysis/query/query.component.ts +++ b/src/app/routes/analysis/query/query.component.ts @@ -1,11 +1,17 @@ -import { LineChartCriteria, TimePeriod } from '@business/entity/data'; -import { PageBean } from '@business/entity/grid'; +import { ExampleService } from '@business/services/util/example.service'; +import { MonitorPointService } from '@business/services/http/monitor-point.service'; +import { AreacodeService } from '@business/services/http/areacode.service'; +import { DataCondition } from './../../../business/entity/data'; +import { LineChartCriteria, TimePeriod, Organization, MonitorPoint } from '@business/entity/data'; +import { PageBean, ResultBean } from '@business/entity/grid'; import { Sensor } from '@business/entity/data'; import { SensorsService } from '@business/services/http/sensors.service'; import { Component, OnInit } from '@angular/core'; import { _HttpClient } from '@delon/theme'; -import { TimeUnits } from '@business/enum/types.enum'; +import { TimeUnits, AreaRange, ResultCode } from '@business/enum/types.enum'; import * as moment from 'moment'; +import { CascaderOption } from 'ng-zorro-antd/src/cascader/nz-cascader.component'; +import { environment } from '@env/environment'; @Component({ selector: 'app-query', @@ -13,79 +19,322 @@ styleUrls: [ './query.component.less' ] }) export class QueryComponent implements OnInit { - public sensorList:Sensor[]; - public timeUnits:{ label: string, value: TimeUnits, disabled: boolean }[] = []; - // public timePeriod:TimePeriod = {startTime:null,endTime:null}; - public lineChartCriteria:LineChartCriteria = {sensorKey:'e1', timePeriod:{startTime:null,endTime:null},dataConditions:[]}; - - get lineChartSensorName():String{ - return !!this.sensorList?this.sensorList.find( sensor => sensor.sensorKey==this.lineChartCriteria.sensorKey).name:null; + public sensorList: Sensor[]; + public timeUnits: { label: string, value: TimeUnits, disabled: boolean }[] = []; + public lineChartCriteria: LineChartCriteria = {sensorKey: 'e1', timePeriod: {startTime: null, endTime: null}, dataConditions: []}; + _areas: {label: any, value: any}; + _monitorPoint; + public monitorPoints: MonitorPoint[]; + get lineChartSensorName(): String { + return !!this.sensorList ? this.sensorList.find( sensor => sensor.sensorKey === this.lineChartCriteria.sensorKey).name : null; } - private _timePeriodUnitValue:TimeUnits=TimeUnits.DAY; - public set timePeriodUnitValue(value:TimeUnits){ + public _timePeriodUnitValue: TimeUnits = TimeUnits.DAY; + public set timePeriodUnitValue(value: TimeUnits) { this._timePeriodUnitValue = value; - switch(value){ - //YYYY-MM-DD HH:mm:ss + switch (value) { + // YYYY-MM-DD HH:mm:ss case TimeUnits.MONTH: - this.timeType.dateFormat ="YYYY-MM"; - this.timeType.mode = "month"; + this.timeType.dateFormat = 'YYYY-MM'; + this.timeType.mode = 'month'; this.timeType.timePickerOption = null; break; case TimeUnits.DAY: - this.timeType.dateFormat ="YYYY-MM-DD"; - this.timeType.mode = "day"; + this.timeType.dateFormat = 'YYYY-MM-DD'; + this.timeType.mode = 'day'; this.timeType.timePickerOption = null; break; case TimeUnits.HOUR: - this.timeType.dateFormat ="YYYY-MM-DD HH ���"; - this.timeType.timePickerOption = {nzFormat:"HH:mm"}; + this.timeType.dateFormat = 'YYYY-MM-DD HH ���'; + this.timeType.mode = 'day'; + this.timeType.timePickerOption = true; + break; + case TimeUnits.MINUTE: + this.timeType.dateFormat = 'YYYY-MM-DD HH:mm'; + this.timeType.mode = 'day'; + this.timeType.timePickerOption = true; break; } } - public timeType:{dateFormat?:string,mode?:'year'|'month'|'day',timePickerOption?:{}} - = {dateFormat:"YYYY-MM-DD",mode:"day",timePickerOption:null}; - get timePeriodUnitName():String { - return this.timeUnits.find( item => item.value == this._timePeriodUnitValue).label; + public timeType: {dateFormat?: string, mode?: 'month'|'day', timePickerOption?: boolean} + = {dateFormat: 'YYYY-MM-DD', mode: 'day', timePickerOption: null}; + get timePeriodUnitName(): String { + return this.timeUnits.find( item => item.value === this._timePeriodUnitValue).label; } constructor( - private sensorsService:SensorsService - ) { - this.initPage(); + private sensorsService: SensorsService, + private areacodeService: AreacodeService, + private http: _HttpClient, + private monitorPointService: MonitorPointService, + ) { } - private initPage(){ - this.sensorsService.getPagingList(null,null).subscribe( + + private initPage() { + this.sensorsService.getPagingList(null, null).subscribe( (res: PageBean) => { this.sensorList = res.data; } ); this.timeUnits.push( - {label:'���',value:TimeUnits.YEAR,disabled:false}, - {label:'���',value:TimeUnits.MONTH,disabled:false}, - {label:'���',value:TimeUnits.DAY,disabled:false}, - {label:'���',value:TimeUnits.HOUR,disabled:false}, - {label:'���',value:TimeUnits.MINUTE,disabled:false} + {label: '���', value: TimeUnits.YEAR, disabled: false}, + {label: '���', value: TimeUnits.MONTH, disabled: false}, + {label: '���', value: TimeUnits.DAY, disabled: false}, + {label: '���', value: TimeUnits.HOUR, disabled: false}, + {label: '���', value: TimeUnits.MINUTE, disabled: false} + ); + const now = new Date(); + this.lineChartCriteria.timePeriod.startTime = now; + this.lineChartCriteria.timePeriod.endTime = new Date(now.getTime()); + // ��������� ��������� + this.http.get(environment.SERVER_BASH_URL + 'organization/get-my-org').subscribe( + ( res: ResultBean<Organization>) => { + if (res.code === ResultCode.SUCCESS) { + const org = res.data; + if (!!org.areaNames) { + const areaNames = org.areaNames; + this._areas = {label: null, value: null}; + this._areas.label = Object.values(areaNames).filter( + val => !!val + ).join('/'); + if (areaNames.areaName != null) { + this._areas.value = org.areaCode; + this.dataConditionTemp.areaRange = AreaRange.AREA; + this.dataConditionTemp.areaRangeId = org.areaCode; + } else if (areaNames.cityName != null) { + this._areas.value = org.cityCode; + this.dataConditionTemp.areaRange = AreaRange.CITY; + this.dataConditionTemp.areaRangeId = org.cityCode; + } else { + this._areas.value = org.provinceCode; + this.dataConditionTemp.areaRange = AreaRange.PROVINCE; + this.dataConditionTemp.areaRangeId = org.provinceCode; + } + } else { + this._areas = {label: '���������/���������/���������', value: 320583}; + this.dataConditionTemp.areaRange = AreaRange.AREA; + this.dataConditionTemp.areaRangeId = 320583; + } + } + } ); } + monitorPointChange(text) { + const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; + const example = new ExampleService(); + let areaName = ''; + switch (this.dataConditionTemp.areaRange) { + case AreaRange.PROVINCE: + areaName = 'provinceCode'; break; + case AreaRange.CITY: + areaName = 'cityCode'; break; + case AreaRange.AREA: + areaName = 'areaCode'; break; + } + if (!!text) { + example.or().andLike({name: 'name', value: '%' + text + '%'}) + .andEqualTo({name: areaName, value: this.dataConditionTemp.areaRangeId}); + } else { + example.or() + .andEqualTo({name: areaName, value: this.dataConditionTemp.areaRangeId}); + } + this.monitorPointService.getPageByExample(pageBean, example).subscribe( + (res: PageBean) => { + if (!!res && !!res.data) { + this.monitorPoints = res.data; + } + } + ); + } ngOnInit() { + this.initPage(); } get _isSameDay() { - console.log(this.lineChartCriteria.timePeriod.startTime && this.lineChartCriteria.timePeriod.endTime && moment(this.lineChartCriteria.timePeriod.startTime).isSame(this.lineChartCriteria.timePeriod.endTime, 'day')); return this.lineChartCriteria.timePeriod.startTime && this.lineChartCriteria.timePeriod.endTime && moment(this.lineChartCriteria.timePeriod.startTime).isSame(this.lineChartCriteria.timePeriod.endTime, 'day'); } - _disabledStartDate = (startValue) => { + get _startShowTime() { + return this.timeType.timePickerOption ? + {nzHideDisabledOptions: true, + nzDisabledHours: () => { + const endTime = this.lineChartCriteria.timePeriod.endTime; + const hours = this.newArray(50); + return this._isSameDay && !!endTime ? hours.slice(endTime.getHours() + 1, 24) : []; + }, + nzDisabledMinutes: (h) => { + if (this._timePeriodUnitValue === TimeUnits.MINUTE) { + const endTime = this.lineChartCriteria.timePeriod.endTime; + if (this._isSameDay && h === endTime.getHours()) { + const minutes = this.newArray(122); + return minutes.slice(endTime.getMinutes() + 1, 60); + } else { + return []; + } + } else { + return this.newArray(60).slice(1); + } + + }, + nzDisabledSeconds: () => { + return this.newArray(60).slice(1); + } + } : false; + } + get _endShowTime() { + return this.timeType.timePickerOption ? + {nzHideDisabledOptions: true, + nzDisabledHours: () => { + const startTime = this.lineChartCriteria.timePeriod.startTime; + return this._isSameDay && !!startTime ? this.newArray(startTime.getHours()) : []; + }, + nzDisabledMinutes: (h) => { + if (this._timePeriodUnitValue === TimeUnits.MINUTE) { + const startTime = this.lineChartCriteria.timePeriod.startTime; + if (this._isSameDay && h === startTime.getHours()) { + return this.newArray(startTime.getMinutes()); + } else { + return []; + } + + } else { + return this.newArray(60).slice(1); + } + }, + nzDisabledSeconds: () => { + return this.newArray(60).slice(1); + } + } : false; + } + newArray = (len) => { + const result = []; + for (let i = 0; i < len; i++) { + result.push(i); + } + return result; + } + _disabledStartDate = (startValue: Date) => { if (!startValue || !this.lineChartCriteria.timePeriod.endTime) { return false; } - console.log(startValue); - console.log("getTime:"+startValue.getTime()); - let _startValue = moment(startValue,this.timeType.dateFormat); - console.log("valueOf:"+_startValue.valueOf()); - return _startValue.valueOf() > this.lineChartCriteria.timePeriod.endTime; - }; - _disabledEndDate = (endValue) => { + let format = this.timeType.dateFormat; + // ������������������������������ ������������������������ 00.00.00 + if (format.indexOf('H', 11)) { + format = format.replace(/HH.*/, ''); + } + const _startValue = moment(moment(startValue).format(format), format); + return _startValue.valueOf() > this.lineChartCriteria.timePeriod.endTime.getTime(); + } + _disabledEndDate = (endValue: Date) => { if (!endValue || !this.lineChartCriteria.timePeriod.startTime) { return false; } - return endValue.getTime() < this.lineChartCriteria.timePeriod.startTime; - }; + const _endValue: Date = new Date(endValue.getTime()); + _endValue.setHours(23); + _endValue.setMinutes(59); + _endValue.setSeconds(59); + return _endValue.getTime() < this.lineChartCriteria.timePeriod.startTime.getTime(); + } + _timeChange = (type: string) => { + const startTime = this.lineChartCriteria.timePeriod.startTime; + const endTime = this.lineChartCriteria.timePeriod.endTime; + if (type === 'start') { + !!endTime ? '' : this.lineChartCriteria.timePeriod.endTime = startTime; + } else { + !!startTime ? '' : this.lineChartCriteria.timePeriod.startTime === endTime; + } + } + get startYear(): number { + !!this.lineChartCriteria.timePeriod.startTime ? + '' : this.lineChartCriteria.timePeriod.startTime = new Date(); + return this.lineChartCriteria.timePeriod.startTime.getFullYear(); + } + set startYear(value) { + !!this.lineChartCriteria.timePeriod.startTime ? + '' : this.lineChartCriteria.timePeriod.startTime = new Date(); + if (this.startYear === this.endYear && value < this.startYear) { + // ������������������������ + setTimeout(() => { + this.endYear += 1; + }, 1); + } + this.lineChartCriteria.timePeriod.startTime.setFullYear(value); + } + get minStartYear(): number { + const now = new Date(); + return now.getFullYear() - 50; + } + get maxStartYear(): number { + return this.endYear; + } + get endYear(): number { + !!this.lineChartCriteria.timePeriod.endTime ? + '' : this.lineChartCriteria.timePeriod.endTime = new Date(); + return this.lineChartCriteria.timePeriod.endTime.getFullYear(); + } + + set endYear(value) { + !!this.lineChartCriteria.timePeriod.endTime ? + '' : this.lineChartCriteria.timePeriod.endTime = new Date(); + if (this.startYear === this.endYear && value > this.startYear) { + // ������������������������ + setTimeout(() => { + this.startYear -= 1; + }, 1); + } + this.lineChartCriteria.timePeriod.endTime.setFullYear(value); + } + get minEndYear(): number { + return this.startYear; + } + get maxEndYear(): number { + const now = new Date(); + return now.getFullYear() + 50; + } + dataConditionTemp: DataCondition = {}; + 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[]) { + if (!!codes && !!codes.length) { + const n = codes.length; + switch (n) { + case 1: + this.dataConditionTemp.areaRangeId = Number(codes[0]); + this.dataConditionTemp.areaRange = AreaRange.PROVINCE; + break; + case 2: + this.dataConditionTemp.areaRangeId = Number(codes[1]); + this.dataConditionTemp.areaRange = AreaRange.CITY; + break; + case 3: + this.dataConditionTemp.areaRangeId = Number(codes[2]); + this.dataConditionTemp.areaRange = AreaRange.AREA; + break; + } + this._monitorPoint = 1; + } + } + setMonitorPoint(value) { + console.log(value); + this.dataConditionTemp.areaRangeId = value; + this.dataConditionTemp.areaRange = AreaRange.MONITORPOINT; + } } diff --git a/src/app/routes/dashboard/v1/v1.component.ts b/src/app/routes/dashboard/v1/v1.component.ts index e8e6596..860fbe8 100644 --- a/src/app/routes/dashboard/v1/v1.component.ts +++ b/src/app/routes/dashboard/v1/v1.component.ts @@ -10,7 +10,7 @@ export class DashboardV1Component implements OnInit { constructor(private http: _HttpClient, public msg: NzMessageService, - public loginService:LoginService) { } + public loginService: LoginService) { } todoData: any[] = [ { completed: true, avatar: '1', name: '���������', content: `������������������������������������������` }, diff --git a/src/app/routes/devices/basic-info/adjust-config/adjust-config.component.ts b/src/app/routes/devices/basic-info/adjust-config/adjust-config.component.ts index 0332aa3..a29198b 100644 --- a/src/app/routes/devices/basic-info/adjust-config/adjust-config.component.ts +++ b/src/app/routes/devices/basic-info/adjust-config/adjust-config.component.ts @@ -14,9 +14,9 @@ styles: [] }) export class AdjustConfigComponent implements OnInit { - record:Device; - _dataValue:{[s:string]:number} = {}; - data:DeviceAdjustValue; + record: Device; + _dataValue: {[s: string]: number} = {}; + data: DeviceAdjustValue; deviceVersionId: number; isSaving = false; grid: Grid<Sensor> = new Grid(null); @@ -53,12 +53,12 @@ constructor( private subject: NzModalSubject, private sensorsService: SensorsService, - private adjustValueService:DeviceAdjustValueService, + private adjustValueService: DeviceAdjustValueService, public msgSrv: NzMessageService, ) { } ngOnInit() { - if(this.record.deviceVersionId==null){ + if (this.record.deviceVersionId == null) { swal(`������������������������`, '������������������������������������������������������������', 'info'); this.subject.destroy(); } @@ -74,21 +74,21 @@ this.adjustValueService.getByDid(this.record.id), this.sensorsService.getPageByVersionId(this.record.deviceVersionId) ).subscribe( - ([adjustRes,sensorsRes]) => { - if(adjustRes!=null && adjustRes.code==1 && sensorsRes != null && sensorsRes.data != null){ + ([adjustRes, sensorsRes]) => { + if (adjustRes != null && adjustRes.code === 1 && sensorsRes != null && sensorsRes.data != null) { this.data = { - deviceId:this.record.id, - value:{} + deviceId: this.record.id, + value: {} }; - if(adjustRes.data!=null){ + if (adjustRes.data != null) { // ��������������������� - Object.assign(this._dataValue,adjustRes.data.value); - this.data['id'] =adjustRes.data.id; + Object.assign(this._dataValue, adjustRes.data.value); + this.data['id'] = adjustRes.data.id; } this.grid.initData(sensorsRes); sensorsRes.data.forEach( - (item:Sensor) => { - this.data.value[item.sensorKey] = this._dataValue[item.sensorKey] == null?0:this._dataValue[item.sensorKey]; + (item: Sensor) => { + this.data.value[item.sensorKey] = this._dataValue[item.sensorKey] == null ? 0 : this._dataValue[item.sensorKey]; } ); this.grid.refreshStatus(); @@ -104,25 +104,24 @@ } save($event) { // $event.preventDefault(); - let isModify = Object.keys(this._dataValue).length != Object.keys(this.data.value).length; - if(!isModify){ + let isModify = Object.keys(this._dataValue).length !== Object.keys(this.data.value).length; + if (!isModify) { isModify = Object.keys(this.data.value).some( key => { return this.data.value[key] !== this._dataValue[key]; } ); } - debugger; - if(isModify){ + if (isModify) { this.adjustValueService.save(this.data).subscribe( - (res:ResultBean<any>) =>{ - if(res!=null&&res.code==1){ + (res: ResultBean<any>) => { + if (res != null && res.code === 1) { this.subject.destroy(); this.msgSrv.success('���������������������'); } } ); - }else{ + } else { this.subject.destroy(); this.msgSrv.success('������������������������'); } diff --git a/src/app/routes/devices/basic-info/basic-info.component.html b/src/app/routes/devices/basic-info/basic-info.component.html index 2b6b68d..bf288eb 100644 --- a/src/app/routes/devices/basic-info/basic-info.component.html +++ b/src/app/routes/devices/basic-info/basic-info.component.html @@ -24,4 +24,4 @@ </div> <simple-table #simpleTable [data]="listUrl" [extraParams]="extraParams" [columns]="columns" [showTotal]="true" [reqReName]="{pi: 'pageIndex',ps: 'pageSize'}" (checkboxChange)="checkboxChange($event)" [ps]="10" [resReName]="{list: 'data',total: 'total'}"></simple-table> -</nz-card> \ No newline at end of file +</nz-card> diff --git a/src/app/routes/devices/basic-info/basic-info.component.ts b/src/app/routes/devices/basic-info/basic-info.component.ts index b468826..5d9b915 100644 --- a/src/app/routes/devices/basic-info/basic-info.component.ts +++ b/src/app/routes/devices/basic-info/basic-info.component.ts @@ -25,8 +25,8 @@ { title: '������', index: 'deviceVersion.name' }, { title: '���������', index: 'monitorPoint.name' }, { title: '���������', index: 'operateUser.name' }, - { title: '������������',width: '100px', type: 'date', index: 'createTime' }, - { title: '������������', width: '100px',type: 'date', index: 'installTime' }, + { title: '������������', width: '100px', type: 'date', index: 'createTime' }, + { title: '������������', width: '100px', type: 'date', index: 'installTime' }, { title: '���������', buttons: [ @@ -46,7 +46,7 @@ { text: `���������������`, type: 'static', - component:AdjustConfigComponent, + component: AdjustConfigComponent, format: (record: any) => `<i class="anticon anticon-setting"></i>���������������` }, { @@ -62,12 +62,12 @@ ]; queryTextStream: Subject<string> = new Subject<string>(); constructor( - private monitorPointService:MonitorPointService, + private monitorPointService: MonitorPointService, private deviceService: DeviceService, private confirmServ: NzModalService, public msgSrv: NzMessageService, private modalHelper: ModalHelper, - private coorPickerService:CoorPickerService + private coorPickerService: CoorPickerService ) { } ngOnInit() { @@ -80,7 +80,7 @@ }); } get listUrl() { - return this.deviceService.getListUrl();; + return this.deviceService.getListUrl(); } extraParams = { queryParams: null }; queryText: string; @@ -157,30 +157,30 @@ ); }); } - configCoord(record:Device):void { - Object.assign(this.coorPickerService.data,record); - let _data = this.coorPickerService.data; + configCoord(record: Device): void { + Object.assign(this.coorPickerService.data, record); + const _data = this.coorPickerService.data; this.monitorPointService.getEntity(record.monitorPointId).subscribe( res => { - if(res!=null && res.code==1 && res.data!=null){ + if (res != null && res.code === 1 && res.data != null) { const areaNames = res.data.areaNames; let adress = null; - if(areaNames != null){ - adress = areaNames.provinceName+areaNames.cityName+areaNames.areaName+res.data.address; + if (areaNames != null) { + adress = areaNames.provinceName + areaNames.cityName + areaNames.areaName + res.data.address; } this.coorPickerService.data.address = adress; this.coorPickerService.data['describe'] = '������������'; } this.modalHelper.static(CoordinatesPickerComponent).subscribe( (staticComp) => { - const data:Device = { - id:record.id, - longitude:_data.longitude, - latitude:_data.latitude, - } + const data: Device = { + id: record.id, + longitude: _data.longitude, + latitude: _data.latitude, + }; this.deviceService.save(data).subscribe( - (res: any) => { - if (res.code === 1) { + (resp: any) => { + if (resp.code === 1) { this.load(); this.msgSrv.success('���������������������'); } @@ -190,6 +190,6 @@ } ); } - ) + ); } } diff --git a/src/app/routes/devices/basic-info/device-edit/device-edit.component.ts b/src/app/routes/devices/basic-info/device-edit/device-edit.component.ts index 49cb12b..c128c0f 100644 --- a/src/app/routes/devices/basic-info/device-edit/device-edit.component.ts +++ b/src/app/routes/devices/basic-info/device-edit/device-edit.component.ts @@ -16,19 +16,19 @@ styles: [] }) export class DeviceEditComponent implements OnInit { - public monitorPoints:any [] = []; - public deviceVersions:any [] = []; - public operateUsers:any [] = []; + public monitorPoints: any [] = []; + public deviceVersions: any [] = []; + public operateUsers: any [] = []; public isSaving = false; constructor( private subject: NzModalSubject, private formBuilder: FormBuilder, - private monitorPointService:MonitorPointService, - private versionService:VersionService, - private operateUserService:OperateUserService + private monitorPointService: MonitorPointService, + private versionService: VersionService, + private operateUserService: OperateUserService ) { } - data:Device; - validateForm:FormGroup; + data: Device; + validateForm: FormGroup; ngOnInit() { const data = this.data; this.monitorPointChange(null); @@ -37,37 +37,37 @@ if (this.data.createTime == null) { this.data.createTime = new Date().getTime(); } - const validates:Device = { - name:[data.name,[Validators.required]], - mac:[data.mac,[Validators.required]], - deviceVersionId:[data.deviceVersionId], - monitorPointId:[data.monitorPointId], - operateUserId:[data.operateUserId], - address:[data.address], - id:[data.id], - longitude:[data.longitude], - latitude:[data.latitude], - createTime:[data.createTime], - installTime:[data.installTime] + const validates: Device = { + name: [data.name, [Validators.required]], + mac: [data.mac, [Validators.required]], + deviceVersionId: [data.deviceVersionId], + monitorPointId: [data.monitorPointId], + operateUserId: [data.operateUserId], + address: [data.address], + id: [data.id], + longitude: [data.longitude], + latitude: [data.latitude], + createTime: [data.createTime], + installTime: [data.installTime] }; this.validateForm = this.formBuilder.group( validates ); } - close(){ + close() { this.subject.destroy(); } - save($event, value, valid){ + save($event, value, valid) { $event.preventDefault(); - if(valid){ + if (valid) { this.isSaving = true; this.data = value; this.subject.next( this ); - }else{ + } else { ToolsService.markAsDirty(this.validateForm); } } - monitorPointChange(text){ + monitorPointChange(text) { const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; this.monitorPointService.getPagingList(pageBean, text).subscribe( (res: PageBean) => { @@ -88,7 +88,7 @@ } ); } - deviceVersionChange(text){ + deviceVersionChange(text) { const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; this.versionService.getPagingList(pageBean, text).subscribe( (res: PageBean) => { @@ -109,7 +109,7 @@ } ); } - operateUserChange(text){ + operateUserChange(text) { const pageBean: PageBean = {pageIndex: 0, pageSize: 20}; this.operateUserService.getPagingList(pageBean, text).subscribe( (res: PageBean) => { diff --git a/src/app/routes/devices/devices.module.ts b/src/app/routes/devices/devices.module.ts index 7a05990..7a0a12d 100644 --- a/src/app/routes/devices/devices.module.ts +++ b/src/app/routes/devices/devices.module.ts @@ -26,7 +26,7 @@ import { CoordinatesPickerComponent } from 'app/routes/map/coordinates-picker/coordinates-picker.component'; import { MapModule } from 'app/routes/map/map.module'; import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; -const COMPONENTS_NOROUNT = [AdjustConfigComponent,DeviceEditComponent,VersionEditComponent, MonitorPointEditComponent, VersionSensorConfigComponent ]; +const COMPONENTS_NOROUNT = [AdjustConfigComponent, DeviceEditComponent, VersionEditComponent, MonitorPointEditComponent, VersionSensorConfigComponent ]; const routes: Routes = [ { @@ -54,9 +54,9 @@ MonitorPointComponent, ...COMPONENTS_NOROUNT ], - providers: [CoorPickerService,DeviceAdjustValueService,OrganizationService, VersionService, + providers: [CoorPickerService, DeviceAdjustValueService, OrganizationService, VersionService, SensorsService, AreacodeService, MonitorPointService, - _HttpClient, FormBuilder,DeviceService,OperateUserService,ToolsService], - entryComponents: [CoordinatesPickerComponent,...COMPONENTS_NOROUNT] + _HttpClient, FormBuilder, DeviceService, OperateUserService, ToolsService], + entryComponents: [CoordinatesPickerComponent, ...COMPONENTS_NOROUNT] }) export class DevicesModule { } 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 9ca1b95..faa04fe 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 @@ -67,7 +67,7 @@ } } ); this.subject.next( this ); - }else { + } else { this.validate(); } } 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 2b2d1c4..a724ad9 100644 --- a/src/app/routes/devices/monitor-point/monitor-point.component.ts +++ b/src/app/routes/devices/monitor-point/monitor-point.component.ts @@ -57,7 +57,7 @@ this.grid.pageSize = 10; } constructor( - private coorPickerService:CoorPickerService, + private coorPickerService: CoorPickerService, private monitorPointService: MonitorPointService, private confirmServ: NzModalService, @@ -179,7 +179,7 @@ } configCoord(record: MonitorPoint): void { Object.assign(this.coorPickerService.data, record); - let _data = this.coorPickerService.data; + const _data = this.coorPickerService.data; const areaNames = record.areaNames; let adress = null; if (areaNames != null) { @@ -193,7 +193,7 @@ id: record.id, longitude: _data.longitude, latitude: _data.latitude, - } + }; this.monitorPointService.save(data).subscribe( (res: any) => { if (res.code === 1) { 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 9624084..b6d02dd 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 @@ -60,7 +60,7 @@ } } ); this.subject.next( this ); - }else { + } else { this.validate(); } } diff --git a/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts b/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts index a06e490..146c9c7 100644 --- a/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts +++ b/src/app/routes/map/coordinates-picker/coordinates-picker.component.ts @@ -1,7 +1,7 @@ import { NzModalSubject } from 'ng-zorro-antd'; import { ReactiveFormsModule } from '@angular/forms'; -import { ViewEncapsulation,Component, ViewChild, ElementRef, NgZone } from '@angular/core'; -import { MapOptions,Point,MarkerOptions,ControlAnchor,NavigationControlOptions,NavigationControlType,BMapInstance } from 'angular2-baidu-map'; +import { ViewEncapsulation, Component, ViewChild, ElementRef, NgZone } from '@angular/core'; +import { MapOptions, Point, MarkerOptions, ControlAnchor, NavigationControlOptions, NavigationControlType, BMapInstance } from 'angular2-baidu-map'; import { CoorPicker } from '@business/entity/data'; import { CoorPickerService } from 'app/routes/map/coordinates-picker/coordinates-picker.service'; @@ -13,37 +13,37 @@ templateUrl: './coordinates-picker.component.html', styleUrls: [ './coordinates-picker.component.css' ], }) -export class CoordinatesPickerComponent{ +export class CoordinatesPickerComponent { Default_LNG = 121; Default_LAT = 31.4; isSaving = false; - markerOption:{ - point:Point, - options:MarkerOptions - }= { - point:null, - options:null + markerOption: { + point: Point, + options: MarkerOptions + } = { + point: null, + options: null }; - data:CoorPicker; - navigationOpts:NavigationControlOptions; + data: CoorPicker; + navigationOpts: NavigationControlOptions; options: MapOptions; - _BMap:any = null; + _BMap: any = null; - constructor(private subject:NzModalSubject,private coorPickerService:CoorPickerService) { + constructor(private subject: NzModalSubject, private coorPickerService: CoorPickerService) { this.data = this.coorPickerService.data; let lng = this.data.longitude; - lng = lng ==0 || lng == null ? this.Default_LNG:lng; + lng = lng === 0 || lng == null ? this.Default_LNG : lng; this.data.longitude = lng; let lat = this.data.latitude; - lat = lat == 0||lat == null ? this.Default_LAT:lat; + lat = lat === 0 || lat == null ? this.Default_LAT : lat; this.data.latitude = lat; this.options = { - minZoom:3, - maxZoom:19, - cursor:'default', + minZoom: 3, + maxZoom: 19, + cursor: 'default', centerAndZoom: { - lng:lng, - lat:lat, + lng: lng, + lat: lat, zoom: 19 }, enableKeyboard: true @@ -51,10 +51,10 @@ this.navigationOpts = { anchor: ControlAnchor.BMAP_ANCHOR_BOTTOM_RIGHT, type: NavigationControlType.BMAP_NAVIGATION_CONTROL_LARGE - } + }; this.markerOption.point = { - lng:lng, - lat:lat + lng: lng, + lat: lat }; this.markerOption.options = { icon: { @@ -64,15 +64,15 @@ width: 30 } }, - offset:{ - height:-30, - width:-15 + offset: { + height: -30, + width: -15 } }; } - private _marker:any = null; - loadMarker(marker){ - if(this._marker==null){ + private _marker: any = null; + loadMarker(marker) { + if (this._marker == null) { this._marker = marker; } } @@ -88,19 +88,19 @@ this._map.addOverlay(this._marker); } ); - this._localSearch= new this._BMap.LocalSearch(map, { - renderOptions:{map: map} + this._localSearch = new this._BMap.LocalSearch(map, { + renderOptions: {map: map} }); - if(this.data.latitude==this.Default_LAT&&this.data.longitude==this.Default_LNG - &&this.data.address!=null){ + if (this.data.latitude === this.Default_LAT && this.data.longitude === this.Default_LNG + && this.data.address != null) { this._localSearch.search(this.data.address); } } - queryTest:string; - mapSearch(param:any){ + queryTest: string; + mapSearch(param: any) { let text = this.queryTest; - text = text == null || text.trim() ==''?'���������':text; + text = text == null || text.trim() === '' ? '���������' : text; this._localSearch.search(text); } clickMap(e: any) { diff --git a/src/app/routes/map/coordinates-picker/coordinates-picker.service.ts b/src/app/routes/map/coordinates-picker/coordinates-picker.service.ts index e3ef2dd..6ecd950 100644 --- a/src/app/routes/map/coordinates-picker/coordinates-picker.service.ts +++ b/src/app/routes/map/coordinates-picker/coordinates-picker.service.ts @@ -3,12 +3,12 @@ @Injectable() export class CoorPickerService { - public data:CoorPicker = { - longitude:0, - latitude:0, - name:'', - describe:'', - address:'' + public data: CoorPicker = { + longitude: 0, + latitude: 0, + name: '', + describe: '', + address: '' }; constructor() { } diff --git a/src/app/routes/map/map.module.ts b/src/app/routes/map/map.module.ts index 7c79fce..eea6ff3 100644 --- a/src/app/routes/map/map.module.ts +++ b/src/app/routes/map/map.module.ts @@ -12,10 +12,10 @@ CommonModule, SharedModule, BaiduMapModule.forRoot({ - ak:'rER1sgBIcQxkfNSlm2wmBGZGgEERrooM' + ak: 'rER1sgBIcQxkfNSlm2wmBGZGgEERrooM' }) ], declarations: [CoordinatesPickerComponent], - exports:[CoordinatesPickerComponent] + exports: [CoordinatesPickerComponent] }) export class MapModule { } diff --git a/src/app/routes/passport/login/login.component.ts b/src/app/routes/passport/login/login.component.ts index c84c2a5..a793455 100644 --- a/src/app/routes/passport/login/login.component.ts +++ b/src/app/routes/passport/login/login.component.ts @@ -1,3 +1,5 @@ +import { error } from 'selenium-webdriver'; +import { HttpErrorResponse } from '@angular/common/http'; import { Authorization } from '@business/entity/token'; import { LoginService } from '@business/services/http/login.service'; import { SettingsService } from '@delon/theme'; @@ -13,7 +15,7 @@ selector: 'passport-login', templateUrl: './login.component.html', styleUrls: [ './login.component.less' ], - providers: [ SocialService,CookieService] + providers: [ SocialService, CookieService] }) export class UserLoginComponent implements OnDestroy { @@ -29,7 +31,7 @@ private settingsService: SettingsService, private socialService: SocialService, @Optional() @Inject(ReuseTabService) private reuseTabService: ReuseTabService, - private loginService:LoginService, + private loginService: LoginService, @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) { this.form = fb.group({ userName: [null, [Validators.required, Validators.minLength(5)]], @@ -83,9 +85,9 @@ if (this.mobile.invalid || this.captcha.invalid) return; } this.loading = true; - this.loginService.validate(this.userName.value,this.password.value).subscribe( - (res:Authorization) => { - if(res.token!=null){ + this.loginService.validate(this.userName.value, this.password.value).subscribe( + (res: Authorization) => { + if (res.token != null) { // ������������������������ this.reuseTabService.clear(); this.tokenService.set({ @@ -97,29 +99,23 @@ this.router.navigate(['/']); } }, - (err) => { - // console.log(err); - if(err instanceof ProgressEvent){ - const error = <ProgressEvent>err; - let xmlHttp = error.target; - if(xmlHttp instanceof XMLHttpRequest){ - const xmlHttpRequest = <XMLHttpRequest> xmlHttp; - console.log(xmlHttpRequest.response); - const response = JSON.parse(xmlHttpRequest.response); - if(response.status == 401&&response.errorCode==10){ - this.validateError["password_incorrect"]=true; - this.loading = false; - } else if(response.status == 401&&response.errorCode==12) { - this.validateError["account_expired"]=true; - this.loading = false; - } - } - } + (err: HttpErrorResponse) => { + if (!!err) { + const errMsg = err.error; + console.log(errMsg); + if (errMsg.status === 401 && errMsg.errorCode === 10) { + this.validateError['password_incorrect'] = true; + this.loading = false; + } else if (errMsg.status === 401 && errMsg.errorCode === 12) { + this.validateError['account_expired'] = true; + this.loading = false; + } + } } ); } - public validateError:{[s:string]:boolean} = {}; + public validateError: {[s: string]: boolean} = {}; // region: social open(type: string, openType: SocialOpenType = 'href') { diff --git a/src/app/routes/routes-routing.module.ts b/src/app/routes/routes-routing.module.ts index 959203c..84f64c1 100644 --- a/src/app/routes/routes-routing.module.ts +++ b/src/app/routes/routes-routing.module.ts @@ -38,7 +38,7 @@ path: 'passport', component: LayoutPassportComponent, children: [ - {data:{title:'������������'}, path: 'login', component: UserLoginComponent } + {data: {title: '������������'}, path: 'login', component: UserLoginComponent } ] }, // passport { 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 index 1d644a1..63a1882 100644 --- 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 @@ -50,7 +50,7 @@ } } ); this.subject.next( this ); - }else { + } else { this.validate(); } } diff --git a/src/app/routes/systems/account/account.component.ts b/src/app/routes/systems/account/account.component.ts index 9eeb426..92c5346 100644 --- a/src/app/routes/systems/account/account.component.ts +++ b/src/app/routes/systems/account/account.component.ts @@ -30,7 +30,7 @@ allChecked = false; indeterminate = false; sortMap: string[] = []; - loading: boolean = true; + loading = true; constructor( public http: HttpClient, @@ -47,7 +47,7 @@ this.query.pageIndex = 1; } this.http.get(environment.SERVER_BASH_URL + '/account/list', {params: this.query}).subscribe((res: any) => { - if (res.code == 0) { + if (res.code === 0) { this.msgSrv.error(res.message); } else { this.data = res.data.data; @@ -67,7 +67,7 @@ account = {}; } this.modalHelper.static(AccountEditComponent, {account}).subscribe((res: any) => { - if (res.code == 0) { + if (res.code === 0) { this.msgSrv.error(res.message); } else { this.msgSrv.success('���������������������'); @@ -104,7 +104,7 @@ checkAll(value: boolean) { this.data.forEach(i => { - if (i.isDelete == '1') { + if (i.isDelete === '1') { i.checked = false; } else { i.checked = value; @@ -132,7 +132,7 @@ if (value) { this.sortMap.push(`${field} ${value}`); } - this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(",") : ''; + this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(',') : ''; this.load(true); } 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 index cf95cce..a313c29 100644 --- a/src/app/routes/systems/organization/organization-config/organization-config.component.html +++ b/src/app/routes/systems/organization/organization-config/organization-config.component.html @@ -51,7 +51,7 @@ </div> </div> </td> - <td nz-td style="padding-top:0px;"> + <td nz-td style="padding-top: 0;"> <div nz-form-control> <nz-switch formControlName="degressEnable" (click)="refreshHasDegression(f.value['alarmLevels'][row.sensorKey]['degressEnable'])" nzDisabled="{{ !f.value['alarmLevels'][row.sensorKey]['enable'] }}"></nz-switch> 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 index 50c4d60..9919313 100644 --- a/src/app/routes/systems/organization/organization-config/organization-config.component.ts +++ b/src/app/routes/systems/organization/organization-config/organization-config.component.ts @@ -47,7 +47,7 @@ setTimeout(() => { this.grid.loading = true; }, 1); - let pageBean = this.organizationService.config.pageBean; + const pageBean = this.organizationService.config.pageBean; let resultBean = this.organizationService.config.resultBean; resultBean = resultBean == null ? {} : resultBean; if (pageBean != null && pageBean.data != null) { @@ -62,30 +62,30 @@ const alarmConfigValue = alarmConfig.value; const alarmLevels = alarmConfigValue.alarmLevels; - let alarmLevelsGroupsConfig = {}; + const alarmLevelsGroupsConfig = {}; Object.keys(alarmLevels).forEach(key => { let increment = alarmLevels[key].increment; - increment = increment == null || increment.length != 3 ? [0, 0, 0] : increment; + increment = increment == null || increment.length !== 3 ? [0, 0, 0] : increment; const incrementArray = this.formBuilder.array([ [increment[0]], [increment[1]], [increment[2]] ]); let degression = alarmLevels[key].degression; - degression = degression == null || degression.length != 3 ? [0, 0, 0] : degression; + degression = degression == null || degression.length !== 3 ? [0, 0, 0] : degression; const degressionArray = this.formBuilder.array([ [degression[0]], [degression[1]], [degression[2]] ]); - //������������������������ + // ������������������������ // let _degressionEnable = degression[0] != 0 || degression[1] != 0 || degression[2] != 0; const alarmSensorGroup = this.formBuilder.group( { - degressEnable:[alarmLevels[key].degressEnable], + degressEnable: [alarmLevels[key].degressEnable], enable: [alarmLevels[key].enable], increment: incrementArray, degression: degressionArray, @@ -119,14 +119,14 @@ level3: [alarmMode.level3] } ), - '_id':alarmConfig.id, + '_id': alarmConfig.id, '_allChecked': [] }); this.validateForm.statusChanges.subscribe( item => { this.setErrorMessage(); } - ) + ); this.refreshIndeterminate(); } this.refreshHasDegression(false); @@ -156,7 +156,7 @@ ); this.refreshIndeterminate(); } - private _allCheckTriggers: number = 0; + private _allCheckTriggers = 0; refreshIndeterminate() { const keys = this.grid.data.map( item => { @@ -167,56 +167,55 @@ const allUnChecked = keys.every(key => !this.validateForm.get('alarmLevels.' + key + '.enable').value); this.indeterminate = (!allChecked) && (!allUnChecked); } - isSaving:boolean = false; + isSaving = false; save($event, value, valid) { $event.preventDefault(); if (valid) { this.isSaving = true; - const data:AlarmConfig = { - id:value._id, - organizationId:this.organization.id, - value:value - } + const data: AlarmConfig = { + id: value._id, + organizationId: this.organization.id, + value: value + }; // ToolsService.removePrivate(data.value); this.alarmConfigService.save(data).subscribe( result => { - if(result!=null&&result.code==1){ - this.msgSrv.success(this.organization.name+' ���������������'); + if (result != null && result.code === 1) { + this.msgSrv.success(this.organization.name + ' ���������������'); this.backToList(); } } ); } - debugger; } - setErrorMessage(){ + setErrorMessage() { this.errorMessage = ''; const errObj = this.getLastError(this.validateForm); - if(errObj!=null&&Object.keys(errObj).length>0){ - if(errObj['increment']){ + if (errObj != null && Object.keys(errObj).length > 0) { + if (errObj['increment']) { this.errorMessage = '������ ������ ������ ������������'; - } else if(errObj['degression']){ + } else if (errObj['degression']) { this.errorMessage = '������������ ������������ ������������ ������������'; - } else if(errObj['pattern']!=null&&errObj['pattern']['requiredPattern'] == '^'+patterns.num.toString()+'$'){ + } else if (errObj['pattern'] != null && errObj['pattern']['requiredPattern'] === '^' + patterns.num.toString() + '$') { this.errorMessage = '���������������������'; } } } - errorMessage:string = ''; - private removeError(error:'increment'|'degression',...controls:AbstractControl[]){ + errorMessage = ''; + private removeError(error: 'increment'|'degression', ...controls: AbstractControl[]) { controls.forEach( item => { - if(item.hasError(error)&&Object.keys(item.errors).length==1){ + if (item.hasError(error) && Object.keys(item.errors).length === 1) { item.setErrors(null); } } ); } - private addError(error:'increment'|'degression',...controls:AbstractControl[]){ + private addError(error: 'increment'|'degression', ...controls: AbstractControl[]) { controls.forEach( item => { - let errs = {}; + const errs = {}; errs[error] = true; item.setErrors(errs); item.markAsDirty(); @@ -224,53 +223,53 @@ ); } private alarmLevelValidator = (control: FormControl): { [s: string]: boolean } => { - const enable = control.get("enable").value; - const degressEnable = control.get("degressEnable").value; - const i0 = control.get("increment.0"); - const i1 = control.get("increment.1"); - const i2 = control.get("increment.2"); - const d0 = control.get("degression.0"); - const d1 = control.get("degression.1"); - const d2 = control.get("degression.2"); + const enable = control.get('enable').value; + const degressEnable = control.get('degressEnable').value; + const i0 = control.get('increment.0'); + const i1 = control.get('increment.1'); + const i2 = control.get('increment.2'); + const d0 = control.get('degression.0'); + const d1 = control.get('degression.1'); + const d2 = control.get('degression.2'); // ��������������� ������������������������������ - if(!enable){ - this.removeError('increment',i0,i1,i2); - this.removeError('degression',d0,d1,d2); + if (!enable) { + this.removeError('increment', i0, i1, i2); + this.removeError('degression', d0, d1, d2); return null; } - let result = {}; - const i0_value = parseInt(i0.value); - const i1_value = parseInt(i1.value); - const i2_value = parseInt(i2.value); - if ((i0_value != 0 || i1_value != 0 || i2_value != 0)&&(i0_value >= i1_value||i1_value >= i2_value)) { - this.addError('increment',i0,i1,i2); - result["increment"] = true; - }else{ - this.removeError('increment',i0,i1,i2); + const result = {}; + const i0_value = parseInt(i0.value, 10); + const i1_value = parseInt(i1.value, 10); + const i2_value = parseInt(i2.value, 10); + if ((i0_value !== 0 || i1_value !== 0 || i2_value !== 0) && (i0_value >= i1_value || i1_value >= i2_value)) { + this.addError('increment', i0, i1, i2); + result['increment'] = true; + } else { + this.removeError('increment', i0, i1, i2); } - const d0_value = parseInt(d0.value); - const d1_value = parseInt(d1.value); - const d2_value = parseInt(d2.value); - if(degressEnable&&(d0_value != 0 || d1_value != 0 || d2_value != 0)&&(d1_value >= d0_value||d2_value >= d1_value)) { - this.addError('degression',d0,d1,d2); - result["degression"] = true; - }else{ - this.removeError('degression',d0,d1,d2); + const d0_value = parseInt(d0.value, 10); + const d1_value = parseInt(d1.value, 10); + const d2_value = parseInt(d2.value, 10); + if (degressEnable && (d0_value !== 0 || d1_value !== 0 || d2_value !== 0) && (d1_value >= d0_value || d2_value >= d1_value)) { + this.addError('degression', d0, d1, d2); + result['degression'] = true; + } else { + this.removeError('degression', d0, d1, d2); } - return Object.keys(result).length == 0?null:result; - }; - getLastError(control:FormGroup|FormArray){ - if(control.errors!=null){ + return Object.keys(result).length === 0 ? null : result; + } + getLastError(control: FormGroup|FormArray) { + if (control.errors != null) { return control.errors; - }else{ + } else { const controls = Object.values(control.controls); - for(let i = controls.length-1;i>=0;i--){ + for (let i = controls.length - 1; i >= 0; i--) { const c = controls[i]; - if(c.errors!=null){ + if (c.errors != null) { return c.errors; - }else if(c instanceof FormArray||c instanceof FormGroup){ + } else if (c instanceof FormArray || c instanceof FormGroup) { const result = this.getLastError(c); - if(result != null) { + if (result != null) { return result; } } @@ -278,15 +277,15 @@ } } public hasDegression = false; - public refreshHasDegression(value){ - if(value){ + public refreshHasDegression(value) { + if (value) { this.hasDegression = true; - }else{ + } else { this.hasDegression = Object.values(this.validateForm.value['alarmLevels']).some( - ( item:any) => { + ( item: any) => { return item['degressEnable']; } - ) + ); } } } 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 24427f4..50d8b5a 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 @@ -75,7 +75,7 @@ } } ); this.subject.next( this ); - }else { + } else { this.validate(); } } 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 index eb79a20..abe84f8 100644 --- a/src/app/routes/systems/organization/organization-list/organization-list.component.ts +++ b/src/app/routes/systems/organization/organization-list/organization-list.component.ts @@ -93,8 +93,8 @@ public msgSrv: NzMessageService, private modalHelper: ModalHelper, private router: Router, - private sensorsService:SensorsService, - private alarmConfigService:AlarmConfigService, + private sensorsService: SensorsService, + private alarmConfigService: AlarmConfigService, ) {} ngOnInit() { @@ -216,14 +216,14 @@ this.grid.loading = true; }, 1); zip( - this.sensorsService.getPagingList({pageIndex:0,pageSize:0}, null), + this.sensorsService.getPagingList({pageIndex: 0, pageSize: 0}, null), this.alarmConfigService.getByOid( row.id ) ).subscribe(([pageBean, resultBean]) => { console.log(pageBean); this.grid.loading = false; this.organizationService.handle = 'config' ; this.organizationService.data = row; - this.organizationService.config = {pageBean,resultBean}; + this.organizationService.config = {pageBean, resultBean}; this.organizationService.title = '������������'; }); } diff --git a/src/app/routes/systems/systems.module.ts b/src/app/routes/systems/systems.module.ts index eae0bff..d1f3d49 100644 --- a/src/app/routes/systems/systems.module.ts +++ b/src/app/routes/systems/systems.module.ts @@ -47,7 +47,7 @@ OrganizationConfigComponent, OrganizationListComponent ], - providers: [ToolsService, SensorsService,OrganizationService, _HttpClient, FormBuilder, AreacodeService], + providers: [ToolsService, SensorsService, OrganizationService, _HttpClient, FormBuilder, AreacodeService], entryComponents: COMPONENTS_NOROUNT }) export class SystemsModule { } diff --git a/src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts b/src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts index fa64f79..754c92f 100644 --- a/src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts +++ b/src/app/routes/users/alarm-user/alarm-user-edit/alarm-user-edit.component.ts @@ -25,7 +25,7 @@ const alarmUser = this.alarmUser; this.validateForm = this.formBuilder.group({ name: [alarmUser.name], - mobile: [alarmUser.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]], + mobile: [alarmUser.mobile, [Validators.pattern('^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$')]], email: [alarmUser.email, [Validators.email]], weixin: [alarmUser.weixin], organizationId: [alarmUser.organizationId], 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 a447e3c..c1342f7 100644 --- a/src/app/routes/users/alarm-user/alarm-user.component.ts +++ b/src/app/routes/users/alarm-user/alarm-user.component.ts @@ -30,7 +30,7 @@ allChecked = false; indeterminate = false; sortMap: string[] = []; - loading: boolean = true; + loading = true; constructor( public http: HttpClient, @@ -64,7 +64,7 @@ alarmUser = {}; } this.modalHelper.static(AlarmUserEditComponent, {alarmUser}).subscribe((res: any) => { - if (res.code == 0) { + if (res.code === 0) { this.msgSrv.error(res.message); } else { this.msgSrv.success('���������������������'); @@ -101,7 +101,7 @@ checkAll(value: boolean) { this.data.forEach(i => { - if (i.isDelete == '1') { + if (i.isDelete === '1') { i.checked = false; } else { i.checked = value; @@ -129,7 +129,7 @@ if (value) { this.sortMap.push(`${field} ${value}`); } - this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(",") : ''; + this.query.sorter = this.sortMap.length > 0 ? this.sortMap.join(',') : ''; this.load(true); } diff --git a/src/app/routes/users/installer/edit/edit.component.ts b/src/app/routes/users/installer/edit/edit.component.ts index b35523c..e19f61d 100644 --- a/src/app/routes/users/installer/edit/edit.component.ts +++ b/src/app/routes/users/installer/edit/edit.component.ts @@ -29,7 +29,7 @@ const user = this.user; this.validateForm = this.formBuilder.group({ name: [user.name], - mobile: [user.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]], + mobile: [user.mobile, [Validators.pattern('^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$')]], email: [user.email], weixin: [user.weixin], organizationId: [user.organizationId], @@ -38,15 +38,15 @@ }); const mobileControl = this.validateForm.get('mobile'); mobileControl.valueChanges.filter(val => { - return val != null && val.trim() != ''; + return val != null && val.trim() !== ''; }).debounceTime(900).distinctUntilChanged().subscribe( value => { - if(mobileControl.errors==null){ - mobileControl.setErrors({unique:true}) - this.http.get(environment.SERVER_BASH_URL + '/operateUser/unique-mobile?mobile='+value) + if (mobileControl.errors == null) { + mobileControl.setErrors({unique: true}); + this.http.get(environment.SERVER_BASH_URL + '/operateUser/unique-mobile?mobile=' + value) .pipe( catchError(() => { const req = <XMLHttpRequest>event.target; - if(req.status==401){ + if (req.status === 401) { this.subject.destroy(); } // ������������������������������������ @@ -54,8 +54,8 @@ }) ) .subscribe( - (value:ResultBean<boolean>) => { - if(value.code == 1 && value.data){ + (val: ResultBean<boolean>) => { + if (val.code === 1 && val.data) { this.validateForm.get('mobile').setErrors(null); } } diff --git a/src/app/routes/users/installer/installer.component.ts b/src/app/routes/users/installer/installer.component.ts index 3a07063..5d5bcd4 100644 --- a/src/app/routes/users/installer/installer.component.ts +++ b/src/app/routes/users/installer/installer.component.ts @@ -3,7 +3,7 @@ import {ModalHelper} from '@delon/theme'; import {HttpClient} from '@angular/common/http'; import {UserInstallerEditComponent} from './edit/edit.component'; -import {environment} from 'environments/environment'; +import {environment} from 'environments/environment'; import {DateService} from '@business/services/util/date.service'; @Component({ @@ -28,7 +28,7 @@ allChecked = false; indeterminate = false; sortMap: any = {}; - loading: boolean = true; + loading = true; constructor( public http: HttpClient, @@ -87,7 +87,7 @@ checkAll(value: boolean) { this.curRows.forEach(i => { - if (i.isDelete == '1') { + if (i.isDelete === '1') { i.checked = false; } else { i.checked = value; diff --git a/src/app/routes/users/users.module.ts b/src/app/routes/users/users.module.ts index 0981a93..2852962 100644 --- a/src/app/routes/users/users.module.ts +++ b/src/app/routes/users/users.module.ts @@ -18,7 +18,7 @@ } ]; -const COMPONENTS_NOROUNT = [ UserInstallerEditComponent,AlarmUserEditComponent ]; +const COMPONENTS_NOROUNT = [ UserInstallerEditComponent, AlarmUserEditComponent ]; @NgModule({ imports: [ diff --git a/tslint.json b/tslint.json index 54f1235..0592ba4 100644 --- a/tslint.json +++ b/tslint.json @@ -68,7 +68,7 @@ "no-switch-case-fall-through": true, "no-trailing-whitespace": false, "no-unnecessary-initializer": true, - "no-unused-expression": true, + "no-unused-expression": false, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, -- Gitblit v1.8.0