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

牛舍详情页-风机,照明

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