Commit 7115de25 authored by yating.lin's avatar yating.lin

牛舍详情页-风机,照明

parent 60b92aeb
...@@ -6,6 +6,7 @@ import { Routes, RouterModule } from '@angular/router'; ...@@ -6,6 +6,7 @@ import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular'; import { IonicModule } from '@ionic/angular';
import { EnvFanPage } from './env-fan.page'; import { EnvFanPage } from './env-fan.page';
import {WtModule} from '../../components/wt/wt.module';
const routes: Routes = [ const routes: Routes = [
{ {
...@@ -15,12 +16,13 @@ const routes: Routes = [ ...@@ -15,12 +16,13 @@ const routes: Routes = [
]; ];
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
FormsModule, FormsModule,
IonicModule, IonicModule,
RouterModule.forChild(routes) RouterModule.forChild(routes),
], WtModule
],
declarations: [EnvFanPage] declarations: [EnvFanPage]
}) })
export class EnvFanPageModule {} export class EnvFanPageModule {}
...@@ -11,10 +11,8 @@ ...@@ -11,10 +11,8 @@
margin-bottom: 5px;">模式状态</h1> margin-bottom: 5px;">模式状态</h1>
<ion-item lines="full"> <ion-item lines="full">
<ion-label>运行模式</ion-label> <ion-label>运行模式</ion-label>
<ion-select multiple="false" cancelText="取消" okText="确认" [(ngModel)]="controlModel"> <ion-select multiple="false" cancelText="取消" okText="确认" [(ngModel)]="controlModel" disabled="true">
<ion-select-option value="0">手控模式</ion-select-option> <ion-select-option *ngFor="let option of controlModelOptions" [value]="option.modelId">{{option.modelValue}}</ion-select-option>
<ion-select-option value="1">自控模式</ion-select-option>
<ion-select-option value="2">智慧控制</ion-select-option>
</ion-select> </ion-select>
</ion-item> </ion-item>
<h1 style=" <h1 style="
...@@ -23,13 +21,9 @@ ...@@ -23,13 +21,9 @@
border-left: 5px solid #28c9bd; border-left: 5px solid #28c9bd;
line-height: 25px; line-height: 25px;
margin-bottom: 5px;">控制/状态</h1> margin-bottom: 5px;">控制/状态</h1>
<!--<ion-item *ngFor="let a of allBtns" lines="full" insert="false">--> <ion-item *ngIf="batchSwitch" lines="full" insert="false">
<!--<ion-label>一键控制</ion-label>-->
<!--<v-switch [value]="a.v" (click)="allCheck(a)" [loading]="a.d"></v-switch>-->
<!--</ion-item>-->
<ion-item lines="full">
<ion-label>一键控制</ion-label> <ion-label>一键控制</ion-label>
<v-switch [value]="false" (click)="allCheck()"></v-switch> <ion-toggle slot="end" [checked]="batchSwitch.op"></ion-toggle>
</ion-item> </ion-item>
<div> <div>
<ion-card *ngFor="let device of devices" class="card" color="white"> <ion-card *ngFor="let device of devices" class="card" color="white">
...@@ -38,7 +32,7 @@ ...@@ -38,7 +32,7 @@
</ion-card-header> </ion-card-header>
<ion-card-content> <ion-card-content>
<v-switch [value]="device.state" (click)="toggle(a)" style="float: none;display: inline-block;margin-top: 5px"></v-switch> <ion-toggle slot="middle" [checked]="device.state"></ion-toggle>
</ion-card-content> </ion-card-content>
</ion-card> </ion-card>
</div> </div>
......
...@@ -3,4 +3,10 @@ ...@@ -3,4 +3,10 @@
display: inline-block; display: inline-block;
width:28%; width:28%;
margin: 10px 10px 5px 5px; margin: 10px 10px 5px 5px;
} }
\ No newline at end of file
.btn-switch {
float: none;
display: inline-block;
margin-top: 5px
}
...@@ -10,16 +10,22 @@ import {Load} from '../../service/load'; ...@@ -10,16 +10,22 @@ import {Load} from '../../service/load';
}) })
export class EnvFanPage implements OnInit { export class EnvFanPage implements OnInit {
/* 风机 */ /* 风机 */
// 牧场区域编号
fieldRegionNo = '';
// 牧场设备类型
fieldDeviceType = '';
// 模式状态 // 模式状态
controlModel = ''; controlModel = 0;
// 设备信息
devices = [];
// 各设备信息
devices = [];
// 一鍵控制信息
batchSwitch = {op: 0, type: '风机'};
// 工作模式 controlModelOptions = [
workModeSetting = { 'workMode' : '1', {modelId: 0, modelValue: '手控模式'},
'DeviceNo' : '', {modelId: 1, modelValue: '自控模式'},
'workModeOld' : '1'}; {modelId: 2, modelValue: '智慧控制'}];
// 发送指令延时判断 // 发送指令延时判断
comm = { comm = {
...@@ -27,10 +33,6 @@ export class EnvFanPage implements OnInit { ...@@ -27,10 +33,6 @@ export class EnvFanPage implements OnInit {
isLoading : true isLoading : true
}; };
allBtns = [{v:1}]; // TODO 待删除
fieldRegionNo = '';
fieldRegionName = '';
constructor(private api: Api, private ac: ActivatedRoute, private load: Load) { } constructor(private api: Api, private ac: ActivatedRoute, private load: Load) { }
ngOnInit() { ngOnInit() {
...@@ -45,40 +47,53 @@ export class EnvFanPage implements OnInit { ...@@ -45,40 +47,53 @@ export class EnvFanPage implements OnInit {
this.load.toLoad('加载中...', false); this.load.toLoad('加载中...', false);
} }
this.api.cowshedApp.getFengJiData([{'fieldRegionNo' : this.fieldRegionNo}, (data) => { this.api.cowshedApp.getFengJiData([{'fieldRegionNo' : this.fieldRegionNo}, (data) => {
if (data) { if (data) {
this.fieldRegionNo = data.fieldRegionNo;
this.fieldDeviceType = data.fieldDeviceType;
this.controlModel = data.controlModel; this.controlModel = data.controlModel;
this.devices = data.param; this.devices = data.param;
// TODO 测试用准备数据 // TODO 测试用准备数据
this.devices.push({fieldDeviceNo: '136641005998194688', fieldDeviceName: 'X号风机组', state: 1}); this.fieldRegionNo = 'FRN136641006052720640';
this.devices.push({fieldDeviceNo: '136641005998194688', fieldDeviceName: 'Y号风机组', state: 0}); this.fieldDeviceType = '风机';
this.controlModel = 0;
this.devices = [{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'A号风机组', state: 1},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'B号风机组', state: 0},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'C号风机组', state: 1},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'D号风机组', state: 0},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'E号风机组', state: 1},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'F号风机组', state: 1}];
// 获取一键控制信息
this.allCheck(this.batchSwitch);
} }
}]); }]);
}
toggle(a) {
a.value = true;
} }
allCheck(a) { allCheck(batchSwitch) {
a.d = true; batchSwitch.type = this.fieldDeviceType;
const req = { const req = {
fieldRegionNo: this.fieldRegionNo, fieldRegionNo: this.fieldRegionNo,
fieldDeviceType: a.t, op: batchSwitch.op, // op: batchSwitch.op ? 0 : 1,
op: a.v ? 0 : 1, fieldDeviceType: batchSwitch.type,
ts: parseInt((new Date().getTime() / 1000).toString(), 10) ts: parseInt((new Date().getTime() / 1000).toString(), 10)
}; };
this.comm.remain = 120; this.comm.remain = 120;
this.api.control.controlBatchSwitch([req, (data) => { this.api.control.controlBatchSwitch([req, (data) => {
if (data.code === 1) { if (data.code === 1) {
this.getData(1); this.batchSwitch.op = data.op;
this.api.presentMsgToast(data.message); this.api.presentMsgToast(data.message);
} else { } else {
this.api.presentMsgToast(data.message); this.api.presentMsgToast(data.message);
} }
this.comm.remain = 0; this.comm.remain = 0;
a.d = false; // batchSwitch.state = false;
}]); }]);
// TODO 测试用准备数据
this.batchSwitch.op = 0;
} }
} }
...@@ -11,10 +11,8 @@ ...@@ -11,10 +11,8 @@
margin-bottom: 5px;">模式状态</h1> margin-bottom: 5px;">模式状态</h1>
<ion-item lines="full"> <ion-item lines="full">
<ion-label>运行模式</ion-label> <ion-label>运行模式</ion-label>
<ion-select multiple="false" cancelText="取消" okText="确认" [(ngModel)]="workModeSetting.workMode" [(value)]="workModeSetting.workMode" (ionChange)="workModeEvent()"> <ion-select multiple="false" cancelText="取消" okText="确认" [(ngModel)]="controlModel" disabled="true">
<ion-select-option value="0">手控模式</ion-select-option> <ion-select-option *ngFor="let option of controlModelOptions" [value]="option.modelId">{{option.modelValue}}</ion-select-option>
<ion-select-option value="1">自控模式</ion-select-option>
<ion-select-option value="2">智慧模式</ion-select-option>
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -26,7 +24,7 @@ ...@@ -26,7 +24,7 @@
margin-bottom: 5px;">时间模式</h1> margin-bottom: 5px;">时间模式</h1>
<ion-item lines="full"> <ion-item lines="full">
<i class="vo v-yue"></i> <i class="vo v-yue"></i>
<span style="margin-left: 60px;font-size:15px"> 开启时间 {{lightMode.openTime}}<br><br>关闭时间 {{lightMode.closeTime}}</span> <span style="margin-left: 60px;font-size:15px"> 开启时间 {{on}}<br><br>关闭时间 {{off}}</span>
</ion-item> </ion-item>
<h1 style=" <h1 style="
font-size: 16px; font-size: 16px;
...@@ -34,10 +32,9 @@ ...@@ -34,10 +32,9 @@
border-left: 5px solid #28c9bd; border-left: 5px solid #28c9bd;
line-height: 25px; line-height: 25px;
margin-bottom: 5px;">控制/状态</h1> margin-bottom: 5px;">控制/状态</h1>
<ion-item *ngFor="let a of allBtns" lines="full" insert="false" > <ion-item *ngIf="batchSwitch" lines="full" insert="false">
<!--<v-switch [value]="a.value" (click)="toggle(a)" [loading]="a.loading"></v-switch>--> <ion-label>一键控制</ion-label>
<ion-label>一键控制{{a.l}}</ion-label> <ion-toggle slot="end" [checked]="batchSwitch.op"></ion-toggle>
<v-switch [value]="a.v" (click)="allCheck(a)" [loading]="a.d"></v-switch>
</ion-item> </ion-item>
<div> <div>
...@@ -52,4 +49,4 @@ ...@@ -52,4 +49,4 @@
</ion-card> </ion-card>
</div> </div>
</ion-content> </ion-content>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {Api} from '../../service/api'; import {Api} from '../../service/api';
import {ActivatedRoute} from '@angular/router';
import {Load} from '../../service/load';
@Component({ @Component({
selector: 'v-env-light', selector: 'v-env-light',
...@@ -8,9 +10,35 @@ import {Api} from '../../service/api'; ...@@ -8,9 +10,35 @@ import {Api} from '../../service/api';
}) })
export class EnvLightPage implements OnInit { export class EnvLightPage implements OnInit {
workModeSetting = { 'workMode' : '1', /* 照明 */
'DeviceNo' : '', // 牧场区域编号
'workModeOld' : '1'}; fieldRegionNo = '';
// 牧场设备类型
fieldDeviceType = '';
// 模式状态
controlModel = 0;
// 开始日期
startDate = '';
// 结束日期
stopDate = '';
// 开启时间
on = '';
// 关闭时间
off = '';
// 各设备信息
devices = [];
// 一鍵控制信息
batchSwitch = {op: 0, type: '照明'};
controlModelOptions = [
{modelId: 0, modelValue: '手控模式'},
{modelId: 1, modelValue: '自控模式'},
{modelId: 2, modelValue: '智慧控制'}];
// workModeSetting = { 'workMode' : '1',
// 'DeviceNo' : '',
// 'workModeOld' : '1'};
// 发送指令延时判断 // 发送指令延时判断
comm = { comm = {
...@@ -18,59 +46,99 @@ export class EnvLightPage implements OnInit { ...@@ -18,59 +46,99 @@ export class EnvLightPage implements OnInit {
isLoading : true isLoading : true
}; };
allBtns = [{v:1}]; // allBtns = [{v: 1}];
fieldRegionNo = ''; // fieldRegionNo = '';
fieldRegionName = ''; // fieldRegionName = '';
lightMode = { lightMode = {
name:'July', name: 'July',
openTime:'19:00', openTime: '19:00',
closeTime:'05:00'}; closeTime: '05:00'};
workarea = { // workarea = {
param: [ // param: [
{ // {
name: '1号组', // name: '1号组',
runningState:true, // runningState: true,
}, // },
{ // {
name: '2号组', // name: '2号组',
runningState:false, // runningState:false,
} // }
] // ]
}; // };
constructor(private api: Api,) { } constructor(private api: Api, private ac: ActivatedRoute, private load: Load) { }
ngOnInit() { ngOnInit() {
this.ac.queryParams.subscribe((data) => {
this.fieldRegionNo = data.no;
});
this.getData(0);
} }
toggle(a) { toggle(a) {
console.log("123"); console.log("123");
} }
allCheck(a) { getData(time) {
a.d = true; if (time) {
this.load.toLoad('加载中...', false);
}
this.api.cowshedApp.getZhaoMingData([{'fieldRegionNo' : this.fieldRegionNo}, (data) => {
if (data) {
this.fieldRegionNo = data.fieldRegionNo;
this.fieldDeviceType = data.fieldDeviceType;
this.controlModel = data.controlModel;
this.startDate = data.startDate;
this.stopDate = data.stopDate;
this.on = data.on;
this.off = data.off;
this.devices = data.param;
// TODO 测试用准备数据
this.fieldRegionNo = 'FRN136641006052720640';
this.fieldDeviceType = '照明';
this.controlModel = 2;
this.on = '19:00';
this.off = '05:00';
this.devices = [{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'A号照明组', state: 1},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'B号照明组', state: 0},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'C号照明组', state: 1},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'D号照明组', state: 0},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'E号照明组', state: 1},
{fieldDeviceNo: '136641005998194688', fieldDeviceName: 'F号照明组', state: 1}];
// 获取一键控制信息
this.allCheck(this.batchSwitch);
}
}]);
}
allCheck(batchSwitch) {
batchSwitch.type = this.fieldDeviceType;
const req = { const req = {
fieldRegionNo: this.fieldRegionNo, fieldRegionNo: this.fieldRegionNo,
op: a.v ? 0 : 1, op: batchSwitch.op, // op: batchSwitch.op ? 0 : 1,
type: a.t, fieldDeviceType: batchSwitch.type,
ts: parseInt((new Date().getTime() / 1000).toString(), 10) ts: parseInt((new Date().getTime() / 1000).toString(), 10)
}; };
this.comm.remain = 120; this.comm.remain = 120;
this.api.control.controlBatchSwitch([req, (data) => { this.api.control.controlBatchSwitch([req, (data) => {
if (data.code === 1) { if (data.code === 1) {
this.getData(1); this.batchSwitch.op = data.op;
this.api.presentMsgToast(data.message); this.api.presentMsgToast(data.message);
} else { } else {
this.api.presentMsgToast(data.message); this.api.presentMsgToast(data.message);
} }
this.comm.remain = 0; this.comm.remain = 0;
a.d = false; // batchSwitch.state = false;
}]); }]);
// TODO 测试用准备数据
this.batchSwitch.op = 0;
} }
getData(a){
}
} }
...@@ -43,6 +43,7 @@ export class Api { ...@@ -43,6 +43,7 @@ export class Api {
// 获取喷淋信息 // 获取喷淋信息
getPenLinData: (data) => this.trans('post', '/cowshedApp/getPenLinData', data), getPenLinData: (data) => this.trans('post', '/cowshedApp/getPenLinData', data),
// 获取照明信息 // 获取照明信息
getZhaoMingData: (data) => this.trans('post', '/cowshedApp/getZhaoMingData', data),
// 获取水槽信息 // 获取水槽信息
}; };
......
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