Commit 64873932 authored by van.chen's avatar van.chen

网管的一些批量操作

parent 95ab2f6f
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</tr> </tr>
</tbody> </tbody>
</nz-table> </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()"> <button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDelete()">
<span>{{'delete' | translate}}</span></button> <span>{{'delete' | translate}}</span></button>
<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!canbind" (click)="allBind()"> <button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!canbind" (click)="allBind()">
...@@ -86,13 +86,8 @@ ...@@ -86,13 +86,8 @@
<button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDivide()"> <button nz-button class="btnAll" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allDivide()">
<span>{{'divide' | translate}}</span> <span>{{'divide' | translate}}</span>
</button> </button>
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()"> <!--<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()">-->
<span>{{'update' | translate}}</span></button> <!--<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>
</div> </div>
<nz-modal [(nzVisible)]="isAddConV" [nzTitle]="isUpdate ? ('updateGateway' | translate) : ('addGateway' | translate)" <nz-modal [(nzVisible)]="isAddConV" [nzTitle]="isUpdate ? ('updateGateway' | translate) : ('addGateway' | translate)"
...@@ -111,11 +106,10 @@ ...@@ -111,11 +106,10 @@
[(value)]="req.configJson"></app-search-item> [(value)]="req.configJson"></app-search-item>
<app-search-select isMust="true" inModal="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate" <app-search-select isMust="true" inModal="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate"
optL="companyName" optL="companyName"
(valueChange)="companySelected($event)"
[data]="companys" optV="companyNo"></app-search-select> [data]="companys" optV="companyNo"></app-search-select>
<app-search-select inModal="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo" <!--<app-search-select inModal="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"-->
[label]="'selectInfluxDB' | translate" optL="databaseName" <!--[label]="'selectInfluxDB' | translate" optL="databaseName"-->
[data]="influxdbs" optV="influxdbDatabaseNo"></app-search-select> <!--[data]="influxdbs" optV="influxdbDatabaseNo"></app-search-select>-->
<app-search-select inModal="true" [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName" <app-search-select inModal="true" [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" optV="sceneNo"></app-search-select> [data]="scenes" optV="sceneNo"></app-search-select>
<app-search-item inModal="true" [label]="'remark' | translate" <app-search-item inModal="true" [label]="'remark' | translate"
...@@ -129,15 +123,29 @@ ...@@ -129,15 +123,29 @@
</ng-template> </ng-template>
</nz-modal> </nz-modal>
<nz-modal [(nzVisible)]="isMultiAddConV" [nzContent]="con2" nzWidth="500" <nz-modal [(nzVisible)]="isMultiAddConV" [nzContent]="con2" nzWidth="500" [nzTitle]="('multiAdd' | translate) + ('gateway' | translate)"
[nzFooter]="foot2" (nzOnCancel)="cancel('isMultiAddConV')" nzMaskClosable="false"> [nzFooter]="foot2" (nzOnCancel)="cancel('isMultiAddConV')" nzMaskClosable="false">
<ng-template #con2> <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" 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>
<ng-template #foot2> <ng-template #foot2>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isMultiAddConV')"> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isMultiAddConV')">
<span>{{'cancel' | translate}}</span></button> <span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req2')"> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req')">
<span>{{'confirm' | translate}}</span></button> <span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
...@@ -151,6 +159,7 @@ ...@@ -151,6 +159,7 @@
</div> </div>
<div class="item-input"> <div class="item-input">
<input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device" <input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device"
(ngModelChange)="companySelected()"
(input)="onInput($event.target?.value)"> (input)="onInput($event.target?.value)">
<nz-autocomplete nzBackfill #auto> <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" [nzLabel]="one.type + '-' + one.sn" [nzValue]="one">
...@@ -159,8 +168,11 @@ ...@@ -159,8 +168,11 @@
</nz-autocomplete> </nz-autocomplete>
</div> </div>
</div> </div>
<app-search-item isMust="true" inModal="true" [label]="'bindTongxinAddr' | translate" nz-tooltip <app-search-select inModal="true" *ngIf="req3.device" [(value)]="req.influxdbDatabaseNo"
[nzTitle]="'gatewayBindTips' | translate" [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> [(value)]="req3.address"></app-search-item>
</ng-template> </ng-template>
<ng-template #foot3> <ng-template #foot3>
...@@ -176,7 +188,6 @@ ...@@ -176,7 +188,6 @@
[nzFooter]="foot4" (nzOnCancel)="cancel('isDivideConV')" nzMaskClosable="false"> [nzFooter]="foot4" (nzOnCancel)="cancel('isDivideConV')" nzMaskClosable="false">
<ng-template #con4> <ng-template #con4>
<app-search-select isMust="true" [(value)]="req4.companyNo" [label]="'selectCompany' | translate" optL="companyName" <app-search-select isMust="true" [(value)]="req4.companyNo" [label]="'selectCompany' | translate" optL="companyName"
(valueChange)="companySelected($event)"
[data]="companys" inModal="true" optV="companyNo"></app-search-select> [data]="companys" inModal="true" optV="companyNo"></app-search-select>
</ng-template> </ng-template>
<ng-template #foot4> <ng-template #foot4>
......
import {Component, OnInit} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {fadeIn} from '../../animation/fade-in'; import {fadeIn} from '../../animation/fade-in';
import {ApiService} from '../../service/api'; import {ApiService} from '../../service/api';
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
...@@ -26,7 +26,6 @@ export class GatewayComponent implements OnInit { ...@@ -26,7 +26,6 @@ export class GatewayComponent implements OnInit {
isAllCheck = false; isAllCheck = false;
isIndeterminate = false; isIndeterminate = false;
listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}]; listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
selectedOne: any = {};
isAddConV = false; isAddConV = false;
isMultiAddConV = false; isMultiAddConV = false;
isUpdate = false; isUpdate = false;
...@@ -48,6 +47,7 @@ export class GatewayComponent implements OnInit { ...@@ -48,6 +47,7 @@ export class GatewayComponent implements OnInit {
page = 1; page = 1;
rows = 10; rows = 10;
total = 0; total = 0;
@ViewChild('influxdb') influx;
constructor(private api: ApiService, private message: NzMessageService, private router: Router, constructor(private api: ApiService, private message: NzMessageService, private router: Router,
private modalService: NzModalService, private translate: TranslateService, private modalService: NzModalService, private translate: TranslateService,
...@@ -68,6 +68,7 @@ export class GatewayComponent implements OnInit { ...@@ -68,6 +68,7 @@ export class GatewayComponent implements OnInit {
this.canBindGateways = data.rows.filter(one => !one.pDeviceNo); this.canBindGateways = data.rows.filter(one => !one.pDeviceNo);
this.data = data.rows; this.data = data.rows;
this.total = data.total; this.total = data.total;
this.oneCheck();
} else if (data.code === 1) { } else if (data.code === 1) {
this.message.success(data && data.message ? data.message : '操作成功'); this.message.success(data && data.message ? data.message : '操作成功');
this.isAddConV = false; this.isAddConV = false;
...@@ -105,9 +106,13 @@ export class GatewayComponent implements OnInit { ...@@ -105,9 +106,13 @@ export class GatewayComponent implements OnInit {
}]); }]);
} }
companySelected(e) { companySelected() {
if (!this.req3.device.companyNo) {
this.message.error('该网关并无所属公司');
return;
}
this.isLoading = true; this.isLoading = true;
this.api.influxdbTables.getByCompanyNo([{companyNo: e}, (data) => { this.api.influxdbTables.getByCompanyNo([{companyNo: this.req3.device.companyNo}, (data) => {
if (data && data.constructor === Array) { if (data && data.constructor === Array) {
this.influxdbs = data; this.influxdbs = data;
} else { } else {
...@@ -176,10 +181,10 @@ export class GatewayComponent implements OnInit { ...@@ -176,10 +181,10 @@ export class GatewayComponent implements OnInit {
this.canbind = false; this.canbind = false;
this.canUnbind = false; this.canUnbind = false;
} else { } else {
const flag = obj[0].pDeviceNo && true; const flag: boolean = !!obj[0].pDeviceNo;
if (obj.filter(one => (obj[0].pDeviceNo && true) === flag).length === obj.length) { if (obj.filter(one => (!!one.pDeviceNo) === flag).length === obj.length) {
this.canbind = flag; this.canbind = !flag;
this.canUnbind = !flag; this.canUnbind = flag;
} else { } else {
this.canbind = false; this.canbind = false;
this.canUnbind = false; this.canUnbind = false;
...@@ -222,7 +227,8 @@ export class GatewayComponent implements OnInit { ...@@ -222,7 +227,8 @@ export class GatewayComponent implements OnInit {
}; };
this.try = { this.try = {
trans: {address: 'bindTongxinAddr'}, trans: {address: 'bindTongxinAddr'},
field: ['address', 'deviceNo'] field: ['address', 'deviceNo'],
num: ['address']
}; };
this.isBindConV = true; this.isBindConV = true;
} }
...@@ -243,7 +249,6 @@ export class GatewayComponent implements OnInit { ...@@ -243,7 +249,6 @@ export class GatewayComponent implements OnInit {
update(one) { update(one) {
this.isMulti = false; this.isMulti = false;
this.req = {...one}; this.req = {...one};
this.companySelected(one.companyNo);
this.try = { this.try = {
trans: {name: 'gatewayName', sn: 'gatewaySN', companyNo: 'selectCompany'}, trans: {name: 'gatewayName', sn: 'gatewaySN', companyNo: 'selectCompany'},
field: ['name', 'sn', 'companyNo', 'deviceNo'] field: ['name', 'sn', 'companyNo', 'deviceNo']
...@@ -280,9 +285,25 @@ export class GatewayComponent implements OnInit { ...@@ -280,9 +285,25 @@ export class GatewayComponent implements OnInit {
this.api.device.updateCompany([this.req4, this.next]); this.api.device.updateCompany([this.req4, this.next]);
// 单个绑定 // 单个绑定
} else if (!this.isMulti && this.isBindConV) { } else if (!this.isMulti && this.isBindConV) {
this.req3.device = null;
this.req3.pDeviceNo = this.req3.device.deviceNo; this.req3.pDeviceNo = this.req3.device.deviceNo;
this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo; this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo;
this.api.device.gatewayBindGateway([this.req3, this.next]); 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 = null;
this.data.map((one, index) => {
if (one.checked) {
this.req3.bindDeviceAddressVos.push({deviceNo: one.deviceNo, address: Number(this.req3.address) + index});
}
});
this.api.device.batchBindDevice([this.req3, this.next]);
} else if (this.isMulti && this.isDivideConV) {
} }
} }
...@@ -307,18 +328,31 @@ export class GatewayComponent implements OnInit { ...@@ -307,18 +328,31 @@ export class GatewayComponent implements OnInit {
multiAdd() { multiAdd() {
this.isUpdate = false; this.isUpdate = false;
this.req = {};
this.try = {
trans: {startSN: 'startSN', num: 'addNum', type: 'type', companyNo: 'selectCompany'},
field: ['startSN', 'num', 'type', 'companyNo']
};
this.isMulti = true; this.isMulti = true;
this.isMultiAddConV = true; this.isMultiAddConV = true;
} }
allDivide() { allDivide() {
this.req4 = {};
this.isMulti = true; this.isMulti = true;
this.isDivideConV = true; this.isDivideConV = true;
this.try = {trans: {companyNo: 'selectCompany'}, field: ['companyNo']};
} }
allBind() { allBind() {
this.isMulti = true; this.isMulti = true;
this.isBindConV = true; this.isBindConV = true;
this.req3 = {};
this.try = {
trans: {address: 'bindStartTongxinAddr'},
field: ['address'],
num: ['address']
};
} }
allDelete() { allDelete() {
...@@ -339,7 +373,16 @@ export class GatewayComponent implements OnInit { ...@@ -339,7 +373,16 @@ export class GatewayComponent implements OnInit {
}); });
} }
unbindAll() {} unbindAll() {
this.isLoading = true;
const obj = [];
this.data.map(one => {
if (one.checked) {
obj.push(one.deviceNo);
}
});
this.api.device.batchUnBindDevice([obj, this.next]);
}
toggleOn(one) { toggleOn(one) {
one.isLoading = true; one.isLoading = true;
......
...@@ -84,11 +84,11 @@ ...@@ -84,11 +84,11 @@
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()"> <button nz-button [nzType]="'primary'" [nzLoading]="isLoading" [disabled]="!isCheckedOne" (click)="allUpdate()">
<span>{{'update' | translate}}</span></button> <span>{{'update' | translate}}</span></button>
</div> </div>
<div class="pagePart whenOneLine"> <!--<div class="pagePart whenOneLine">-->
<nz-pagination [nzPageIndex]="page" [nzTotal]="total" [nzPageSize]="rows" <!--<nz-pagination [nzPageIndex]="page" [nzTotal]="total" [nzPageSize]="rows"-->
[nzShowTotal]="totalTemplate"></nz-pagination> <!--[nzShowTotal]="totalTemplate"></nz-pagination>-->
<ng-template #totalTemplate> 共 {{ total }} 项</ng-template> <!--<ng-template #totalTemplate> 共 {{ total }} 项</ng-template>-->
</div> <!--</div>-->
</div> </div>
<nz-modal [(nzVisible)]="isAddConV" [nzContent]="con1" nzWidth="500" [nzTitle]="isUpdate ? ('updateSensor' | translate) : ('addSensor' | translate)" <nz-modal [(nzVisible)]="isAddConV" [nzContent]="con1" nzWidth="500" [nzTitle]="isUpdate ? ('updateSensor' | translate) : ('addSensor' | translate)"
......
...@@ -190,10 +190,10 @@ export class SensorMgrComponent implements OnInit { ...@@ -190,10 +190,10 @@ export class SensorMgrComponent implements OnInit {
this.canbind = false; this.canbind = false;
this.canUnbind = false; this.canUnbind = false;
} else { } else {
const flag = obj[0].isOn; const flag: boolean = !!obj[0].pDeviceNo;
if (obj.filter(one => one.isOn === flag).length === obj.length) { if (obj.filter(one => (!!one.pDeviceNo) === flag).length === obj.length) {
this.canbind = flag; this.canbind = !flag;
this.canUnbind = !flag; this.canUnbind = flag;
} else { } else {
this.canbind = false; this.canbind = false;
this.canUnbind = false; this.canUnbind = false;
......
...@@ -158,9 +158,13 @@ ...@@ -158,9 +158,13 @@
"isSaveOtherProbesModel": "另存为通道模板", "isSaveOtherProbesModel": "另存为通道模板",
"isSaveOtherTopicModel": "另存为主题模板", "isSaveOtherTopicModel": "另存为主题模板",
"bindTongxinAddr": "绑定通信地址", "bindTongxinAddr": "绑定通信地址",
"bindStartTongxinAddr": "绑定通信起始地址",
"bindUpGateway": "绑定上级网关", "bindUpGateway": "绑定上级网关",
"gatewayBindTips": "Modbus, Sub1G, LoRa等通信协议地址", "gatewayBindTips": "Modbus, Sub1G, LoRa等通信协议地址",
"wrongNum": "数值填写错误", "wrongNum": "数值填写错误",
"updateTopic": "编辑主题", "updateTopic": "编辑主题",
"wrongEng": "部分字段要求为英文格式" "wrongEng": "部分字段要求为英文格式",
"addNum": "新增数量",
"startSN": "起始序列号",
"confirmUnbindSelectedRecord": "确认解绑选中的这些设备吗"
} }
...@@ -6,7 +6,8 @@ export const environment = { ...@@ -6,7 +6,8 @@ export const environment = {
production: false, 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.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