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

调整layout 对应BUG等

parent 3f220d94
<?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>
<description>test</description>
<author email="frank.feng@witium.com" href="http://muchang.witium.com/">Van.chen - frank.feng</author>
......
......@@ -4203,10 +4203,9 @@
}
},
"eventemitter3": {
"version": "3.1.0",
"resolved": "http://registry.npm.taobao.org/eventemitter3/download/eventemitter3-3.1.0.tgz",
"integrity": "sha1-CQtNbNvWRe0Qv3UNS1QHlC17oWM=",
"dev": true
"version": "4.0.0",
"resolved": "https://registry.npm.taobao.org/eventemitter3/download/eventemitter3-4.0.0.tgz",
"integrity": "sha1-1lF2FjiH7lnzhtZMgmELaWpKdOs="
},
"events": {
"version": "3.0.0",
......@@ -5685,6 +5684,14 @@
"eventemitter3": "^3.0.0",
"follow-redirects": "^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": {
......
......@@ -46,6 +46,7 @@
"core-js": "^2.5.4",
"echarts": "^4.2.1",
"es6-promise-plugin": "^4.2.2",
"eventemitter3": "^4.0.0",
"ionic-native": "^2.9.0",
"loaders.css": "^0.1.2",
"mqtt": "^2.18.8",
......
......@@ -93,7 +93,7 @@
<div style="width:65%; float: left">
<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.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.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>
......
......@@ -137,7 +137,7 @@
border: 4px solid #61C7CC;
background-color: #61C7CC;
border-radius: 100%;
top: 35%;
// top: 35%;
right: -24px;
z-index: 99;
}
......
......@@ -7,6 +7,7 @@ import { IonInfiniteScroll } from '@ionic/angular';
import {Loading} from '../../service/loading';
import {Load} from '../../service/load';
import {Constants} from '../../service/constants';
import {EventService} from '../../service/event';
@Component({
selector: 'v-env-alarm-detail',
......@@ -62,7 +63,8 @@ export class EnvAlarmDetailPage implements OnInit {
// @ViewChild('currentItem') currentItem;
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() {
......@@ -79,7 +81,7 @@ export class EnvAlarmDetailPage implements OnInit {
}
ionViewWillLeave() {
console.log('ionViewWillLeave');
console.log('env-alarm-detail: ionViewWillLeave');
this.page = 1;
this.disposeState = '';
this.fieldDeviceType = '';
......@@ -96,6 +98,7 @@ export class EnvAlarmDetailPage implements OnInit {
this.ac.queryParams.subscribe((data) => {
console.log('init');
this.fieldRegionNo = data.no;
this.fieldRegionName = data.fieldRegionName;
this.displayArea = data.displayArea;
this.curInterval = data.interval;
......@@ -276,7 +279,7 @@ export class EnvAlarmDetailPage implements OnInit {
async onRecvClick(alarm) {
console.log(alarm);
const alert = await this.alterContoller.create({
const alert = await this.alterController.create({
header: '请注意',
message: '请确认该故障是否为真实故障?',
mode: 'ios',
......@@ -354,6 +357,8 @@ export class EnvAlarmDetailPage implements OnInit {
this.infiniteScroll.disabled = false;
this.getTroubleList(false);
this.getAlarmList(false);
this.eventService.event.emit('refreshAlarmInfo');
}
wait(time) {
......
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {Api} from '../../service/api';
import {NavController} from '@ionic/angular';
import {Load} from '../../service/load';
import {EventService} from '../../service/event';
@Component({
selector: 'v-env-alarm',
templateUrl: './env-alarm.page.html',
styleUrls: ['./env-alarm.page.scss'],
selector: 'v-env-alarm',
templateUrl: './env-alarm.page.html',
styleUrls: ['./env-alarm.page.scss'],
})
export class EnvAlarmPage implements OnInit {
alarmItems = [];
alarmItems = [];
curFieldRegion = {factoryNo: '',
factoryName: '',
fieldRegionNo: '',
fieldRegionName: '',
devErr: 0,
devErrTotal: 0,
alarm: 0,
alarmTotal: 0,
total: 0};
curFieldRegion = {
factoryNo: '',
factoryName: '',
fieldRegionNo: '',
fieldRegionName: '',
devErr: 0,
devErrTotal: 0,
alarm: 0,
alarmTotal: 0,
total: 0
};
curInterval = '12';
popoverElement = null;
constructor(private api: Api, public nav: NavController, private load: Load) {
// 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() {
this.init();
}
ionViewWillLeave() {
}
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;
this.alarmItems.forEach(item => (item.interval = this.curInterval));
}
}
}]);
}
toControl(one, displayArea) {
const query = '/env-alarmDetail?no=' + one.fieldRegionNo
constructor(private api: Api, public nav: NavController, private load: Load, public eventService: EventService) {
}
ngOnInit() {
console.log('env-alarm: ngOnInit');
this.init();
this.eventService.event.on('refreshAlarmInfo', () => {
console.log('refreshAlarmInfo');
this.init();
});
}
// ionic的生命周期函数
ionViewWillEnter() {
console.log('env-alarm: ionViewWillEnter');
// this.init();
}
ionViewDidEnter() {
console.log('env-alarm: ionViewDidEnter');
// this.init();
}
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;
this.alarmItems.forEach(item => (item.interval = this.curInterval));
}
}
}]);
}
toControl(one, displayArea) {
const query = '/env-alarmDetail?no=' + one.fieldRegionNo + '&fieldRegionName=' + one.fieldRegionName
+ '&displayArea=' + displayArea + '&interval=' + one.interval;
// this.tf.transfer({
// url: '/' + one.url,
// query: query,
// hash: ''
// });
console.log(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
this.curFieldRegion = one;
......@@ -141,23 +98,33 @@ export class EnvAlarmPage implements OnInit {
}
getStartTime(interval) {
const now = new Date;
const year = now.getFullYear();
const month = now.getMonth() - interval;
const day = now.getDate();
const time = new Date(year, month, day, 0, 0, 0);
return time;
const now = new Date;
const year = now.getFullYear();
const month = now.getMonth() - interval;
const day = now.getDate();
const time = new Date(year, month, day, 0, 0, 0);
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;
}
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;
}
......@@ -165,6 +132,8 @@ export class EnvAlarmPage implements OnInit {
setTimeout(() => {
this.init();
event.target.complete();
}, 3000);
}, 1500);
}
}
......@@ -208,8 +208,8 @@ export class EnvCfgPage implements OnInit {
this.shower.controlModel = value.controlModel;
this.shower.dataConfig = value.dataConfig;
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;
case '照明' :
const lightConfig = JSON.parse(value.controlConfig);
......@@ -329,7 +329,8 @@ export class EnvCfgPage implements OnInit {
this.isFanDisplay = this.fan.controlModel === Constants.CONTROLL_SELF;
break;
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;
case 'light' :
this.isLightDisplay = this.light.controlModel === Constants.CONTROLL_SELF;
......@@ -482,28 +483,41 @@ export class EnvCfgPage implements OnInit {
return false;
}
}
if (this.shower.controlModel === Constants.CONTROLL_SELF) {
let hasError = false;
if (this.shower.controlModel === Constants.CONTROLL_SELF || this.shower.controlModel === Constants.CONTROLL_REMOTR) {
let showerHasError = false;
let showerHasBlank = false;
this.shower.controlConfig.map(allCfg => {
if (!hasError) {
hasError = this.isEmpty(allCfg.config.name);
if (!showerHasBlank) {
showerHasBlank = this.isEmpty(allCfg.config.name);
}
if (!showerHasBlank) {
showerHasBlank = this.isEmpty(allCfg.config.interval);
}
if (!showerHasBlank) {
showerHasBlank = this.isEmpty(allCfg.config.T);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.interval);
if (!showerHasBlank) {
showerHasBlank = this.isEmpty(allCfg.config.A);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.T);
if (!showerHasBlank) {
showerHasBlank = this.isEmpty(allCfg.config.B);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.A);
if (!showerHasBlank && !showerHasError) {
showerHasError = !this.isNumber(allCfg.config.interval);
}
if (!hasError) {
hasError = this.isEmpty(allCfg.config.B);
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('请完成喷淋配置');
return false;
} else if (showerHasError) {
this.api.presentMsgToast('喷淋配置: 请输入正确的时间');
return false;
}
}
if (this.light.controlModel === Constants.CONTROLL_SELF) {
......
......@@ -101,16 +101,30 @@ export class EnvDetailPage implements OnInit {
const environmentConfigJson = JSON.parse(data.environmentConfigJson.toString());
this.item = data;
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.inHouseName = this.getInHouseState(data.inHouse.inHouse);
this.inHouseState = data.inHouse.inHouse === 1 ? true : false;
this.setInHouseInfo(data.inHouse);
this.initLayout(environmentConfigJson);
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) {
this.fanLink = '/env-detail/fan/';
this.showerLink = '/env-detail/shower/' + this.fieldRegionNo + '/' + this.item.operationModel;
......@@ -150,24 +164,28 @@ export class EnvDetailPage implements OnInit {
getHeatStressLevelName(level) {
let levelName = '';
switch (level) {
case 0:
levelName = '无';
break;
case 1 :
levelName = '轻';
break;
case 2 :
levelName = '中';
break;
case 3 :
levelName = '重';
break;
case 4 :
levelName = 'II重';
break;
default:
break;
if (level === undefined || level === null) {
levelName = '无';
} else {
switch (level) {
case 0:
levelName = '无';
break;
case 1 :
levelName = '轻';
break;
case 2 :
levelName = '中';
break;
case 3 :
levelName = '重';
break;
case 4 :
levelName = 'II重';
break;
default:
break;
}
}
return levelName;
}
......
......@@ -24,7 +24,7 @@
[rows]="tableRows"
[columnMode]="ColumnMode.force"
[scrollbarH]="true"
[scrollbarV]="true"
[scrollbarV]="false"
[headerHeight]="48"
[rowClass]="getRowClass"
[cssClasses]="'font-content'"
......@@ -37,7 +37,7 @@
</ngx-datatable-column>
<ngx-datatable-column name="湿度<br>% RH" prop="humi" [width]="60">
</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>
</div>
......
......@@ -23,23 +23,77 @@ export class EnvHistoryPage implements OnInit {
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 = [];
tableColumns = [
{ name: '时间', prop: 'ts'},
{ name: '热应激', prop: 'thi'},
{ name: '温度 <br> ℃', prop: 'temp'},
{ name: '湿度 <br> rH', prop: 'humi'},
{ name: '氨气浓度 <br> ppm', prop: 'NH3'}
];
tableColumnWidths = [
{column: 'ts', width: 70},
{column: 'thi', width: 80},
{column: 'temp', width: 70},
{column: 'humi', width: 70},
{column: 'NH3', width: 90}
];
rowCount = 0;
// tableColumns = [
// { name: '时间', prop: 'ts'},
// { name: '热应激', prop: 'thi'},
// { name: '温度 <br> ℃', prop: 'temp'},
// { name: '湿度 <br> rH', prop: 'humi'},
// { name: '氨气浓度 <br> ppm', prop: 'NH3'}
// ];
// tableColumnWidths = [
// {column: 'ts', width: 70},
// {column: 'thi', width: 80},
// {column: 'temp', width: 70},
// {column: 'humi', width: 70},
// {column: 'NH3', width: 90}
// ];
// rowCount = 0;
ngOnInit() {
this.init();
......@@ -79,6 +133,14 @@ export class EnvHistoryPage implements OnInit {
}
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 humi = [];
const thi = [];
......@@ -96,7 +158,7 @@ export class EnvHistoryPage implements OnInit {
}
if (param.thi && param.thi.constructor === Array) {
param.thi.map(item => {
thi.push(item.value);
thi.push(Number(item.value).toFixed(0));
});
}
......@@ -123,6 +185,9 @@ export class EnvHistoryPage implements OnInit {
// visualMap: [
// {show: false, type: 'continuous', seriesIndex: 0, min: 0, max: 400},
// {show: false, type: 'continuous', seriesIndex: 1, dimension: 0, min: 0, max: 400}],
grid: {
right: '25%'
},
xAxis: {
name: '', type: 'category',
data: times,
......@@ -139,41 +204,50 @@ export class EnvHistoryPage implements OnInit {
type: 'value',
splitLine: {show: false},
position: 'left',
min: 0,
max: 50,
axisLine: {
lineStyle: {
width: 2,
color: 'rgba(97, 199, 204, 0.8)', // y轴的轴线的宽度和颜色
width: 1,
color: 'rgba(76, 208, 209, 0.8)', // y轴的轴线的宽度和颜色
}
},
},
{
name: '湿度(%)',
name: '湿度(% RH)',
type: 'value',
min: 0,
max: 100,
splitLine: {show: false},
position: 'right',
axisLine: {
lineStyle: {
width: 2,
color: 'rgba(22, 95, 175, 0.8)', // y轴的轴线的宽度和颜色 #2598D6
width: 1,
color: 'rgba(92, 178, 241, 0.8)', // y轴的轴线的宽度和颜色 #2598D6
}
}
},
{
name: '', // 热应激
type: 'value',
min: 0,
max: 5,
splitLine: {show: true},
position: 'right',
offset: 35,
axisLine: {
lineStyle: {
width: 3,
color: '#EFB827', // y轴的轴线的宽度和颜色 rgba(239, 184, 39,0.5)
}
},
axisLabel: {
formatter: function(params) {
const current = heatLevel.find( item => (item.id === params));
return current.value;
},
}
}
// {
// name: '热应激',
// type: 'value',
// min: 0,
// max: 5,
// splitLine: {show: false},
// position: 'right',
// offset: -20,
// axisLine: {
// lineStyle: {
// width: 0,
// color: 'rgba(239, 184, 39,0.5)', // y轴的轴线的宽度和颜色
// }
// }
// },
],
series: [
{
......@@ -182,7 +256,7 @@ export class EnvHistoryPage implements OnInit {
type: 'line',
itemStyle: {
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,40 +267,79 @@ export class EnvHistoryPage implements OnInit {
type: 'line',
itemStyle: {
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: '热应激',
data: thi,
yAxisIndex: 1,
yAxisIndex: 2,
type: 'line',
itemStyle: {
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) {
this.tableRows = [];
param.map((item, index) => {
this.tableRows.push({
id: index + 1,
ts: this.datePipe.transform(item.ts, 'hh:mm'),
thi: item.heatStressLevel,
temp: item.temp.toFixed(2),
humi: item.humi.toFixed(1),
NH3: item.NH3.toFixed(3)
});
if (this.hasAllData(item)) {
this.tableRows.push({
id: index + 1,
ts: this.datePipe.transform(item.ts, 'hh:mm'),
thi: item.heatStressLevel,
temp: item.temp.toFixed(2),
humi: item.humi.toFixed(1),
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) {
return {
'light-color': row.id % 2 === 0
......
......@@ -5,6 +5,7 @@ import {Api} from '../../service/api';
import {Load} from '../../service/load';
import {NavController} from '@ionic/angular';
import {Network} from '@ionic-native/network/ngx';
import {EventService} from '../../service/event';
@Component({
......@@ -15,7 +16,7 @@ import {Network} from '@ionic-native/network/ngx';
export class EnvHomePage implements OnInit {
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;
......@@ -67,8 +68,15 @@ export class EnvHomePage implements OnInit {
}
}
ngOnInit() {
// ionic的生命周期函数
ionViewWillEnter() {
console.log('env-home: ionViewWillEnter');
this.init();
}
ngOnInit() {
// console.log('env-home: ngOnInit');
// this.init();
// this.ionViewWillEnter();
}
......@@ -76,11 +84,7 @@ export class EnvHomePage implements OnInit {
this.slideDidChange();
this.getData(0);
}
// ionic的生命周期函数
// ionViewWillEnter() {
// this.slideDidChange();
// this.getData(0);
// }
getData(time) {
if (this.isNetConnected()) {
......@@ -199,6 +203,7 @@ export class EnvHomePage implements OnInit {
setTimeout(() => {
this.getData(0);
event.target.complete();
this.eventService.event.emit('refreshAlarmInfo');
}, 2000);
}
......
......@@ -57,7 +57,12 @@ export class EnvLightPage implements OnInit {
private alertControlle: AlertController, public loading: Loading) {
}
ionViewWillLeave() {
clearInterval(this.commTmr);
}
ngOnInit() {
console.log('env-light: ngOnInit');
this.comm.remain = 0;
this.comm.isLoading = false;
this.commTmr = window.setInterval(() => {
......@@ -80,16 +85,13 @@ export class EnvLightPage implements OnInit {
// this.init();
// }
ionViewWillLeave() {
clearInterval(this.commTmr);
}
init() {
this.route.paramMap.subscribe(params => {
this.fieldRegionNo = params.get('fieldRegionNo');
this.operationModel = + params.get('operationModel');
this.getData(0);
});
this.getData(0);
}
getData(time) {
......
......@@ -74,10 +74,10 @@ export class EnvShowerPage implements OnInit {
public loading: Loading) {
this.param[0].fieldDeviceName = 'A区';
this.param[1].fieldDeviceName = 'B区';
this.route.paramMap.subscribe(params => {
this.fieldRegionNo = params.get('fieldRegionNo');
this.getData(0);
});
// this.route.paramMap.subscribe(params => {
// this.fieldRegionNo = params.get('fieldRegionNo');
// this.getData(0);
// });
}
ngOnInit() {
......@@ -98,10 +98,10 @@ export class EnvShowerPage implements OnInit {
this.init();
}
ionViewWillEnter() {
console.log('ionViewWillEnter_shower');
this.init();
}
// ionViewWillEnter() {
// console.log('ionViewWillEnter_shower');
// this.init();
// }
ionViewWillLeave() {
clearInterval(this.commTmr);
}
......@@ -153,6 +153,14 @@ export class EnvShowerPage implements OnInit {
}
initButtons() {
// 自控状态下 设备全部为打开状态
// if (this.controlModel === Constants.CONTROLL_SELF || this.controlModel === Constants.CONTROLL_WISDOM) {
// this.param.forEach((device) => {
// // 自控的场合 小按钮打开
// device.op = true;
// });
// }
this.param.forEach((device) => {
// 远控的场合 小按钮活性(disabled = false)
device.disabled = !(this.controlModel === Constants.CONTROLL_REMOTR);
......
......@@ -26,6 +26,7 @@ export class EnvWaterchannelPage implements OnInit {
// this.ac.queryParams.subscribe((data) => {
// this.fieldRegionNo = data.no;
// });
console.log('env-waterChannel: ngOnInit');
this.init();
}
......
import {Component, ComponentFactoryResolver, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, ActivationStart, Router, RouterOutlet} from '@angular/router';
import {Api} from '../../service/api';
import {EventService} from '../../service/event';
@Component({
selector: 'v-tabs',
......@@ -11,7 +12,7 @@ export class TabsPage implements OnInit {
@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 {
// });
this.totalAlert = 0;
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;
});
}
}
}]);
this.init();
// 监听[告警数]变化
this.eventService.event.on('refreshAlarmInfo', () => {
console.log('refreshAlarmInfo');
this.init();
});
}
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 {
this.tf.transfer({url: '/index'});
this.mqtt.getUserInfo();
if(this.saveMimaCheck === true) {
if (this.saveMimaCheck === true) {
window.localStorage.setItem('muchangUsername', this.req.name);
window.localStorage.setItem('muchangPassword', this.req.ps);
}
......
......@@ -14,7 +14,7 @@ export class Constants {
public static CONTROLL_REMOTR = 1; // 远控(手动控制)
public static CONTROLL_SELF = 2; // 自控
public static CONTROLL_WISDOM = 3; // 智慧控制
public static CONTROLL_CONFUSION = 4; // 智慧控制
public static CONTROLL_CONFUSION = 4; // 混乱
public static LOADING_SHORT = 10; // 单个开关
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 {
height: unset !important;
}
.ngx-datatable .datatable-body {
// height:303px !important;
}
.ngx-datatable .datatable-body-cell {
border-right: 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