Commit 6271f8cc authored by van.chen's avatar van.chen

提交一下

parent 026761a8
<div class="tableBar" @fade>
<div class="btnLine" style="margin-bottom: 10px">
<label class="subTitle"> {{topicName}} 通道模板{{'detail' | translate}}</label>
<button nz-button [nzType]="'primary'" [nzLoading]="isLoading" (click)="add()"><span>{{'addWay' | translate}}</span></button>
<app-back [isLoading]="isLoading"></app-back>
</div>
<nz-table #nzTable
[nzData]="data"
[nzSize]="'middle'"
nzShowSizeChanger
[nzLoading]="isLoading">
<thead nz-thead>
<tr>
<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>
<th nz-th><span>{{'isAlarm' | translate}}</span></th>
<th nz-th><span>{{'oper' | translate}}</span></th>
</tr>
</thead>
<tbody nz-tbody>
<tr *ngFor="let one of nzTable.data, let i = index">
<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.upperAlarmLimit}}</td>
<td nz-td>{{one.alarmDown}}</td>
<td nz-td>{{one.lowerAlarmLimit}}</td>
<td nz-td>{{one.isAlarm === 1 ? '是': '否'}}</td>
<td nz-td>
<span class="editSpan" (click)="update(one)">{{'update' | translate}}</span>
<nz-divider nzType="vertical"></nz-divider>
<span class="deleteFontColor" (click)="deleteConfirm(one)">{{'delete' | translate}}</span>
</td>
</tr>
</tbody>
</nz-table>
</div>
<nz-modal [(nzVisible)]="isV" [nzContent]="con1" nzWidth="750"
[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 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>
<div class="searchItem inModal">
<div class="item-label"><span class="deleteFontColor">* </span>{{'isAlarm' | translate}}</div>
<div class="item-input">
<nz-radio-group [(ngModel)]="req.isAlarm">
<label nz-radio [nzValue]="1"></label>
<label nz-radio [nzValue]="0"></label>
</nz-radio-group>
</div>
</div>
</div>
<div class="half">
<app-search-item 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>
</div>
<div class="searchItem inModal">
<div class="item-label" style="width: 149px;"><span class="deleteFontColor">* </span>{{'wayInfo' | translate}}</div>
<div class="item-input" style="width: calc(100% - 158px);">
<textarea nz-input [(ngModel)]="req.boxedart"></textarea>
</div>
</div>
</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>
</ng-template>
</nz-modal>
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';
@Component({
selector: 'app-sensor-topic-way',
templateUrl: './sensor-topic-way.component.html',
styles: [],
animations: [fadeIn]
})
export class SensorTopicWayComponent implements OnInit {
req: any = {};
data = [];
isLoading = false;
deviceNo = '';
topicName = '';
isV = false;
isUpdate = false;
constructor(private api: ApiService, private message: NzMessageService, private ac: ActivatedRoute,
private translate: TranslateService, private router: Router, private modalService: NzModalService) {
}
ngOnInit() {
this.init();
}
init() {
this.ac.queryParams.subscribe((params) => {
if (params.deviceNo) {
this.deviceNo = params.deviceNo;
this.topicName = params.topicName;
this.getData();
}
});
}
getData() {
this.isLoading = true;
this.api.probes.getAll([{deviceNo: this.deviceNo, topicName: this.topicName}, this.next]);
}
next = (data) => {
if (data && data.constructor === Array) {
this.data = data;
} else if (data && data.code === 1) {
this.message.success(data.message ? data.message : '操作成功');
this.isV = false;
this.getData();
} else if (data && data.code === 0) {
this.message.error(data.message ? data.message : '操作失败');
} else {
this.message.error(data && data.message ? data.message : '获取数据失败');
}
this.isLoading = false;
}
add() {
this.req = {};
this.isUpdate = false;
this.isV = true;
}
update(one) {
this.isUpdate = true;
this.req = {...one};
this.req.oldName = one.name;
this.isV = true;
}
cancel() {
this.isV = false;
}
save() {
this.isLoading = true;
this.req.deviceNo = this.deviceNo;
this.req.topicName = this.topicName;
if (this.isUpdate) {
this.api.probes.updateProbes([this.req, this.next]);
} else {
this.api.probes.addProbes([this.req, this.next]);
}
}
deleteConfirm(one) {
this.modalService.confirm({
nzTitle : '<i> </i>',
nzContent: '<b>' + this.translate.instant('confirmDeleteThisRecord') + '</b>',
nzOnOk : () => this.delete(one)
});
}
delete(one) {
this.isLoading = true;
this.api.probes.delAProbes([{deviceNo: this.deviceNo, name: one.name, topicName: this.topicName}, this.next]);
}
}
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