Commit dc93586a authored by aymen.du's avatar aymen.du

开始制作环控

parent 997e3bd3
......@@ -32,6 +32,7 @@
],
"styles": [
"node_modules/ng-zorro-antd-mobile/src/ng-zorro-antd-mobile.min.css",
"node_modules/loaders.css/loaders.css",
"src/assets/icon/iconfont.css",
{
"input": "src/theme/variables.scss"
......
......@@ -6922,6 +6922,11 @@
"json5": "^1.0.1"
}
},
"loaders.css": {
"version": "0.1.2",
"resolved": "https://registry.npm.taobao.org/loaders.css/download/loaders.css-0.1.2.tgz",
"integrity": "sha1-Op+0NybHMzSjgUKvnQYpAZtlh0M="
},
"locate-path": {
"version": "2.0.0",
"resolved": "http://registry.npm.taobao.org/locate-path/download/locate-path-2.0.0.tgz",
......
......@@ -42,6 +42,7 @@
"cordova-plugin-whitelist": "^1.3.3",
"core-js": "^2.5.4",
"es6-promise-plugin": "^4.2.2",
"loaders.css": "^0.1.2",
"mqtt": "^2.18.8",
"ng-zorro-antd-mobile": "^0.11.9",
"rxjs": "~6.3.3",
......
......@@ -2,12 +2,12 @@
import {trigger, style, state, transition, animate} from '@angular/animations';
export const flyIn = trigger('EnterLeave', [
state('flyIn', style({transform: 'translateX(0)'})),
// state('flyIn', style({transform: 'translateX(0)'})),
transition(':enter', [
style({transform: 'translateX(100%)'}), animate('300ms ease-in')
]),
// transition(':leave', [
// animate('0.3s ease-out', style({transform: 'translateX(-100%)'}))
// ])
transition(':leave', [
animate('1300ms ease-out', style({transform: 'translateX(-100%)'}))
])
]
);
......@@ -25,7 +25,16 @@ const routes: Routes = [
{path: 'mine', component: MinePage}
]
},
{path: 'login', component: LoginPage}
{path: 'login', component: LoginPage},
{path: 'tabs', loadChildren: './envCtrl/tabs/tabs.module#TabsPageModule'},
// { path: 'env-detail', loadChildren: './envCtrl/env-detail/env-detail.module#EnvDetailPageModule' },
// { path: 'env-cfg', loadChildren: './envCtrl/env-cfg/env-cfg.module#EnvCfgPageModule' },
// { path: 'env-alarm', loadChildren: './envCtrl/env-alarm/env-alarm.module#EnvAlarmPageModule' },
// { path: 'env-home', loadChildren: './envCtrl/env-home/env-home.module#EnvHomePageModule' },
// { path: 'env-detail', loadChildren: './envCtrl/env-detail/env-detail.module#EnvDetailPageModule' },
// { path: 'env-cfg', loadChildren: './envCtrl/env-cfg/env-cfg.module#EnvCfgPageModule' },
// { path: 'env-alarm', loadChildren: './envCtrl/env-alarm/env-alarm.module#EnvAlarmPageModule' },
{ path: 'env-home', loadChildren: './envCtrl/env-home/env-home.module#EnvHomePageModule' },
];
@NgModule({
......
......@@ -10,7 +10,7 @@ import {StatusBar} from '@ionic-native/status-bar/ngx';
import {LocalNotifications} from '@ionic-native/local-notifications/ngx';
import {FormsModule} from '@angular/forms';
import {HTTP_INTERCEPTORS} from '@angular/common/http';
import {NgZorroAntdMobileModule} from 'ng-zorro-antd-mobile';
import {NgZorroAntdMobileModule, TabsModule} from 'ng-zorro-antd-mobile';
import {AppComponent} from './app.component';
import {AppRoutingModule} from './app-routing.module';
......@@ -39,6 +39,9 @@ import {Transfer} from './service/transfer';
import {AuthInterceptor} from './service/token';
import {Mqtt} from './service/mqtt';
import {Load} from './service/load';
import {LoadingBumpComponent} from './components/loading-bump/loading-bump.component';
import {KanbanComponent} from './components/kanban/kanban.component';
import {WtModule} from './components/wt/wt.module';
@NgModule({
declarations: [
......@@ -48,6 +51,7 @@ import {Load} from './service/load';
AlarmBarComponent,
SearchHistoryComponent,
RefreshComponent,
LoadingBumpComponent,
HomePage,
EastPage,
LoginPage,
......@@ -66,7 +70,9 @@ import {Load} from './service/load';
FormsModule,
HttpClientModule,
BrowserAnimationsModule,
NgZorroAntdMobileModule
NgZorroAntdMobileModule,
TabsModule,
WtModule,
],
providers: [
StatusBar,
......
<div class="mainCon" style="padding-top: 45px;" @EnterLeave>
<div class="mainCon" style="padding-top: 45px;" [@EnterLeave]>
<Navbar [leftContent]="icon"
(onLeftClick)="onLeftClick()"
[rightContent]="r"
......@@ -44,21 +44,31 @@
</div>
</div>
<div class="middlePart">
<ion-item>
<ion-item lines="full">
<ion-label>运行模式</ion-label>
<ion-select multiple="false" cancelText="取消" okText="确认" [value]="workModeSetting.workMode" (ionChange)="workModeEvent()">
<ion-select-option value="0">手动模式</ion-select-option>
<ion-select-option value="1">半自动</ion-select-option>
<ion-select multiple="false" cancelText="取消" okText="确认" [(ngModel)]="workModeSetting.workMode" [(value)]="workModeSetting.workMode" (ionChange)="workModeEvent()">
<ion-select-option value="0">现场控制</ion-select-option>
<ion-select-option value="1">远程手控</ion-select-option>
<ion-select-option value="2">全自动</ion-select-option>
</ion-select>
</ion-item>
<!--<ion-label>发现设备运行时间过长</ion-label>-->
</div>
<div class="bottomPart">
<ListItem multipleLine *ngFor="let a of devices;let i = index">
{{a.fieldDeviceName}}
<v-switch [value]="a.value" [disabled]="true" [loading]="a.loading"></v-switch>
</ListItem>
<ion-list>
<ion-item *ngFor="let a of devices;let i = index" lines = "full">
<ion-label>{{a.fieldDeviceName}}</ion-label>
<v-switch (click)="toggle(a)" [value]="a.value" [disabled]="opDisable" [loading]="a.loading" ></v-switch>
</ion-item>
</ion-list>
<!--<ListItem multipleLine *ngFor="let a of devices;let i = index">-->
<!---->
<!---->
<!--</ListItem>-->
</div>
<ion-button color="danger" expand="full" (click)="unlock()" *ngIf="alarmMsg.locked">现设备运行时间过长点击解锁</ion-button>
</div>
<ng-template #icon>
<span class="vo v-back"></span>
......@@ -71,3 +81,5 @@
<v-switch [value]="value[1]" [disabled]="nanLoading || value[0]" (click)="toggleNb(1)"
[loading]="beiLoading"></v-switch>
</ng-template>
<v-loading-bump style="z-index: 9999; color: red" [remain]="comm.remain" *ngIf="comm.isLoading"></v-loading-bump>
import {Component, OnInit} from '@angular/core';
import {Component, OnInit, HostBinding} from '@angular/core';
import {Transfer} from '../service/transfer';
import {Api} from '../service/api';
import {Load} from '../service/load';
......@@ -7,7 +7,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations';
import {fadeIn} from '../animations/fade-in';
import {toLeft} from '../animations/toLeftAndBack';
import {flyIn} from '../animations/flyIn';
import {NavController} from '@ionic/angular';
import {AlertController, NavController} from '@ionic/angular';
@Component({
selector: 'v-east',
......@@ -43,22 +43,90 @@ export class EastPage implements OnInit {
devices = [];
fieldRegionNo = '';
fieldRegionName = '';
opDisable = true;
// 发送指令延时判断
comm = {
remain : 20,
isLoading : true
};
// 工作模式
workModeSetting = { 'workMode' : '1',
'DeviceNo' : '',
'workModeOld' : '1'};
// 运行时间过长,解除报警用
alarmMsg = { locked : false,
DeviceNo : ''};
// workModeSetting = { 'workMode' : '1',
// 'DeviceNo':'' };
workMode = '1';
workModeSetting = {'workMode' : '1',
'DeviceNo' : '' };
EnterLeave = 'flyIn';
commTmr: any;
@HostBinding('style.display') display = 'block';
// @HostBinding('style.position') position = 'absolute';
constructor(private tf: Transfer, private api: Api, private load: Load, private ac: ActivatedRoute, private nav: NavController) {
constructor(private tf: Transfer, private api: Api, private load: Load, private ac: ActivatedRoute, private nav: NavController,
private alterContoller: AlertController) {
}
ngOnInit() {
this.comm.isLoading = false;
this.comm.remain = 0;
this.ac.queryParams.subscribe((data) => {
this.fieldRegionNo = data.no;
this.fieldRegionName = data.name;
});
this.commTmr = window.setInterval(() => {
console.log(this.comm.remain);
if (this.comm.remain > 0) {
this.comm.remain = this.comm.remain - 1;
}
if ( this.comm.remain < 1 ) {
this.comm.isLoading = false;
} else {
this.comm.isLoading = true;
}
}, 1000) ;
}
unlock() {
const opt = {fieldDeviceNo : this.alarmMsg.DeviceNo ,
op : 1 ,
startTime: parseInt((new Date().getTime() / 1000).toString(), 10),
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
opt.startTime = opt.ts;
this.comm.remain = 20;
this.api.control.controlSwitch([opt, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
this.alarmMsg.locked = false;
} else {
this.api.presentMsgToast(data.message);
}
this.comm.remain = 0;
}]);
}
workModeEvent() {
let opt = {fieldDeviceNo : this.workModeSetting.DeviceNo ,
console.log(this.workMode);
if ( this.workModeSetting.workModeOld === this.workModeSetting.workMode ) {
return;
}
const opt = {fieldDeviceNo : this.workModeSetting.DeviceNo ,
op : this.workModeSetting.workMode ,
startTime: parseInt((new Date().getTime() / 1000).toString(), 10),
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
......@@ -66,8 +134,20 @@ export class EastPage implements OnInit {
opt.startTime = opt.ts;
this.comm.remain = 20;
this.api.control.controlSwitch([opt, (data) => {
;
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
if ( this.workModeSetting.workMode !== '2' ) {
this.opDisable = false;
}
this.comm.remain = 0;
}]);
}
......@@ -82,6 +162,7 @@ export class EastPage implements OnInit {
ionViewWillLeave() {
clearTimeout(this._inv);
clearInterval(this.commTmr);
}
toggleNb(index) {
......@@ -98,22 +179,73 @@ export class EastPage implements OnInit {
}
}
// toggle(a) {
// a.loading = true;
// const req = {
// fieldDeviceNo: a.fieldDeviceNo,
// op: a.value ? 0 : 1,
// ts: parseInt((new Date().getTime() / 1000).toString(), 10)
// };
// this.comm.remain = 20;
// this.api.control.controlSwitch([req, (data) => {
// if (data && data.code === 1) {
// this.getData(1);
// this.api.presentMsgToast(data.message);
// } else {
// this.api.presentMsgToast(data.message);
// }
// this.comm.remain = 0;
// a.loading = false;
// }]);
// }
async opChangeComfirm(a) {
const msgHeader = a.fieldDeviceName;
const msgOp = a.value ? '关闭' : '打开';
const alert = await this.alterContoller.create({
header: '请注意',
// subHeader: '确定要' + msgOp + ' ' + msgHeader + ' 这个泵吗?',
message: '确定要' + msgOp + ' ' + msgHeader + ' 吗?',
mode: 'ios',
buttons: [
{
text: '取消',
cssClass: 'width: 40%',
}, {
text: '确定',
cssClass: 'width: 40%',
handler: () => {
const req = {
fieldDeviceNo: a.fieldDeviceNo,
op: a.value ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 20;
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
} else {
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
}
a.loading = false;
}]);
}
}
]
});
await alert.present();
}
toggle(a) {
a.loading = true;
const req = {
fieldDeviceNo: a.fieldDeviceNo,
op: a.value ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
a.loading = false;
}]);
// a.loading = true;
if ( this.opDisable === false) {
this.opChangeComfirm(a);
}
}
cancel() {
......@@ -136,6 +268,7 @@ export class EastPage implements OnInit {
startTime: parseInt((new Date().getTime() / 1000).toString(), 10),
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 20;
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
......@@ -144,6 +277,7 @@ export class EastPage implements OnInit {
this.api.presentMsgToast(data.message);
}
this.cancel();
this.comm.remain = 0;
}]);
}
......@@ -156,23 +290,7 @@ export class EastPage implements OnInit {
if (time) {
this.load.toLoad('加载中...', false);
}
this.api.app.getDeviceData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data.constructor === Array) {
this.devices = data;
debugger
this.devices.forEach((value, i) => {
if ( value.fieldDeviceType === '配置' ) {
this.workModeSetting.workMode = value.value;
this.workModeSetting.DeviceNo = value.fieldDeviceNo;
}
}
)
} else {
this.api.presentMsgToast(data.message || '获取数据失败');
}
this.load.offLoad();
}]);
this.api.app.getLiquidLevelData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (typeof (data.liquidLevel) === 'number') {
......@@ -195,6 +313,49 @@ export class EastPage implements OnInit {
this.api.presentMsgToast(data.message || '获取数据失败');
}
}]);
this.api.app.getDeviceData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data.constructor === Array) {
this.devices = [];
this.alarmMsg.locked = false;
data.forEach((value, i) => {
if ( value.fieldDeviceType === '配置' && value.fieldDeviceName === '运行模式') {
this.workModeSetting.workMode = value.value === null ? '1' : value.value.toString();
this.workModeSetting.DeviceNo = value.fieldDeviceNo;
this.workModeSetting.workModeOld = value.value === null ? '1' : value.value.toString();
if ( this.workModeSetting.workMode !== '2' ) {
this.opDisable = false;
}
} else if ( value.fieldDeviceType === '配置' && value.fieldDeviceName === '解除报警') {
this.alarmMsg.DeviceNo = value.fieldDeviceNo;
// this.alarmMsg.locked = value.value === 1 ? true : false;
} else {
if ( value.fieldDeviceType === '泵' || value.fieldDeviceType === '搅拌器' ) {
if ( this.checkBit(value.value, 6) === true ) {
this.alarmMsg.locked = true;
}
}
value.value = value.value & 0x1;
this.devices.push(value);
}
}
);
} else {
this.api.presentMsgToast(data.message || '获取数据失败');
}
this.load.offLoad();
}]);
}
checkBit( a, bit ) {
a = a & 0x40;
if ( a ) {
return true;
} else {
return false;
}
}
pullToRefresh() {
......
......@@ -10,7 +10,7 @@
[setFocus]="false" (onFocus)="toggleFocus(true)" (onBlur)="toggleFocus(false)"
(onClear)="searchText ='';toggleFocus(false);"></SearchBar>
</div>
<!--<v-search *ngIf="ifFocus" [(value)]="searchText"></v-search>-->
<v-search *ngIf="ifFocus" [(value)]="searchText"></v-search>
<ion-slides style="width: 100%;height: 125px;" mode="ios"
[options]="lunbo" #slide (ionSlideTouchEnd)="slideDidChange()">
<ion-slide class="slideCon" *ngFor="let one of imgs">
......@@ -30,8 +30,8 @@
</ion-header>
<!--<div class="seePart">-->
<ion-content fullscreen="true" style="--padding-start:0px;--padding-end:0px;height: 5000px; overflow-y: auto;overflow-x: hidden;-webkit-overflow-scrolling: touch;" scroll="true" >
<!--<ion-content fullscreen="true" style="&#45;&#45;padding-start:0px;&#45;&#45;padding-end:0px;height: 5000px; overflow-y: auto;overflow-x: hidden;-webkit-overflow-scrolling: touch;" scroll="true" >-->
<ion-content>
<div style="background-color: #efeff4; width: 100%;" class="bigbk">
<div class="out" *ngIf="items.length === 0 && !isError">
<i class="vo v-none"></i>
......
.mainCon{
//overflow-y: auto;overflow-x: hidden;-webkit-overflow-scrolling: touch;
overflow-y: auto;overflow-x: hidden;-webkit-overflow-scrolling: touch;
}
.inBox {
......@@ -45,7 +45,7 @@
}
.right {
//float: right;
float: right;
color: #aaa;
}
......@@ -109,6 +109,8 @@
display: inline-block;
width: calc(100% - 30px);
vertical-align: top;
background-color: #28c9bd
}
.listview{
......
......@@ -12,7 +12,8 @@
<div class="mainContent">
<div class="contentPart">
<div class="leftOnPart" (click)="goTo('home')"></div>
<div class="rightOnPart " (click)="goTo('row')"></div>
<!--<div class="rightOnPart " (click)="goTo('row')"></div>-->
<div class="rightOnPart " (click)="goTo('tabs/tab-home')"></div>
<div class="leftUnderPart" (click)="goTo('alarm')"></div>
<div class="rightUnderPart" (click)="goTo('mine')"></div>
</div>
......
......@@ -34,7 +34,7 @@
<div Button class="button" (click)="loginOut()" [type]="'primary'" style="letter-spacing: 2px">退出登录</div>
</div>
<div style="position: fixed;bottom: 20px;display: inline-block;width: 100%;text-align: center;color: #666666;font-size: 14px;">
版本信息: v2.3.1
版本信息: v2.6.1
</div>
</div>
......
<div class="mainCon" style="padding-top: 45px;">
<div class="mainCon" style="padding-top: 45px;" [@EnterLeave]>
<Navbar [leftContent]="icon"
(onLeftClick)="onLeftClick()"
[rightContent]="r"
......@@ -25,19 +25,48 @@
</div>
</ListItem>
</div>
<div class="bottomPart">
<ListItem multipleLine *ngFor="let a of allBtns">
一键控制{{a.l}}
<v-switch [value]="a.v" (click)="allCheck(a)" [loading]="a.d"></v-switch>
</ListItem>
<div class="middlePart">
<ion-list>
<ion-item lines = "full" >
<ion-label>运行模式</ion-label>
<ion-select multiple="false" cancelText="取消" okText="确认" [(ngModel)]="workModeSetting.workMode" [(value)]="workModeSetting.workMode" (ionChange)="workModeEvent()">
<ion-select-option value="0">现场控制</ion-select-option>
<ion-select-option value="1">远程手控</ion-select-option>
<ion-select-option value="2">全自动</ion-select-option>
</ion-select>
</ion-item>
<!--一键控制{{a.l}}-->
<!--<v-switch [value]="a.v" (click)="allCheck(a)" [loading]="a.d"></v-switch>-->
<ion-item *ngFor="let a of allBtns" lines="full" insert="false" >
<!--<v-switch [value]="a.value" (click)="toggle(a)" [loading]="a.loading"></v-switch>-->
<ion-label>一键控制{{a.l}}</ion-label>
<v-switch [value]="a.v" (click)="allCheck(a)" [loading]="a.d"></v-switch>
</ion-item>
</ion-list>
</div>
<div class="bottomPart">
<ListItem multipleLine *ngFor="let a of devices;let i = index">
{{a.fieldDeviceName}}
<v-switch [value]="a.value" (click)="toggle(a)" [loading]="a.loading"></v-switch>
</ListItem>
<ion-list>
<!--{{a.fieldDeviceName}}-->
<ion-item *ngFor="let a of devices;let i = index" lines="full">
<!--<v-switch [value]="a.value" (click)="toggle(a)" [loading]="a.loading"></v-switch>-->
<ion-label>{{a.fieldDeviceName}}</ion-label>
<v-switch [value]="a.value" (click)="toggle(a)" [loading]="a.loading"></v-switch>
</ion-item>
</ion-list>
</div>
</div>
<ng-template #icon>
<span class="vo v-back"></span>
</ng-template>
<!--<div class="popBox123" style="z-index: 9999;-->
<!--position: absolute;-->
<!--top: 40%;-->
<!--width: 500px;-->
<!--background-color: #ffffff;">-->
<!--<div class="content-frank">正在向设备发起指令,预计还有 15 秒</div>-->
<!--</div>-->
<v-loading-bump style="z-index: 9999; color: red" [remain]="comm.remain" *ngIf="comm.isLoading"></v-loading-bump>
......@@ -32,3 +32,8 @@
height: 32px;
font-size: 16px;
}
.mainCon{
height: 100%;
background-color: white;
}
......@@ -3,11 +3,17 @@ import {Transfer} from '../service/transfer';
import {Api} from '../service/api';
import {Load} from '../service/load';
import {ActivatedRoute} from '@angular/router';
import {flyIn} from '../animations/flyIn';
import {AlertController} from '@ionic/angular';
import {debug} from 'util';
@Component({
selector: 'v-other',
templateUrl: './other.page.html',
styleUrls: ['./other.page.scss'],
animations: [
flyIn
]
})
export class OtherPage implements OnInit {
value = [false, false, false, false, false, false, false];
......@@ -24,6 +30,12 @@ export class OtherPage implements OnInit {
allBtns = [];
fieldRegionGroup = '';
// 发送指令延时判断
comm = {
remain : 20,
isLoading : true
};
state = {
refreshState: {
currentState: 'deactivate',
......@@ -35,44 +47,144 @@ export class OtherPage implements OnInit {
directionName: 'up'
};
constructor(private tf: Transfer, private api: Api, private load: Load, private ac: ActivatedRoute) {
// 工作模式
workModeSetting = { 'workMode' : '1',
'DeviceNo' : '',
'workModeOld' : '1'};
// 运行时间过长,解除报警用
alarmMsg = { locked : false,
DeviceNo : ''};
commTmr: any;
constructor(private tf: Transfer, private api: Api, private load: Load, private ac: ActivatedRoute,
private alterContoller: AlertController) {
}
ngOnInit() {
this.comm.isLoading = false;
this.comm.remain = 0;
this.ac.queryParams.subscribe((data) => {
this.fieldRegionNo = data.no;
this.fieldRegionName = data.name;
this.fieldRegionGroup = data.group;
});
this.commTmr = window.setInterval(() => {
console.log(this.comm.remain);
if (this.comm.remain > 0) {
this.comm.remain = this.comm.remain - 1;
}
if ( this.comm.remain === 0 ) {
this.comm.isLoading = false;
} else {
this.comm.isLoading = true;
}
}, 1000) ;
}
// ionic的生命周期函数
ionViewWillEnter() {
this.getData(1);
this.getData(0);
}
ionViewWillLeave() {
clearTimeout(this._inv);
clearInterval(this.commTmr);
}
toggle(a) {
a.loading = true;
const req = {
fieldDeviceNo: a.fieldDeviceNo,
op: a.value ? 0 : 1,
unlock() {
const opt = {fieldDeviceNo : this.alarmMsg.DeviceNo ,
op : 0 ,
startTime: parseInt((new Date().getTime() / 1000).toString(), 10),
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.api.control.controlSwitch([req, (data) => {
opt.startTime = opt.ts;
this.api.control.controlSwitch([opt, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
a.loading = false;
}]);
}
workModeEvent() {
if ( this.workModeSetting.workModeOld === this.workModeSetting.workMode ) {
return;
}
const opt = {fieldDeviceNo : this.workModeSetting.DeviceNo ,
op : this.workModeSetting.workMode ,
startTime: parseInt((new Date().getTime() / 1000).toString(), 10),
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
opt.startTime = opt.ts;
this.api.control.controlSwitch([opt, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
}]);
}
async opChangeComfirm(a) {
const msgHeader = a.fieldDeviceName;
const msgOp = a.value ? '关闭' : '打开';
const alert = await this.alterContoller.create({
header: '请注意',
// subHeader: '确定要' + msgOp + ' ' + msgHeader + ' 这个泵吗?',
message: '确定要' + msgOp + ' ' + msgHeader + ' 吗?',
mode: 'ios',
buttons: [
{
text: '取消',
cssClass: 'width: 40%',
}, {
text: '确定',
cssClass: 'width: 40%',
handler: () => {
const req = {
fieldDeviceNo: a.fieldDeviceNo,
op: a.value ? 0 : 1,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 20;
this.api.control.controlSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
} else {
this.comm.remain = 0;
this.api.presentMsgToast(data.message);
}
a.loading = false;
}]);
}
}
]
});
await alert.present();
}
toggle(a) {
// a.loading = true;
this.opChangeComfirm(a);
}
onLeftClick() {
this.tf.transfer({url: '/home'});
}
......@@ -94,7 +206,10 @@ export class OtherPage implements OnInit {
this.devices.filter(b => b.fieldDeviceType === a).length) {
c.v = 1;
}
obj.push(c);
if (a !== '配置') {
obj.push(c);
}
});
this.allBtns = obj;
}
......@@ -108,6 +223,7 @@ export class OtherPage implements OnInit {
type: a.t,
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
this.comm.remain = 120;
this.api.control.controlBatchSwitch([req, (data) => {
if (data.code === 1) {
this.getData(1);
......@@ -115,6 +231,7 @@ export class OtherPage implements OnInit {
} else {
this.api.presentMsgToast(data.message);
}
this.comm.remain = 0;
a.d = false;
}]);
}
......@@ -125,11 +242,23 @@ export class OtherPage implements OnInit {
}
this.api.app.getDeviceData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data.constructor === Array) {
this.devices = data;
this.devices = [];
this.types = Array.from(new Set(data.map(a => a.fieldDeviceType)));
if (time) {
this.initAllBtn();
}
// if (time) {
data.forEach((value, i) => {
if ( value.fieldDeviceType === '配置' && value.fieldDeviceName === '运行模式') {
this.workModeSetting.workMode = value.value === null ? '1' : value.value.toString();
this.workModeSetting.DeviceNo = value.fieldDeviceNo;
this.workModeSetting.workModeOld = value.value === null ? '1' : value.value.toString();
} else if ( value.fieldDeviceType === '配置' && value.fieldDeviceName === '解除报警') {
this.alarmMsg.DeviceNo = value.fieldDeviceNo;
this.alarmMsg.locked = value.value === 1 ? true : false;
} else {
this.devices.push(value);
}
});
this.initAllBtn();
// }
} else {
this.api.presentMsgToast(data.message || '获取数据失败');
}
......
......@@ -44,7 +44,7 @@
}
],
"no-arg": true,
"no-bitwise": true,
"no-bitwise": false,
"no-console": [
true,
"debug",
......
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