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

四个主页面的表单验证

parent 86fbbd44
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<span>{{'search' | translate}}</span></button> <span>{{'search' | translate}}</span></button>
<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>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,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" [disabled]="true" (click)="toggleOn(one)" [(ngModel)]="one.state" <nz-switch [nzControl]="true" (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>
...@@ -89,30 +89,30 @@ ...@@ -89,30 +89,30 @@
<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 inModal="true" isMust="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 *ngIf="!isUpdate" isMust="true" 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 *ngIf="!isUpdate" isMust="true" 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 isMust="true" 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" isMust="true" 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" [(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" inModal="true" optV="companyNo"></app-search-select> [data]="companys" optV="companyNo"></app-search-select>
<app-search-select isMust="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo" <app-search-select inModal="true" *ngIf="req.companyNo" [(value)]="req.influxdbDatabaseNo"
[label]="'selectInfluxDB' | translate" optL="databaseName" [label]="'selectInfluxDB' | translate" optL="databaseName"
[data]="influxdbs" inModal="true" optV="influxdbDatabaseNo"></app-search-select> [data]="influxdbs" optV="influxdbDatabaseNo"></app-search-select>
<app-search-select [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName" <app-search-select inModal="true" [(value)]="req.sceneNo" [label]="'selectScene' | translate" optL="sceneName"
[data]="scenes" inModal="true" optV="sceneNo"></app-search-select> [data]="scenes" optV="sceneNo"></app-search-select>
<app-search-item inModal="true" isMust="true" [label]="'remark' | translate" <app-search-item inModal="true" [label]="'remark' | translate"
[(value)]="req.remark"></app-search-item> [(value)]="req.remark"></app-search-item>
</ng-template> </ng-template>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')">
<span>{{'cancel' | translate}}</span></button> <span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save()"> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req')">
<span>{{'confirm' | translate}}</span></button> <span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
<ng-template #foot2> <ng-template #foot2>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isMultiAddConV')"> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isMultiAddConV')">
<span>{{'cancel' | translate}}</span></button> <span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('isMultiAddConV')"> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req2')">
<span>{{'confirm' | translate}}</span></button> <span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<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')">
<span>{{'cancel' | translate}}</span></button> <span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save()"> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req3')">
<span>{{'confirm' | translate}}</span></button> <span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
<ng-template #foot4> <ng-template #foot4>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isDivideConV')"> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isDivideConV')">
<span>{{'cancel' | translate}}</span></button> <span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('isDivideConV')"> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req4')">
<span>{{'confirm' | translate}}</span></button> <span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
...@@ -4,14 +4,12 @@ import {ApiService} from '../../service/api'; ...@@ -4,14 +4,12 @@ import {ApiService} from '../../service/api';
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {TranslateService} from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import {CheckService} from '../../service/check';
@Component({ @Component({
selector: 'app-gateway', selector: 'app-gateway',
templateUrl: './gateway.component.html', templateUrl: './gateway.component.html',
styles: [` styles: [`
:host ::ng-deep .anticon-filter {
left: 73px;
}
.btnPart { .btnPart {
padding: 10px; padding: 10px;
} }
...@@ -48,9 +46,11 @@ export class GatewayComponent implements OnInit { ...@@ -48,9 +46,11 @@ export class GatewayComponent implements OnInit {
req3: any = {}; req3: any = {};
scenes = [{sceneNo: '123', sceneName: 'qq'}]; scenes = [{sceneNo: '123', sceneName: 'qq'}];
req4: any = {}; req4: any = {};
try = {};
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,
private ck: CheckService) {
} }
ngOnInit() { ngOnInit() {
...@@ -169,8 +169,8 @@ export class GatewayComponent implements OnInit { ...@@ -169,8 +169,8 @@ export class GatewayComponent implements OnInit {
this.canbind = false; this.canbind = false;
this.canUnbind = false; this.canUnbind = false;
} else { } else {
const flag = obj[0].isOn; const flag = obj[0].pDeviceNo && true;
if (obj.filter(one => one.isOn === flag).length === obj.length) { if (obj.filter(one => (obj[0].pDeviceNo && true) === flag).length === obj.length) {
this.canbind = flag; this.canbind = flag;
this.canUnbind = !flag; this.canUnbind = !flag;
} else { } else {
...@@ -194,9 +194,11 @@ export class GatewayComponent implements OnInit { ...@@ -194,9 +194,11 @@ export class GatewayComponent implements OnInit {
// 单个的方法 // 单个的方法
add() { add() {
this.req = {};
this.isMulti = false; this.isMulti = false;
this.isUpdate = false; this.isUpdate = false;
this.isAddConV = true; this.isAddConV = true;
this.try = {field: ['name', 'sn', 'companyNo']};
} }
bind(one) { bind(one) {
...@@ -208,6 +210,7 @@ export class GatewayComponent implements OnInit { ...@@ -208,6 +210,7 @@ export class GatewayComponent implements OnInit {
influxdbDatabaseNo: '', influxdbDatabaseNo: '',
pDeviceNo: '' pDeviceNo: ''
}; };
this.try = {field: ['address', 'deviceNo', 'pDeviceNo']};
this.isBindConV = true; this.isBindConV = true;
} }
...@@ -228,6 +231,7 @@ export class GatewayComponent implements OnInit { ...@@ -228,6 +231,7 @@ export class GatewayComponent implements OnInit {
this.isMulti = false; this.isMulti = false;
this.req = {...one}; this.req = {...one};
this.companySelected(one.companyNo); this.companySelected(one.companyNo);
this.try = {field: ['name', 'sn', 'companyNo', 'deviceNo']};
this.isUpdate = true; this.isUpdate = true;
this.isAddConV = true; this.isAddConV = true;
} }
...@@ -235,6 +239,7 @@ export class GatewayComponent implements OnInit { ...@@ -235,6 +239,7 @@ export class GatewayComponent implements OnInit {
divide(one) { divide(one) {
this.isMulti = false; this.isMulti = false;
this.req4 = {...one}; this.req4 = {...one};
this.try = {field: ['companyNo', 'deviceNo']};
this.isDivideConV = true; this.isDivideConV = true;
} }
...@@ -244,6 +249,10 @@ export class GatewayComponent implements OnInit { ...@@ -244,6 +249,10 @@ export class GatewayComponent implements OnInit {
save(v) { save(v) {
this.isLoading = true; this.isLoading = true;
if (!this.ck.formCheck(this[v], this.try)) {
this.isLoading = false;
return;
}
// 单个新增 // 单个新增
if (!this.isMulti && this.isAddConV && !this.isUpdate) { if (!this.isMulti && this.isAddConV && !this.isUpdate) {
this.api.device.addGateway([this.req, this.next]); this.api.device.addGateway([this.req, this.next]);
...@@ -317,9 +326,14 @@ export class GatewayComponent implements OnInit { ...@@ -317,9 +326,14 @@ export class GatewayComponent implements OnInit {
toggleOn(one) { toggleOn(one) {
one.isLoading = true; one.isLoading = true;
setTimeout(() => { this.api.device.mountUninstallDevice([{deviceNo: one.deviceNo, state: one.state === 0 ? 1 : 0}, (data) => {
one.isOn = !one.isOn; if (data && data.code === 1) {
one.state = one.state === 0 ? 1 : 0;
this.message.success(data && data.message ? data.message : '操作成功');
} else {
this.message.error(data && data.message ? data.message : '操作失败');
}
one.isLoading = false; one.isLoading = false;
}, 2000); }]);
} }
} }
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</ng-template> </ng-template>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><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> </ng-template>
</nz-modal> </nz-modal>
......
...@@ -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 {Router} from '@angular/router'; import {Router} from '@angular/router';
import {CheckService} from '../../service/check';
@Component({ @Component({
selector: 'app-module-mgr', selector: 'app-module-mgr',
...@@ -20,9 +21,10 @@ export class ModuleMgrComponent implements OnInit { ...@@ -20,9 +21,10 @@ export class ModuleMgrComponent implements OnInit {
isSaveOther = false; isSaveOther = false;
isUpdate = false; isUpdate = false;
moduleName = ''; moduleName = '';
try: any = {};
constructor(private api: ApiService, private message: NzMessageService, private modalService: NzModalService, constructor(private api: ApiService, private message: NzMessageService, private modalService: NzModalService,
private translate: TranslateService, private router: Router) { private translate: TranslateService, private router: Router, private ck: CheckService) {
} }
ngOnInit() { ngOnInit() {
...@@ -64,7 +66,8 @@ export class ModuleMgrComponent implements OnInit { ...@@ -64,7 +66,8 @@ export class ModuleMgrComponent implements OnInit {
} }
toDetail(one) { toDetail(one) {
this.router.navigate(['/app/deviceCenter/moduleMgr/moduleDetail'], {queryParams: {probesModelNo: one.probesModelNo, probesModelName: one.probesModelName}}); this.router.navigate(['/app/deviceCenter/moduleMgr/moduleDetail'],
{queryParams: {probesModelNo: one.probesModelNo, probesModelName: one.probesModelName}});
} }
saveOther(one) { saveOther(one) {
...@@ -72,22 +75,29 @@ export class ModuleMgrComponent implements OnInit { ...@@ -72,22 +75,29 @@ export class ModuleMgrComponent implements OnInit {
} }
add() { add() {
this.req = {};
this.isUpdate = false; this.isUpdate = false;
this.isAddConV = true; this.isAddConV = true;
this.try = {field: ['probesModelName', 'num']};
} }
update(one) { update(one) {
this.isUpdate = true; this.isUpdate = true;
this.req = {...one}; this.req = {...one};
this.isAddConV = true; this.isAddConV = true;
this.try = {field: ['probesModelNo', 'probesModelName']};
} }
cancel(v) { cancel(v) {
this[v] = false; this[v] = false;
} }
save() { save(v) {
this.isLoading = true; this.isLoading = true;
if (!this.ck.formCheck(this[v], this.try)) {
this.isLoading = false;
return;
}
if (this.isUpdate) { if (this.isUpdate) {
this.api.probesModel.updateProbesModel([this.req, this.next]); this.api.probesModel.updateProbesModel([this.req, this.next]);
} else { } else {
......
...@@ -58,6 +58,8 @@ ...@@ -58,6 +58,8 @@
<span *ngIf="one.pDeviceNo" class="editSpan" (click)="unbind(one)">{{'unbind' | translate}}</span> <span *ngIf="one.pDeviceNo" class="editSpan" (click)="unbind(one)">{{'unbind' | translate}}</span>
<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 *ngIf="!one.pDeviceNo && !one.state" nzType="vertical"></nz-divider>
<span *ngIf="!one.pDeviceNo && !one.state" class="editSpan" (click)="divide(one)">{{'divide' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider> <nz-divider nzType="vertical"></nz-divider>
<span class="deleteFontColor" (click)="deleteConfirm(one)">{{'delete' | translate}}</span> <span class="deleteFontColor" (click)="deleteConfirm(one)">{{'delete' | translate}}</span>
</td> </td>
...@@ -109,7 +111,7 @@ ...@@ -109,7 +111,7 @@
</ng-template> </ng-template>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('isAddConV')"><span>{{'confirm' | translate}}</span></button> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req')"><span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
...@@ -145,18 +147,20 @@ ...@@ -145,18 +147,20 @@
<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')">
<span>{{'cancel' | translate}}</span></button> <span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save()"> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req3')">
<span>{{'confirm' | translate}}</span></button> <span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
<nz-modal [(nzVisible)]="isDivideConV" [nzContent]="con5" nzWidth="500" <nz-modal [(nzVisible)]="isDivideConV" [nzContent]="con5" nzWidth="500" [nzTitle]="('divide' | translate) + ('sensor' | translate)"
[nzFooter]="foot5" (nzOnCancel)="cancel('isDivideConV')" nzMaskClosable="false"> [nzFooter]="foot5" (nzOnCancel)="cancel('isDivideConV')" nzMaskClosable="false">
<ng-template #con5> <ng-template #con5>
分配传感器 <app-search-select isMust="true" [(value)]="req5.companyNo" [label]="'selectCompany' | translate" optL="companyName"
(valueChange)="companySelected($event)"
[data]="companys" inModal="true" optV="companyNo"></app-search-select>
</ng-template> </ng-template>
<ng-template #foot5> <ng-template #foot5>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isDivideConV')"><span>{{'cancel' | translate}}</span></button> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isDivideConV')"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('isDivideConV')"><span>{{'confirm' | translate}}</span></button> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req5')"><span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
...@@ -4,14 +4,12 @@ import {NzMessageService, NzModalService} from 'ng-zorro-antd'; ...@@ -4,14 +4,12 @@ import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {Router} from '@angular/router'; import {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-mgr', selector: 'app-sensor-mgr',
templateUrl: './sensor-mgr.component.html', templateUrl: './sensor-mgr.component.html',
styles: [` styles: [`
:host ::ng-deep .anticon-filter {
left: 73px;
}
.btnPart { .btnPart {
padding: 10px; padding: 10px;
} }
...@@ -29,7 +27,6 @@ export class SensorMgrComponent implements OnInit { ...@@ -29,7 +27,6 @@ export class SensorMgrComponent implements OnInit {
isAllCheck = false; isAllCheck = false;
isIndeterminate = false; isIndeterminate = false;
listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}]; listOfBind = [{text: '已绑定', value: 1}, {text: '未绑定', value: 0}];
selectedOne: any = {};
isAddConV = false; isAddConV = false;
isMultiAddConV = false; isMultiAddConV = false;
isBindConV = false; isBindConV = false;
...@@ -48,9 +45,11 @@ export class SensorMgrComponent implements OnInit { ...@@ -48,9 +45,11 @@ export class SensorMgrComponent implements OnInit {
selectedGateways = []; selectedGateways = [];
canBindGateways = []; canBindGateways = [];
req3: any = {}; req3: any = {};
req5: any = {};
try = {};
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, private ck: CheckService) {
} }
ngOnInit() { ngOnInit() {
...@@ -218,8 +217,10 @@ export class SensorMgrComponent implements OnInit { ...@@ -218,8 +217,10 @@ export class SensorMgrComponent implements OnInit {
// 单个的方法 // 单个的方法
add() { add() {
this.req = {};
this.isMulti = false; this.isMulti = false;
this.isAddConV = true; this.isAddConV = true;
this.try = {field: ['name', 'sn', 'type', 'companyNo']};
} }
bind(one) { bind(one) {
...@@ -232,6 +233,7 @@ export class SensorMgrComponent implements OnInit { ...@@ -232,6 +233,7 @@ export class SensorMgrComponent implements OnInit {
pDeviceNo: '' pDeviceNo: ''
}; };
this.isBindConV = true; this.isBindConV = true;
this.try = {field: ['address', 'deviceNo', 'pDeviceNo']};
} }
unbind(one) { unbind(one) {
...@@ -247,19 +249,32 @@ export class SensorMgrComponent implements OnInit { ...@@ -247,19 +249,32 @@ export class SensorMgrComponent implements OnInit {
this.api.device.unBindDevice([{deviceNo: one.deviceNo}, this.next]); this.api.device.unBindDevice([{deviceNo: one.deviceNo}, this.next]);
} }
divide(one) {
this.isMulti = false;
this.req5 = {...one};
this.try = {field: ['companyNo', 'deviceNo']};
this.isDivideConV = true;
}
update(one) { update(one) {
this.isMulti = false; this.isMulti = false;
this.req = {...one}; this.req = {...one};
this.companySelected(one.companyNo); this.companySelected(one.companyNo);
this.isUpdate = true; this.isUpdate = true;
this.isAddConV = true; this.isAddConV = true;
this.try = {field: ['name', 'sn', 'type', 'companyNo', 'deviceNo']};
} }
cancel(v) { cancel(v) {
this[v] = false; this[v] = false;
} }
save() { save(v) {
this.isLoading = true;
if (!this.ck.formCheck(this[v], this.try)) {
this.isLoading = false;
return;
}
if (!this.isMulti && this.isAddConV && !this.isUpdate) { if (!this.isMulti && this.isAddConV && !this.isUpdate) {
this.req.alarmMethodNos = []; this.req.alarmMethodNos = [];
this.req.alarmUsers = []; this.req.alarmUsers = [];
...@@ -274,6 +289,8 @@ export class SensorMgrComponent implements OnInit { ...@@ -274,6 +289,8 @@ export class SensorMgrComponent implements OnInit {
this.req3.pDeviceNo = this.req3.device.deviceNo; this.req3.pDeviceNo = this.req3.device.deviceNo;
this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo; this.req3.influxdbDatabaseNo = this.req3.device.influxdbDatabaseNo;
this.api.device.gatewayBindGateway([this.req3, this.next]); this.api.device.gatewayBindGateway([this.req3, this.next]);
} else if (!this.isMulti && this.isDivideConV) {
this.api.device.updateCompany([this.req5, this.next]);
} }
} }
...@@ -333,9 +350,14 @@ export class SensorMgrComponent implements OnInit { ...@@ -333,9 +350,14 @@ export class SensorMgrComponent implements OnInit {
toggleOn(one) { toggleOn(one) {
one.isLoading = true; one.isLoading = true;
setTimeout(() => { this.api.device.mountUninstallDevice([{deviceNo: one.deviceNo, state: one.state === 0 ? 1 : 0}, (data) => {
one.isOn = !one.isOn; if (data && data.code === 1) {
one.state = one.state === 0 ? 1 : 0;
this.message.success(data && data.message ? data.message : '操作成功');
} else {
this.message.error(data && data.message ? data.message : '操作失败');
}
one.isLoading = false; one.isLoading = false;
}, 2000); }]);
} }
} }
...@@ -84,7 +84,7 @@ export class TopicModuleDetailComponent implements OnInit { ...@@ -84,7 +84,7 @@ export class TopicModuleDetailComponent implements OnInit {
this.message.error(data && data.message ? data.message : '获取数据失败'); this.message.error(data && data.message ? data.message : '获取数据失败');
} }
this.isLoading = false; this.isLoading = false;
}; }
add() { add() {
this.req = {}; this.req = {};
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</ng-template> </ng-template>
<ng-template #foot1> <ng-template #foot1>
<button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button> <button nz-button nzType="default" [nzLoading]="isLoading" (click)="cancel('isAddConV')"><span>{{'cancel' | translate}}</span></button>
<button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('isAddConV')"><span>{{'confirm' | translate}}</span></button> <button nz-button nzType="primary" [nzLoading]="isLoading" (click)="save('req')"><span>{{'confirm' | translate}}</span></button>
</ng-template> </ng-template>
</nz-modal> </nz-modal>
......
...@@ -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 {Router} from '@angular/router'; import {Router} from '@angular/router';
import {CheckService} from '../../service/check';
@Component({ @Component({
selector: 'app-topic-module-mgr', selector: 'app-topic-module-mgr',
...@@ -20,9 +21,10 @@ export class TopicModuleMgrComponent implements OnInit { ...@@ -20,9 +21,10 @@ export class TopicModuleMgrComponent implements OnInit {
isSaveOther = false; isSaveOther = false;
isUpdate = false; isUpdate = false;
topicModuleName = ''; topicModuleName = '';
try = {};
constructor(private api: ApiService, private message: NzMessageService, private modalService: NzModalService, constructor(private api: ApiService, private message: NzMessageService, private modalService: NzModalService,
private translate: TranslateService, private router: Router) { private translate: TranslateService, private router: Router, private ck: CheckService) {
} }
ngOnInit() { ngOnInit() {
...@@ -64,7 +66,8 @@ export class TopicModuleMgrComponent implements OnInit { ...@@ -64,7 +66,8 @@ export class TopicModuleMgrComponent implements OnInit {
} }
toDetail(one) { toDetail(one) {
this.router.navigate(['/app/deviceCenter/topicModuleMgr/topicModuleDetail'], {queryParams: {topicModelNo: one.topicModelNo, topicModuleName: one.topicModuleName}}); this.router.navigate(['/app/deviceCenter/topicModuleMgr/topicModuleDetail'],
{queryParams: {topicModelNo: one.topicModelNo, topicModuleName: one.topicModuleName}});
} }
saveOther(one) { saveOther(one) {
...@@ -75,20 +78,26 @@ export class TopicModuleMgrComponent implements OnInit { ...@@ -75,20 +78,26 @@ export class TopicModuleMgrComponent implements OnInit {
this.isUpdate = false; this.isUpdate = false;
this.req = {}; this.req = {};
this.isAddConV = true; this.isAddConV = true;
this.try = {field: ['topicModelName', 'prefixName']};
} }
update(one) { update(one) {
this.isUpdate = true; this.isUpdate = true;
this.req = {...one}; this.req = {...one};
this.isAddConV = true; this.isAddConV = true;
this.try = {field: ['topicModelNo', 'topicModelName', 'prefixName']};
} }
cancel(v) { cancel(v) {
this[v] = false; this[v] = false;
} }
save() { save(v) {
this.isLoading = true; this.isLoading = true;
if (!this.ck.formCheck(this[v], this.try)) {
this.isLoading = false;
return;
}
if (this.isUpdate) { if (this.isUpdate) {
this.api.topicModel.updateTopic([this.req, this.next]); this.api.topicModel.updateTopic([this.req, this.next]);
} else { } else {
......
...@@ -126,7 +126,6 @@ export class ApiService { ...@@ -126,7 +126,6 @@ export class ApiService {
getAll: (data) => this.trans('post', '/device/device/getAll', data), getAll: (data) => this.trans('post', '/device/device/getAll', data),
getByTerm: (data) => this.trans('post', '/device/device/getByTerm', data), getByTerm: (data) => this.trans('post', '/device/device/getByTerm', data),
mountUninstallDevice: (data) => this.trans('post', '/device/device/mountUninstallDevice', data), mountUninstallDevice: (data) => this.trans('post', '/device/device/mountUninstallDevice', data),
mountUninstallGateway: (data) => this.trans('post', '/device/device/mountUninstallGateway', 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),
updateGateway: (data) => this.trans('post', '/device/device/updateGateway', data), updateGateway: (data) => this.trans('post', '/device/device/updateGateway', data),
......
...@@ -10,7 +10,7 @@ export class CheckService { ...@@ -10,7 +10,7 @@ export class CheckService {
formCheck(data, req) { formCheck(data, req) {
const fNum = req.field.length; const fNum = req.field.length;
const fieldStr = '-' + req.field.join('-') + '-'; const fieldStr = '-' + req.field.join('-') + '-';
const field = req.field.filter((item) => data[item] !== null && !isUndefined(data[item])).length; const field = req.field.filter((item) => data[item] !== '' && data[item] !== null && !isUndefined(data[item])).length;
if (field !== fNum) { if (field !== fNum) {
this.message.warning(this.translate.instant('pleaseFillAll')); this.message.warning(this.translate.instant('pleaseFillAll'));
return false; return false;
......
...@@ -153,5 +153,6 @@ ...@@ -153,5 +153,6 @@
"updateWay": "编辑通道", "updateWay": "编辑通道",
"updateTime": "更新时间", "updateTime": "更新时间",
"updateData": "最新数据", "updateData": "最新数据",
"see": "查看" "see": "查看",
"pleaseFillAll": "请填完所有必填项"
} }
export const environment = { export const environment = {
production: true, production: true,
baseUrl: 'http://47.111.110.50:8094', // 对外访问测试网地址 baseUrl: 'http://cloud-test.witium.com/api', // 对外访问测试网地址
}; };
...@@ -391,3 +391,7 @@ label.subTitle { ...@@ -391,3 +391,7 @@ label.subTitle {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
} }
.ant-table-body table thead tr th, table tbody tr {
text-align: center;
}
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