Commit aed2f0f4 authored by yating.lin's avatar yating.lin

调整layout 对应BUG等

parent 3f220d94
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<widget id="com.witium.muchang.test" version="2.9.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.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>牧场云</name> <name>牧场云</name>
<description>test</description> <description>test</description>
<author email="frank.feng@witium.com" href="http://muchang.witium.com/">Van.chen - frank.feng</author> <author email="frank.feng@witium.com" href="http://muchang.witium.com/">Van.chen - frank.feng</author>
......
...@@ -4203,10 +4203,9 @@ ...@@ -4203,10 +4203,9 @@
} }
}, },
"eventemitter3": { "eventemitter3": {
"version": "3.1.0", "version": "4.0.0",
"resolved": "http://registry.npm.taobao.org/eventemitter3/download/eventemitter3-3.1.0.tgz", "resolved": "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-4.0.0.tgz",
"integrity": "sha1-CQtNbNvWRe0Qv3UNS1QHlC17oWM=", "integrity": "sha1-1lF2FjiH7lnzhtZMgmELaWpKdOs="
"dev": true
}, },
"events": { "events": {
"version": "3.0.0", "version": "3.0.0",
...@@ -5685,6 +5684,14 @@ ...@@ -5685,6 +5684,14 @@
"eventemitter3": "^3.0.0", "eventemitter3": "^3.0.0",
"follow-redirects": "^1.0.0", "follow-redirects": "^1.0.0",
"requires-port": "^1.0.0" "requires-port": "^1.0.0"
},
"dependencies": {
"eventemitter3": {
"version": "3.1.2",
"resolved": "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-3.1.2.tgz",
"integrity": "sha1-LT1I+cNGaY/Og6hdfWZOmFNd9uc=",
"dev": true
}
} }
}, },
"http-proxy-agent": { "http-proxy-agent": {
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
"core-js": "^2.5.4", "core-js": "^2.5.4",
"echarts": "^4.2.1", "echarts": "^4.2.1",
"es6-promise-plugin": "^4.2.2", "es6-promise-plugin": "^4.2.2",
"eventemitter3": "^4.0.0",
"ionic-native": "^2.9.0", "ionic-native": "^2.9.0",
"loaders.css": "^0.1.2", "loaders.css": "^0.1.2",
"mqtt": "^2.18.8", "mqtt": "^2.18.8",
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<div style="width:65%; float: left"> <div style="width:65%; float: left">
<h3 style="margin-bottom: 5px;" class="font-content-title">{{item.description}}</h3> <h3 style="margin-bottom: 5px;" class="font-content-title">{{item.description}}</h3>
<div *ngIf="item.data !== null && item.data.temp !== undefined && item.data.temp !== null && item.data.temp !== ''" class="warnContent font-content">温度: {{item.data.temp | number:'0.1-1'}} ℃</div> <div *ngIf="item.data !== null && item.data.temp !== undefined && item.data.temp !== null && item.data.temp !== ''" class="warnContent font-content">温度: {{item.data.temp | number:'0.1-1'}} ℃</div>
<div *ngIf="item.data !== null && item.data.humi !== undefined && item.data.humi !== null && item.data.humi !== ''" class="warnContent font-content">湿度: {{item.data.humi | number:'0.0-0'}} %</div> <div *ngIf="item.data !== null && item.data.humid !== undefined && item.data.humid !== null && item.data.humid !== ''" class="warnContent font-content">湿度: {{item.data.humid | number:'0.0-0'}} % RH</div>
<div *ngIf="item.data !== null && item.data.heatStressLevel !== undefined && item.data.heatStressLevel !== null && item.data.heatStressLevel !== ''" class="warnContent font-content">热应激等级: {{item.data.heatStressLevel}}</div> <div *ngIf="item.data !== null && item.data.heatStressLevel !== undefined && item.data.heatStressLevel !== null && item.data.heatStressLevel !== ''" class="warnContent font-content">热应激等级: {{item.data.heatStressLevel}}</div>
<div *ngIf="item.data !== null && item.data.liquidPump !== undefined && item.data.liquidPump !== null && item.data.liquidPump !== ''" class="warnContent font-content">供液泵: {{item.data.liquidPump | number:'0.0-3'}} MPa</div> <div *ngIf="item.data !== null && item.data.liquidPump !== undefined && item.data.liquidPump !== null && item.data.liquidPump !== ''" class="warnContent font-content">供液泵: {{item.data.liquidPump | number:'0.0-3'}} MPa</div>
<div *ngIf="item.data !== null && item.data.press !== undefined && item.data.press !== null && item.data.press !== ''" class="warnContent font-content">电磁阀: {{item.data.press | number:'0.0-3'}} MPa</div> <div *ngIf="item.data !== null && item.data.press !== undefined && item.data.press !== null && item.data.press !== ''" class="warnContent font-content">电磁阀: {{item.data.press | number:'0.0-3'}} MPa</div>
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
border: 4px solid #61C7CC; border: 4px solid #61C7CC;
background-color: #61C7CC; background-color: #61C7CC;
border-radius: 100%; border-radius: 100%;
top: 35%; // top: 35%;
right: -24px; right: -24px;
z-index: 99; z-index: 99;
} }
......
...@@ -7,6 +7,7 @@ import { IonInfiniteScroll } from '@ionic/angular'; ...@@ -7,6 +7,7 @@ import { IonInfiniteScroll } from '@ionic/angular';
import {Loading} from '../../service/loading'; import {Loading} from '../../service/loading';
import {Load} from '../../service/load'; import {Load} from '../../service/load';
import {Constants} from '../../service/constants'; import {Constants} from '../../service/constants';
import {EventService} from '../../service/event';
@Component({ @Component({
selector: 'v-env-alarm-detail', selector: 'v-env-alarm-detail',
...@@ -62,7 +63,8 @@ export class EnvAlarmDetailPage implements OnInit { ...@@ -62,7 +63,8 @@ export class EnvAlarmDetailPage implements OnInit {
// @ViewChild('currentItem') currentItem; // @ViewChild('currentItem') currentItem;
constructor(private ac: ActivatedRoute, private api: Api, public load: Load, public loadingController: LoadingController, constructor(private ac: ActivatedRoute, private api: Api, public load: Load, public loadingController: LoadingController,
private alterContoller: AlertController, private datePipe: DatePipe, public loading: Loading) { private alterController: AlertController, private datePipe: DatePipe, public loading: Loading,
public eventService: EventService) {
} }
ngOnInit() { ngOnInit() {
...@@ -79,7 +81,7 @@ export class EnvAlarmDetailPage implements OnInit { ...@@ -79,7 +81,7 @@ export class EnvAlarmDetailPage implements OnInit {
} }
ionViewWillLeave() { ionViewWillLeave() {
console.log('ionViewWillLeave'); console.log('env-alarm-detail: ionViewWillLeave');
this.page = 1; this.page = 1;
this.disposeState = ''; this.disposeState = '';
this.fieldDeviceType = ''; this.fieldDeviceType = '';
...@@ -96,6 +98,7 @@ export class EnvAlarmDetailPage implements OnInit { ...@@ -96,6 +98,7 @@ export class EnvAlarmDetailPage implements OnInit {
this.ac.queryParams.subscribe((data) => { this.ac.queryParams.subscribe((data) => {
console.log('init'); console.log('init');
this.fieldRegionNo = data.no; this.fieldRegionNo = data.no;
this.fieldRegionName = data.fieldRegionName;
this.displayArea = data.displayArea; this.displayArea = data.displayArea;
this.curInterval = data.interval; this.curInterval = data.interval;
...@@ -276,7 +279,7 @@ export class EnvAlarmDetailPage implements OnInit { ...@@ -276,7 +279,7 @@ export class EnvAlarmDetailPage implements OnInit {
async onRecvClick(alarm) { async onRecvClick(alarm) {
console.log(alarm); console.log(alarm);
const alert = await this.alterContoller.create({ const alert = await this.alterController.create({
header: '请注意', header: '请注意',
message: '请确认该故障是否为真实故障?', message: '请确认该故障是否为真实故障?',
mode: 'ios', mode: 'ios',
...@@ -354,6 +357,8 @@ export class EnvAlarmDetailPage implements OnInit { ...@@ -354,6 +357,8 @@ export class EnvAlarmDetailPage implements OnInit {
this.infiniteScroll.disabled = false; this.infiniteScroll.disabled = false;
this.getTroubleList(false); this.getTroubleList(false);
this.getAlarmList(false); this.getAlarmList(false);
this.eventService.event.emit('refreshAlarmInfo');
} }
wait(time) { wait(time) {
......
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {Api} from '../../service/api'; import {Api} from '../../service/api';
import {NavController} from '@ionic/angular'; import {NavController} from '@ionic/angular';
import {Load} from '../../service/load'; import {Load} from '../../service/load';
import {EventService} from '../../service/event';
@Component({ @Component({
selector: 'v-env-alarm', selector: 'v-env-alarm',
templateUrl: './env-alarm.page.html', templateUrl: './env-alarm.page.html',
styleUrls: ['./env-alarm.page.scss'], styleUrls: ['./env-alarm.page.scss'],
}) })
export class EnvAlarmPage implements OnInit { export class EnvAlarmPage implements OnInit {
alarmItems = []; alarmItems = [];
curFieldRegion = {factoryNo: '', curFieldRegion = {
factoryName: '', factoryNo: '',
fieldRegionNo: '', factoryName: '',
fieldRegionName: '', fieldRegionNo: '',
devErr: 0, fieldRegionName: '',
devErrTotal: 0, devErr: 0,
alarm: 0, devErrTotal: 0,
alarmTotal: 0, alarm: 0,
total: 0}; alarmTotal: 0,
total: 0
};
curInterval = '12'; curInterval = '12';
popoverElement = null; popoverElement = null;
constructor(private api: Api, public nav: NavController, private load: Load) { constructor(private api: Api, public nav: NavController, private load: Load, public eventService: EventService) {
// customElements.define('popover-page', class ModalContent extends HTMLElement { }
// connectedCallback() {
// this.innerHTML = ` ngOnInit() {
// <ion-list class="popContent"> console.log('env-alarm: ngOnInit');
// <ion-radio-group style=""> this.init();
// <ion-item style="">
// <ion-label class="popLabel">近一年</ion-label> this.eventService.event.on('refreshAlarmInfo', () => {
// <ion-radio slot="start" value="12" checked id="popSelect1"></ion-radio> console.log('refreshAlarmInfo');
// </ion-item> this.init();
// <ion-item style=""> });
// <ion-label class="popLabel">近六个月</ion-label> }
// <ion-radio slot="start" value="6" id="popSelect2"></ion-radio>
// </ion-item> // ionic的生命周期函数
// <ion-item style=""> ionViewWillEnter() {
// <ion-label class="popLabel">近三个月</ion-label> console.log('env-alarm: ionViewWillEnter');
// <ion-radio slot="start" value="3" id="popSelect3"></ion-radio> // this.init();
// </ion-item> }
// <ion-item style="">
// <ion-label class="popLabel">近一个月</ion-label> ionViewDidEnter() {
// <ion-radio slot="start" value="1" id="popSelect4"></ion-radio> console.log('env-alarm: ionViewDidEnter');
// </ion-item> // this.init();
// </ion-radio-group> }
// </ion-list>
// `; init() {
// } this.curInterval = '12';
// }); this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => {
if (data.total > 0) {
} if (data.rows && data.rows.constructor === Array) {
this.alarmItems = data.rows;
ngOnInit() { this.alarmItems.forEach(item => (item.interval = this.curInterval));
this.init(); }
} }
}]);
ionViewWillLeave() { }
} toControl(one, displayArea) {
init () { const query = '/env-alarmDetail?no=' + one.fieldRegionNo + '&fieldRegionName=' + one.fieldRegionName
this.curInterval = '12';
this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => {
if (data.total > 0) {
if (data.rows && data.rows.constructor === Array) {
this.alarmItems = data.rows;
this.alarmItems.forEach(item => (item.interval = this.curInterval));
}
}
}]);
}
toControl(one, displayArea) {
const query = '/env-alarmDetail?no=' + one.fieldRegionNo
+ '&displayArea=' + displayArea + '&interval=' + one.interval; + '&displayArea=' + displayArea + '&interval=' + one.interval;
// this.tf.transfer({
// url: '/' + one.url,
// query: query,
// hash: ''
// });
console.log(query);
this.nav.navigateForward(query); this.nav.navigateForward(query);
} }
// async presentPopover(fieldRegionInfo) {
// this.curFieldRegion = fieldRegionInfo;
// this.popoverElement = Object.assign(document.createElement('ion-popover'), {
// component: 'popover-page',
// event: event,
// cssClass: ['width: 150px']
// });
// document.body.appendChild(this.popoverElement);
// return await this.popoverElement.present().then( (res) => {
// document.getElementById('popSelect1').onclick = () => {
// this.dismissPopover(12);
// this.curInterval = 12;
// };
// document.getElementById('popSelect2').onclick = () => {
// this.dismissPopover(6);
// this.curInterval = 6;
// };
// document.getElementById('popSelect3').onclick = () => {
// this.dismissPopover(3);
// this.curInterval = 3;
// };
// document.getElementById('popSelect4').onclick = () => {
// this.dismissPopover(1);
// this.curInterval = 1;
// };
// });
// }
dismissPopover(one) { // interval, fieldRegionInfo dismissPopover(one) { // interval, fieldRegionInfo
this.curFieldRegion = one; this.curFieldRegion = one;
...@@ -141,23 +98,33 @@ export class EnvAlarmPage implements OnInit { ...@@ -141,23 +98,33 @@ export class EnvAlarmPage implements OnInit {
} }
getStartTime(interval) { getStartTime(interval) {
const now = new Date; const now = new Date;
const year = now.getFullYear(); const year = now.getFullYear();
const month = now.getMonth() - interval; const month = now.getMonth() - interval;
const day = now.getDate(); const day = now.getDate();
const time = new Date(year, month, day, 0, 0, 0); const time = new Date(year, month, day, 0, 0, 0);
return time; return time;
} }
displayInterval(interval) { displayInterval(interval) {
let displayValue = ''; let displayValue = '';
switch (interval) { switch (interval) {
case 12: displayValue = '近一年'; break; case 12:
case 6: displayValue = '近六个月'; break; displayValue = '近一年';
case 3: displayValue = '近三个月'; break; break;
case 1: displayValue = '近一个月'; break; case 6:
default: displayValue = '近一年'; break; displayValue = '近六个月';
} break;
case 3:
displayValue = '近三个月';
break;
case 1:
displayValue = '近一个月';
break;
default:
displayValue = '近一年';
break;
}
document.getElementById(this.curFieldRegion.fieldRegionNo).innerText = displayValue; document.getElementById(this.curFieldRegion.fieldRegionNo).innerText = displayValue;
} }
...@@ -165,6 +132,8 @@ export class EnvAlarmPage implements OnInit { ...@@ -165,6 +132,8 @@ export class EnvAlarmPage implements OnInit {
setTimeout(() => { setTimeout(() => {
this.init(); this.init();
event.target.complete(); event.target.complete();
}, 3000);
}, 1500);
} }
} }
...@@ -208,8 +208,8 @@ export class EnvCfgPage implements OnInit { ...@@ -208,8 +208,8 @@ export class EnvCfgPage implements OnInit {
this.shower.controlModel = value.controlModel; this.shower.controlModel = value.controlModel;
this.shower.dataConfig = value.dataConfig; this.shower.dataConfig = value.dataConfig;
this.shower.controlConfig = showerConfig; this.shower.controlConfig = showerConfig;
// 手控 自控模式下 可编辑
this.isShowerDisplay = this.shower.controlModel === Constants.CONTROLL_SELF; this.isShowerDisplay = this.shower.controlModel === Constants.CONTROLL_SELF || this.shower.controlModel === Constants.CONTROLL_REMOTR;
break; break;
case '照明' : case '照明' :
const lightConfig = JSON.parse(value.controlConfig); const lightConfig = JSON.parse(value.controlConfig);
...@@ -329,7 +329,8 @@ export class EnvCfgPage implements OnInit { ...@@ -329,7 +329,8 @@ export class EnvCfgPage implements OnInit {
this.isFanDisplay = this.fan.controlModel === Constants.CONTROLL_SELF; this.isFanDisplay = this.fan.controlModel === Constants.CONTROLL_SELF;
break; break;
case 'shower' : case 'shower' :
this.isShowerDisplay = this.shower.controlModel === Constants.CONTROLL_SELF; // 手控 自控模式下 可编辑
this.isShowerDisplay = this.shower.controlModel === Constants.CONTROLL_SELF || this.shower.controlModel === Constants.CONTROLL_REMOTR;
break; break;
case 'light' : case 'light' :
this.isLightDisplay = this.light.controlModel === Constants.CONTROLL_SELF; this.isLightDisplay = this.light.controlModel === Constants.CONTROLL_SELF;
...@@ -482,28 +483,41 @@ export class EnvCfgPage implements OnInit { ...@@ -482,28 +483,41 @@ export class EnvCfgPage implements OnInit {
return false; return false;
} }
} }
if (this.shower.controlModel === Constants.CONTROLL_SELF) { if (this.shower.controlModel === Constants.CONTROLL_SELF || this.shower.controlModel === Constants.CONTROLL_REMOTR) {
let hasError = false; let showerHasError = false;
let showerHasBlank = false;
this.shower.controlConfig.map(allCfg => { this.shower.controlConfig.map(allCfg => {
if (!hasError) { if (!showerHasBlank) {
hasError = this.isEmpty(allCfg.config.name); showerHasBlank = this.isEmpty(allCfg.config.name);
}
if (!showerHasBlank) {
showerHasBlank = this.isEmpty(allCfg.config.interval);
}
if (!showerHasBlank) {
showerHasBlank = this.isEmpty(allCfg.config.T);
} }
if (!hasError) { if (!showerHasBlank) {
hasError = this.isEmpty(allCfg.config.interval); showerHasBlank = this.isEmpty(allCfg.config.A);
} }
if (!hasError) { if (!showerHasBlank) {
hasError = this.isEmpty(allCfg.config.T); showerHasBlank = this.isEmpty(allCfg.config.B);
} }
if (!hasError) { if (!showerHasBlank && !showerHasError) {
hasError = this.isEmpty(allCfg.config.A); showerHasError = !this.isNumber(allCfg.config.interval);
} }
if (!hasError) { if (!showerHasBlank && !showerHasError) {
hasError = this.isEmpty(allCfg.config.B); showerHasError = !this.isNumber(allCfg.config.A);
}
if (!showerHasBlank && !showerHasError) {
showerHasError = !this.isNumber(allCfg.config.B);
} }
}); });
if (hasError) { if (showerHasBlank) {
this.api.presentMsgToast('请完成喷淋配置'); this.api.presentMsgToast('请完成喷淋配置');
return false; return false;
} else if (showerHasError) {
this.api.presentMsgToast('喷淋配置: 请输入正确的时间');
return false;
} }
} }
if (this.light.controlModel === Constants.CONTROLL_SELF) { if (this.light.controlModel === Constants.CONTROLL_SELF) {
......
...@@ -101,16 +101,30 @@ export class EnvDetailPage implements OnInit { ...@@ -101,16 +101,30 @@ export class EnvDetailPage implements OnInit {
const environmentConfigJson = JSON.parse(data.environmentConfigJson.toString()); const environmentConfigJson = JSON.parse(data.environmentConfigJson.toString());
this.item = data; this.item = data;
this.item.heatStressLevelName = this.getHeatStressLevelName(data.heatStressLevel); this.item.heatStressLevelName = this.getHeatStressLevelName(data.heatStressLevel);
this.item.inHouse.inHouseName = this.getInHouseState(data.inHouse.inHouse);
this.item.inHouse.inHouseState = data.inHouse.inHouse === 1 ? true : false; this.setInHouseInfo(data.inHouse);
this.inHouseName = this.getInHouseState(data.inHouse.inHouse);
this.inHouseState = data.inHouse.inHouse === 1 ? true : false;
this.initLayout(environmentConfigJson); this.initLayout(environmentConfigJson);
this.setConfusionModelControll(); this.setConfusionModelControll();
} }
}]); }]);
} }
setInHouseInfo(inHouse) {
if (inHouse === undefined || inHouse === null ||
inHouse.inHouse === undefined || inHouse.inHouse === null) {
this.item.inHouse.inHouseName = '离舍';
this.item.inHouse.inHouseState = false;
this.inHouseName = '离舍';
this.inHouseState = false;
} else {
this.item.inHouse.inHouseName = this.getInHouseState(inHouse.inHouse);
this.item.inHouse.inHouseState = inHouse.inHouse === 1 ? true : false;
this.inHouseName = this.getInHouseState(inHouse.inHouse);
this.inHouseState = inHouse.inHouse === 1 ? true : false;
}
}
initLayout(environmentConfigJson) { initLayout(environmentConfigJson) {
this.fanLink = '/env-detail/fan/'; this.fanLink = '/env-detail/fan/';
this.showerLink = '/env-detail/shower/' + this.fieldRegionNo + '/' + this.item.operationModel; this.showerLink = '/env-detail/shower/' + this.fieldRegionNo + '/' + this.item.operationModel;
...@@ -150,24 +164,28 @@ export class EnvDetailPage implements OnInit { ...@@ -150,24 +164,28 @@ export class EnvDetailPage implements OnInit {
getHeatStressLevelName(level) { getHeatStressLevelName(level) {
let levelName = ''; let levelName = '';
switch (level) { if (level === undefined || level === null) {
case 0: levelName = '无';
levelName = '无'; } else {
break; switch (level) {
case 1 : case 0:
levelName = '轻'; levelName = '无';
break; break;
case 2 : case 1 :
levelName = '中'; levelName = '轻';
break; break;
case 3 : case 2 :
levelName = '重'; levelName = '中';
break; break;
case 4 : case 3 :
levelName = 'II重'; levelName = '重';
break; break;
default: case 4 :
break; levelName = 'II重';
break;
default:
break;
}
} }
return levelName; return levelName;
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
[rows]="tableRows" [rows]="tableRows"
[columnMode]="ColumnMode.force" [columnMode]="ColumnMode.force"
[scrollbarH]="true" [scrollbarH]="true"
[scrollbarV]="true" [scrollbarV]="false"
[headerHeight]="48" [headerHeight]="48"
[rowClass]="getRowClass" [rowClass]="getRowClass"
[cssClasses]="'font-content'" [cssClasses]="'font-content'"
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</ngx-datatable-column> </ngx-datatable-column>
<ngx-datatable-column name="湿度<br>% RH" prop="humi" [width]="60"> <ngx-datatable-column name="湿度<br>% RH" prop="humi" [width]="60">
</ngx-datatable-column> </ngx-datatable-column>
<ngx-datatable-column name="氨气浓度<br>ppm" prop="NH3" [width]="90"> <ngx-datatable-column name="氨气浓度<br>ppm" prop="NH3" [width]="75">
</ngx-datatable-column> </ngx-datatable-column>
</ngx-datatable> </ngx-datatable>
</div> </div>
......
...@@ -5,6 +5,7 @@ import {Api} from '../../service/api'; ...@@ -5,6 +5,7 @@ import {Api} from '../../service/api';
import {Load} from '../../service/load'; import {Load} from '../../service/load';
import {NavController} from '@ionic/angular'; import {NavController} from '@ionic/angular';
import {Network} from '@ionic-native/network/ngx'; import {Network} from '@ionic-native/network/ngx';
import {EventService} from '../../service/event';
@Component({ @Component({
...@@ -15,7 +16,7 @@ import {Network} from '@ionic-native/network/ngx'; ...@@ -15,7 +16,7 @@ import {Network} from '@ionic-native/network/ngx';
export class EnvHomePage implements OnInit { export class EnvHomePage implements OnInit {
constructor(private tf: Transfer, private ac: ActivatedRoute, private network: Network, constructor(private tf: Transfer, private ac: ActivatedRoute, private network: Network,
private api: Api, private load: Load, public nav: NavController) { private api: Api, private load: Load, public nav: NavController, public eventService: EventService) {
} }
@ViewChild('slide') slide; @ViewChild('slide') slide;
...@@ -67,8 +68,15 @@ export class EnvHomePage implements OnInit { ...@@ -67,8 +68,15 @@ export class EnvHomePage implements OnInit {
} }
} }
ngOnInit() { // ionic的生命周期函数
ionViewWillEnter() {
console.log('env-home: ionViewWillEnter');
this.init(); this.init();
}
ngOnInit() {
// console.log('env-home: ngOnInit');
// this.init();
// this.ionViewWillEnter(); // this.ionViewWillEnter();
} }
...@@ -76,11 +84,7 @@ export class EnvHomePage implements OnInit { ...@@ -76,11 +84,7 @@ export class EnvHomePage implements OnInit {
this.slideDidChange(); this.slideDidChange();
this.getData(0); this.getData(0);
} }
// ionic的生命周期函数
// ionViewWillEnter() {
// this.slideDidChange();
// this.getData(0);
// }
getData(time) { getData(time) {
if (this.isNetConnected()) { if (this.isNetConnected()) {
...@@ -199,6 +203,7 @@ export class EnvHomePage implements OnInit { ...@@ -199,6 +203,7 @@ export class EnvHomePage implements OnInit {
setTimeout(() => { setTimeout(() => {
this.getData(0); this.getData(0);
event.target.complete(); event.target.complete();
this.eventService.event.emit('refreshAlarmInfo');
}, 2000); }, 2000);
} }
......
...@@ -57,7 +57,12 @@ export class EnvLightPage implements OnInit { ...@@ -57,7 +57,12 @@ export class EnvLightPage implements OnInit {
private alertControlle: AlertController, public loading: Loading) { private alertControlle: AlertController, public loading: Loading) {
} }
ionViewWillLeave() {
clearInterval(this.commTmr);
}
ngOnInit() { ngOnInit() {
console.log('env-light: ngOnInit');
this.comm.remain = 0; this.comm.remain = 0;
this.comm.isLoading = false; this.comm.isLoading = false;
this.commTmr = window.setInterval(() => { this.commTmr = window.setInterval(() => {
...@@ -80,16 +85,13 @@ export class EnvLightPage implements OnInit { ...@@ -80,16 +85,13 @@ export class EnvLightPage implements OnInit {
// this.init(); // this.init();
// } // }
ionViewWillLeave() {
clearInterval(this.commTmr);
}
init() { init() {
this.route.paramMap.subscribe(params => { this.route.paramMap.subscribe(params => {
this.fieldRegionNo = params.get('fieldRegionNo'); this.fieldRegionNo = params.get('fieldRegionNo');
this.operationModel = + params.get('operationModel'); this.operationModel = + params.get('operationModel');
this.getData(0);
}); });
this.getData(0);
} }
getData(time) { getData(time) {
......
...@@ -74,10 +74,10 @@ export class EnvShowerPage implements OnInit { ...@@ -74,10 +74,10 @@ export class EnvShowerPage implements OnInit {
public loading: Loading) { public loading: Loading) {
this.param[0].fieldDeviceName = 'A区'; this.param[0].fieldDeviceName = 'A区';
this.param[1].fieldDeviceName = 'B区'; this.param[1].fieldDeviceName = 'B区';
this.route.paramMap.subscribe(params => { // this.route.paramMap.subscribe(params => {
this.fieldRegionNo = params.get('fieldRegionNo'); // this.fieldRegionNo = params.get('fieldRegionNo');
this.getData(0); // this.getData(0);
}); // });
} }
ngOnInit() { ngOnInit() {
...@@ -98,10 +98,10 @@ export class EnvShowerPage implements OnInit { ...@@ -98,10 +98,10 @@ export class EnvShowerPage implements OnInit {
this.init(); this.init();
} }
ionViewWillEnter() { // ionViewWillEnter() {
console.log('ionViewWillEnter_shower'); // console.log('ionViewWillEnter_shower');
this.init(); // this.init();
} // }
ionViewWillLeave() { ionViewWillLeave() {
clearInterval(this.commTmr); clearInterval(this.commTmr);
} }
...@@ -153,6 +153,14 @@ export class EnvShowerPage implements OnInit { ...@@ -153,6 +153,14 @@ export class EnvShowerPage implements OnInit {
} }
initButtons() { initButtons() {
// 自控状态下 设备全部为打开状态
// if (this.controlModel === Constants.CONTROLL_SELF || this.controlModel === Constants.CONTROLL_WISDOM) {
// this.param.forEach((device) => {
// // 自控的场合 小按钮打开
// device.op = true;
// });
// }
this.param.forEach((device) => { this.param.forEach((device) => {
// 远控的场合 小按钮活性(disabled = false) // 远控的场合 小按钮活性(disabled = false)
device.disabled = !(this.controlModel === Constants.CONTROLL_REMOTR); device.disabled = !(this.controlModel === Constants.CONTROLL_REMOTR);
......
...@@ -26,6 +26,7 @@ export class EnvWaterchannelPage implements OnInit { ...@@ -26,6 +26,7 @@ export class EnvWaterchannelPage implements OnInit {
// this.ac.queryParams.subscribe((data) => { // this.ac.queryParams.subscribe((data) => {
// this.fieldRegionNo = data.no; // this.fieldRegionNo = data.no;
// }); // });
console.log('env-waterChannel: ngOnInit');
this.init(); this.init();
} }
......
import {Component, ComponentFactoryResolver, OnInit, ViewChild} from '@angular/core'; import {Component, ComponentFactoryResolver, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, ActivationStart, Router, RouterOutlet} from '@angular/router'; import {ActivatedRoute, ActivationStart, Router, RouterOutlet} from '@angular/router';
import {Api} from '../../service/api'; import {Api} from '../../service/api';
import {EventService} from '../../service/event';
@Component({ @Component({
selector: 'v-tabs', selector: 'v-tabs',
...@@ -11,7 +12,7 @@ export class TabsPage implements OnInit { ...@@ -11,7 +12,7 @@ export class TabsPage implements OnInit {
@ViewChild(RouterOutlet) outlet: RouterOutlet; @ViewChild(RouterOutlet) outlet: RouterOutlet;
constructor(private router: Router, private api: Api ) { constructor(private router: Router, private api: Api, public eventService: EventService) {
} }
...@@ -25,18 +26,28 @@ export class TabsPage implements OnInit { ...@@ -25,18 +26,28 @@ export class TabsPage implements OnInit {
// }); // });
this.totalAlert = 0; this.totalAlert = 0;
this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => { this.init();
if (data.total > 0) {
this.totalAlert = 0; // 监听[告警数]变化
const rows = data.rows; this.eventService.event.on('refreshAlarmInfo', () => {
if (rows.constructor === Array) { console.log('refreshAlarmInfo');
rows.map((value, index) => { this.init();
this.totalAlert = this.totalAlert + value.devErr + value.alarm; });
});
}
}
}]);
} }
init() {
this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => {
if (data.total > 0) {
this.totalAlert = 0;
const rows = data.rows;
if (rows.constructor === Array) {
rows.map((value, index) => {
this.totalAlert = this.totalAlert + value.devErr + value.alarm;
});
}
}
}]);
}
} }
...@@ -42,7 +42,7 @@ export class LoginPage implements OnInit { ...@@ -42,7 +42,7 @@ export class LoginPage implements OnInit {
this.tf.transfer({url: '/index'}); this.tf.transfer({url: '/index'});
this.mqtt.getUserInfo(); this.mqtt.getUserInfo();
if(this.saveMimaCheck === true) { if (this.saveMimaCheck === true) {
window.localStorage.setItem('muchangUsername', this.req.name); window.localStorage.setItem('muchangUsername', this.req.name);
window.localStorage.setItem('muchangPassword', this.req.ps); window.localStorage.setItem('muchangPassword', this.req.ps);
} }
......
...@@ -14,7 +14,7 @@ export class Constants { ...@@ -14,7 +14,7 @@ export class Constants {
public static CONTROLL_REMOTR = 1; // 远控(手动控制) public static CONTROLL_REMOTR = 1; // 远控(手动控制)
public static CONTROLL_SELF = 2; // 自控 public static CONTROLL_SELF = 2; // 自控
public static CONTROLL_WISDOM = 3; // 智慧控制 public static CONTROLL_WISDOM = 3; // 智慧控制
public static CONTROLL_CONFUSION = 4; // 智慧控制 public static CONTROLL_CONFUSION = 4; // 混乱
public static LOADING_SHORT = 10; // 单个开关 public static LOADING_SHORT = 10; // 单个开关
public static LOADING_LONG = 40; // 一键控制等 public static LOADING_LONG = 40; // 一键控制等
......
import { Injectable } from '@angular/core';
import {EventEmitter} from 'eventemitter3';
@Injectable({
providedIn: 'root'
})
export class EventService {
public event: any;
constructor() {
this.event = new EventEmitter();
}
}
...@@ -348,6 +348,9 @@ img { ...@@ -348,6 +348,9 @@ img {
height: unset !important; height: unset !important;
} }
.ngx-datatable .datatable-body {
// height:303px !important;
}
.ngx-datatable .datatable-body-cell { .ngx-datatable .datatable-body-cell {
border-right: 1px solid #ffffff; border-right: 1px solid #ffffff;
border-bottom: 1px solid #ffffff; border-bottom: 1px solid #ffffff;
......
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