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

改了一堆

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