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({
...@@ -13,7 +14,8 @@ export class EnvAlarmPage implements OnInit { ...@@ -13,7 +14,8 @@ export class EnvAlarmPage implements OnInit {
alarmItems = []; alarmItems = [];
curFieldRegion = {factoryNo: '', curFieldRegion = {
factoryNo: '',
factoryName: '', factoryName: '',
fieldRegionNo: '', fieldRegionNo: '',
fieldRegionName: '', fieldRegionName: '',
...@@ -21,49 +23,37 @@ export class EnvAlarmPage implements OnInit { ...@@ -21,49 +23,37 @@ export class EnvAlarmPage implements OnInit {
devErrTotal: 0, devErrTotal: 0,
alarm: 0, alarm: 0,
alarmTotal: 0, alarmTotal: 0,
total: 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 = `
// <ion-list class="popContent">
// <ion-radio-group style="">
// <ion-item style="">
// <ion-label class="popLabel">近一年</ion-label>
// <ion-radio slot="start" value="12" checked id="popSelect1"></ion-radio>
// </ion-item>
// <ion-item style="">
// <ion-label class="popLabel">近六个月</ion-label>
// <ion-radio slot="start" value="6" id="popSelect2"></ion-radio>
// </ion-item>
// <ion-item style="">
// <ion-label class="popLabel">近三个月</ion-label>
// <ion-radio slot="start" value="3" id="popSelect3"></ion-radio>
// </ion-item>
// <ion-item style="">
// <ion-label class="popLabel">近一个月</ion-label>
// <ion-radio slot="start" value="1" id="popSelect4"></ion-radio>
// </ion-item>
// </ion-radio-group>
// </ion-list>
// `;
// }
// });
} }
ngOnInit() { ngOnInit() {
console.log('env-alarm: ngOnInit');
this.init(); this.init();
this.eventService.event.on('refreshAlarmInfo', () => {
console.log('refreshAlarmInfo');
this.init();
});
} }
ionViewWillLeave() { // ionic的生命周期函数
ionViewWillEnter() {
console.log('env-alarm: ionViewWillEnter');
// this.init();
}
ionViewDidEnter() {
console.log('env-alarm: ionViewDidEnter');
// this.init();
} }
init () {
init() {
this.curInterval = '12'; this.curInterval = '12';
this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => { this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => {
if (data.total > 0) { if (data.total > 0) {
...@@ -74,46 +64,13 @@ export class EnvAlarmPage implements OnInit { ...@@ -74,46 +64,13 @@ export class EnvAlarmPage implements OnInit {
} }
}]); }]);
} }
toControl(one, displayArea) { toControl(one, displayArea) {
const query = '/env-alarmDetail?no=' + one.fieldRegionNo const query = '/env-alarmDetail?no=' + one.fieldRegionNo + '&fieldRegionName=' + one.fieldRegionName
+ '&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;
this.load.toLoad('加载中...', false); this.load.toLoad('加载中...', false);
...@@ -152,11 +109,21 @@ export class EnvAlarmPage implements OnInit { ...@@ -152,11 +109,21 @@ export class EnvAlarmPage implements OnInit {
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 (!hasError) { if (!showerHasBlank) {
hasError = this.isEmpty(allCfg.config.interval); showerHasBlank = this.isEmpty(allCfg.config.interval);
} }
if (!hasError) { if (!showerHasBlank) {
hasError = this.isEmpty(allCfg.config.T); showerHasBlank = this.isEmpty(allCfg.config.T);
} }
if (!hasError) { if (!showerHasBlank) {
hasError = this.isEmpty(allCfg.config.A); showerHasBlank = this.isEmpty(allCfg.config.A);
} }
if (!hasError) { if (!showerHasBlank) {
hasError = this.isEmpty(allCfg.config.B); showerHasBlank = this.isEmpty(allCfg.config.B);
}
if (!showerHasBlank && !showerHasError) {
showerHasError = !this.isNumber(allCfg.config.interval);
}
if (!showerHasBlank && !showerHasError) {
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,6 +164,9 @@ export class EnvDetailPage implements OnInit { ...@@ -150,6 +164,9 @@ export class EnvDetailPage implements OnInit {
getHeatStressLevelName(level) { getHeatStressLevelName(level) {
let levelName = ''; let levelName = '';
if (level === undefined || level === null) {
levelName = '无';
} else {
switch (level) { switch (level) {
case 0: case 0:
levelName = '无'; levelName = '无';
...@@ -169,6 +186,7 @@ export class EnvDetailPage implements OnInit { ...@@ -169,6 +186,7 @@ export class EnvDetailPage implements OnInit {
default: default:
break; 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>
......
...@@ -23,23 +23,77 @@ export class EnvHistoryPage implements OnInit { ...@@ -23,23 +23,77 @@ export class EnvHistoryPage implements OnInit {
item: any = {}; item: any = {};
chartOption = {}; chartOption = {
backgroundColor: '#fff',
tooltip: {
trigger: 'axis',
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: 'line', // 默认为直线,可选为:'line' | 'shadow'
label: 'cross',
show: true
},
},
legend: {
data: ['温度', '湿度', '热应激']
},
grid: {
right: '25%'
},
xAxis: {},
yAxis: [],
series: [
{
name: '温度',
data: [],
type: 'line',
itemStyle: {
normal: {
color: 'rgba(76, 208, 209, 0.8)', // '#D71F8B' rgba(215, 31, 139, 0.8)
}
},
},
{
name: '湿度',
data: [],
yAxisIndex: 1,
type: 'line',
itemStyle: {
normal: {
color: 'rgba(92, 178, 241, 0.8)', // rgba(37, 152, 214,0.5) rgba(22, 95, 175, 0.8)
}
},
},
{
name: '热应激',
data: [],
yAxisIndex: 2,
type: 'line',
itemStyle: {
normal: {
color: '#EFB827', // #EFB827 rgba(183, 164, 223, 0.8)
label: {formatter: ''}
},
},
}]};
tableRows = []; tableRows = [];
tableColumns = [ // tableColumns = [
{ name: '时间', prop: 'ts'}, // { name: '时间', prop: 'ts'},
{ name: '热应激', prop: 'thi'}, // { name: '热应激', prop: 'thi'},
{ name: '温度 <br> ℃', prop: 'temp'}, // { name: '温度 <br> ℃', prop: 'temp'},
{ name: '湿度 <br> rH', prop: 'humi'}, // { name: '湿度 <br> rH', prop: 'humi'},
{ name: '氨气浓度 <br> ppm', prop: 'NH3'} // { name: '氨气浓度 <br> ppm', prop: 'NH3'}
]; // ];
tableColumnWidths = [ // tableColumnWidths = [
{column: 'ts', width: 70}, // {column: 'ts', width: 70},
{column: 'thi', width: 80}, // {column: 'thi', width: 80},
{column: 'temp', width: 70}, // {column: 'temp', width: 70},
{column: 'humi', width: 70}, // {column: 'humi', width: 70},
{column: 'NH3', width: 90} // {column: 'NH3', width: 90}
]; // ];
rowCount = 0; // rowCount = 0;
ngOnInit() { ngOnInit() {
this.init(); this.init();
...@@ -79,6 +133,14 @@ export class EnvHistoryPage implements OnInit { ...@@ -79,6 +133,14 @@ export class EnvHistoryPage implements OnInit {
} }
paintChart(param) { paintChart(param) {
const heatLevel = [
{id: 0, value: ''},
{id: 1, value: '轻'},
{id: 2, value: '中'},
{id: 3, value: '重'},
{id: 4, value: 'Ⅱ重'},
{id: 5, value: ''},
];
const temp = []; const temp = [];
const humi = []; const humi = [];
const thi = []; const thi = [];
...@@ -96,7 +158,7 @@ export class EnvHistoryPage implements OnInit { ...@@ -96,7 +158,7 @@ export class EnvHistoryPage implements OnInit {
} }
if (param.thi && param.thi.constructor === Array) { if (param.thi && param.thi.constructor === Array) {
param.thi.map(item => { param.thi.map(item => {
thi.push(item.value); thi.push(Number(item.value).toFixed(0));
}); });
} }
...@@ -123,6 +185,9 @@ export class EnvHistoryPage implements OnInit { ...@@ -123,6 +185,9 @@ export class EnvHistoryPage implements OnInit {
// visualMap: [ // visualMap: [
// {show: false, type: 'continuous', seriesIndex: 0, min: 0, max: 400}, // {show: false, type: 'continuous', seriesIndex: 0, min: 0, max: 400},
// {show: false, type: 'continuous', seriesIndex: 1, dimension: 0, min: 0, max: 400}], // {show: false, type: 'continuous', seriesIndex: 1, dimension: 0, min: 0, max: 400}],
grid: {
right: '25%'
},
xAxis: { xAxis: {
name: '', type: 'category', name: '', type: 'category',
data: times, data: times,
...@@ -139,41 +204,50 @@ export class EnvHistoryPage implements OnInit { ...@@ -139,41 +204,50 @@ export class EnvHistoryPage implements OnInit {
type: 'value', type: 'value',
splitLine: {show: false}, splitLine: {show: false},
position: 'left', position: 'left',
min: 0,
max: 50,
axisLine: { axisLine: {
lineStyle: { lineStyle: {
width: 2, width: 1,
color: 'rgba(97, 199, 204, 0.8)', // y轴的轴线的宽度和颜色 color: 'rgba(76, 208, 209, 0.8)', // y轴的轴线的宽度和颜色
} }
}, },
}, },
{ {
name: '湿度(%)', name: '湿度(% RH)',
type: 'value', type: 'value',
min: 0,
max: 100, max: 100,
splitLine: {show: false}, splitLine: {show: false},
position: 'right', position: 'right',
axisLine: { axisLine: {
lineStyle: { lineStyle: {
width: 2, width: 1,
color: 'rgba(22, 95, 175, 0.8)', // y轴的轴线的宽度和颜色 #2598D6 color: 'rgba(92, 178, 241, 0.8)', // y轴的轴线的宽度和颜色 #2598D6
} }
} }
} },
// { {
// name: '热应激', name: '', // 热应激
// type: 'value', type: 'value',
// min: 0, min: 0,
// max: 5, max: 5,
// splitLine: {show: false}, splitLine: {show: true},
// position: 'right', position: 'right',
// offset: -20, offset: 35,
// axisLine: { axisLine: {
// lineStyle: { lineStyle: {
// width: 0, width: 3,
// color: 'rgba(239, 184, 39,0.5)', // y轴的轴线的宽度和颜色 color: '#EFB827', // y轴的轴线的宽度和颜色 rgba(239, 184, 39,0.5)
// } }
// } },
// }, axisLabel: {
formatter: function(params) {
const current = heatLevel.find( item => (item.id === params));
return current.value;
},
}
}
], ],
series: [ series: [
{ {
...@@ -182,7 +256,7 @@ export class EnvHistoryPage implements OnInit { ...@@ -182,7 +256,7 @@ export class EnvHistoryPage implements OnInit {
type: 'line', type: 'line',
itemStyle: { itemStyle: {
normal: { normal: {
color: 'rgba(97, 199, 204, 0.8)', // '#D71F8B' rgba(215, 31, 139, 0.8) color: 'rgba(76, 208, 209, 0.8)', // '#D71F8B' rgba(215, 31, 139, 0.8)
} }
}, },
}, },
...@@ -193,28 +267,48 @@ export class EnvHistoryPage implements OnInit { ...@@ -193,28 +267,48 @@ export class EnvHistoryPage implements OnInit {
type: 'line', type: 'line',
itemStyle: { itemStyle: {
normal: { normal: {
color: 'rgba(22, 95, 175, 0.8)', // rgba(37, 152, 214,0.5) color: 'rgba(92, 178, 241, 0.8)', // rgba(37, 152, 214,0.5) rgba(22, 95, 175, 0.8)
} }
}, },
}, },
{ {
name: '热应激', name: '热应激',
data: thi, data: thi,
yAxisIndex: 1, yAxisIndex: 2,
type: 'line', type: 'line',
itemStyle: { itemStyle: {
normal: { normal: {
color: '#EFB827', color: '#EFB827', // #EFB827 rgba(183, 164, 223, 0.8)
} }
}, },
} }
] ]
}; };
// this.chartOption.series[2].itemStyle.normal.label.formatter = function(params) {
// let text = '';
// const current = this.heatLevel.find((item, index) => {
// return item.id === params.data;
// });
// text = current ? current.value : '';
// return text;
// };
}
setHeatLevelName(params) {
// let text = params + '度';
// const current = this.heatLevel.find((item, index) => {
// return item.id === params.data;
// });
// text = current ? current.value : '';
// return params + '度';
} }
paintTable(param) { paintTable(param) {
this.tableRows = []; this.tableRows = [];
param.map((item, index) => { param.map((item, index) => {
if (this.hasAllData(item)) {
this.tableRows.push({ this.tableRows.push({
id: index + 1, id: index + 1,
ts: this.datePipe.transform(item.ts, 'hh:mm'), ts: this.datePipe.transform(item.ts, 'hh:mm'),
...@@ -223,10 +317,29 @@ export class EnvHistoryPage implements OnInit { ...@@ -223,10 +317,29 @@ export class EnvHistoryPage implements OnInit {
humi: item.humi.toFixed(1), humi: item.humi.toFixed(1),
NH3: item.NH3.toFixed(3) NH3: item.NH3.toFixed(3)
}); });
}
}); });
} }
hasAllData(param) {
if (!this.isEmpty(param.heatStressLevel) ||
!this.isEmpty(param.temp) ||
!this.isEmpty(param.humi) ||
!this.isEmpty(param.NH3)) {
return true;
} else {
return false;
}
}
isEmpty(value) {
if (value === undefined || value === null || value === '') {
return true;
} else {
return false;
}
}
getRowClass(row) { getRowClass(row) {
return { return {
'light-color': row.id % 2 === 0 'light-color': row.id % 2 === 0
......
...@@ -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,6 +26,17 @@ export class TabsPage implements OnInit { ...@@ -25,6 +26,17 @@ export class TabsPage implements OnInit {
// }); // });
this.totalAlert = 0; this.totalAlert = 0;
this.init();
// 监听[告警数]变化
this.eventService.event.on('refreshAlarmInfo', () => {
console.log('refreshAlarmInfo');
this.init();
});
}
init() {
this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => { this.api.alert.getAll([{fieldRegionType: '牛舍'}, (data) => {
if (data.total > 0) { if (data.total > 0) {
this.totalAlert = 0; this.totalAlert = 0;
...@@ -38,5 +50,4 @@ export class TabsPage implements OnInit { ...@@ -38,5 +50,4 @@ export class TabsPage implements OnInit {
}]); }]);
} }
} }
...@@ -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