Commit 22da2b90 authored by yating.lin's avatar yating.lin

修改网关管理页面、传感器管理页面

parent 776417ce
......@@ -108,12 +108,15 @@
[(value)]="req.configJson"></app-search-item>
<app-search-select isMust="true" inModal="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate"
optL="companyName"
[data]="companys" optV="companyNo"></app-search-select>
<!--<app-search-select inModal="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"-->
<!--[label]="'selectInfluxDB' | translate" optL="databaseName"-->
<!--[data]="influxdbs" optV="influxdbDatabaseNo"></app-search-select>-->
[data]="companys" optV="companyNo"
(valueChange)="onAddChangeCompany(req.companyNo)"></app-search-select>
<app-search-select inModal="true" [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" optV="sceneNo"></app-search-select>
<app-search-select inModal="true" [label]="'selectInfluxDBTable' | translate" [(value)]="req.influxdbDatabaseNo"
[data]="companyInfluxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
<app-search-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
</ng-template>
......@@ -135,12 +138,14 @@
<app-search-item isMust="true" inModal="true" [label]="'type' | translate"
[(value)]="req.type"></app-search-item>
<app-search-select isMust="true" inModal="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate"
optL="companyName" [data]="companys" optV="companyNo"></app-search-select>
<app-search-select inModal="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"
[label]="'selectInfluxDB' | translate" optL="databaseName"
[data]="influxdbs" optV="influxdbDatabaseNo"></app-search-select>
optL="companyName" [data]="companys" optV="companyNo"
(valueChange)="onAddChangeCompany(req.companyNo)"></app-search-select>
<app-search-select inModal="true" [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" optV="sceneNo"></app-search-select>
<app-search-select inModal="true" [label]="'selectInfluxDBTable' | translate" [(value)]="req.influxdbDatabaseNo"
[data]="companyInfluxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
<app-search-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
</ng-template>
......@@ -186,7 +191,12 @@
[nzFooter]="foot4" (nzOnCancel)="cancel('isDivideConV')" nzMaskClosable="false">
<ng-template #con4>
<app-search-select isMust="true" [(value)]="req4.companyNo" [label]="'selectCompany' | translate" optL="companyName"
[data]="companys" inModal="true" optV="companyNo"></app-search-select>
[data]="companys" inModal="true" optV="companyNo"
(valueChange)="onDivideChangeCompany(req4.companyNo)"></app-search-select>
<app-search-select isMust="true" inModal="true" [label]="'selectCompanyInfluxDBTable' | translate" [(value)]="req4.influxdbDatabaseNo"
[data]="companyInfluxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
</ng-template>
<ng-template #foot4>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isDivideConV')">
......
......@@ -49,6 +49,9 @@ export class GatewayComponent implements OnInit {
total = 0;
@ViewChild('influxdb') influx;
influxDBTableList = [];
companyInfluxDBTableList = [];
constructor(private api: ApiService, private message: NzMessageService, private router: Router,
private modalService: NzModalService, private translate: TranslateService,
private ck: CheckService) {
......@@ -61,6 +64,7 @@ export class GatewayComponent implements OnInit {
init() {
this.getData();
this.getCompanys();
this.getAllInfluxDB();
}
next = (data) => {
......@@ -230,7 +234,7 @@ export class GatewayComponent implements OnInit {
this.req3 = {
address: '',
deviceNo: one.deviceNo,
influxdbDatabaseNo: 'ITN78344312655581185',
influxdbDatabaseNo: one.influxdbDatabaseNo,
pDeviceNo: ''
};
this.try = {
......@@ -257,6 +261,7 @@ export class GatewayComponent implements OnInit {
update(one) {
this.isMulti = false;
this.req = {...one};
this.getInfluxDBByCompany(one.companyNo);
this.try = {
trans: {name: 'gatewayName', sn: 'gatewaySN', companyNo: 'selectCompany'},
field: ['name', 'sn', 'companyNo', 'deviceNo']
......@@ -268,7 +273,10 @@ export class GatewayComponent implements OnInit {
divide(one) {
this.isMulti = false;
this.req4 = {...one};
this.try = {trans: {companyNo: 'selectCompany'}, field: ['companyNo', 'deviceNo']};
this.getInfluxDBByCompany(one.companyNo);
this.try = {
trans: {companyNo: 'selectCompany', influxdbDatabaseNo: 'selectCompanyInfluxDBTable'},
field: ['companyNo', 'deviceNo', 'influxdbDatabaseNo']};
this.isDivideConV = true;
}
......@@ -278,41 +286,31 @@ export class GatewayComponent implements OnInit {
save(v) {
this.isLoading = true;
console.log('im here');
if (!this.ck.formCheck(this[v], this.try)) {
this.isLoading = false;
return;
}
console.log('im here 2');
// 单个新增
if (!this.isMulti && this.isAddConV && !this.isUpdate) {
console.log('add');
this.api.device.addGateway([this.req, this.next]);
// 单个编辑
} else if (!this.isMulti && this.isAddConV && this.isUpdate) {
console.log('updateGateway');
this.api.device.updateGateway([this.req, this.next]);
// 单个分配
} else if (!this.isMulti && this.isDivideConV) {
console.log('updateCompany');
this.api.device.updateCompany([this.req4, this.next]);
// 单个绑定
} else if (!this.isMulti && this.isBindConV) {
console.log('gatewayBindGateway');
// this.req3.device = null;
this.req3.pDeviceNo = this.req3.device.deviceNo;
this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo ? this.req3.device.influxdbDatabaseNo : 'ITN78344312655581185';
this.api.device.gatewayBindGateway([this.req3, this.next]);
// 批量新增
} else if (this.isMulti && this.isMultiAddConV) {
console.log('batchAddGateway');
this.api.device.batchAddGateway([this.req, this.next]);
// 批量绑定
} else if (this.isMulti && this.isBindConV) {
console.log('multiply');
this.req3.bindDeviceAddressVos = [];
this.req3.pDeviceNo = this.req3.device.deviceNo;
this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo ? this.req3.device.influxdbDatabaseNo : 'ITN78344312655581185';
this.req3.device = null;
this.data.map((one) => {
......@@ -329,7 +327,6 @@ export class GatewayComponent implements OnInit {
this.req4.devices.push(one.deviceNo);
}
});
this.req4.influxdbDatabaseNo = 'ITN78344312655581185';
this.api.device.batchUpdateCompany([this.req4, this.next]);
}
}
......@@ -368,7 +365,9 @@ export class GatewayComponent implements OnInit {
this.req4 = {};
this.isMulti = true;
this.isDivideConV = true;
this.try = {trans: {companyNo: 'selectCompany'}, field: ['companyNo']};
this.try = {
trans: {companyNo: 'selectCompany', influxdbDatabaseNo: 'selectCompanyInfluxDBTable'},
field: ['companyNo', 'influxdbDatabaseNo']};
}
allBind() {
......@@ -433,4 +432,45 @@ export class GatewayComponent implements OnInit {
one.isLoading = false;
}]);
}
getAllInfluxDB() {
this.isLoading = true;
this.influxDBTableList = [];
this.api.influxdbTables.getAll( ['', (data) => {
if (data && data.constructor === Array) {
this.influxDBTableList = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
getInfluxDBByCompany(value) {
this.companyInfluxDBTableList = [];
if (value) {
this.isLoading = true;
this.api.influxdbTables.getByCompanyNo( [{companyNo: value}, (data) => {
if (data && data.constructor === Array) {
this.companyInfluxDBTableList = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
}
}
onAddChangeCompany(value) {
this.req.influxdbDatabaseNo = null;
this.companyInfluxDBTableList = [];
this.getInfluxDBByCompany(value);
}
onDivideChangeCompany(value) {
this.req4.influxdbDatabaseNo = null;
this.companyInfluxDBTableList = [];
this.getInfluxDBByCompany(value);
}
}
......@@ -103,12 +103,12 @@
<app-search-select *ngIf="!isUpdate" isMust="true" [(value)]="req.topicModelNo" [label]="'topicModel' | translate" optL="topicModelName"
[data]="topicModels" inModal="true" optV="topicModelNo"></app-search-select>
<app-search-select isMust="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate" optL="companyName"
(valueChange)="companySelected($event)" [data]="companys" inModal="true" optV="companyNo"></app-search-select>
(valueChange)="onAddChangeCompany(req.companyNo)" [data]="companys" inModal="true" optV="companyNo"></app-search-select>
<app-search-select [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" inModal="true" optV="sceneNo"></app-search-select>
<app-search-select inModal="true" [label]="'selectInfluxDBTable' | translate" [(value)]="req.influxdbDatabaseNo"
[data]="influxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
[data]="companyInfluxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
<app-search-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
......@@ -131,12 +131,13 @@
<app-search-select isMust="true" [(value)]="req.topicModelNo" [label]="'topicModel' | translate" optL="topicModelName"
[data]="topicModels" inModal="true" optV="topicModelNo"></app-search-select>
<app-search-select isMust="true" inModal="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate"
optL="companyName" [data]="companys" optV="companyNo"></app-search-select>
optL="companyName" [data]="companys" optV="companyNo"
(valueChange)="onAddChangeCompany(req.companyNo)"></app-search-select>
<app-search-select inModal="true" [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" optV="sceneNo"></app-search-select>
<app-search-select inModal="true" [label]="'selectInfluxDBTable' | translate" [(value)]="req.influxdbDatabaseNo"
[data]="influxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
[data]="companyInfluxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
<app-search-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
......@@ -179,7 +180,8 @@
[nzFooter]="foot5" (nzOnCancel)="cancel()" nzMaskClosable="false">
<ng-template #con5>
<app-search-select isMust="true" [(value)]="req5.companyNo" [label]="'selectCompany' | translate" optL="companyName"
[data]="companys" inModal="true" optV="companyNo" (valueChange)="onChangeDivideCompany(req5.companyNo)"></app-search-select>
[data]="companys" inModal="true" optV="companyNo"
(valueChange)="onDivideChangeCompany(req5.companyNo)"></app-search-select>
<app-search-select isMust="true" inModal="true" [label]="'selectCompanyInfluxDBTable' | translate" [(value)]="req5.influxdbDatabaseNo"
[data]="companyInfluxDBTableList" optL="databaseName" optV="influxdbDatabaseNo"></app-search-select>
......
......@@ -301,7 +301,7 @@ export class SensorMgrComponent implements OnInit {
update(one) {
this.isMulti = false;
this.req = {...one};
this.companySelected(one.companyNo);
this.getInfluxDBByCompany(one.companyNo);
this.isUpdate = true;
this.isAddConV = true;
this.try = {
......@@ -331,7 +331,12 @@ export class SensorMgrComponent implements OnInit {
}
}
onChangeDivideCompany(value) {
onAddChangeCompany(value) {
this.req.influxdbDatabaseNo = null;
this.companyInfluxDBTableList = [];
this.getInfluxDBByCompany(value);
}
onDivideChangeCompany(value) {
this.req5.influxdbDatabaseNo = null;
this.companyInfluxDBTableList = [];
this.getInfluxDBByCompany(value);
......@@ -372,7 +377,6 @@ export class SensorMgrComponent implements OnInit {
} else if (this.isMulti && this.isBindConV) {
this.req3.bindDeviceAddressVos = [];
this.req3.pDeviceNo = this.req3.device.deviceNo;
// this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo ? this.req3.device.influxdbDatabaseNo : 'ITN78344312655581185';
this.req3.device = null;
this.data.map((one) => {
if (one.checked) {
......@@ -388,7 +392,6 @@ export class SensorMgrComponent implements OnInit {
this.req5.devices.push(one.deviceNo);
}
});
// this.req5.influxdbDatabaseNo = 'ITN78344312655581185';
this.api.device.batchUpdateCompany([this.req5, this.next]);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment