From 565f5b26ee306966f0b4b9447b7a8f9b04a9fe00 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Fri, 15 Jun 2018 09:21:00 +0800 Subject: [PATCH] 改变暂存 --- src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.html | 6 + src/app/routes/devices/basic-info/basic-info.component.ts | 2 src/app/routes/dashboard/workplace/workplace.component.ts | 44 +++++----- src/app/routes/sensors/sensors.module.ts | 4 src/app/routes/systems/organization/organization-config/organization-config.component.html | 2 src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.ts | 43 ++++++++++ src/app/routes/sensors/basic-info/basic-info.component.ts | 11 ++ src/app/routes/devices/basic-info/device-edit/device-edit.component.ts | 30 +++--- src/app/business/enum/types.enum.ts | 20 ++-- src/app/business/services/util/tools.service.ts | 4 src/app/routes/devices/monitor-point/monitor-point.component.ts | 8 +- src/app/business/services/http/device.service.ts | 4 src/app/routes/sensors/basic-info/basic-info.component.html | 10 +- 13 files changed, 127 insertions(+), 61 deletions(-) diff --git a/src/app/business/enum/types.enum.ts b/src/app/business/enum/types.enum.ts index ad1f20a..c48b149 100644 --- a/src/app/business/enum/types.enum.ts +++ b/src/app/business/enum/types.enum.ts @@ -9,17 +9,19 @@ YEAR= 'YEAR', MONTH= 'MONTH', DAY= 'DAY', HOUR= 'HOUR', MINUTE= 'MINUTE' } export enum AreaRange { - PROVINCE= 'PROVINCE', - CITY= 'CITY', - AREA= 'AREA', - MONITORPOINT= 'MONITORPOINT', - DEVICE= 'DEVICE' + PROVINCE= 1, + CITY= 2, + AREA= 3, + TOWN= 4, + VILLAGE= 5, + MONITORPOINT= 6, + DEVICE= 7 } export enum ResultCode { SUCCESS= 1, FAIL= 0 } -export enum DeviceDimension{ +export enum DeviceDimension { MONITORPOINT= 'MONITORPOINT', // ��������������� ������������������������������������ - PROFESSION='PROFESSION', - NONE='NONE' -} \ No newline at end of file + PROFESSION= 'PROFESSION', + NONE= 'NONE' +} diff --git a/src/app/business/services/http/device.service.ts b/src/app/business/services/http/device.service.ts index 9fc6c5e..8bf7bfd 100644 --- a/src/app/business/services/http/device.service.ts +++ b/src/app/business/services/http/device.service.ts @@ -12,7 +12,7 @@ list: environment.SERVER_BASH_URL + 'device/page-list', save: environment.SERVER_BASH_URL + 'device/add-or-modify', delete: environment.SERVER_BASH_URL + 'device/delete-by-ids', - count: environment.SERVER_BASH_URL +'device/count-by-example' + count: environment.SERVER_BASH_URL + 'device/count-by-example' }; public getListUrl () { return this.urls.list; @@ -34,7 +34,7 @@ } public countByExample(example: ExampleService): Observable<ResultBean<number>> { return this.http.get(this.urls.count, { queryParams: example.getSqlParam()}); - }; + } public getPageByExample(page: PageBean, example: ExampleService): Observable<PageBean> { let orderByClause = ''; const _queryParams = !!example ? example.getSqlParam() : ''; diff --git a/src/app/business/services/util/tools.service.ts b/src/app/business/services/util/tools.service.ts index 825acf1..243051f 100644 --- a/src/app/business/services/util/tools.service.ts +++ b/src/app/business/services/util/tools.service.ts @@ -28,8 +28,8 @@ } ); } - public static toThousands(num: string): string { - var num = (num || 0).toString(), result = ''; + public static toThousands(number: string): string { + let num = (number || 0).toString(), result = ''; while (num.length > 3) { result = ',' + num.slice(-3) + result; num = num.slice(0, num.length - 3); diff --git a/src/app/routes/dashboard/workplace/workplace.component.ts b/src/app/routes/dashboard/workplace/workplace.component.ts index bc27c03..a3ede59 100644 --- a/src/app/routes/dashboard/workplace/workplace.component.ts +++ b/src/app/routes/dashboard/workplace/workplace.component.ts @@ -25,9 +25,9 @@ avgDeviceCount = ''; deviceCountLoading = true; // ������������ - alarmCountList:{x: string,y: number}[] = null; + alarmCountList: {x: string, y: number}[] = null; alarmCountCurrMonth = ''; - alarmCountCurrDay = '';// ������������������ + alarmCountCurrDay = ''; // ������������������ alarmCountLoading = true; operationLoading = true; operNormalPercent = 0; @@ -160,45 +160,45 @@ // }); // this.totalDeviceCount += fakeDC[i]; // } - let example1 = new ExampleService(); - let mo = moment(); - example1.or().andGreaterThanOrEqualTo({ name: "createTime", value: mo.format('YYYY-MM-01 00:00:00') }); - let example2 = new ExampleService(); - let example3 = new ExampleService(); - example3.or().andNotEqualTo({name:'state',value:4}); + const example1 = new ExampleService(); + const mo = moment(); + example1.or().andGreaterThanOrEqualTo({ name: 'createTime', value: mo.format('YYYY-MM-01 00:00:00') }); + const example2 = new ExampleService(); + const example3 = new ExampleService(); + example3.or().andNotEqualTo({name: 'state', value: 4}); zip(this.deviceService.countByExample(example1), this.deviceService.countByExample(example2), - this.http.get<ResultBean<{time: string,count: number}[]>>('device/count-by-times',{start:mo.format('YYYY-01-01 00:00:00'),end:mo.format('YYYY-12-31 23:59:59')}), + this.http.get<ResultBean<{time: string, count: number}[]>>('device/count-by-times', {start: mo.format('YYYY-01-01 00:00:00'), end: mo.format('YYYY-12-31 23:59:59')}), this.deviceService.countByExample(example3)).subscribe( - ([rWtihAvg, rWithToltal,rWithList,rWithNormal]) => { - if (!!rWtihAvg.code && !!rWithToltal&&!!rWithList.code) { + ([rWtihAvg, rWithToltal, rWithList, rWithNormal]) => { + if (!!rWtihAvg.code && !!rWithToltal && !!rWithList.code) { this.avgDeviceCount = ToolsService.toThousands(rWtihAvg.data.toString()); this.totalDeviceCount = ToolsService.toThousands(rWithToltal.data.toString()); this.totalDeviceCountList = rWithList.data.map(item => { - return {x:item.time,y:item.count}; - }) - this.operNormalPercent = Math.round(rWithNormal.data/rWithToltal.data*100); + return {x: item.time, y: item.count}; + }); + this.operNormalPercent = Math.round(rWithNormal.data / rWithToltal.data * 100); this.deviceCountLoading = false; this.operationLoading = false; } } ); zip( - this.http.get<ResultBean<{time: string,count: number}[]>>("alarm/count-by-times",{start: mo.format('YYYY-MM-01 00:00:00'),end: null,timeUnits: TimeUnits.DAY}), - this.http.get<ResultBean<{time: string,count: number}[]>>("alarm/count-by-times",{start: mo.format('YYYY-MM-01 00:00:00'),end: null}), - this.http.get<ResultBean<{time: string,count: number}[]>>("alarm/count-by-times",{start: mo.format('YYYY-MM-DD 00:00:00'),end: null}) + this.http.get<ResultBean<{time: string, count: number}[]>>('alarm/count-by-times', {start: mo.format('YYYY-MM-01 00:00:00'), end: null, timeUnits: TimeUnits.DAY}), + this.http.get<ResultBean<{time: string, count: number}[]>>('alarm/count-by-times', {start: mo.format('YYYY-MM-01 00:00:00'), end: null}), + this.http.get<ResultBean<{time: string, count: number}[]>>('alarm/count-by-times', {start: mo.format('YYYY-MM-DD 00:00:00'), end: null}) ).subscribe( - ([rWithList,rWithMonth,rWithDay]) => { - if(!!rWithList.code&&!!rWithMonth.code&&!!rWithDay.code){ + ([rWithList, rWithMonth, rWithDay]) => { + if (!!rWithList.code && !!rWithMonth.code && !!rWithDay.code) { this.alarmCountList = rWithList.data.map( item => { - return {x:item.time,y:item.count}; + return {x: item.time, y: item.count}; } ); - if(!!rWithMonth.data&&rWithMonth.data.length>0){ + if (!!rWithMonth.data && rWithMonth.data.length > 0) { this.alarmCountCurrMonth = ToolsService.toThousands(rWithMonth.data[0].count.toString()); } - if(!!rWithDay.data&&rWithDay.data.length>0) { + if (!!rWithDay.data && rWithDay.data.length > 0) { this.alarmCountCurrDay = ToolsService.toThousands(rWithDay.data[0].count.toString()); } this.alarmCountLoading = false; 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 526253c..3dfa853 100644 --- a/src/app/routes/devices/basic-info/basic-info.component.ts +++ b/src/app/routes/devices/basic-info/basic-info.component.ts @@ -182,7 +182,7 @@ } } ); - }else { + } else { this.openMap(record); } } 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 15870e2..fa62a0d 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 @@ -31,8 +31,8 @@ private monitorPointService: MonitorPointService, private versionService: VersionService, private operateUserService: OperateUserService, - private deviceService:DeviceService, - private http:_HttpClient + private deviceService: DeviceService, + private http: _HttpClient ) { } data: Device; //������������������ @@ -40,8 +40,8 @@ validateForm: FormGroup; ngOnInit() { debugger; - if(!!this.data){ - Object.assign(this.originalData,this.data); + if (!!this.data) { + Object.assign(this.originalData, this.data); } const data = this.data; this.monitorPointChange(null); @@ -53,7 +53,7 @@ } const validates: Device = { name: [data.name, [Validators.required]], - mac: [data.mac, [Validators.required],[this.macAsyncValidator]], + mac: [data.mac, [Validators.required], [this.macAsyncValidator]], deviceVersionId: [data.deviceVersionId], monitorPointId: [data.monitorPointId], professionId: [data.professionId], @@ -70,20 +70,20 @@ ); } macAsyncValidator = (control: FormControl): any => { - return Observable.create(observer =>{ + return Observable.create(observer => { // ���������������mac��������� - if(!!this.originalData&&this.originalData.mac === control.value){ + if (!!this.originalData && this.originalData.mac === control.value) { observer.next(null); observer.complete(); - }else { + } else { const exampleService = new ExampleService(); - exampleService.or().andEqualTo({name:'mac',value:control.value}); + exampleService.or().andEqualTo({name: 'mac', value: control.value}); this.deviceService.countByExample(exampleService).subscribe( res => { debugger; - if(!!res.code&&!!res.data){ + if (!!res.code && !!res.data) { observer.next({ error: true, duplicated: true }); - }else{ + } else { observer.next(null); } observer.complete(); @@ -92,7 +92,7 @@ } }); - }; + } close() { this.subject.destroy(); } @@ -106,10 +106,10 @@ ToolsService.markAsDirty(this.validateForm); } } - professionChange(){ - this.http.get<ResultBean<any[]>>(environment.SERVER_BASH_URL+"profession/getall").subscribe( + professionChange() { + this.http.get<ResultBean<any[]>>(environment.SERVER_BASH_URL + 'profession/getall').subscribe( result => { - if(!!result.code){ + if (!!result.code) { this.professions = result.data; } } 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 9d69db9..0fd59a7 100644 --- a/src/app/routes/devices/monitor-point/monitor-point.component.ts +++ b/src/app/routes/devices/monitor-point/monitor-point.component.ts @@ -183,13 +183,13 @@ const areaNames = record.areaNames; let adress = ''; if (areaNames != null) { - adress += !!areaNames.provinceName?areaNames.provinceName:''; + adress += !!areaNames.provinceName ? areaNames.provinceName : ''; adress += ' '; - adress += !!areaNames.cityName?areaNames.cityName:''; + adress += !!areaNames.cityName ? areaNames.cityName : ''; adress += ' '; - adress += !!areaNames.areaName?areaNames.areaName:''; + adress += !!areaNames.areaName ? areaNames.areaName : ''; adress += ' '; - adress += !!record.address?record.address:''; + adress += !!record.address ? record.address : ''; } this.coorPickerService.data.address = adress; this.coorPickerService.data['describe'] = '������������������'; 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 1ee8934..dcc90d7 100644 --- a/src/app/routes/sensors/basic-info/basic-info.component.html +++ b/src/app/routes/sensors/basic-info/basic-info.component.html @@ -52,11 +52,13 @@ </span> </td> <td nz-td> - <a (click)="addOrModify(row)">������</a> + <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> + <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)="configSensorUnit(row)">������������</a> </td> </tr> </tbody> 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 18ffc48..491aa4f 100644 --- a/src/app/routes/sensors/basic-info/basic-info.component.ts +++ b/src/app/routes/sensors/basic-info/basic-info.component.ts @@ -7,6 +7,7 @@ import { Component, OnInit } from '@angular/core'; import { Subject } from 'rxjs/Subject'; import { SensorEditComponent } from './sensor-edit/sensor-edit.component'; +import { SensorUnitComponent } from './sensor-unit/sensor-unit.component'; @@ -171,5 +172,15 @@ } this.load(); } + configSensorUnit(d) { + const data = {}; + if ( d != null) { + Object.assign(data, d); + } + this.modalHelper.static(SensorUnitComponent, { data }).subscribe( + res => { + } + ); + } } diff --git a/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.html b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.html new file mode 100644 index 0000000..05ff1c6 --- /dev/null +++ b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.html @@ -0,0 +1,6 @@ +<div class="modal-header"> + <div class="modal-title">������-���������������</div> +</div> +<form [formGroup]="validateForm" (ngSubmit)="save($event,validateForm.value,validateForm.valid)" nz-form [nzType]="'horizontal'"> + +</form> diff --git a/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.ts b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.ts new file mode 100644 index 0000000..35a0948 --- /dev/null +++ b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit/sensor-unit.component.ts @@ -0,0 +1,43 @@ +import { Component, OnInit } from '@angular/core'; +import { _HttpClient } from '@delon/theme'; +import { NzModalSubject } from 'ng-zorro-antd'; +import { FormGroup } from '@angular/forms'; + +@Component({ + selector: 'app-sensor-unit', + templateUrl: './sensor-unit.component.html', +}) +export class SensorUnitComponent implements OnInit { + public isSaving = false; + public validateForm: FormGroup; + public data: any; + constructor( + private subject: NzModalSubject, + private http: _HttpClient + ) { } + + ngOnInit() { + } + 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]; + } + } ); + } 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 440d5e9..e69c7de 100644 --- a/src/app/routes/sensors/sensors.module.ts +++ b/src/app/routes/sensors/sensors.module.ts @@ -8,6 +8,7 @@ import { _HttpClient } from '@delon/theme/services/http/http.client'; import { FormBuilder } from '@angular/forms'; import { SensorEditComponent } from './basic-info/sensor-edit/sensor-edit.component'; +import { SensorUnitComponent } from './basic-info/sensor-unit/sensor-unit.component'; const routes: Routes = [ { @@ -17,7 +18,7 @@ ] } ]; -const COMPONENTS_NOROUNT = [SensorEditComponent]; +const COMPONENTS_NOROUNT = [SensorEditComponent, SensorUnitComponent]; @NgModule({ imports: [ // ������������������������������������ @@ -28,6 +29,7 @@ ], declarations: [ BasicInfoComponent, + SensorUnitComponent, SensorEditComponent ], providers: [SensorsService, _HttpClient, FormBuilder], 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 254d2b1..a88f3cd 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 @@ -34,7 +34,7 @@ </tr> </thead> <tbody formGroupName="alarmLevels" nz-tbody> - <tr nz-tbody-tr *ngFor="let row of nzTable.data" formGroupName="{{row.sensorKey}}"> + <tr nz-tbody-tr style="height:50px;" *ngFor="let row of nzTable.data" formGroupName="{{row.sensorKey}}"> <td nz-td [nzCheckbox]="true"> <label nz-checkbox formControlName="enable"></label> -- Gitblit v1.8.0