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

改了一堆

parent 79a42491
<div class="searchItem" [ngClass]="{'inModal': inModal}"> <div class="searchItem" [ngClass]="{'inModal': inModal}">
<div class="item-label"><span *ngIf="isMust" class="deleteFontColor">* </span>{{label}}</div> <div class="item-label"><span *ngIf="isMust" class="deleteFontColor">* </span>{{label}}</div>
<div class="item-input"> <div class="item-input">
<nz-select *ngIf="!readonly" [(ngModel)]="value" [nzNoAnimation]="true" style="width: 100%;" [nzMode]="nzMode" (ngModelChange)="onChange()"> <nz-select *ngIf="!readonly" [nzAllowClear]="true" [(ngModel)]="value" [nzNoAnimation]="true" style="width: 100%;" [nzMode]="nzMode" (ngModelChange)="onChange()">
<nz-option *ngFor="let one of data" [nzLabel]="one[optL]" [nzValue]="one[optV]"></nz-option> <nz-option *ngFor="let one of data" [nzLabel]="one[optL]" [nzValue]="one[optV]"></nz-option>
</nz-select> </nz-select>
<span *ngIf="readonly">{{value}}</span> <span *ngIf="readonly">{{value}}</span>
......
<div @fade class="tableBar" style="padding: 0 15px;"> <div @fade class="tableBar" style="padding: 0 15px;">
<div class="backBtnOnTabset"> <div class="backBtnOnTabset" style="top: 10px">
<app-back [isLoading]="isLoading"></app-back> <app-back [isLoading]="isLoading"></app-back>
</div> </div>
<nz-tabset> <!--<nz-tabset>-->
<nz-tab nzTitle="传感器"> <!--<nz-tab nzTitle="传感器">-->
<div class="subTitle"> <div class="subTitle" style="padding-top: 10px">
{{'gateway' | translate}} {{name}} {{'detail' | translate}} {{'gateway' | translate}} {{name}} {{'detail' | translate}}
</div> </div>
<nz-table #nzTable <nz-table #nzTable
...@@ -34,48 +34,48 @@ ...@@ -34,48 +34,48 @@
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
</nz-tab> <!--</nz-tab>-->
<nz-tab nzTitle="通道"> <!--<nz-tab nzTitle="通道">-->
<div class="subTitle"> <!--<div class="subTitle">-->
{{'gateway' | translate}} {{name}} {{'wayDetail' | translate}} <!--{{'gateway' | translate}} {{name}} {{'wayDetail' | translate}}-->
</div> <!--</div>-->
<nz-table #nzTable2 <!--<nz-table #nzTable2-->
[nzData]="wayData" <!--[nzData]="wayData"-->
[nzSize]="'middle'" <!--[nzSize]="'middle'"-->
nzShowSizeChanger <!--nzShowSizeChanger-->
[nzShowPagination]="true" <!--[nzShowPagination]="true"-->
[nzLoading]="isLoading"> <!--[nzLoading]="isLoading">-->
<thead nz-thead> <!--<thead nz-thead>-->
<tr> <!--<tr>-->
<th nz-th><span>{{'sensorSN' | translate}}</span></th> <!--<th nz-th><span>{{'sensorSN' | translate}}</span></th>-->
<th nz-th><span>{{'wayName' | translate}}</span></th> <!--<th nz-th><span>{{'wayName' | translate}}</span></th>-->
<th nz-th><span>{{'wayAlias' | translate}}</span></th> <!--<th nz-th><span>{{'wayAlias' | translate}}</span></th>-->
<th nz-th><span>{{'per' | translate}}</span></th> <!--<th nz-th><span>{{'per' | translate}}</span></th>-->
<th nz-th><span>{{'wayType' | translate}}</span></th> <!--<th nz-th><span>{{'wayType' | translate}}</span></th>-->
<th nz-th><span>{{'max' | translate}}</span></th> <!--<th nz-th><span>{{'max' | translate}}</span></th>-->
<th nz-th><span>{{'min' | translate}}</span></th> <!--<th nz-th><span>{{'min' | translate}}</span></th>-->
<th nz-th><span>{{'alarmMax' | translate}}</span></th> <!--<th nz-th><span>{{'alarmMax' | translate}}</span></th>-->
<th nz-th><span>{{'alarmMaxMax' | translate}}</span></th> <!--<th nz-th><span>{{'alarmMaxMax' | translate}}</span></th>-->
<th nz-th><span>{{'alarmMin' | translate}}</span></th> <!--<th nz-th><span>{{'alarmMin' | translate}}</span></th>-->
<th nz-th><span>{{'alarmMinMin' | translate}}</span></th> <!--<th nz-th><span>{{'alarmMinMin' | translate}}</span></th>-->
</tr> <!--</tr>-->
</thead> <!--</thead>-->
<tbody nz-tbody> <!--<tbody nz-tbody>-->
<tr *ngFor="let one of nzTable2.data, let i = index"> <!--<tr *ngFor="let one of nzTable2.data, let i = index">-->
<td nz-td>{{one.sn}}</td> <!--<td nz-td>{{one.sn}}</td>-->
<td nz-td>{{one.name}}</td> <!--<td nz-td>{{one.name}}</td>-->
<td nz-td>{{one.alias}}</td> <!--<td nz-td>{{one.alias}}</td>-->
<td nz-td>{{one.unit}}</td> <!--<td nz-td>{{one.unit}}</td>-->
<td nz-td>{{one.type}}</td> <!--<td nz-td>{{one.type}}</td>-->
<td nz-td>{{one.rangeMax}}</td> <!--<td nz-td>{{one.rangeMax}}</td>-->
<td nz-td>{{one.rangeMin}}</td> <!--<td nz-td>{{one.rangeMin}}</td>-->
<td nz-td>{{one.alarmUp}}</td> <!--<td nz-td>{{one.alarmUp}}</td>-->
<td nz-td>{{one.alarmDown}}</td> <!--<td nz-td>{{one.alarmDown}}</td>-->
<td nz-td>{{one.upperAlarmLimit}}</td> <!--<td nz-td>{{one.upperAlarmLimit}}</td>-->
<td nz-td>{{one.lowerAlarmLimit}}</td> <!--<td nz-td>{{one.lowerAlarmLimit}}</td>-->
</tr> <!--</tr>-->
</tbody> <!--</tbody>-->
</nz-table> <!--</nz-table>-->
</nz-tab> <!--</nz-tab>-->
</nz-tabset> <!--</nz-tabset>-->
</div> </div>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<button nz-button class="btnAll" [nzLoading]="isLoading" (click)="onGetAll()"><span>{{'allData' | translate}}</span> <button nz-button class="btnAll" [nzLoading]="isLoading" (click)="onGetAll()"><span>{{'allData' | translate}}</span>
</button> </button>
<button nz-button class="btnAdd" [nzLoading]="isLoading" (click)="multiAdd()"> <button nz-button class="btnAdd" [nzLoading]="isLoading" (click)="multiAdd()">
<span>{{'multiAdd' | translate}}</span></button> <span>{{'multiAdd' | translate}}</span></button>
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="add()"> <button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="add()">
<span>{{'addGateway' | translate}}</span></button> <span>{{'addGateway' | translate}}</span></button>
</div> </div>
...@@ -15,7 +15,13 @@ ...@@ -15,7 +15,13 @@
<div class="tableBar" @fade> <div class="tableBar" @fade>
<nz-table #nzTable <nz-table #nzTable
[nzData]="data" [nzData]="data"
[nzLoading]="isLoading"> [nzLoading]="isLoading"
[nzFrontPagination]="false"
[(nzPageIndex)]="page"
[(nzPageSize)]="rows"
[nzTotal]="total"
(nzPageIndexChange)="pageChange()"
(nzPageSizeChange)="pageChange()">
<thead nz-thead> <thead nz-thead>
<tr> <tr>
<!--<th--> <!--<th-->
...@@ -49,7 +55,7 @@ ...@@ -49,7 +55,7 @@
<td nz-td>{{one.type}}</td> <td nz-td>{{one.type}}</td>
<td nz-td>{{one.simcard}}</td> <td nz-td>{{one.simcard}}</td>
<td nz-td> <td nz-td>
<nz-switch [nzControl]="true" (click)="toggleOn(one)" [(ngModel)]="one.state" <nz-switch [nzControl]="true" [disabled]="one.pDeviceNo" (click)="toggleOn(one)" [(ngModel)]="one.state"
[nzLoading]="one.isLoading"></nz-switch> [nzLoading]="one.isLoading"></nz-switch>
</td> </td>
<td nz-td>{{one.pDeviceNo ? '是' : '否'}}</td> <td nz-td>{{one.pDeviceNo ? '是' : '否'}}</td>
...@@ -61,7 +67,8 @@ ...@@ -61,7 +67,8 @@
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<span class="editSpan" (click)="update(one)">{{'update' | translate}}</span> <span class="editSpan" (click)="update(one)">{{'update' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<span *ngIf="!one.pDeviceNo && !one.state" class="editSpan" (click)="divide(one)">{{'divide' | translate}}</span> <span *ngIf="!one.pDeviceNo && !one.state" class="editSpan"
(click)="divide(one)">{{'divide' | translate}}</span>
<nz-divider *ngIf="!one.pDeviceNo && !one.state" nzType="vertical"></nz-divider> <nz-divider *ngIf="!one.pDeviceNo && !one.state" nzType="vertical"></nz-divider>
<span class="deleteFontColor" (click)="deleteConfirm(one)">{{'delete' | translate}}</span> <span class="deleteFontColor" (click)="deleteConfirm(one)">{{'delete' | translate}}</span>
</td> </td>
...@@ -86,19 +93,22 @@ ...@@ -86,19 +93,22 @@
<!--<ng-template #totalTemplate> 共 {{ total }} 项</ng-template>--> <!--<ng-template #totalTemplate> 共 {{ total }} 项</ng-template>-->
<!--</div>--> <!--</div>-->
</div> </div>
<nz-modal [(nzVisible)]="isAddConV" [nzTitle]="isUpdate ? ('updateGateway' | translate) : ('addGateway' | translate)" [nzContent]="con1" nzWidth="500" <nz-modal [(nzVisible)]="isAddConV" [nzTitle]="isUpdate ? ('updateGateway' | translate) : ('addGateway' | translate)"
[nzContent]="con1" nzWidth="500"
[nzFooter]="foot1" (nzOnCancel)="cancel('isAddConV')" nzMaskClosable="false"> [nzFooter]="foot1" (nzOnCancel)="cancel('isAddConV')" nzMaskClosable="false">
<ng-template #con1> <ng-template #con1>
<app-search-item isMust="true" inModal="true" [label]="'gatewayName' | translate" <app-search-item isMust="true" inModal="true" [label]="'gatewayName' | translate"
[(value)]="req.name"></app-search-item> [(value)]="req.name"></app-search-item>
<app-search-item isMust="true" *ngIf="!isUpdate" inModal="true" [label]="'gatewaySN' | translate" <app-search-item isMust="true" *ngIf="!isUpdate" inModal="true" [label]="'gatewaySN' | translate"
[(value)]="req.sn"></app-search-item> [(value)]="req.sn"></app-search-item>
<app-search-item isMust="true" *ngIf="!isUpdate" inModal="true" [label]="'type' | translate" [(value)]="req.type"></app-search-item> <app-search-item isMust="true" *ngIf="!isUpdate" inModal="true" [label]="'type' | translate"
[(value)]="req.type"></app-search-item>
<app-search-item inModal="true" [label]="'simcard' | translate" <app-search-item inModal="true" [label]="'simcard' | translate"
[(value)]="req.simcard"></app-search-item> [(value)]="req.simcard"></app-search-item>
<app-search-item *ngIf="!isUpdate" inModal="true" [label]="'configJson' | translate" <app-search-item *ngIf="!isUpdate" inModal="true" [label]="'configJson' | translate"
[(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" optL="companyName" <app-search-select isMust="true" inModal="true" [(value)]="req.companyNo" [label]="'selectCompany' | translate"
optL="companyName"
(valueChange)="companySelected($event)" (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"
...@@ -130,7 +140,7 @@ ...@@ -130,7 +140,7 @@
</ng-template> </ng-template>
</nz-modal> </nz-modal>
<nz-modal [(nzVisible)]="isBindConV" [nzContent]="con3" nzWidth="500" [nzTitle]="'bindGateway' | translate" <nz-modal [(nzVisible)]="isBindConV" [nzContent]="con3" nzWidth="500" [nzTitle]="'bindUpGateway' | translate"
[nzFooter]="foot3" (nzOnCancel)="cancel('isBindConV')" nzMaskClosable="false"> [nzFooter]="foot3" (nzOnCancel)="cancel('isBindConV')" nzMaskClosable="false">
<ng-template #con3> <ng-template #con3>
<div class="searchItem inModal"> <div class="searchItem inModal">
...@@ -138,15 +148,18 @@ ...@@ -138,15 +148,18 @@
<span class="deleteFontColor">* </span>{{'selectGateway' | translate}} <span class="deleteFontColor">* </span>{{'selectGateway' | translate}}
</div> </div>
<div class="item-input"> <div class="item-input">
<input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device" (input)="onInput($event.target?.value)"> <input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device"
(input)="onInput($event.target?.value)">
<nz-autocomplete nzBackfill #auto> <nz-autocomplete nzBackfill #auto>
<nz-auto-option *ngFor="let one of selectedGateways" [nzLabel]="one.name + '-' + one.sn" [nzValue]="one"> <nz-auto-option *ngFor="let one of selectedGateways" [nzLabel]="one.type + '-' + one.sn" [nzValue]="one">
{{one.name}} - {{one.sn}} {{one.type}} - {{one.sn}}
</nz-auto-option> </nz-auto-option>
</nz-autocomplete> </nz-autocomplete>
</div> </div>
</div> </div>
<app-search-item isMust="true" inModal="true" [label]="'belongAddress' | translate" [(value)]="req3.address"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'bindTongxinAddr' | translate" nz-tooltip
[nzTitle]="'gatewayBindTips' | translate"
[(value)]="req3.address"></app-search-item>
</ng-template> </ng-template>
<ng-template #foot3> <ng-template #foot3>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isBindConV')"> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isBindConV')">
...@@ -156,7 +169,8 @@ ...@@ -156,7 +169,8 @@
</ng-template> </ng-template>
</nz-modal> </nz-modal>
<nz-modal [(nzVisible)]="isDivideConV" [nzTitle]="('gateway' | translate) + ('divide' | translate)" [nzContent]="con4" nzWidth="500" <nz-modal [(nzVisible)]="isDivideConV" [nzTitle]="('gateway' | translate) + ('divide' | translate)" [nzContent]="con4"
nzWidth="500"
[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"
......
...@@ -19,9 +19,8 @@ import {CheckService} from '../../service/check'; ...@@ -19,9 +19,8 @@ import {CheckService} from '../../service/check';
export class GatewayComponent implements OnInit { export class GatewayComponent implements OnInit {
data = []; data = [];
query = { query: any = {
gatewayName: '', model: 0
gatewaySN: ''
}; };
isLoading = false; isLoading = false;
isAllCheck = false; isAllCheck = false;
...@@ -40,13 +39,15 @@ export class GatewayComponent implements OnInit { ...@@ -40,13 +39,15 @@ export class GatewayComponent implements OnInit {
req: any = {}; req: any = {};
companys = []; companys = [];
influxdbs = []; influxdbs = [];
filterFlag = null;
selectedGateways = []; selectedGateways = [];
canBindGateways = []; canBindGateways = [];
req3: any = {}; req3: any = {};
scenes = [{sceneNo: '123', sceneName: 'qq'}]; scenes = [{sceneNo: '123', sceneName: 'qq'}];
req4: any = {}; req4: any = {};
try = {}; try = {};
page = 1;
rows = 10;
total = 0;
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,
...@@ -63,18 +64,17 @@ export class GatewayComponent implements OnInit { ...@@ -63,18 +64,17 @@ export class GatewayComponent implements OnInit {
} }
next = (data) => { next = (data) => {
if (data && data.constructor === Array) { if (data && data.rows && data.rows.constructor === Array) {
const flag = !(this.filterFlag === 0 || this.filterFlag === 1); this.canBindGateways = data.rows.filter(one => !one.pDeviceNo);
this.canBindGateways = data.filter(one => !one.pDeviceNo); this.data = data.rows;
this.data = data.filter(one => (one.pDeviceNo && this.filterFlag || flag) this.total = data.total;
&& one.name.indexOf(this.query.gatewayName) > -1 && one.sn.indexOf(this.query.gatewaySN) > -1);
} 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;
this.isMultiAddConV = false; this.isMultiAddConV = false;
this.isBindConV = false; this.isBindConV = false;
this.isDivideConV = false; this.isDivideConV = false;
this.getData(); this.search();
} else if (data.code === 0) { } else if (data.code === 0) {
this.message.error(data && data.message ? data.message : '操作失败'); this.message.error(data && data.message ? data.message : '操作失败');
} else { } else {
...@@ -85,7 +85,12 @@ export class GatewayComponent implements OnInit { ...@@ -85,7 +85,12 @@ export class GatewayComponent implements OnInit {
getData() { getData() {
this.isLoading = true; this.isLoading = true;
this.api.device.getAll([{model: 0}, this.next]); this.api.device.getAll(this.page, this.rows, [{model: 0}, this.next]);
}
search() {
this.isLoading = true;
this.api.device.getByTerm(this.page, this.rows, [this.query, this.next]);
} }
getCompanys() { getCompanys() {
...@@ -113,17 +118,19 @@ export class GatewayComponent implements OnInit { ...@@ -113,17 +118,19 @@ export class GatewayComponent implements OnInit {
} }
onSearch() { onSearch() {
this.filterFlag = null; this.page = 1;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}]; this.search();
this.getData(); }
pageChange() {
this.search();
} }
onGetAll() { onGetAll() {
this.page = 1;
this.query = { this.query = {
gatewayName: '', model: 0
gatewaySN: ''
}; };
this.filterFlag = null;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}]; this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
this.getData(); this.getData();
} }
...@@ -182,8 +189,8 @@ export class GatewayComponent implements OnInit { ...@@ -182,8 +189,8 @@ export class GatewayComponent implements OnInit {
// 筛选 // 筛选
filter(e) { filter(e) {
this.filterFlag = e; this.query.isBind = e;
this.getData(); this.search();
} }
// 跳转详情 // 跳转详情
...@@ -290,6 +297,7 @@ export class GatewayComponent implements OnInit { ...@@ -290,6 +297,7 @@ export class GatewayComponent implements OnInit {
} }
multiAdd() { multiAdd() {
this.isUpdate = false;
this.isMulti = true; this.isMulti = true;
this.isMultiAddConV = true; this.isMultiAddConV = true;
} }
...@@ -328,7 +336,7 @@ export class GatewayComponent implements OnInit { ...@@ -328,7 +336,7 @@ export class GatewayComponent implements OnInit {
one.isLoading = true; one.isLoading = true;
this.api.device.mountUninstallDevice([{deviceNo: one.deviceNo, state: one.state === 0 ? 1 : 0}, (data) => { this.api.device.mountUninstallDevice([{deviceNo: one.deviceNo, state: one.state === 0 ? 1 : 0}, (data) => {
if (data && data.code === 1) { if (data && data.code === 1) {
one.state = one.state === 0 ? 1 : 0; this.search();
this.message.success(data && data.message ? data.message : '操作成功'); this.message.success(data && data.message ? data.message : '操作成功');
} else { } else {
this.message.error(data && data.message ? data.message : '操作失败'); this.message.error(data && data.message ? data.message : '操作失败');
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<thead nz-thead> <thead nz-thead>
<tr> <tr>
<th nz-th><span>{{'wayName' | translate}}</span></th> <th nz-th><span>{{'wayName' | translate}}</span></th>
<th nz-th><span>{{'moduleName' | translate}}</span></th> <!--<th nz-th><span>{{'moduleName' | translate}}</span></th>-->
<th nz-th><span>{{'wayAlias' | translate}}</span></th> <th nz-th><span>{{'wayAlias' | translate}}</span></th>
<th nz-th><span>{{'per' | translate}}</span></th> <th nz-th><span>{{'per' | translate}}</span></th>
<th nz-th><span>{{'wayType' | translate}}</span></th> <th nz-th><span>{{'wayType' | translate}}</span></th>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<tbody nz-tbody> <tbody nz-tbody>
<tr *ngFor="let one of nzTable.data, let i = index"> <tr *ngFor="let one of nzTable.data, let i = index">
<td nz-td>{{one.name}}</td> <td nz-td>{{one.name}}</td>
<td nz-td>{{one.probesModelName}}</td> <!--<td nz-td>{{one.probesModelName}}</td>-->
<td nz-td>{{one.alias}}</td> <td nz-td>{{one.alias}}</td>
<td nz-td>{{one.unit}}</td> <td nz-td>{{one.unit}}</td>
<td nz-td>{{one.type}}</td> <td nz-td>{{one.type}}</td>
...@@ -53,12 +53,12 @@ ...@@ -53,12 +53,12 @@
[nzFooter]="foot1" [nzTitle]="isUpdate ? ('update' | translate) : ('add' | translate)" (nzOnCancel)="cancel()" nzMaskClosable="false"> [nzFooter]="foot1" [nzTitle]="isUpdate ? ('update' | translate) : ('add' | translate)" (nzOnCancel)="cancel()" nzMaskClosable="false">
<ng-template #con1> <ng-template #con1>
<div class="half"> <div class="half">
<app-search-item isMust="true" inModal="true" [label]="'wayName' | translate" [(value)]="req.name"></app-search-item> <app-search-item nz-tooltip nzTitle="此处输入为英文" isMust="true" inModal="true" [label]="'wayName' | translate" [(value)]="req.name"></app-search-item>
<app-search-item inModal="true" [label]="'per' | translate" [(value)]="req.unit"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'per' | translate" [(value)]="req.unit"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'wayDescription' | translate" [(value)]="req.description"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'wayDescription' | translate" [(value)]="req.description"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'max' | translate" [(value)]="req.rangeMax"></app-search-item> <app-search-item inModal="true" [label]="'max' | translate" [(value)]="req.rangeMax"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMax' | translate" [(value)]="req.alarmUp"></app-search-item> <app-search-item inModal="true" [label]="'alarmMax' | translate" [(value)]="req.alarmUp"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMaxMax' | translate" [(value)]="req.upperAlarmLimit"></app-search-item> <app-search-item inModal="true" [label]="'alarmMaxMax' | translate" [(value)]="req.upperAlarmLimit"></app-search-item>
<div class="searchItem inModal"> <div class="searchItem inModal">
<div class="item-label"><span class="deleteFontColor">* </span>{{'isAlarm' | translate}}</div> <div class="item-label"><span class="deleteFontColor">* </span>{{'isAlarm' | translate}}</div>
<div class="item-input"> <div class="item-input">
...@@ -70,15 +70,15 @@ ...@@ -70,15 +70,15 @@
</div> </div>
</div> </div>
<div class="half"> <div class="half">
<app-search-item inModal="true" [label]="'wayAlias' | translate" [(value)]="req.alias"></app-search-item> <app-search-item isMust="true" nz-tooltip nzTitle="此处输入为英文" inModal="true" [label]="'wayAlias' | translate" [(value)]="req.alias"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'wayType' | translate" [(value)]="req.type"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'wayType' | translate" [(value)]="req.type"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'min' | translate" [(value)]="req.rangeMin"></app-search-item> <app-search-item inModal="true" [label]="'min' | translate" [(value)]="req.rangeMin"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMin' | translate" [(value)]="req.alarmDown"></app-search-item> <app-search-item inModal="true" [label]="'alarmMin' | translate" [(value)]="req.alarmDown"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMinMin' | translate" [(value)]="req.lowerAlarmLimit"></app-search-item> <app-search-item inModal="true" [label]="'alarmMinMin' | translate" [(value)]="req.lowerAlarmLimit"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmInterval' | translate" [(value)]="req.alarmInterval"></app-search-item> <app-search-item inModal="true" [label]="'alarmInterval' | translate" [(value)]="req.alarmInterval"></app-search-item>
</div> </div>
<div class="searchItem inModal"> <div class="searchItem inModal">
<div class="item-label" style="width: 149px;"><span class="deleteFontColor">* </span>{{'wayInfo' | translate}}</div> <div class="item-label" style="width: 149px;">{{'wayInfo' | translate}}</div>
<div class="item-input" style="width: calc(100% - 158px);"> <div class="item-input" style="width: calc(100% - 158px);">
<textarea nz-input [(ngModel)]="req.boxedart"></textarea> <textarea nz-input [(ngModel)]="req.boxedart"></textarea>
</div> </div>
......
...@@ -4,6 +4,7 @@ import {NzMessageService, NzModalService} from 'ng-zorro-antd'; ...@@ -4,6 +4,7 @@ import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {TranslateService} from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import {fadeIn} from '../../animation/fade-in'; import {fadeIn} from '../../animation/fade-in';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {CheckService} from '../../service/check';
@Component({ @Component({
selector: 'app-module-detail', selector: 'app-module-detail',
...@@ -20,9 +21,11 @@ export class ModuleDetailComponent implements OnInit { ...@@ -20,9 +21,11 @@ export class ModuleDetailComponent implements OnInit {
probesModelName = ''; probesModelName = '';
isV = false; isV = false;
isUpdate = false; isUpdate = false;
try;
constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute, constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute,
private translate: TranslateService, private router: Router, private modalService: NzModalService) { private translate: TranslateService, private router: Router, private modalService: NzModalService,
private ck: CheckService) {
} }
ngOnInit() { ngOnInit() {
...@@ -76,6 +79,10 @@ export class ModuleDetailComponent implements OnInit { ...@@ -76,6 +79,10 @@ export class ModuleDetailComponent implements OnInit {
this.req = {}; this.req = {};
this.isUpdate = false; this.isUpdate = false;
this.isV = true; this.isV = true;
this.try = {
field: ['probesModelNo', 'name', 'alias', 'description', 'type', 'unit', 'isAlarm'],
eng: ['name', 'alias']
};
} }
update(one) { update(one) {
...@@ -83,6 +90,10 @@ export class ModuleDetailComponent implements OnInit { ...@@ -83,6 +90,10 @@ export class ModuleDetailComponent implements OnInit {
this.req = {...one}; this.req = {...one};
this.req.oldName = one.name; this.req.oldName = one.name;
this.isV = true; this.isV = true;
this.try = {
field: ['probesModelNo', 'name', 'alias', 'description', 'type', 'unit', 'isAlarm'],
eng: ['name', 'alias']
};
} }
cancel() { cancel() {
...@@ -92,6 +103,10 @@ export class ModuleDetailComponent implements OnInit { ...@@ -92,6 +103,10 @@ export class ModuleDetailComponent implements OnInit {
save() { save() {
this.isLoading = true; this.isLoading = true;
this.req.probesModelNo = this.probesModelNo; this.req.probesModelNo = this.probesModelNo;
if (!this.ck.formCheck(this.req, this.try)) {
this.isLoading = false;
return false;
}
if (this.isUpdate) { if (this.isUpdate) {
this.api.probesModelInfo.updateProbesModelInfo([this.req, this.next]); this.api.probesModelInfo.updateProbesModelInfo([this.req, this.next]);
} else { } else {
......
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ApiService} from '../../service/api'; import {ApiService} from '../../service/api';
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {fadeIn} from '../../animation/fade-in'; import {fadeIn} from '../../animation/fade-in';
import {TranslateService} from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import {CheckService} from '../../service/check';
@Component({ @Component({
selector: 'app-sensor-detail', selector: 'app-sensor-detail',
...@@ -20,6 +21,7 @@ export class SensorDetailComponent implements OnInit { ...@@ -20,6 +21,7 @@ export class SensorDetailComponent implements OnInit {
req: any = {}; req: any = {};
req2: any = {}; req2: any = {};
req3 = {}; req3 = {};
req4 = {};
req5: any = {}; req5: any = {};
isUC = false; isUC = false;
isUC2 = false; isUC2 = false;
...@@ -31,8 +33,13 @@ export class SensorDetailComponent implements OnInit { ...@@ -31,8 +33,13 @@ export class SensorDetailComponent implements OnInit {
wayData = []; wayData = [];
selectTime3 = 24; selectTime3 = 24;
isClose = false; isClose = false;
constructor(private api: ApiService, private message: NzMessageService, private router: Router, isSaveOther = false;
private ac: ActivatedRoute, private modalService: NzModalService, private translate: TranslateService) { } companyNo = '';
try = {};
constructor(private api: ApiService, private message: NzMessageService, private router: Router, private ck: CheckService,
private ac: ActivatedRoute, private modalService: NzModalService, private translate: TranslateService) {
}
ngOnInit() { ngOnInit() {
this.init(); this.init();
...@@ -43,6 +50,7 @@ export class SensorDetailComponent implements OnInit { ...@@ -43,6 +50,7 @@ export class SensorDetailComponent implements OnInit {
if (e.deviceNo) { if (e.deviceNo) {
this.deviceNo = e.deviceNo; this.deviceNo = e.deviceNo;
this.name = e.name; this.name = e.name;
this.companyNo = e.companyNo;
this.getTopicData(); this.getTopicData();
this.getProbsModels(); this.getProbsModels();
this.getTopicModels(); this.getTopicModels();
...@@ -66,7 +74,8 @@ export class SensorDetailComponent implements OnInit { ...@@ -66,7 +74,8 @@ export class SensorDetailComponent implements OnInit {
} else { } else {
this.message.error(data && data.message ? data.message : '获取数据失败'); this.message.error(data && data.message ? data.message : '获取数据失败');
} }
} this.isLoading = false;
};
getProbsModels() { getProbsModels() {
this.isLoading = true; this.isLoading = true;
...@@ -133,39 +142,57 @@ export class SensorDetailComponent implements OnInit { ...@@ -133,39 +142,57 @@ export class SensorDetailComponent implements OnInit {
{queryParams: {deviceNo: one.deviceNo, topicName: one.topicName}}); {queryParams: {deviceNo: one.deviceNo, topicName: one.topicName}});
} }
onSearch() {} onSearch() {
}
close() {} close() {
}
changeModel() { changeModel() {
this.isMC = true; this.isMC = true;
this.req5 = { this.req5 = {
deviceNo: this.deviceNo deviceNo: this.deviceNo
}; };
this.try = {field: []};
} }
add() { add() {
this.isUpdate = false; this.isUpdate = false;
this.req = {}; this.req = {};
this.req.deviceNo = this.deviceNo; this.req.deviceNo = this.deviceNo;
this.req.frequency = 0;
this.isUC = true; this.isUC = true;
this.try = {
field: ['dataType', 'deviceNo', 'frequency', 'interval', 'topicName', 'topicType'],
num: ['interval', 'dataInterval']
};
} }
update(one) { update(one) {
this.req = {...one}; this.req = {...one};
this.isUpdate = true; this.isUpdate = true;
this.req.frequency = 0;
this.req.oldTopicName = one.topicName; this.req.oldTopicName = one.topicName;
this.isUC = true; this.isUC = true;
this.try = {
field: ['dataType', 'deviceNo', 'frequency', 'interval', 'topicName', 'topicType', 'oldTopicName'],
num: ['interval', 'dataInterval']
};
} }
cancel() { cancel() {
this.isUC = false; this.isUC = false;
this.isMC = false; this.isMC = false;
this.isUC2 = false; this.isUC2 = false;
this.isSaveOther = false;
} }
save() { save(v) {
this.isLoading = true; this.isLoading = true;
if (!this.ck.formCheck(this[v], this.try)) {
this.isLoading = false;
return;
}
if (this.isUC && this.isUpdate) { if (this.isUC && this.isUpdate) {
this.api.topic.updateTopic([this.req, this.next]); this.api.topic.updateTopic([this.req, this.next]);
} else if (this.isUC && !this.isUpdate) { } else if (this.isUC && !this.isUpdate) {
...@@ -178,14 +205,16 @@ export class SensorDetailComponent implements OnInit { ...@@ -178,14 +205,16 @@ export class SensorDetailComponent implements OnInit {
} else if (this.isUC2 && !this.isUpdate) { } else if (this.isUC2 && !this.isUpdate) {
this.req2.deviceNo = this.deviceNo; this.req2.deviceNo = this.deviceNo;
this.api.probes.addProbes([this.req2, this.next]); this.api.probes.addProbes([this.req2, this.next]);
} else if (this.isSaveOther) {
this.api.topic.saveAsTopicModel([this.req4, this.next]);
} }
} }
deleteConfirm(one) { deleteConfirm(one) {
this.modalService.confirm({ this.modalService.confirm({
nzTitle : '<i> </i>', nzTitle: '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>', nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete(one) nzOnOk: () => this.delete(one)
}); });
} }
...@@ -200,6 +229,7 @@ export class SensorDetailComponent implements OnInit { ...@@ -200,6 +229,7 @@ export class SensorDetailComponent implements OnInit {
this.req2 = {}; this.req2 = {};
this.req2.deviceNo = this.deviceNo; this.req2.deviceNo = this.deviceNo;
this.isUC2 = true; this.isUC2 = true;
this.try = {field: ['deviceNo', 'topicName', 'name', 'alias', 'description', 'type', 'unit', 'isAlarm']};
} }
update2(one) { update2(one) {
...@@ -208,13 +238,14 @@ export class SensorDetailComponent implements OnInit { ...@@ -208,13 +238,14 @@ export class SensorDetailComponent implements OnInit {
this.isUpdate = true; this.isUpdate = true;
this.req2.oldName = one.name; this.req2.oldName = one.name;
this.isUC2 = true; this.isUC2 = true;
this.try = {field: ['deviceNo', 'oldName', 'topicName', 'name', 'alias', 'description', 'type', 'unit', 'isAlarm']};
} }
deleteConfirm2(one) { deleteConfirm2(one) {
this.modalService.confirm({ this.modalService.confirm({
nzTitle : '<i> </i>', nzTitle: '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>', nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete2(one) nzOnOk: () => this.delete2(one)
}); });
} }
...@@ -223,5 +254,17 @@ export class SensorDetailComponent implements OnInit { ...@@ -223,5 +254,17 @@ export class SensorDetailComponent implements OnInit {
this.api.probes.delAProbes([{deviceNo: one.deviceNo, topicName: one.topicName, name: one.name}, this.next]); this.api.probes.delAProbes([{deviceNo: one.deviceNo, topicName: one.topicName, name: one.name}, this.next]);
} }
toSee() {} toSee() {
}
saveOther() {
debugger;
this.isSaveOther = true;
this.req4 = {
companyNo: this.companyNo,
deviceNo: this.deviceNo,
newTopicModelName: ''
};
this.try = {field: ['companyNo', 'deviceNo', 'newTopicModelName']};
}
} }
...@@ -15,7 +15,13 @@ ...@@ -15,7 +15,13 @@
<div class="tableBar" @fade> <div class="tableBar" @fade>
<nz-table #nzTable <nz-table #nzTable
[nzData]="data" [nzData]="data"
[nzLoading]="isLoading"> [nzLoading]="isLoading"
[nzFrontPagination]="false"
[(nzPageIndex)]="page"
[(nzPageSize)]="rows"
[nzTotal]="total"
(nzPageIndexChange)="pageChange()"
(nzPageSizeChange)="pageChange()">
<thead nz-thead> <thead nz-thead>
<tr> <tr>
<!--<th--> <!--<th-->
...@@ -136,8 +142,8 @@ ...@@ -136,8 +142,8 @@
<div class="item-input"> <div class="item-input">
<input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device" (input)="onInput($event.target?.value)"> <input nz-input placeholder="" [nzAutocomplete]="auto" [(ngModel)]="req3.device" (input)="onInput($event.target?.value)">
<nz-autocomplete nzBackfill #auto> <nz-autocomplete nzBackfill #auto>
<nz-auto-option *ngFor="let one of selectedGateways" [nzLabel]="one.name + '-' + one.sn" [nzValue]="one"> <nz-auto-option *ngFor="let one of selectedGateways" [nzLabel]="one.type + '-' + one.sn" [nzValue]="one">
{{one.name}} - {{one.sn}} {{one.type}} - {{one.sn}}
</nz-auto-option> </nz-auto-option>
</nz-autocomplete> </nz-autocomplete>
</div> </div>
......
...@@ -19,9 +19,8 @@ import {CheckService} from '../../service/check'; ...@@ -19,9 +19,8 @@ import {CheckService} from '../../service/check';
export class SensorMgrComponent implements OnInit { export class SensorMgrComponent implements OnInit {
data = []; data = [];
query = { query: any = {
sensorName: '', model: 1
sensorSN: ''
}; };
isLoading = false; isLoading = false;
isAllCheck = false; isAllCheck = false;
...@@ -41,12 +40,14 @@ export class SensorMgrComponent implements OnInit { ...@@ -41,12 +40,14 @@ export class SensorMgrComponent implements OnInit {
companys = []; companys = [];
influxdbs = []; influxdbs = [];
scenes = [{sceneNo: '123', sceneName: 'qq'}]; scenes = [{sceneNo: '123', sceneName: 'qq'}];
filterFlag;
selectedGateways = []; selectedGateways = [];
canBindGateways = []; canBindGateways = [];
req3: any = {}; req3: any = {};
req5: any = {}; req5: any = {};
try = {}; try = {};
page = 1;
rows = 10;
total = 0;
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 ck: CheckService) { private modalService: NzModalService, private translate: TranslateService, private ck: CheckService) {
...@@ -64,10 +65,9 @@ export class SensorMgrComponent implements OnInit { ...@@ -64,10 +65,9 @@ export class SensorMgrComponent implements OnInit {
} }
next = (data) => { next = (data) => {
if (data && data.constructor === Array) { if (data && data.rows && data.rows.constructor === Array) {
const flag = !(this.filterFlag === 0 || this.filterFlag === 1); this.data = data.rows;
this.data = data.filter(one => (one.pDeviceNo && this.filterFlag || flag) this.total = data.total;
&& one.name.indexOf(this.query.sensorName) > -1 && one.sn.indexOf(this.query.sensorSN) > -1);
} 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;
...@@ -85,7 +85,16 @@ export class SensorMgrComponent implements OnInit { ...@@ -85,7 +85,16 @@ export class SensorMgrComponent implements OnInit {
getData() { getData() {
this.isLoading = true; this.isLoading = true;
this.api.device.getAll([{model: 1}, this.next]); this.api.device.getAll(this.page, this.rows, [{model: 1}, this.next]);
}
search() {
this.isLoading = true;
this.api.device.getByTerm(this.page, this.rows, [this.query, this.next]);
}
pageChange() {
this.search();
} }
getTopicModels() { getTopicModels() {
...@@ -114,9 +123,9 @@ export class SensorMgrComponent implements OnInit { ...@@ -114,9 +123,9 @@ export class SensorMgrComponent implements OnInit {
getGateways() { getGateways() {
this.isLoading = true; this.isLoading = true;
this.api.device.getAll([{model: 0}, (data) => { this.api.device.getAll(1, 1000000, [{model: 0}, (data) => {
if (data && data.constructor === Array) { if (data && data.rows && data.rows.constructor === Array) {
this.canBindGateways = data.filter(one => !one.pDeviceNo); this.canBindGateways = data.rows.filter(one => !one.pDeviceNo);
} else { } else {
this.message.error(data && data.message ? data.message : '获取数据失败'); this.message.error(data && data.message ? data.message : '获取数据失败');
} }
...@@ -125,17 +134,17 @@ export class SensorMgrComponent implements OnInit { ...@@ -125,17 +134,17 @@ export class SensorMgrComponent implements OnInit {
} }
onSearch() { onSearch() {
this.filterFlag = null; this.page = 1;
this.query.isBind = null;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}]; this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
this.getData(); this.search();
} }
onGetAll() { onGetAll() {
this.page = 1;
this.query = { this.query = {
sensorName: '', model: 1
sensorSN: ''
}; };
this.filterFlag = null;
this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}]; this.listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
this.getData(); this.getData();
} }
...@@ -194,8 +203,8 @@ export class SensorMgrComponent implements OnInit { ...@@ -194,8 +203,8 @@ export class SensorMgrComponent implements OnInit {
// 筛选 // 筛选
filter(e) { filter(e) {
this.filterFlag = e; this.query.isBind = e;
this.getData(); this.search();
} }
companySelected(e) { companySelected(e) {
...@@ -212,7 +221,8 @@ export class SensorMgrComponent implements OnInit { ...@@ -212,7 +221,8 @@ export class SensorMgrComponent implements OnInit {
// 跳转详情 // 跳转详情
toSee(e) { toSee(e) {
this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail'], {queryParams: {deviceNo: e.deviceNo, name: e.name}}); this.router.navigate(['/app/deviceCenter/sensorMgr/sensorDetail'],
{queryParams: {deviceNo: e.deviceNo, name: e.name, companyNo: e.companyNo}});
} }
// 单个的方法 // 单个的方法
...@@ -220,6 +230,7 @@ export class SensorMgrComponent implements OnInit { ...@@ -220,6 +230,7 @@ export class SensorMgrComponent implements OnInit {
this.req = {}; this.req = {};
this.isMulti = false; this.isMulti = false;
this.isAddConV = true; this.isAddConV = true;
this.isUpdate = false;
this.try = {field: ['name', 'sn', 'type', 'companyNo']}; this.try = {field: ['name', 'sn', 'type', 'companyNo']};
} }
...@@ -314,6 +325,7 @@ export class SensorMgrComponent implements OnInit { ...@@ -314,6 +325,7 @@ export class SensorMgrComponent implements OnInit {
} }
multiAdd() { multiAdd() {
this.isUpdate = false;
this.isMulti = true; this.isMulti = true;
this.isMultiAddConV = true; this.isMultiAddConV = true;
} }
......
<div class="tableBar" @fade> <div class="tableBar" @fade>
<div class="btnLine" style="margin-bottom: 10px"> <div class="btnLine" style="margin-bottom: 10px">
<label class="subTitle"> {{topicName}} 通道模板{{'detail' | translate}}</label> <label class="subTitle"> {{topicName}} 主题{{'detail' | translate}}</label>
<button nz-button nzType="primary" style="margin-right: 10px" [nzLoading]="isLoading" (click)="saveOther()"><span>
{{'isSaveOtherProbesModel' | translate}}</span></button>
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="add()"><span>{{'addWay' | translate}}</span></button> <button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="add()"><span>{{'addWay' | translate}}</span></button>
<app-back [isLoading]="isLoading"></app-back> <app-back [isLoading]="isLoading"></app-back>
</div> </div>
...@@ -51,12 +53,12 @@ ...@@ -51,12 +53,12 @@
[nzFooter]="foot1" [nzTitle]="isUpdate ? ('update' | translate) : ('add' | translate)" (nzOnCancel)="cancel()" nzMaskClosable="false"> [nzFooter]="foot1" [nzTitle]="isUpdate ? ('update' | translate) : ('add' | translate)" (nzOnCancel)="cancel()" nzMaskClosable="false">
<ng-template #con1> <ng-template #con1>
<div class="half"> <div class="half">
<app-search-item isMust="true" inModal="true" [label]="'wayName' | translate" [(value)]="req.name"></app-search-item> <app-search-item nz-tooltip nzTitle="此处输入为英文" isMust="true" inModal="true" [label]="'wayName' | translate" [(value)]="req.name"></app-search-item>
<app-search-item inModal="true" [label]="'per' | translate" [(value)]="req.unit"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'per' | translate" [(value)]="req.unit"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'wayDescription' | translate" [(value)]="req.description"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'wayDescription' | translate" [(value)]="req.description"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'max' | translate" [(value)]="req.rangeMax"></app-search-item> <app-search-item inModal="true" [label]="'max' | translate" [(value)]="req.rangeMax"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMax' | translate" [(value)]="req.alarmUp"></app-search-item> <app-search-item inModal="true" [label]="'alarmMax' | translate" [(value)]="req.alarmUp"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMaxMax' | translate" [(value)]="req.upperAlarmLimit"></app-search-item> <app-search-item inModal="true" [label]="'alarmMaxMax' | translate" [(value)]="req.upperAlarmLimit"></app-search-item>
<div class="searchItem inModal"> <div class="searchItem inModal">
<div class="item-label"><span class="deleteFontColor">* </span>{{'isAlarm' | translate}}</div> <div class="item-label"><span class="deleteFontColor">* </span>{{'isAlarm' | translate}}</div>
<div class="item-input"> <div class="item-input">
...@@ -68,15 +70,15 @@ ...@@ -68,15 +70,15 @@
</div> </div>
</div> </div>
<div class="half"> <div class="half">
<app-search-item inModal="true" [label]="'wayAlias' | translate" [(value)]="req.alias"></app-search-item> <app-search-item nz-tooltip nzTitle="此处输入为英文" isMust="true" inModal="true" [label]="'wayAlias' | translate" [(value)]="req.alias"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'wayType' | translate" [(value)]="req.type"></app-search-item> <app-search-item isMust="true" inModal="true" [label]="'wayType' | translate" [(value)]="req.type"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'min' | translate" [(value)]="req.rangeMin"></app-search-item> <app-search-item inModal="true" [label]="'min' | translate" [(value)]="req.rangeMin"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMin' | translate" [(value)]="req.alarmDown"></app-search-item> <app-search-item inModal="true" [label]="'alarmMin' | translate" [(value)]="req.alarmDown"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmMinMin' | translate" [(value)]="req.lowerAlarmLimit"></app-search-item> <app-search-item inModal="true" [label]="'alarmMinMin' | translate" [(value)]="req.lowerAlarmLimit"></app-search-item>
<app-search-item isMust="true" inModal="true" [label]="'alarmInterval' | translate" [(value)]="req.alarmInterval"></app-search-item> <app-search-item inModal="true" [label]="'alarmInterval' | translate" [(value)]="req.alarmInterval"></app-search-item>
</div> </div>
<div class="searchItem inModal"> <div class="searchItem inModal">
<div class="item-label" style="width: 149px;"><span class="deleteFontColor">* </span>{{'wayInfo' | translate}}</div> <div class="item-label" style="width: 149px;">{{'wayInfo' | translate}}</div>
<div class="item-input" style="width: calc(100% - 158px);"> <div class="item-input" style="width: calc(100% - 158px);">
<textarea nz-input [(ngModel)]="req.boxedart"></textarea> <textarea nz-input [(ngModel)]="req.boxedart"></textarea>
</div> </div>
...@@ -84,6 +86,19 @@ ...@@ -84,6 +86,19 @@
</ng-template> </ng-template>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><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()"><span>{{'confirm' | 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)]="isSaveOther" [nzContent]="con2" nzWidth="500" [nzTitle]="'isSaveOtherProbesModel' | translate"
[nzFooter]="foot2" (nzOnCancel)="cancel()" nzMaskClosable="false">
<ng-template #con2>
<app-search-item inModal="true" isMust="true" [label]="'moduleName' | translate" [(value)]="req2.newProbesModelName"></app-search-item>
<!--<app-search-select isMust="true" inModal="true" [(value)]="req2.companyNo" [label]="'selectCompany' | translate" optL="companyName"-->
<!--[data]="companys" optV="companyNo"></app-search-select>-->
</ng-template>
<ng-template #foot2>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel()"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req2')"><span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ApiService} from '../../service/api'; import {ApiService} from '../../service/api';
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {TranslateService} from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import {fadeIn} from '../../animation/fade-in'; import {fadeIn} from '../../animation/fade-in';
import {CheckService} from '../../service/check';
@Component({ @Component({
selector: 'app-sensor-topic-way', selector: 'app-sensor-topic-way',
...@@ -14,15 +15,20 @@ import {fadeIn} from '../../animation/fade-in'; ...@@ -14,15 +15,20 @@ import {fadeIn} from '../../animation/fade-in';
export class SensorTopicWayComponent implements OnInit { export class SensorTopicWayComponent implements OnInit {
req: any = {}; req: any = {};
req2;
data = []; data = [];
isLoading = false; isLoading = false;
deviceNo = ''; deviceNo = '';
topicName = ''; topicName = '';
isV = false; isV = false;
isUpdate = false; isUpdate = false;
isSaveOther = false;
companyNo = '';
try = {};
constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute, constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute,
private translate: TranslateService, private router: Router, private modalService: NzModalService) { private translate: TranslateService, private router: Router, private modalService: NzModalService,
private ck: CheckService) {
} }
ngOnInit() { ngOnInit() {
...@@ -34,6 +40,7 @@ export class SensorTopicWayComponent implements OnInit { ...@@ -34,6 +40,7 @@ export class SensorTopicWayComponent implements OnInit {
if (params.deviceNo) { if (params.deviceNo) {
this.deviceNo = params.deviceNo; this.deviceNo = params.deviceNo;
this.topicName = params.topicName; this.topicName = params.topicName;
this.companyNo = params.companyNo;
this.getData(); this.getData();
} }
}); });
...@@ -63,6 +70,10 @@ export class SensorTopicWayComponent implements OnInit { ...@@ -63,6 +70,10 @@ export class SensorTopicWayComponent implements OnInit {
this.req = {}; this.req = {};
this.isUpdate = false; this.isUpdate = false;
this.isV = true; this.isV = true;
this.try = {
field: ['deviceNo', 'topicName', 'name', 'alias', 'description', 'type', 'unit', 'isAlarm'],
eng: ['name', 'alias']
};
} }
update(one) { update(one) {
...@@ -70,28 +81,41 @@ export class SensorTopicWayComponent implements OnInit { ...@@ -70,28 +81,41 @@ export class SensorTopicWayComponent implements OnInit {
this.req = {...one}; this.req = {...one};
this.req.oldName = one.name; this.req.oldName = one.name;
this.isV = true; this.isV = true;
this.try = {
field: ['deviceNo', 'topicName', 'name', 'alias', 'description', 'type', 'unit', 'isAlarm'],
eng: ['name', 'alias']
};
} }
cancel() { cancel() {
this.isV = false; this.isV = false;
this.isSaveOther = false;
} }
save() { save(v) {
this.isLoading = true; this.isLoading = true;
this.req.deviceNo = this.deviceNo; this.req.deviceNo = this.deviceNo;
this.req.topicName = this.topicName; this.req.topicName = this.topicName;
if (this.isUpdate) { if (!this.ck.formCheck(this[v], this.try)) {
this.isLoading = false;
return false;
}
if (this.isV && this.isUpdate) {
this.api.probes.updateProbes([this.req, this.next]); this.api.probes.updateProbes([this.req, this.next]);
} else { } else if (this.isV && !this.isUpdate) {
this.api.probes.addProbes([this.req, this.next]); this.api.probes.addProbes([this.req, this.next]);
} else if (this.isSaveOther) {
this.api.probes.saveAsProbesModel([this.req2, this.next]);
} else {
this.isLoading = false;
} }
} }
deleteConfirm(one) { deleteConfirm(one) {
this.modalService.confirm({ this.modalService.confirm({
nzTitle : '<i> </i>', nzTitle: '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>', nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete(one) nzOnOk: () => this.delete(one)
}); });
} }
...@@ -99,4 +123,15 @@ export class SensorTopicWayComponent implements OnInit { ...@@ -99,4 +123,15 @@ export class SensorTopicWayComponent implements OnInit {
this.isLoading = true; this.isLoading = true;
this.api.probes.delAProbes([{deviceNo: this.deviceNo, name: one.name, topicName: this.topicName}, this.next]); this.api.probes.delAProbes([{deviceNo: this.deviceNo, name: one.name, topicName: this.topicName}, this.next]);
} }
saveOther() {
this.isSaveOther = true;
this.req2 = {
companyNo: this.companyNo,
newProbesModelName: '',
deviceNo: this.deviceNo,
topicName: this.topicName
};
this.try = {field: ['newProbesModelName', 'deviceNo']};
}
} }
...@@ -78,7 +78,7 @@ export class TopicModuleMgrComponent implements OnInit { ...@@ -78,7 +78,7 @@ export class TopicModuleMgrComponent implements OnInit {
this.message.error(data && data.message ? data.message : '获取数据失败'); this.message.error(data && data.message ? data.message : '获取数据失败');
} }
this.isLoading = false; this.isLoading = false;
}; }
toDetail(one) { toDetail(one) {
this.router.navigate(['/app/deviceCenter/topicModuleMgr/topicModuleDetail'], this.router.navigate(['/app/deviceCenter/topicModuleMgr/topicModuleDetail'],
......
...@@ -109,6 +109,7 @@ export class ApiService { ...@@ -109,6 +109,7 @@ export class ApiService {
addTopic: (data) => this.trans('post', '/device/topic/addTopic', data), addTopic: (data) => this.trans('post', '/device/topic/addTopic', data),
delTopic: (data) => this.trans('post', '/device/topic/delTopic', data), delTopic: (data) => this.trans('post', '/device/topic/delTopic', data),
getByDeviceNo: (data) => this.trans('post', '/device/topic/getByDeviceNo', data), getByDeviceNo: (data) => this.trans('post', '/device/topic/getByDeviceNo', data),
saveAsTopicModel: (data) => this.trans('post', '/device/topic/saveAsTopicModel', data),
updateTopic: (data) => this.trans('post', '/device/topic/updateTopic', data), updateTopic: (data) => this.trans('post', '/device/topic/updateTopic', data),
}; };
...@@ -125,8 +126,8 @@ export class ApiService { ...@@ -125,8 +126,8 @@ export class ApiService {
deploySensor: (data) => this.trans('post', '/device/device/deploySensor', data), deploySensor: (data) => this.trans('post', '/device/device/deploySensor', data),
gatewayBindGateway: (data) => this.trans('post', '/device/device/bindDevice', data), gatewayBindGateway: (data) => this.trans('post', '/device/device/bindDevice', data),
getSensorByMaxDevice: (data) => this.trans('post', '/device/device/getSensorByMaxDevice', data), getSensorByMaxDevice: (data) => this.trans('post', '/device/device/getSensorByMaxDevice', data),
getAll: (data) => this.trans('post', '/device/device/getAll', data), getAll: (page, rows, data) => this.trans('post', '/device/device/getAll?page=' + page + '&rows=' + rows, data),
getByTerm: (data) => this.trans('post', '/device/device/getByTerm', data), getByTerm: (page, rows, data) => this.trans('post', '/device/device/getByTerm?page=' + page + '&rows=' + rows, data),
mountUninstallDevice: (data) => this.trans('post', '/device/device/mountUninstallDevice', data), mountUninstallDevice: (data) => this.trans('post', '/device/device/mountUninstallDevice', data),
unBindDevice: (data) => this.trans('post', '/device/device/unBindDevice', data), unBindDevice: (data) => this.trans('post', '/device/device/unBindDevice', data),
updateCompany: (data) => this.trans('post', '/device/device/updateCompany', data), updateCompany: (data) => this.trans('post', '/device/device/updateCompany', data),
...@@ -146,6 +147,7 @@ export class ApiService { ...@@ -146,6 +147,7 @@ export class ApiService {
addProbes: (data) => this.trans('post', '/device/probes/addProbes', data), addProbes: (data) => this.trans('post', '/device/probes/addProbes', data),
delAProbes: (data) => this.trans('post', '/device/probes/delAProbes', data), delAProbes: (data) => this.trans('post', '/device/probes/delAProbes', data),
getAll: (data) => this.trans('post', '/device/probes/getAll', data), getAll: (data) => this.trans('post', '/device/probes/getAll', data),
saveAsProbesModel: (data) => this.trans('post', '/device/probes/saveAsProbesModel', data),
getProbesByGateway: (data) => this.trans('post', '/device/probes/getProbesByGateway', data), getProbesByGateway: (data) => this.trans('post', '/device/probes/getProbesByGateway', data),
updateProbes: (data) => this.trans('post', '/device/probes/updateProbes', data), updateProbes: (data) => this.trans('post', '/device/probes/updateProbes', data),
}; };
......
...@@ -46,6 +46,14 @@ export class CheckService { ...@@ -46,6 +46,14 @@ export class CheckService {
this.message.warning(this.translate.instant('wrongNum')); this.message.warning(this.translate.instant('wrongNum'));
return false; return false;
} }
const eNum = req.eng ? req.eng.length : 0;
const eng = req.eng ? req.eng.filter((item) => this.checkEng(fieldStr, data, item)).length : 0;
if (eng !== eNum) {
this.message.warning(this.translate.instant('wrongEng'));
return false;
}
return true; return true;
} }
...@@ -105,4 +113,16 @@ export class CheckService { ...@@ -105,4 +113,16 @@ export class CheckService {
return false; return false;
} }
} }
private checkEng(fieldStr, data, eng) {
if ((data[eng] === '' || isUndefined(data[eng]) || data[eng] === null) && fieldStr.indexOf('-' + eng + '-') > -1) {
return true;
}
const reg = new RegExp( '^[a-zA-Z]*$');
if (reg.test(data[eng])) {
return true;
} else {
return false;
}
}
} }
...@@ -156,5 +156,11 @@ ...@@ -156,5 +156,11 @@
"see": "查看", "see": "查看",
"pleaseFillAll": "请填完所有必填项", "pleaseFillAll": "请填完所有必填项",
"isSaveOtherProbesModel": "另存为通道模板", "isSaveOtherProbesModel": "另存为通道模板",
"isSaveOtherTopicModel": "另存为主题模板" "isSaveOtherTopicModel": "另存为主题模板",
"bindTongxinAddr": "绑定通信地址",
"bindUpGateway": "绑定上级网关",
"gatewayBindTips": "Modbus, Sub1G, LoRa等通信协议地址",
"wrongNum": "数值填写错误",
"updateTopic": "编辑主题",
"wrongEng": "部分字段要求为英文格式"
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
export const environment = { 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', // 对外访问测试网地址 baseUrl: 'http://172.16.1.53:8092', // cy
}; };
/* /*
......
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