From 27cd36be226ca2434f06b1ae9e4d43f1fea639ab Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Mon, 25 Jun 2018 16:40:28 +0800
Subject: [PATCH] 组织配置单位和页面显示
---
src/app/routes/systems/organization/organization-list/organization-list.component.ts | 49 ++
src/app/business/services/http/sensor-unit.service.ts | 18 +
src/app/business/services/http/organization.service.ts | 16
src/app/routes/sensors/sensors.module.ts | 4
src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.html | 150 ++++++++++
src/app/routes/systems/organization/organization-list/organization-list.component.html | 19 +
src/app/routes/devices/basic-info/device-edit/device-edit.component.ts | 1
src/app/routes/systems/organization/organization.component.html | 2
src/app/business/enum/types.enum.ts | 6
src/app/business/services/util/tools.service.ts | 7
src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.ts | 83 +++++
src/app/business/entity/data.ts | 20 +
src/app/routes/systems/systems.module.ts | 4
src/app/routes/systems/organization/organization-config/organization-config.component.ts | 4
package.json | 1
src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.ts | 135 ++++++++
src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.html | 42 ++
src/app/routes/sensors/basic-info/basic-info.component.html | 2
src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.html | 81 +++++
src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.ts | 222 ++++++++++++++
20 files changed, 837 insertions(+), 29 deletions(-)
diff --git a/package.json b/package.json
index 97fcb96..18af71a 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,6 @@
},
"license": "MIT",
"scripts": {
- "precommit": "npm run lint-staged",
"ng": "ng",
"start": "ng serve --host=0.0.0.0",
"serve:hmr": "ng serve -o --hmr -e=hmr",
diff --git a/src/app/business/entity/data.ts b/src/app/business/entity/data.ts
index c44c39f..2cd044c 100644
--- a/src/app/business/entity/data.ts
+++ b/src/app/business/entity/data.ts
@@ -1,5 +1,5 @@
import { Column } from '@business/entity/grid';
-import { AlarmStyle, TimeUnits, AreaRange, DeviceDimension } from '@business/enum/types.enum';
+import { AlarmStyle, TimeUnits, AreaRange, DeviceDimension, Operator } from '@business/enum/types.enum';
export interface AreaNames {
@@ -167,3 +167,21 @@
category: string;
value: number;
}
+export interface OperatorRule {
+ operator: Operator;
+ value: number;
+}
+export interface SensorUnit {
+ id?: number|any;
+ originalUnitName?: string;
+ name?: string|any;
+ rules?: OperatorRule[]|any;
+ sensorId?: number|any;
+}
+export interface OrganizationSensorUnit {
+ id?: number|any;
+ sensorUnitId?: number|any;
+ sensorUnit?: SensorUnit|any;
+ sensor?: Sensor|any;
+ organizationId?: number|any;
+}
diff --git a/src/app/business/enum/types.enum.ts b/src/app/business/enum/types.enum.ts
index 8ad8cd7..36dd800 100644
--- a/src/app/business/enum/types.enum.ts
+++ b/src/app/business/enum/types.enum.ts
@@ -25,3 +25,9 @@
PROFESSION= 'PROFESSION',
NONE= 'NONE'
}
+export enum Operator {
+ PLUS = 'PLUS', // ���
+ MINUS = 'MINUS', // ���
+ MULTIPLY = 'MULTIPLY', // ���
+ DIVIDE = 'DIVIDE' // ���
+ }
diff --git a/src/app/business/services/http/organization.service.ts b/src/app/business/services/http/organization.service.ts
index 6f3ff0b..20fb068 100644
--- a/src/app/business/services/http/organization.service.ts
+++ b/src/app/business/services/http/organization.service.ts
@@ -1,4 +1,4 @@
-import { Organization, AlarmConfig } from '@business/entity/data';
+import { Organization, AlarmConfig, OrganizationSensorUnit, SensorUnit } from '@business/entity/data';
import { ExampleService } from '@business/services/util/example.service';
import { _HttpClient } from '@delon/theme';
import { environment } from 'environments/environment';
@@ -11,10 +11,10 @@
@Injectable()
export class OrganizationService {
- handle: 'list'|'config' = 'list';
- config: {pageBean: PageBean, resultBean: ResultBean<AlarmConfig>};
+ handle: 'list'|'config'|'unit'|'screen' = 'list';
+ config: {pageBean?: PageBean, resultBean?: ResultBean<AlarmConfig|any>} = {};
data: Organization;
- title: '������������'|'������������' = '������������';
+ title: '������������'|'������������������'|'������������������'|'������������������' = '������������';
private urls = {
list: environment.SERVER_BASH_URL + '/organization/page-list',
save: environment.SERVER_BASH_URL + '/organization/add-or-modify',
@@ -40,4 +40,12 @@
public delete(...ids: number[]): Observable<any> {
return this.http.post(this.urls.delete, ids);
}
+ public getResultBeanData(key: string) {
+ if (!!this.config.resultBean
+ && !!this.config.resultBean.code
+ && !!this.config.resultBean.data) {
+ return this.config.resultBean.data[key];
+ }
+ return null;
+ }
}
diff --git a/src/app/business/services/http/sensor-unit.service.ts b/src/app/business/services/http/sensor-unit.service.ts
new file mode 100644
index 0000000..9e050f8
--- /dev/null
+++ b/src/app/business/services/http/sensor-unit.service.ts
@@ -0,0 +1,18 @@
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs/Observable';
+import { SensorUnit } from '@business/entity/data';
+import { _HttpClient } from '@delon/theme';
+import { ResultBean } from '@business/entity/grid';
+
+@Injectable()
+export class SensorUnitService {
+ private urls = {
+ list: 'sensor-unit/gets-bysid',
+ };
+ constructor(
+ private http: _HttpClient
+ ) { }
+ public getListBySensorId(sensorId: number): Observable<ResultBean<SensorUnit[]>> {
+ return this.http.get( this.urls.list, { sensorId : sensorId });
+ }
+}
diff --git a/src/app/business/services/util/tools.service.ts b/src/app/business/services/util/tools.service.ts
index 243051f..3478144 100644
--- a/src/app/business/services/util/tools.service.ts
+++ b/src/app/business/services/util/tools.service.ts
@@ -15,6 +15,13 @@
}
);
}
+ public static getValueFormControl(controlSet: FormGroup, name: string) {
+ return controlSet.controls[name].value;
+ }
+ public static setValueToControl(controlSet: FormGroup, name: string, value: any) {
+ controlSet.controls[name].setValue(value);
+ controlSet.controls[name].updateValueAndValidity();
+ }
public static removePrivate(obj: object) {
Object.keys(obj).forEach(
(key: string) => {
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 fa62a0d..47ec2f0 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
@@ -39,7 +39,6 @@
originalData: Device = {};
validateForm: FormGroup;
ngOnInit() {
- debugger;
if (!!this.data) {
Object.assign(this.originalData, this.data);
}
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 dcc90d7..c5a31b2 100644
--- a/src/app/routes/sensors/basic-info/basic-info.component.html
+++ b/src/app/routes/sensors/basic-info/basic-info.component.html
@@ -18,7 +18,7 @@
</nz-alert>
</div>
<nz-table #nzTable
- [nzAjaxData]="grid.data"
+ [nzAjaxData]="grid.data"
[nzTotal]="grid.total"
[(nzPageIndex)]="grid.pageIndex"
[(nzPageSize)]="grid.pageSize"
diff --git a/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.html b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.html
index 11b8126..e6f6a46 100644
--- a/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.html
+++ b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.html
@@ -1,3 +1,84 @@
<div class="modal-header">
<div class="modal-title">������-���������������</div>
</div>
+<form [formGroup]="validateForm" (ngSubmit)="save($event,validateForm.value,validateForm.valid)" nz-form [nzType]="'horizontal'">
+ <div nz-form-item nz-row class="mb-sm">
+ <div nz-form-label nz-col [nzSm]="7" [nzXs]="24">
+ <label nz-form-item-required>������</label>
+ </div>
+ <div nz-form-control nz-col [nzSpan]="5" nzHasFeedback>
+ <label>{{ data.name }}</label>
+ </div>
+ <div nz-form-label nz-col [nzSm]="2" [nzXs]="24">
+ <label nz-form-item-required>���������</label>
+ </div>
+ <div nz-form-control nz-col [nzSpan]="5" nzHasFeedback>
+ <label>{{ data.unit }}</label>
+ </div>
+ </div>
+ <div nz-form-item nz-row class="mb-sm">
+ <div nz-form-label nz-col [nzSm]="7" [nzXs]="24">
+ <label nz-form-item-required>������������</label>
+ </div>
+ <div nz-form-control nz-col [nzSpan]="10" nzHasFeedback>
+ <nz-input formControlName="name" maxlength="20" [nzPlaceHolder]="'������'">
+ </nz-input>
+ </div>
+ </div>
+ <div nz-form-item nz-row class="mb-sm">
+ <div nz-form-label nz-col [nzSm]="7" [nzXs]="24">
+ <label nz-form-item-required>������������</label>
+ </div>
+ <div nz-form-control nz-col [nzSpan]="10">
+ <nz-select formControlName="_rule-operator" style="width: 18%">
+ <nz-option *ngFor="let option of operatorOptions" [nzLabel]="option.label" [nzValue]="option.value">
+ </nz-option>
+ </nz-select>
+ <nz-input-number formControlName="_rule-value" style="width: 20%" [nzMin]="0.000001" maxlength="20" [nzStep]="0.000001"></nz-input-number>
+ <button nz-button style="left: 1px;" [nzType]="'default'" (click) = "addRule($event)"><i class="anticon anticon-plus"></i></button>
+ </div>
+ </div>
+ <div nz-form-item nz-row class="mb-sm">
+ <div nz-col [nzSm]="7" [nzXs]="24">
+ </div>
+ <div nz-form-control nz-col [nzSpan]="9" nzHasFeedback>
+ <nz-input nzReadonly = "true" formControlName="_rules" maxlength="10000" [nzPlaceHolder]="'(���������������������������������)'">
+ </nz-input>
+ </div>
+ <div nz-col [nzSpan]="3" style="padding-left: 8px;padding-top: 2px;">
+ <button nz-button [nzType]="'default'" (click) = "clearRules($event)"><i class="anticon anticon-close"></i></button>
+ </div>
+ </div>
+ <div nz-row class="mb-sm">
+ <div nz-col [nzSm]="7" [nzXs]="24">
+ </div>
+ <div nz-col [nzSpan]="10" style="text-align:right;">
+ <button nz-button [nzType]="'default'" (click)="reset($event)">������������</button>
+ <button nz-button [nzType]="'primary'" [nzLoading]="isSaving">
+ <span *ngIf="getValueFormControl('id') !== null">������������</span>
+ <span *ngIf="getValueFormControl('id') === null">������������</span>
+ </button>
+ </div>
+ </div>
+ </form>
+ <div nz-row class="mb-sm">
+ <div nz-col [nzSm]="5" [nzXs]="24">
+ </div>
+ <div nz-col [nzSm]="13" [nzXs]="24">
+ <div style="display: block;overflow-y:auto; width:100%;max-height:200px;border: 0;padding: 0;margin: 0">
+ <div *ngFor="let item of dataList" nz-row class="mb-sm" style="padding:4px 0 0 0;border-top: 2px dotted #e9e9e9;">
+ <div nz-col [nzSm]="8" [nzXs]="24">
+ <label>{{item.name}}</label>
+ </div>
+ <div nz-col [nzSm]="8" [nzXs]="24">
+ <label>{{item.rules.replace('{0}','������')}}</label>
+ </div>
+ <div nz-col [nzSm]="8" [nzXs]="24">
+ <a (click)="toEdit(item)">������</a>
+ <span> | </span>
+ <nz-popconfirm [nzTitle]="'���������������?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(item.id)" >
+ <a nz-popconfirm>������</a>
+ </nz-popconfirm>
+ </div>
+ </div>
+ </div>
\ No newline at end of file
diff --git a/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.ts b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.ts
index 35a0948..2965818 100644
--- a/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.ts
+++ b/src/app/routes/sensors/basic-info/sensor-unit/sensor-unit.component.ts
@@ -1,7 +1,12 @@
import { Component, OnInit } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { NzModalSubject } from 'ng-zorro-antd';
-import { FormGroup } from '@angular/forms';
+import { FormGroup, Validators, FormBuilder, FormControl } from '@angular/forms';
+import { Sensor, SensorUnit, OperatorRule } from '@business/entity/data';
+import { ToolsService } from '@business/services/util/tools.service';
+import { Operator, ResultCode } from '@business/enum/types.enum';
+import { ResultBean } from '@business/entity/grid';
+import { SensorUnitService } from '@business/services/http/sensor-unit.service';
@Component({
selector: 'app-sensor-unit',
@@ -10,13 +15,44 @@
export class SensorUnitComponent implements OnInit {
public isSaving = false;
public validateForm: FormGroup;
- public data: any;
+ public operatorOptions: {label: string, value: Operator} [] = [
+ {label: '���', value: Operator.PLUS},
+ {label: '���', value: Operator.MINUS},
+ {label: '���', value: Operator.MULTIPLY},
+ {label: '���', value: Operator.DIVIDE}
+ ];
+ // public rule = '���';
+ public data: Sensor;
+ public dataList: SensorUnit[] = [];
constructor(
private subject: NzModalSubject,
- private http: _HttpClient
+ private formBuilder: FormBuilder,
+ private http: _HttpClient,
+ private sensorUnitService: SensorUnitService
) { }
-
+ loadDataList() {
+ this.sensorUnitService.getListBySensorId(this.data.id).subscribe(
+ res => {
+ if (res.code === 1 ) {
+ this.dataList = res.data;
+ }
+ }
+ );
+ }
ngOnInit() {
+ this.loadDataList();
+ const validates: SensorUnit = {
+ id: [null ],
+ sensorId: [this.data.id, [Validators.required] ],
+ name: [null, [Validators.required] ]
+ };
+ validates['_rule-operator'] = [Operator.MULTIPLY];
+ validates['_rule-value'] = 1000;
+ validates['_rules'] = [null, [Validators.required]];
+ this.validateForm = this.formBuilder.group(
+ validates
+ );
+ // this.validateForm.controls['_rules'].disable();
}
save($event, value, valid) {
$event.preventDefault();
@@ -25,19 +61,100 @@
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];
+ ToolsService.removePrivate(value);
+ const sensorUnit: SensorUnit = {};
+ Object.assign(sensorUnit, value);
+ sensorUnit['rules'] = this.rulesToString(this.rules);
+ sensorUnit['originalUnitName'] = this.data.unit;
+ console.log(JSON.stringify(sensorUnit));
+ this.http.post('sensor-unit/add-or-modify', sensorUnit).subscribe(
+ (res: ResultBean<any>) => {
+ if (!!res.code) {
+ for (const i in this.validateForm.controls) {
+ this.validateForm.controls[ i ].enable();
+ }
+ this.isSaving = false;
+ this.loadDataList();
+ this.reset();
}
- } );
+ }
+ );
} else {
this.validate();
}
+ }
+ toEdit(item) {
+ this.reset();
+ this.setValueToControl('id', item.id);
+ this.setValueToControl('name', item.name);
+ }
+ delete(id) {
+ this.http.get('sensor-unit/delete', {id: id}).subscribe(
+ (res: ResultBean<any>) => {
+ if (!!res.code ) {
+ this.loadDataList();
+ }
+ }
+ );
}
validate() {
for (const i in this.validateForm.controls) {
this.validateForm.controls[ i ].markAsDirty();
}
}
+ private rules: OperatorRule[] = [];
+ addRule(event) {
+ event.preventDefault();
+ const rule: OperatorRule = {
+ operator: this.getValueFormControl('_rule-operator'),
+ value: this.getValueFormControl('_rule-value')
+ };
+ this.rules.push(rule);
+ this.setValueToControl('_rules' , this.rulesToString(this.rules, '������'));
+ }
+ rulesToString(rules , dataLabel?: string) {
+ let rulesString = '' ;
+ dataLabel = dataLabel === undefined ? '{0}' : dataLabel;
+ if (!!this.rules && this.rules.length > 0) {
+ // const dataLabel = '������';
+ rulesString += dataLabel ;
+ this.rules.forEach(rule => {
+ if (!rulesString.endsWith(dataLabel)) {
+ rulesString = '(' + rulesString + ')';
+ }
+ switch (rule.operator) {
+ case Operator.PLUS: rulesString += '+' + rule.value + 'd'; break;
+ case Operator.MINUS: rulesString += '-' + rule.value + 'd'; break;
+ case Operator.MULTIPLY: rulesString += '*' + rule.value + 'd'; break;
+ case Operator.DIVIDE: rulesString += '/' + rule.value + 'd'; break;
+ }
+ });
+ }
+ return rulesString;
+ }
+ getValueFormControl(controlName: string) {
+ return ToolsService.getValueFormControl(this.validateForm, controlName);
+ }
+ setValueToControl(controlName: string, value: any) {
+ ToolsService.setValueToControl(this.validateForm, controlName, value);
+ }
+ clearRules(event) {
+ event.preventDefault();
+ this.rules = [];
+ this.setValueToControl('_rules', this.rulesToString(this.rules, '������'));
+ }
+ // print() {
+ // debugger;
+ // console.log(this.validateForm.controls['_rule']);
+ // }
+ reset(event?: any) {
+ if (!!event) {
+ event.preventDefault();
+ }
+ this.setValueToControl('id', null);
+ this.setValueToControl('name', null);
+ this.setValueToControl('_rules', null);
+ this.setValueToControl('_rule-operator', Operator.MULTIPLY);
+ this.setValueToControl('_rule-value', 1000);
+ }
}
diff --git a/src/app/routes/sensors/sensors.module.ts b/src/app/routes/sensors/sensors.module.ts
index e69c7de..9412be2 100644
--- a/src/app/routes/sensors/sensors.module.ts
+++ b/src/app/routes/sensors/sensors.module.ts
@@ -9,6 +9,8 @@
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';
+import { ToolsService } from '@business/services/util/tools.service';
+import { SensorUnitService } from '@business/services/http/sensor-unit.service';
const routes: Routes = [
{
@@ -32,7 +34,7 @@
SensorUnitComponent,
SensorEditComponent
],
- providers: [SensorsService, _HttpClient, FormBuilder],
+ providers: [SensorsService, _HttpClient, FormBuilder, ToolsService, SensorUnitService],
entryComponents: COMPONENTS_NOROUNT
})
export class SensorsModule { }
diff --git a/src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.html b/src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.html
new file mode 100644
index 0000000..ecffbf9
--- /dev/null
+++ b/src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.html
@@ -0,0 +1,150 @@
+<nz-tabset [nzTabPosition]="'left'" [(nzSelectedIndex)]="selectedIndex" (nzSelectedIndexChange)="swapTab()">
+ <nz-tab *ngFor="let tab of deviceVersions">
+ <ng-template #nzTabHeading>
+ {{tab.name}}
+ </ng-template>
+ <nz-spin [nzSpinning]="isSpinning">
+ <form nz-form>
+ <nz-card [nzBordered]="false" nzTitle="���������({{surplusSensors.length}})">
+ <div nz-form-item nz-row>
+ <ng-container *ngFor="let sensor of surplusSensors,index as i">
+ <div nz-form-control nz-col [nzSm]="2">
+ <label>{{ sensor.name }}</label>
+ </div>
+ <div nz-form-control nz-col [nzSm]="4">
+ <nz-dropdown [nzTrigger]="'click'">
+ <a class="ant-dropdown-link" nz-dropdown>
+ ������
+ <i class="anticon anticon-down"></i>
+ </a>
+ <ul nz-menu>
+ <li nz-menu-item>
+ <a (click)="moveTo(surplusSensors,i,defaultMonitorItems)">
+ ���������
+ </a>
+ </li>
+ <li nz-menu-divider></li>
+ <li nz-menu-item (click)="moveTo(surplusSensors,i,coreMonitorItems)" [nzDisable]="isCoreItemsFull">
+ ���������
+ <span *ngIf="isCoreItemsFull">(������)</span>
+ </li>
+ </ul>
+ </nz-dropdown>
+ </div>
+ </ng-container>
+ </div>
+ <nz-row nzType="flex" nzJustify="end" nzAlign="top">
+ <nz-col nzSpan="4" >
+ <button (click)="moveAllto(surplusSensors,defaultMonitorItems)" nz-button>���������������������</button>
+ </nz-col>
+ </nz-row>
+ </nz-card>
+ <div nz-form-item nz-row>
+ <div nz-form-control nz-col [nzSm]="8"></div>
+ <div nz-form-control nz-col [nzSm]="8">
+ <label class="display-3">������������ :</label>
+ <span class="display-3">{{ chartSensorName }}</span>
+ </div>
+ <div nz-form-control nz-col [nzSm]="8"></div>
+ </div>
+ <nz-card [nzBordered]="false" nzTitle="���������({{defaultMonitorItems.length}})">
+ <div *ngFor="let sensor of defaultMonitorItems,index as i" nz-form-item nz-row>
+ <div nz-form-control nz-col [nzSm]="6">
+ <label>{{ sensor.name }}</label>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <a (click)="itemUp(defaultMonitorItems,i)">������</a>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <a (click)="itemDown(defaultMonitorItems,i)">������</a>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <a (click)="setChartSensorKey(sensor.sensorKey)">������������</a>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <nz-dropdown [nzTrigger]="'click'">
+ <a class="ant-dropdown-link" nz-dropdown>
+ ������
+ <i class="anticon anticon-down"></i>
+ </a>
+ <ul nz-menu>
+ <li nz-menu-item>
+ <a (click)="moveTo(defaultMonitorItems,i,surplusSensors)">
+ ���������
+ </a>
+ </li>
+ <li nz-menu-divider></li>
+ <li nz-menu-item (click)="moveTo(defaultMonitorItems,i,coreMonitorItems)" [nzDisable]="isCoreItemsFull">
+ ���������
+ <span *ngIf="isCoreItemsFull">(������)</span>
+ </li>
+ </ul>
+ </nz-dropdown>
+ </div>
+ </div>
+ </nz-card>
+ <nz-card [nzBordered]="false" nzTitle="���������({{coreMonitorItems.length}}/6)">
+ <div *ngFor="let sensor of coreMonitorItems,index as i" nz-form-item nz-row>
+ <div nz-form-control nz-col [nzSm]="6">
+ <label>{{ sensor.name }}</label>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <a (click)="itemUp(coreMonitorItems,i)">������</a>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <a (click)="itemDown(coreMonitorItems,i)">������</a>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <a (click)="setChartSensorKey(sensor.sensorKey)">������������</a>
+ </div>
+ <div nz-form-control nz-col [nzSm]="3">
+ <nz-dropdown [nzTrigger]="'click'">
+ <a class="ant-dropdown-link" nz-dropdown>
+ ������
+ <i class="anticon anticon-down"></i>
+ </a>
+ <ul nz-menu>
+ <li nz-menu-item>
+ <a (click)="moveTo(coreMonitorItems,i,surplusSensors)">
+ ���������
+ </a>
+ </li>
+ <li nz-menu-divider></li>
+ <li nz-menu-item (click)="moveTo(coreMonitorItems,i,defaultMonitorItems)">
+ ���������
+ </li>
+ </ul>
+ </nz-dropdown>
+ </div>
+ </div>
+ </nz-card>
+ <nz-card [nzBordered]="false" nzTitle="���������({{optionalFixedItems.length}})">
+ <div nz-form-item nz-row>
+ <ng-container *ngFor="let sensor of optionalFixedItems,index as i">
+ <div nz-form-control nz-col [nzSm]="2">
+ </div>
+ <div nz-form-control nz-col [nzSm]="4">
+ <label nz-checkbox [ngModel]="isFixedSensorSelected(sensor.sensorKey)"
+ (ngModelChange) = "changeFixedItem( $event, sensor)"
+ name="fixed_{{sensor.sensorKey}}_selected"></label>
+
+ <label>{{ sensor.name }}</label>
+ </div>
+ </ng-container>
+ </div>
+ </nz-card>
+ </form>
+ </nz-spin>
+ </nz-tab>
+</nz-tabset>
+<footer-toolbar>
+ <label>���������������</label>
+ <span [ngStyle]="{'font-size': '16px','font-weight': 'bold','margin-right':'30px'}">{{ organization.name }}</span>
+ <button nz-button type="button" (click)="backToList()">������</button>
+ <button nz-button [nzType]="'primary'" (click)="save()" [nzLoading]="isSaving">
+ <span>
+ ������
+ <span *ngIf="isSaving">���</span>
+ </span>
+ </button>
+</footer-toolbar>
diff --git a/src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.ts b/src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.ts
new file mode 100644
index 0000000..62ac30c
--- /dev/null
+++ b/src/app/routes/systems/organization/organization-config-screen/organization-config-screen.component.ts
@@ -0,0 +1,222 @@
+import { Component, OnInit } from '@angular/core';
+import { _HttpClient } from '@delon/theme';
+import { NzMessageService } from 'ng-zorro-antd';
+import { OrganizationService } from '@business/services/http/organization.service';
+import { Sensor, Organization } from '@business/entity/data';
+import { ResultBean } from '@business/entity/grid';
+
+@Component({
+ selector: 'app-organization-config-screen',
+ templateUrl: './organization-config-screen.component.html',
+})
+export class OrganizationConfigScreenComponent implements OnInit {
+
+ constructor(
+ private http: _HttpClient,
+ private organizationService: OrganizationService,
+ public msgSrv: NzMessageService
+ ) { }
+ public selectedIndex = 0;
+ public defaultSwapFlag: string;
+ public coreSwapFlag: string;
+ public organization: Organization;
+ public deviceVersions: any[] = [];
+ public addedSensors: any[] = [];
+ // ������������������
+ public surplusSensors: any[] = [];
+ public defaultMonitorItems: any[] = [];
+ public coreMonitorItems: any[] = [];
+ public optionalFixedItems: any[] = [];
+ public fixedMonitorItems: any[] = [];
+ public chartSensorKey: string;
+
+ ngOnInit() {
+ this.organization = this.organizationService.data;
+ this.deviceVersions =
+ !!this.organizationService.getResultBeanData('deviceVersions') ?
+ this.organizationService.getResultBeanData('deviceVersions') : [];
+ const rtdLayout = this.organizationService.getResultBeanData('rtdLayout');
+ const sensorCombs = <any[]>this.organizationService.getResultBeanData('sensorCombs');
+ const optionalFixedItems = <any[]>this.organizationService.getResultBeanData('optionalFixedItems');
+ this.loadPage(rtdLayout, sensorCombs, optionalFixedItems);
+ }
+ swapTab() {
+ const version = this.deviceVersions[this.selectedIndex];
+ this.isSaving = true;
+ this.isSpinning = true;
+ this.http.get('org-layout/rtd-act-config', {orgId: this.organization.id, versionNo: version.version }).subscribe(
+ (res: ResultBean<any>) => {
+ if ( res.code > 0 ) {
+ const data = res.data;
+ const rtdLayout = data.rtdLayout;
+ const sensorCombs = data.sensorCombs;
+ const optionalFixedItems = data.optionalFixedItems;
+ this.loadPage(rtdLayout, sensorCombs, optionalFixedItems);
+ this.isSaving = false;
+ this.isSpinning = false;
+ }
+ }
+ );
+ }
+ loadPage(rtdLayout:
+ {chartSensorKey: string,
+ coreMonitorItems: any[],
+ defaultMonitorItems: any [],
+ optionalFixedItems: any[],
+ fixedMonitorItems: any[]}
+ , sensorCombs: any[], optionalFixedItems: any[]) {
+ this.chartSensorKey = '';
+ this.coreMonitorItems = [];
+ this.defaultMonitorItems = [];
+ this.addedSensors = [];
+ this.surplusSensors = [];
+ this.fixedMonitorItems = [];
+ this.optionalFixedItems = !!optionalFixedItems ? optionalFixedItems : [];
+ if (!!rtdLayout && !!sensorCombs.length) {
+ this.chartSensorKey = rtdLayout.chartSensorKey;
+ this.coreMonitorItems = rtdLayout.coreMonitorItems;
+ this.defaultMonitorItems = rtdLayout.defaultMonitorItems;
+ this.fixedMonitorItems = rtdLayout.fixedMonitorItems;
+ this.addedSensors = [...rtdLayout.coreMonitorItems, ...rtdLayout.defaultMonitorItems];
+ this.surplusSensors = sensorCombs.filter(
+ ( item: any ) => {
+ return !this.addedSensors.some(
+ (sen: any) => {
+ return item.sensorKey === sen.sensorKey;
+ }
+ );
+ }
+ );
+ } else {
+ this.surplusSensors = sensorCombs;
+ }
+ }
+ public get haveTaps(): Boolean {
+ return !!this.deviceVersions && !!this.deviceVersions.length;
+ }
+ public get isCoreItemsFull(): Boolean {
+ return this.coreMonitorItems.length >= 6;
+ }
+ public setChartSensorKey(sensorKey) {
+ this.chartSensorKey = sensorKey;
+ }
+ public itemUp(items: any[], index) {
+ if (index !== 0 ) {
+ const tempIndex = index - 1;
+ const temp = items[tempIndex];
+ items[tempIndex] = items[index];
+ items[index] = temp;
+ }
+ }
+ public itemDown(items: any[], index) {
+ if (index < (items.length - 1) ) {
+ const tempIndex = index + 1;
+ const temp = items[tempIndex];
+ items[tempIndex] = items[index];
+ items[index] = temp;
+ }
+ }
+
+ moveTo(source: any[], sIndex: number, target: any[]) {
+ const temp = source[sIndex];
+ source.splice(sIndex, 1);
+ target.push(temp);
+ // ������������������
+ this.refreshAddedList();
+ this.refreshChartSensorKey();
+ }
+ moveAllto(source: any[], target: any[]) {
+ const length = source.length;
+ target.push(...source);
+ source.splice(0, length);
+ this.refreshAddedList();
+ this.refreshChartSensorKey();
+ }
+ public refreshChartSensorKey() {
+ const isChartKeyRemoved = this.surplusSensors.some(
+ item => {
+ return item.sensorKey === this.chartSensorKey;
+ }
+ );
+ if (isChartKeyRemoved || !this.chartSensorKey) {
+ this.chartSensorKey = null;
+ const length = this.addedSensors.length;
+ if (length > 0) {
+ this.chartSensorKey = this.addedSensors[length - 1].sensorKey;
+ }
+ }
+ }
+ public get chartSensorName() {
+ const sensor = this.addedSensors.find(
+ item => {
+ return item.sensorKey === this.chartSensorKey;
+ }
+ );
+ return !!sensor ? sensor.name : '';
+ }
+ refreshAddedList() {
+ this.addedSensors = [...this.defaultMonitorItems, ...this.coreMonitorItems];
+ }
+ public isSaving = false;
+ public isSpinning = false;
+ save() {
+ this.isSaving = true;
+ const version = this.deviceVersions[this.selectedIndex].version;
+ const orgId = this.organization.id;
+ if ( !!this.addedSensors.length ) {
+ const rtdLayout = {
+ chartSensorKey: this.chartSensorKey,
+ defaultMonitorItems: this.defaultMonitorItems,
+ coreMonitorItems: this.coreMonitorItems,
+ fixedMonitorItems: this.fixedMonitorItems
+ };
+ const rtdLayoutUpload = {
+ realTimeDeviceLayout : rtdLayout,
+ organizationId: orgId,
+ version: version
+ };
+ this.http.post('org-layout/rtd-save', rtdLayoutUpload).subscribe(
+ (res: ResultBean<any>) => {
+ if (res.code > 0 ) {
+ this.isSaving = false;
+ this.msgSrv.success('������������');
+ }
+ }
+ );
+ } else {
+ this.http.get('org-layout/rtd-remove', {orgId: orgId, version: version}).subscribe(
+ (res: ResultBean<any>) => {
+ if (res.code > 0 ) {
+ this.isSaving = false;
+ this.msgSrv.success('������������');
+ }
+ }
+ );
+ }
+ }
+ isFixedSensorSelected(sensorKey: string) {
+ const isSelected = this.fixedMonitorItems.some( item => {
+ return item.sensorKey === sensorKey;
+ });
+ return isSelected;
+ }
+
+ changeFixedItem(event, sensor) {
+ if (event) {
+ this.fixedMonitorItems.push(sensor);
+ } else {
+ const delteIndex = this.fixedMonitorItems.findIndex(
+ item => {
+ return item.sensorKey === sensor.sensorKey;
+ }
+ );
+ if (delteIndex > 0 ) {
+ this.fixedMonitorItems.splice(delteIndex, 1);
+ }
+ }
+ }
+ backToList() {
+ this.organizationService.handle = 'list';
+ this.organizationService.title = '������������';
+ }
+}
diff --git a/src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.html b/src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.html
new file mode 100644
index 0000000..d4ad476
--- /dev/null
+++ b/src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.html
@@ -0,0 +1,42 @@
+<form nz-form>
+ <ng-container *ngIf="!!osuTowDimList.length; else elseTemplate">
+ <div *ngFor= "let osuList of osuTowDimList" nz-form-item nz-row>
+ <ng-container *ngFor="let osu of osuList">
+ <div nz-form-label nz-col [nzSm]="3">
+ <label>{{osu.sensor.description}}</label>
+ </div>
+ <div nz-form-control nz-col [nzSm]="4">
+ <nz-select [nzMode]="'default'" nzAllowClear
+ nzPlaceHolder="{{osu.sensor.unit}}(������������)" [(ngModel)]="osu.sensorUnitId" name="sensorUnitId">
+ <nz-option
+ *ngFor="let option of sensorUnitMap[osu.sensor.id]"
+ [nzLabel]="option.name"
+ [nzValue]="option.id">
+ </nz-option>
+ </nz-select>
+ </div>
+ </ng-container>
+ </div>
+ </ng-container>
+ <ng-template #elseTemplate>
+ <div nz-form-item nz-row>
+ <div nz-form-label nz-col [nzSm]="24" style="text-align: center;">
+ <h2>���������������������������������������������������</h2>
+ </div>
+ </div>
+ </ng-template>
+
+
+
+</form>
+<footer-toolbar>
+ <label>���������������</label>
+ <span [ngStyle]="{'font-size': '16px','font-weight': 'bold','margin-right':'30px'}">{{ organization.name }}</span>
+ <button nz-button type="button" (click)="backToList()">������</button>
+ <button nz-button [nzType]="'primary'" (click)="save()" [nzLoading]="isSaving">
+ <span>
+ ������
+ <span *ngIf="isSaving">���</span>
+ </span>
+ </button>
+</footer-toolbar>
diff --git a/src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.ts b/src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.ts
new file mode 100644
index 0000000..29678a3
--- /dev/null
+++ b/src/app/routes/systems/organization/organization-config-unit/organization-config-unit.component.ts
@@ -0,0 +1,83 @@
+import { Component, OnInit } from '@angular/core';
+import { _HttpClient } from '@delon/theme';
+import { OrganizationService } from '@business/services/http/organization.service';
+import { Organization, OrganizationSensorUnit } from '@business/entity/data';
+import { ResultBean } from '@business/entity/grid';
+import { NzMessageService } from 'ng-zorro-antd';
+
+@Component({
+ selector: 'app-organization-config-unit',
+ templateUrl: './organization-config-unit.component.html',
+})
+export class OrganizationConfigUnitComponent implements OnInit {
+ public organization: Organization;
+ constructor(
+ private http: _HttpClient,
+ private organizationService: OrganizationService,
+ public msgSrv: NzMessageService
+ ) { }
+ public osuTowDimList: OrganizationSensorUnit[][] = [];
+
+ public originalOsuList: OrganizationSensorUnit[] = [];
+ public osuList: OrganizationSensorUnit[];
+ public sensorUnitMap;
+ ngOnInit() {
+ this.organization = this.organizationService.data;
+ this.sensorUnitMap = <OrganizationSensorUnit []> this.organizationService.config.resultBean.data.sensorUnitMap;
+ const osuList = <OrganizationSensorUnit []> this.organizationService.config.resultBean.data.osuList;
+ this.osuList = osuList;
+ // ������������������
+ osuList.forEach(item => {
+ const osu = {};
+ Object.assign(osu, item);
+ this.originalOsuList.push(osu);
+ });
+ if ( !!osuList ) {
+ for (let index = 0 ; index < osuList.length; index += 3 ) {
+ const osuListTemp: OrganizationSensorUnit[] = [];
+ for (let n = 0 ; n < 3; n++ ) {
+ const nTemp = index + n;
+ if (nTemp < osuList.length ) {
+ osuListTemp.push(osuList[nTemp]);
+ }
+ }
+ this.osuTowDimList.push(osuListTemp);
+ }
+ }
+ console.log(this.osuTowDimList);
+ }
+ public isSaving = false;
+ save() {
+ this.isSaving = true;
+ const modifyList = [];
+ // ���������������������
+ this.osuList.forEach(
+ item => {
+ const osu = this.originalOsuList.find(
+ su => {
+ return su.sensor.id === item.sensor.id &&
+ su.sensorUnitId !== item.sensorUnitId;
+ }
+ );
+ if (!!osu) {
+ modifyList.push(item);
+ }
+ }
+ );
+ if (!!modifyList.length) {
+ this.http.post('org-sunit/saves', modifyList).subscribe(
+ (res: ResultBean<any>) => {
+ if (res.code > 0 ) {
+ this.isSaving = false;
+ this.msgSrv.success(this.organization.name + ' ���������������');
+ // this.backToList();
+ }
+ }
+ );
+ }
+ }
+ backToList() {
+ this.organizationService.handle = 'list';
+ this.organizationService.title = '������������';
+ }
+}
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 607f51d..fe80593 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
@@ -57,7 +57,7 @@
alarmConfig = this.alarmConfigService.generateAlarmConfig(pageBean.data);
} else {
// ������ ������ ���������
- alarmConfig = this.alarmConfigService.generateAlarmConfig(pageBean.data, resultBean.data);
+ alarmConfig = this.alarmConfigService.generateAlarmConfig(pageBean.data, <AlarmConfig>resultBean.data);
}
const alarmConfigValue = alarmConfig.value;
@@ -183,7 +183,7 @@
result => {
if (result != null && result.code === 1) {
this.msgSrv.success(this.organization.name + ' ���������������');
- this.backToList();
+ // this.backToList();
}
}
);
diff --git a/src/app/routes/systems/organization/organization-list/organization-list.component.html b/src/app/routes/systems/organization/organization-list/organization-list.component.html
index e1ed4eb..0bb7324 100644
--- a/src/app/routes/systems/organization/organization-list/organization-list.component.html
+++ b/src/app/routes/systems/organization/organization-list/organization-list.component.html
@@ -51,8 +51,6 @@
</span>
</td>
<td nz-td>
- <a (click)="config(row)">������</a>
- <span nz-table-divider></span>
<a (click)="addOrModify(row)">������</a>
<span nz-table-divider></span>
<nz-popconfirm [nzTitle]="'������������������'+grid.title+'���?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" >
@@ -60,6 +58,23 @@
</nz-popconfirm>
<span nz-table-divider></span>
<a [routerLink]="['/systems/registration']" (click)="registration(row)">���������</a>
+ <span nz-table-divider></span>
+ <nz-dropdown>
+ <a class="ant-dropdown-link" nz-dropdown>
+ ������ <i class="anticon anticon-down"></i>
+ </a>
+ <ul nz-menu>
+ <li nz-menu-item>
+ <a (click)="configAlarm(row)">������������������</a>
+ </li>
+ <li nz-menu-item>
+ <a (click)="configScreenLayout(row)">������������������</a>
+ </li>
+ <li nz-menu-item>
+ <a (click)="configShowUnit(row)">������������������</a>
+ </li>
+ </ul>
+ </nz-dropdown>
</td>
</tr>
</tbody>
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 38ced8b..3cce5b9 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
@@ -1,11 +1,11 @@
import { AlarmConfigService } from '@business/services/http/alarm-config.service';
import { SensorsService } from '@business/services/http/sensors.service';
import { Router } from '@angular/router';
-import { ModalHelper } from '@delon/theme';
+import { ModalHelper, _HttpClient } from '@delon/theme';
import { NzModalService, NzMessageService } from 'ng-zorro-antd';
import { OrganizationService } from '@business/services/http/organization.service';
-import { Grid, Column, PageBean } from '@business/entity/grid';
-import { Organization } from '@business/entity/data';
+import { Grid, Column, PageBean, ResultBean } from '@business/entity/grid';
+import { Organization, OrganizationSensorUnit } from '@business/entity/data';
import { Component, OnInit } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { Types } from '@business/enum/types.enum';
@@ -95,6 +95,7 @@
private router: Router,
private sensorsService: SensorsService,
private alarmConfigService: AlarmConfigService,
+ private http: _HttpClient
) {}
ngOnInit() {
@@ -210,7 +211,7 @@
}
this.load();
}
- config(row) {
+ configAlarm(row) {
// ������������������ExpressionChangedAfterItHasBeenCheckedError
setTimeout(() => {
this.grid.loading = true;
@@ -219,15 +220,49 @@
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.title = '������������';
+ this.organizationService.title = '������������������';
});
}
-
+ configScreenLayout(row) {
+ // ������������������ExpressionChangedAfterItHasBeenCheckedError
+ setTimeout(() => {
+ this.grid.loading = true;
+ }, 1);
+ this.http.get('org-layout/rtd-config', {orgId: row.id}).subscribe(
+ (res: ResultBean<any>) => {
+ if ( res.code > 0 ) {
+ this.grid.loading = false;
+ this.organizationService.handle = 'screen' ;
+ this.organizationService.data = row;
+ this.organizationService.config['resultBean'] = res;
+ console.log(res);
+ this.organizationService.title = '������������������';
+ }
+ }
+ );
+ }
+ configShowUnit(row) {
+ // ������������������ExpressionChangedAfterItHasBeenCheckedError
+ setTimeout(() => {
+ this.grid.loading = true;
+ }, 1);
+ this.http.get('org-sunit/gets-byoid', {orgId: row.id}).subscribe(
+ (res: ResultBean<any>) => {
+ if ( res.code > 0 ) {
+ this.grid.loading = false;
+ this.organizationService.handle = 'unit' ;
+ this.organizationService.data = row;
+ this.organizationService.config['resultBean'] = res;
+ console.log(res);
+ this.organizationService.title = '������������������';
+ }
+ }
+ );
+ }
registration(row) {
sessionStorage.setItem('organization', JSON.stringify(row));
}
diff --git a/src/app/routes/systems/organization/organization.component.html b/src/app/routes/systems/organization/organization.component.html
index eb4b3db..8e39e35 100644
--- a/src/app/routes/systems/organization/organization.component.html
+++ b/src/app/routes/systems/organization/organization.component.html
@@ -5,6 +5,8 @@
<ng-template #body>
<app-organization-list *ngIf="organizationService.handle=='list'"></app-organization-list>
<app-organization-config *ngIf="organizationService.handle=='config'"></app-organization-config>
+ <app-organization-config-screen *ngIf="organizationService.handle=='screen'"></app-organization-config-screen>
+ <app-organization-config-unit *ngIf="organizationService.handle=='unit'"></app-organization-config-unit>
</ng-template>
</nz-card>
diff --git a/src/app/routes/systems/systems.module.ts b/src/app/routes/systems/systems.module.ts
index dd8ad35..e3e7ba5 100644
--- a/src/app/routes/systems/systems.module.ts
+++ b/src/app/routes/systems/systems.module.ts
@@ -18,6 +18,8 @@
import { RegistrationComponent } from './registration/registration.component';
import { SensorsService } from '@business/services/http/sensors.service';
import { BusinessModule } from '@business/business.module';
+import { OrganizationConfigScreenComponent } from './organization/organization-config-screen/organization-config-screen.component';
+import { OrganizationConfigUnitComponent } from './organization/organization-config-unit/organization-config-unit.component';
const routes: Routes = [
{
@@ -48,6 +50,8 @@
OrganizationComponent,
OrganizationConfigComponent,
OrganizationListComponent,
+ OrganizationConfigScreenComponent,
+ OrganizationConfigUnitComponent,
RegistrationComponent
],
providers: [ToolsService, SensorsService, OrganizationService, _HttpClient, FormBuilder, AreacodeService],
--
Gitblit v1.8.0