Commit 48554d2d authored by van.chen's avatar van.chen

传感器的批量操作

parent 8cef0734
......@@ -159,18 +159,14 @@
</div>
<div class="item-input">
<input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device"
(ngModelChange)="companySelected()"
(input)="onInput($event.target?.value)">
<nz-autocomplete nzBackfill #auto>
<nz-auto-option *ngFor="let one of selectedGateways" [nzLabel]="one.type + '-' + one.sn" [nzValue]="one">
<nz-auto-option *ngFor="let one of selectedGateways" (click)="companySelected()" [nzLabel]="one.type + '-' + one.sn" [nzValue]="one">
{{one.type}} - {{one.sn}}
</nz-auto-option>
</nz-autocomplete>
</div>
</div>
<app-search-select inModal="true" *ngIf="req3.device" [(value)]="req.influxdbDatabaseNo"
[label]="'selectInfluxDB' | translate" optL="databaseName"
[data]="influxdbs" optV="influxdbDatabaseNo"></app-search-select>
<app-search-item isMust="true" inModal="true" [label]="isMulti ? ('bindStartTongxinAddr' | translate): ('bindTongxinAddr' | translate)"
nz-tooltip [nzTitle]="'gatewayBindTips' | translate"
[(value)]="req3.address"></app-search-item>
......
......@@ -107,19 +107,19 @@ export class GatewayComponent implements OnInit {
}
companySelected() {
if (!this.req3.device.companyNo) {
this.message.error('该网关并无所属公司');
return;
}
this.isLoading = true;
this.api.influxdbTables.getByCompanyNo([{companyNo: this.req3.device.companyNo}, (data) => {
if (data && data.constructor === Array) {
this.influxdbs = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
// if (!this.req3.device.companyNo) {
// this.message.error('该网关并无所属公司');
// return;
// }
// this.isLoading = true;
// this.api.influxdbTables.getByCompanyNo([{companyNo: this.req3.device.companyNo}, (data) => {
// if (data && data.constructor === Array) {
// this.influxdbs = data;
// } else {
// this.message.error(data && data.message ? data.message : '获取数据失败');
// }
// this.isLoading = false;
// }]);
}
onSearch() {
......@@ -289,21 +289,33 @@ export class GatewayComponent implements OnInit {
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) {
this.api.device.batchAddGateway([this.req, this.next]);
// 批量绑定
} 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, index) => {
let i = 0;
this.data.map((one) => {
if (one.checked) {
this.req3.bindDeviceAddressVos.push({deviceNo: one.deviceNo, address: Number(this.req3.address) + index});
this.req3.bindDeviceAddressVos.push({deviceNo: one.deviceNo, address: Number(this.req3.address) + i});
i++;
}
});
this.api.device.batchBindDevice([this.req3, this.next]);
// 批量分配
} else if (this.isMulti && this.isDivideConV) {
this.req4.devices = [];
this.data.map((one) => {
if (one.checked) {
this.req4.devices.push(one.deviceNo);
}
});
this.req4.influxdbDatabaseNo = 'ITN78344312655581185';
this.api.device.batchUpdateCompany([this.req4, this.next]);
}
}
......@@ -346,13 +358,13 @@ export class GatewayComponent implements OnInit {
allBind() {
this.isMulti = true;
this.isBindConV = true;
this.req3 = {};
this.try = {
trans: {address: 'bindStartTongxinAddr'},
field: ['address'],
num: ['address']
};
this.isBindConV = true;
}
allDelete() {
......@@ -363,7 +375,16 @@ export class GatewayComponent implements OnInit {
});
}
deleteAll() {}
deleteAll() {
const obj = [];
this.data.map((one) => {
if (one.checked) {
obj.push(one.deviceNo);
}
});
this.isLoading = true;
this.api.device.batchDelDevice([obj, this.next]);
}
allUnbind() {
this.modalService.confirm({
......
......@@ -72,7 +72,7 @@
</tr>
</tbody>
</nz-table>
<div class="btnLine whenOneLine" style="text-align: left; margin-top: -48px;">
<div class="btnLine whenOneLine" style="position: absolute;bottom: 30px;">
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDelete()">
<span>{{'delete' | translate}}</span></button>
<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!canbind" (click)="allBind()"><span>{{'bind' | translate}}</span>
......@@ -81,14 +81,9 @@
<span>{{'unbind' | translate}}</span></button>
<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDivide()"><span>{{'divide' | translate}}</span>
</button>
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()">
<span>{{'update' | translate}}</span></button>
<!--<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()">-->
<!--<span>{{'update' | translate}}</span></button>-->
</div>
<!--<div class="pagePart whenOneLine">-->
<!--<nz-pagination [nzPageIndex]="page" [nzTotal]="total" [nzPageSize]="rows"-->
<!--[nzShowTotal]="totalTemplate"></nz-pagination>-->
<!--<ng-template #totalTemplate> 共 {{ total }} 项</ng-template>-->
<!--</div>-->
</div>
<nz-modal [(nzVisible)]="isAddConV" [nzContent]="con1" nzWidth="500" [nzTitle]="isUpdate ? ('updateSensor' | translate) : ('addSensor' | translate)"
......@@ -107,33 +102,49 @@
[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>
<app-search-select isMust="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"
[label]="'selectInfluxDB' | translate" optL="databaseName"
[data]="influxdbs" inModal="true" optV="influxdbDatabaseNo"></app-search-select>
<!--<app-search-select isMust="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"-->
<!--[label]="'selectInfluxDB' | translate" optL="databaseName"-->
<!--[data]="influxdbs" inModal="true" optV="influxdbDatabaseNo"></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-item inModal="true" isMust="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
</ng-template>
<ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req')"><span>{{'confirm' | translate}}</span></button>
</ng-template>
</nz-modal>
<nz-modal [(nzVisible)]="isMultiAddConV" [nzContent]="con2" nzWidth="500"
[nzFooter]="foot2" (nzOnCancel)="cancel('isMultiAddConV')" nzMaskClosable="false">
<nz-modal [(nzVisible)]="isMultiAddConV" [nzContent]="con2" nzWidth="500" [nzTitle]="('multiAdd' | translate) + ('sensor' | translate)"
[nzFooter]="foot2" (nzOnCancel)="cancel()" nzMaskClosable="false">
<ng-template #con2>
批量新增传感器
<app-search-item isMust="true" inModal="true" [label]="'startSN' | translate"
[(value)]="req.startSN"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'addNum' | translate"
[(value)]="req.num"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'type' | translate"
[(value)]="req.type"></app-search-item>
<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>
<!--<app-search-select inModal="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"-->
<!--[label]="'selectInfluxDB' | translate" optL="databaseName"-->
<!--[data]="influxdbs" optV="influxdbDatabaseNo"></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-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item>
</ng-template>
<ng-template #foot2>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isMultiAddConV')"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('isMultiAddConV')"><span>{{'confirm' | translate}}</span></button>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req')"><span>{{'confirm' | translate}}</span></button>
</ng-template>
</nz-modal>
<nz-modal [(nzVisible)]="isBindConV" [nzContent]="con3" nzWidth="500" [nzTitle]="'bindGateway' | translate"
[nzFooter]="foot3" (nzOnCancel)="cancel('isBindConV')" nzMaskClosable="false">
[nzFooter]="foot3" (nzOnCancel)="cancel()" nzMaskClosable="false">
<ng-template #con3>
<div class="searchItem inModal">
<div class="item-label">
......@@ -142,7 +153,7 @@
<div class="item-input">
<input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device" (input)="onInput($event.target?.value)">
<nz-autocomplete nzBackfill #auto>
<nz-auto-option *ngFor="let one of selectedGateways" [nzLabel]="one.type + '-' + one.sn" [nzValue]="one">
<nz-auto-option *ngFor="let one of selectedGateways" (click)="companySelected()" [nzLabel]="one.type + '-' + one.sn" [nzValue]="one">
{{one.type}} - {{one.sn}}
</nz-auto-option>
</nz-autocomplete>
......@@ -153,7 +164,7 @@
[(value)]="req3.address"></app-search-item>
</ng-template>
<ng-template #foot3>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isBindConV')">
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()">
<span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req3')">
<span>{{'confirm' | translate}}</span></button>
......@@ -161,13 +172,13 @@
</nz-modal>
<nz-modal [(nzVisible)]="isDivideConV" [nzContent]="con5" nzWidth="500" [nzTitle]="('divide' | translate) + ('sensor' | translate)"
[nzFooter]="foot5" (nzOnCancel)="cancel('isDivideConV')" nzMaskClosable="false">
[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"></app-search-select>
</ng-template>
<ng-template #foot5>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isDivideConV')"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req5')"><span>{{'confirm' | translate}}</span></button>
</ng-template>
</nz-modal>
......@@ -68,12 +68,10 @@ export class SensorMgrComponent implements OnInit {
if (data && data.rows && data.rows.constructor === Array) {
this.data = data.rows;
this.total = data.total;
this.oneCheck();
} else if (data.code === 1) {
this.message.success(data && data.message ? data.message : '操作成功');
this.isAddConV = false;
this.isMultiAddConV = false;
this.isBindConV = false;
this.isDivideConV = false;
this.cancel();
this.getData();
} else if (data.code === 0) {
this.message.error(data && data.message ? data.message : '操作失败');
......@@ -208,15 +206,15 @@ export class SensorMgrComponent implements OnInit {
}
companySelected(e) {
this.isLoading = true;
this.api.influxdbTables.getByCompanyNo([{companyNo: e}, (data) => {
if (data && data.constructor === Array) {
this.influxdbs = data;
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}]);
// this.isLoading = true;
// this.api.influxdbTables.getByCompanyNo([{companyNo: e}, (data) => {
// if (data && data.constructor === Array) {
// this.influxdbs = data;
// } else {
// this.message.error(data && data.message ? data.message : '获取数据失败');
// }
// this.isLoading = false;
// }]);
}
// 跳转详情
......@@ -284,8 +282,11 @@ export class SensorMgrComponent implements OnInit {
field: ['name', 'sn', 'type', 'companyNo', 'deviceNo']};
}
cancel(v) {
this[v] = false;
cancel() {
this.isMultiAddConV = false;
this.isAddConV = false;
this.isBindConV = false;
this.isDivideConV = false;
}
save(v) {
......@@ -294,22 +295,56 @@ export class SensorMgrComponent implements OnInit {
this.isLoading = false;
return;
}
// 单个新增
if (!this.isMulti && this.isAddConV && !this.isUpdate) {
this.req.alarmMethodNos = [];
this.req.alarmUsers = [];
this.req.model = 1;
this.api.device.addSensorOrBlend([this.req, this.next]);
// 单个编辑
} else if (!this.isMulti && this.isAddConV && this.isUpdate) {
this.req.alarmMethodNos = [];
this.req.alarmUsers = [];
this.req.model = 1;
this.api.device.updateSensor([this.req, this.next]);
// 单个绑定
} else if (!this.isMulti && this.isBindConV) {
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.isDivideConV) {
this.api.device.updateCompany([this.req5, this.next]);
// 批量新增
} else if (this.isMulti && this.isMultiAddConV) {
this.req.alarmMethodNos = [];
this.req.alarmUsers = [];
this.req.model = 1;
this.api.device.batchAddSensor([this.req, this.next]);
// 批量绑定
} 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;
let i = 0;
this.data.map((one) => {
if (one.checked) {
this.req3.bindDeviceAddressVos.push({deviceNo: one.deviceNo, address: Number(this.req3.address) + i});
i++;
}
});
this.api.device.batchBindDevice([this.req3, this.next]);
// 批量分配
} else if (this.isMulti && this.isDivideConV) {
this.req5.devices = [];
this.data.map((one) => {
if (one.checked) {
this.req5.devices.push(one.deviceNo);
}
});
this.req5.influxdbDatabaseNo = 'ITN78344312655581185';
this.api.device.batchUpdateCompany([this.req5, this.next]);
}
}
......@@ -335,16 +370,29 @@ export class SensorMgrComponent implements OnInit {
multiAdd() {
this.isUpdate = false;
this.isMulti = true;
this.req = {};
this.try = {
trans: {startSN: 'startSN', num: 'addNum', type: 'type', companyNo: 'selectCompany', topicModelNo: 'topicModel'},
field: ['startSN', 'num', 'type', 'companyNo', 'topicModelNo']
};
this.isMultiAddConV = true;
}
allDivide() {
this.isMulti = true;
this.req5 = {};
this.try = {trans: {companyNo: 'selectCompany'}, field: ['companyNo']};
this.isDivideConV = true;
}
allBind() {
this.isMulti = true;
this.req3 = {};
this.try = {
trans: {address: 'bindStartTongxinAddr'},
field: ['address'],
num: ['address']
};
this.isBindConV = true;
}
......@@ -356,7 +404,16 @@ export class SensorMgrComponent implements OnInit {
});
}
deleteAll() {}
deleteAll() {
const obj = [];
this.data.map((one) => {
if (one.checked) {
obj.push(one.deviceNo);
}
});
this.isLoading = true;
this.api.device.batchDelDevice([obj, this.next]);
}
allUnbind() {
this.modalService.confirm({
......@@ -366,7 +423,16 @@ export class SensorMgrComponent implements OnInit {
});
}
unbindAll() {}
unbindAll() {
const obj = [];
this.data.map((one) => {
if (one.checked) {
obj.push(one.deviceNo);
}
});
this.isLoading = true;
this.api.device.batchUnBindDevice([obj, this.next]);
}
toggleOn(one) {
one.isLoading = true;
......
......@@ -4,9 +4,9 @@
export const environment = {
production: false,
// baseUrl: 'http://cloud-test.witium.com/api', // 对外访问测试网地址
baseUrl: 'http://cloud-test.witium.com/api', // 对外访问测试网地址
// baseUrl: 'http://172.16.1.53:8092', // cy
baseUrl: 'http://172.16.1.52:8094', // zz
// baseUrl: 'http://172.16.1.52:8094', // zz
// baseUrl: 'http://172.16.1.13:8094', // 测试
};
......
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