Commit 8f091c44 authored by yating.lin's avatar yating.lin

风机页面追加刷新

parent 5f8c9752
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.witium.muchang.test" version="2.9.6.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.witium.muchang.test" version="2.9.6.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>牧场云</name>
<description>test</description>
<author email="frank.feng@witium.com" href="http://muchang.witium.com/">Van.chen - frank.feng</author>
......
......@@ -318,7 +318,7 @@ export class EnvAlarmDetailPage implements OnInit {
disposeState: 1,
isReal: real === 1 ? 1 : 0
};
this.loading.presentLoading(Constants.LOADING_SHORT);
this.loading.presentLoading(Constants.LOADING_SHORT, true);
this.api.troubleLog.processingFailure([req, (data) => {
if (data && data.code === 1) {
this.api.presentMsgToast(data.message);
......
......@@ -106,27 +106,27 @@ export class EnvAlarmPage implements OnInit {
return time;
}
displayInterval(interval) {
let displayValue = '';
switch (interval) {
case 12:
displayValue = '近一年';
break;
case 6:
displayValue = '近六个月';
break;
case 3:
displayValue = '近三个月';
break;
case 1:
displayValue = '近一个月';
break;
default:
displayValue = '近一年';
break;
}
document.getElementById(this.curFieldRegion.fieldRegionNo).innerText = displayValue;
}
// displayInterval(interval) {
// let displayValue = '';
// switch (interval) {
// case 12:
// displayValue = '近一年';
// break;
// case 6:
// displayValue = '近六个月';
// break;
// case 3:
// displayValue = '近三个月';
// break;
// case 1:
// displayValue = '近一个月';
// break;
// default:
// displayValue = '近一年';
// break;
// }
// document.getElementById(this.curFieldRegion.fieldRegionNo).innerText = displayValue;
// }
doRefresh(event) {
setTimeout(() => {
......
......@@ -409,7 +409,7 @@ export class EnvCfgPage implements OnInit {
// this.load.toLoad('加载中...', false);
// this.comm.remain = 150;
this.loading.presentLoading(Constants.LOADING_LONG);
this.loading.presentLoading(Constants.LOADING_LONG, true);
this.curCowshed.isWisdomModel = this.curCowshed.isWisdomModelChecked ? 1 : 0;
// 回舍时默认设备都为打开状态
this.curCowshed.back.forEach(one => (one.flag = true));
......
......@@ -10,9 +10,9 @@
</ion-toolbar>
<div class="top">
<span [ngClass]="{'online': item.online, 'offline': !item.online}">{{item.online ? '在线' : '离线'}} </span>
<span *ngIf="item.operationModel === 1 || item.operationModel === 0" class="online">{{item.operationModel ? '远控' :'现控'}} </span>
<span *ngIf="item.operationModel === 4" class="offline">现控 </span>
<span *ngIf="item.operationModel === 1" [ngClass]="{'online': item.isWisdomModel, 'offline': !item.isWisdomModel}" class="online">智控 </span>
<span *ngIf="item.online && item.operationModel === 1 || item.operationModel === 0" class="online">{{item.operationModel ? '远控' :'现控'}} </span>
<span *ngIf="item.online && item.operationModel === 4" class="offline">现控 </span>
<span *ngIf="item.online && item.operationModel === 1" [ngClass]="{'online': item.isWisdomModel, 'offline': !item.isWisdomModel}" class="online">智控 </span>
<span *ngIf="item.ts" class="right font-ts">{{item.ts | date: 'yyyy-MM-dd HH:mm'}}</span>
</div>
<div style="background-color: #F0F0F0;" align="center">
......
......@@ -6,6 +6,7 @@ import {Load} from '../../service/load';
import {Transfer} from '../../service/transfer';
import {Loading} from '../../service/loading';
import {Constants} from '../../service/constants';
import {EventService} from '../../service/event';
@Component({
selector: 'v-env-detail',
......@@ -19,7 +20,8 @@ export class EnvDetailPage implements OnInit {
private ac: ActivatedRoute,
private load: Load,
private tf: Transfer,
public loading: Loading) {
public loading: Loading,
public eventService: EventService) {
this.ac.queryParams.subscribe((data) => {
if (data.no) {
this.fieldRegionNo = data.no;
......@@ -84,8 +86,8 @@ export class EnvDetailPage implements OnInit {
this.comm.isLoading = false;
this.comm.remain = 0;
this.ac.queryParams.subscribe((data) => {
if (data.no) {
this.fieldRegionNo = data.no;
if (data.fieldRegionNo) {
this.fieldRegionNo = data.fieldRegionNo;
this.operationModel = data.operationModel;
this.getData(0);
}
......@@ -216,7 +218,7 @@ export class EnvDetailPage implements OnInit {
opt.ts = new Date().valueOf();
// this.comm.remain = 20;
this.loading.presentLoading(Constants.LOADING_LONG);
this.loading.presentLoading(Constants.LOADING_LONGER, true);
this.api.control.controlCowedSwitch([opt, (data) => {
// if (data && data.code === 1) {
// this.getData(1);
......@@ -226,9 +228,19 @@ export class EnvDetailPage implements OnInit {
// this.api.presentMsgToast(data.message);
// }
this.getData(0);
this.api.presentMsgToast(data.message);
this.comm.remain = 0;
this.loading.closeLoading();
if (data && data.code === 1) {
this.api.presentMsgToast(data.message); // '传输成功, 设备操作中'
this.eventService.event.emit('inOutHouseController');
// setTimeout(() => {
// this.loading.closeLoading();
// this.eventService.event.emit('inOutHouseController');
// }, 65000);
} else {
this.api.presentMsgToast(data.message);
}
}]);
}
}
......
......@@ -6,6 +6,7 @@ import { AlertController } from '@ionic/angular';
import {Constants} from '../../service/constants';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import {Loading} from '../../service/loading';
import {EventService} from '../../service/event';
@Component({
......@@ -24,6 +25,8 @@ export class EnvFanPage implements OnInit {
// 模式状态
controlModel = 0;
// 是否在配置页中勾选风机
enabled = 0;
// 各设备信息
devices = [];
// 一鍵控制按钮
......@@ -44,16 +47,20 @@ export class EnvFanPage implements OnInit {
commTmr: any;
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private alertController: AlertController,
public loading: Loading) {
public loading: Loading, public eventService: EventService) {
this.ac.queryParams.subscribe((data) => {
if (data && data.no !== null) {
this.fieldRegionNo = data.no;
if (data && data.fieldRegionNo !== undefined && data.fieldRegionNo !== null && data.fieldRegionNo !== '') {
this.fieldRegionNo = data.fieldRegionNo;
this.operationModel = data.operationModel;
}
});
}
ionViewWillEnter() {
this.init();
}
ngOnInit() {
// this.ionViewWillEnter();
this.comm.remain = 0;
......@@ -71,10 +78,11 @@ export class EnvFanPage implements OnInit {
}
}, 1000) ;
this.init();
}
ionViewWillEnter() {
this.init();
// 订阅详情页【在离舍】开关
this.eventService.event.on('inOutHouseController', () => {
console.log('inOutHouseController');
this.getData(0);
});
}
ionViewWillLeave() {
......@@ -82,19 +90,25 @@ export class EnvFanPage implements OnInit {
}
init() {
this.ac.queryParams.subscribe((data) => {
if (data && data.no !== null) {
this.fieldRegionNo = data.no;
this.operationModel = data.operationModel;
this.getData(0);
}
if (this.fieldRegionNo !== undefined && this.fieldRegionNo !== null && this.fieldRegionNo !== '') {
this.getData(0);
} else {
this.ac.queryParams.subscribe((data) => {
if (data && data.fieldRegionNo !== undefined && data.fieldRegionNo !== null && data.fieldRegionNo !== '') {
this.fieldRegionNo = data.fieldRegionNo;
this.operationModel = data.operationModel;
this.getData(0);
}
});
});
}
}
getData(time) {
console.log();
if (time) {
this.load.toLoad('加载中...', false);
}
this.loading.presentLoading(Constants.LOADING_SHORTER, false);
this.api.cowshedApp.getFengJiData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.fieldRegionNo) {
this.fieldRegionNo = data.fieldRegionNo;
......@@ -104,9 +118,11 @@ export class EnvFanPage implements OnInit {
this.devices.forEach(device => {
device.op = device.state === 1;
});
this.enabled = data.enabled;
this.initButtons();
this.setConfusionModelControll();
this.resetButtons();
}
this.load.offLoad();
}]);
......@@ -131,6 +147,25 @@ export class EnvFanPage implements OnInit {
});
}
resetButtons() {
console.log('reset buttons');
this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.inHouse) {
const inHouse = data.inHouse.inHouse;
const isInHouse = inHouse === 0; // 离舍-0 在舍-1
// 离舍的场合,配置页被勾选: 所有按钮非活性
if (isInHouse && this.enabled) {
console.log('离舍时,开关非活性');
this.batchSwitch.disabled = isInHouse;
this.devices.forEach((device) => {
device.disabled = isInHouse;
});
}
}
this.loading.closeLoading();
}]);
}
toggle(btn) {
this.opChangeComfirm(btn);
}
......@@ -143,6 +178,7 @@ export class EnvFanPage implements OnInit {
// subHeader: '确定要' + msgOp + ' ' + msgHeader + ' 这个泵吗?',
message: '所有' + msgHeader + '即将' + msgOp + ',要继续吗?',
mode: 'ios',
backdropDismiss: false,
buttons: [
{
text: '取消',
......@@ -173,7 +209,7 @@ export class EnvFanPage implements OnInit {
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
// this.comm.remain = 150;
this.loading.presentLoading(Constants.LOADING_LONG);
this.loading.presentLoading(Constants.LOADING_LONG, true);
// 一键开启设备
this.api.control.controlCowedBatchSwitch([req, (data) => {
// if (data.code === 1) {
......@@ -214,7 +250,7 @@ export class EnvFanPage implements OnInit {
};
// this.comm.remain = 60;
this.loading.presentLoading(Constants.LOADING_SHORT);
this.loading.presentLoading(Constants.LOADING_SHORT, true);
this.api.control.controlCowedSwitch([req, (data) => {
if (data && data.code === 1) {
......
......@@ -71,9 +71,9 @@
<!--<span *ngIf="item.ts" class="right">{{item.ts | date: 'yyyy-MM-dd HH:mm'}}</span>-->
<div [ngClass]="{'online': item.online, 'offline': !item.online}">{{item.online ? '在线' : '离线'}} </div>
<!-- 1:远控 0:现控 4:混乱 -->
<div *ngIf="item.operationModel === 1 || item.operationModel === 0" class="online">{{item.operationModel === 1 ? '远控' :'现控'}} </div>
<div *ngIf="item.operationModel === 4" class="offline">现控 </div>
<div *ngIf="item.operationModel === 1" [ngClass]="{'online': item.isWisdomModel, 'offline': !item.isWisdomModel}" class="online">智控 </div>
<div *ngIf="item.online && (item.operationModel === 1 || item.operationModel === 0)" class="online">{{item.operationModel === 1 ? '远控' :'现控'}} </div>
<div *ngIf="item.online && item.operationModel === 4" class="offline">现控 </div>
<div *ngIf="item.online && item.operationModel === 1" [ngClass]="{'online': item.isWisdomModel, 'offline': !item.isWisdomModel}" class="online">智控 </div>
<div *ngIf="item.ts !== null" class="right font-note">{{item.ts | date: 'yyyy-MM-dd HH:mm'}}</div>
</div>
</div>
......
......@@ -225,7 +225,7 @@ export class EnvHomePage implements OnInit {
}
toControl(one) {
const query = '/env-detail?no=' + one.fieldRegionNo + '&operationModel=' + one.operationModel;
const query = '/env-detail?fieldRegionNo=' + one.fieldRegionNo + '&operationModel=' + one.operationModel;
this.tf.transfer({
url: '/' + one.url,
query: query,
......
......@@ -6,6 +6,7 @@ import {AlertController} from '@ionic/angular';
import {Constants} from '../../service/constants';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import {Loading} from '../../service/loading';
import {EventService} from '../../service/event';
@Component({
selector: 'v-env-light',
......@@ -34,6 +35,8 @@ export class EnvLightPage implements OnInit {
// 当前月份
curDate = 0;
// 是否在配置页中勾选照明
enabled = 0;
// 各设备信息
devices = [];
// 一鍵控制信息
......@@ -54,13 +57,18 @@ export class EnvLightPage implements OnInit {
commTmr: any;
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute,
private alertControlle: AlertController, public loading: Loading) {
private alertControlle: AlertController, public loading: Loading, private eventService: EventService) {
}
ionViewWillLeave() {
clearInterval(this.commTmr);
}
ionViewWillEnter() {
console.log('ionViewWillEnter_light');
this.init();
}
ngOnInit() {
console.log('env-light: ngOnInit');
this.comm.remain = 0;
......@@ -78,11 +86,12 @@ export class EnvLightPage implements OnInit {
}
}, 1000);
this.init();
}
ionViewWillEnter() {
console.log('ionViewWillEnter_light');
this.init();
// 订阅详情页【在离舍】开关
this.eventService.event.on('inOutHouseController', () => {
console.log('inOutHouseController');
this.getData(0);
});
}
init() {
......@@ -99,6 +108,7 @@ export class EnvLightPage implements OnInit {
if (time) {
this.load.toLoad('加载中...', false);
}
this.loading.presentLoading(Constants.LOADING_SHORTER, false);
this.api.cowshedApp.getZhaoMingData([{'fieldRegionNo': this.fieldRegionNo}, (data) => {
if (data) {
this.fieldRegionNo = data.fieldRegionNo;
......@@ -113,9 +123,11 @@ export class EnvLightPage implements OnInit {
this.devices.forEach(device => {
device.op = device.state === 1 ? true : false;
});
this.enabled = data.enabled;
this.initButtons();
this.setConfusionModelControll();
this.resetButtons();
}
this.load.offLoad();
}]);
......@@ -160,6 +172,24 @@ export class EnvLightPage implements OnInit {
});
}
resetButtons() {
this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.inHouse) {
const inHouse = data.inHouse.inHouse;
const isInHouse = inHouse === 0; // 离舍-0 在舍-1
// 离舍的场合,配置页被勾选: 所有按钮非活性
if (isInHouse && this.enabled) {
console.log('离舍时,开关非活性');
this.batchSwitch.disabled = isInHouse;
this.devices.forEach((device) => {
device.disabled = isInHouse;
});
}
}
this.loading.closeLoading();
}]);
}
toggle(btn) {
this.opChangeComfirm(btn);
}
......@@ -178,6 +208,7 @@ export class EnvLightPage implements OnInit {
header: '请注意',
message: msgContent,
mode: 'ios',
backdropDismiss: false,
buttons: [
{
text: '取消',
......@@ -208,7 +239,7 @@ export class EnvLightPage implements OnInit {
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
// this.comm.remain = 150;
this.loading.presentLoading(Constants.LOADING_LONG);
this.loading.presentLoading(Constants.LOADING_LONG, true);
// 一键开启设备
this.api.control.controlCowedBatchSwitch([req, (data) => {
......@@ -246,7 +277,7 @@ export class EnvLightPage implements OnInit {
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
// this.comm.remain = 60;
this.loading.presentLoading(Constants.LOADING_SHORT);
this.loading.presentLoading(Constants.LOADING_SHORT, true);
this.api.control.controlCowedSwitch([req, (data) => {
if (data && data.code === 1) {
this.comm.remain = 0;
......
......@@ -4,6 +4,7 @@ import {ActivatedRoute} from '@angular/router';
import {Load} from '../../service/load';
import {Constants} from '../../service/constants';
import {Loading} from '../../service/loading';
import {EventService} from '../../service/event';
@Component({
selector: 'v-env-shower',
......@@ -42,6 +43,9 @@ export class EnvShowerPage implements OnInit {
b: 0, // A区喷淋时间
offset: 0
};
// 是否在配置页中勾选喷淋
enabled = 0;
// 各设备信息
param: any = [{
fieldDeviceNo: '',
......@@ -71,7 +75,7 @@ export class EnvShowerPage implements OnInit {
{modelId: 3, modelValue: '智控模式'}];
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute,
public loading: Loading) {
public loading: Loading, public eventService: EventService) {
this.param[0].fieldDeviceName = 'A区';
this.param[1].fieldDeviceName = 'B区';
// this.route.paramMap.subscribe(params => {
......@@ -80,6 +84,15 @@ export class EnvShowerPage implements OnInit {
// });
}
ionViewWillEnter() {
console.log('ionViewWillEnter_shower');
this.init();
}
ionViewWillLeave() {
clearInterval(this.commTmr);
}
ngOnInit() {
this.comm.remain = 0;
this.comm.isLoading = false;
......@@ -96,15 +109,11 @@ export class EnvShowerPage implements OnInit {
}
}, 1000) ;
this.init();
}
ionViewWillEnter() {
console.log('ionViewWillEnter_shower');
this.init();
}
ionViewWillLeave() {
clearInterval(this.commTmr);
// 订阅详情页【在离舍】开关
this.eventService.event.on('inOutHouseController', () => {
console.log('inOutHouseController');
this.getData(0);
});
}
init() {
......@@ -119,6 +128,7 @@ export class EnvShowerPage implements OnInit {
if (time) {
this.load.toLoad('加载中...', false);
}
this.loading.presentLoading(Constants.LOADING_SHORTER, false);
this.api.cowshedApp.getPenLinData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data) {
this.fieldRegionNo = data.fieldRegionNo;
......@@ -139,8 +149,12 @@ export class EnvShowerPage implements OnInit {
if (this.param[1]) {
this.fieldDeviceNameB = this.param[1].fieldDeviceName;
}
this.enabled = data.enabled;
this.initButtons();
this.setConfusionModelControll();
this.resetButtons();
}
this.load.offLoad();
}]);
......@@ -168,6 +182,23 @@ export class EnvShowerPage implements OnInit {
});
}
resetButtons() {
this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.inHouse) {
const inHouse = data.inHouse.inHouse;
const isInHouse = inHouse === 0; // 离舍-0 在舍-1
// 离舍的场合,配置页被勾选: 所有按钮非活性
if (isInHouse && this.enabled) {
console.log('离舍时,开关非活性');
this.param.forEach((device) => {
device.disabled = isInHouse;
});
}
}
this.loading.closeLoading();
}]);
}
// 单个设备控制
deviceCheck(btn) {
const req = {
......@@ -177,7 +208,7 @@ export class EnvShowerPage implements OnInit {
ts: parseInt((new Date().getTime() / 1000).toString(), 10)
};
// this.comm.remain = 60;
this.loading.presentLoading(Constants.LOADING_SHORT);
this.loading.presentLoading(Constants.LOADING_SHORT, true);
this.api.control.controlCowedSwitch([req, (data) => {
if (data && data.code === 1) {
this.comm.remain = 0;
......
......@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
import {Api} from '../../service/api';
import {ActivatedRoute} from '@angular/router';
import {Load} from '../../service/load';
import {Constants} from '../../service/constants';
import {Loading} from '../../service/loading';
@Component({
selector: 'v-env-waterchannel',
......@@ -20,7 +22,7 @@ export class EnvWaterchannelPage implements OnInit {
isLoading : true
};
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute) { }
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute, public loading: Loading) { }
ngOnInit() {
// this.ac.queryParams.subscribe((data) => {
......@@ -47,11 +49,13 @@ export class EnvWaterchannelPage implements OnInit {
if (time) {
this.load.toLoad('加载中...', false);
}
this.loading.presentLoading(Constants.LOADING_SHORTER, false);
this.api.cowshedApp.getShuiCaoData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data) {
this.devices = data.param;
}
this.load.offLoad();
this.loading.closeLoading();
}]);
}
}
......@@ -16,8 +16,11 @@ export class Constants {
public static CONTROLL_WISDOM = 3; // 智慧控制
public static CONTROLL_CONFUSION = 4; // 混乱
// 刷新时间(秒)
public static LOADING_SHORTER = 0.3; // 单个开关
public static LOADING_SHORT = 10; // 单个开关
public static LOADING_LONG = 40; // 一键控制等
public static LOADING_LONGER = 60; // 一键控制等
}
......@@ -7,37 +7,45 @@ export class Loading {
}
loading: any;
loadingIsOpen: any;
countdown = 0;
interval: any;
async presentLoading(time) {
clearInterval(this.interval);
this.countdown = time;
this.loading = await this.loadingController.create({
mode: 'ios',
spinner: 'circles',
message: '通信中,还剩 ' + time + ' 秒',
cssClass: 'main-color',
duration: time * 1000
});
this.loading.present();
this.interval = window.setInterval(() => {
if (this.countdown > 0) {
this.countdown--;
this.loading.message = '通信中,还剩 ' + this.countdown + ' 秒';
} else {
this.loading.message = '';
}
}, 1000)
async presentLoading(time, showMessage) {
if (this.loadingIsOpen) {
clearInterval(this.interval);
} else {
console.log('loading is open');
this.loadingIsOpen = true;
this.countdown = time;
this.loading = await this.loadingController.create({
mode: 'ios',
spinner: 'circles',
message: showMessage ? '通信中,还剩 ' + time + ' 秒' : '',
cssClass: 'main-color',
duration: time * 1000
});
this.loading.present();
this.interval = window.setInterval(() => {
if (this.countdown > 0) {
this.countdown--;
this.loading.message = showMessage ? '通信中,还剩 ' + this.countdown + ' 秒' : '';
} else {
this.loading.message = '';
}
}, 1000)
const { role, data } = await this.loading.onDidDismiss();
const { role, data } = await this.loading.onDidDismiss();
console.log('Loading dismissed!');
console.log('Loading dismissed!');
}
}
async closeLoading() {
if (this.loading !== undefined || this.loading !== null) {
console.log('loading is close');
this.loading.dismiss();
this.loading.onDidDismiss();
this.loadingIsOpen = false;
clearInterval(this.interval);
}
}
......
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