Commit 072dfe3d authored by yating.lin's avatar yating.lin

整理按钮活性非活性控制

parent ee5a8176
...@@ -57,9 +57,9 @@ const routes: Routes = [ ...@@ -57,9 +57,9 @@ const routes: Routes = [
component: EnvDetailPage, component: EnvDetailPage,
children: [ children: [
{path: 'fan', component: EnvFanPage}, {path: 'fan', component: EnvFanPage},
{path: 'shower/:fieldRegionNo/:operationModel', component: EnvShowerPage}, {path: 'shower/:fieldRegionNo/:operationModel/:online', component: EnvShowerPage},
{path: 'light/:fieldRegionNo/:operationModel', component: EnvLightPage}, {path: 'light/:fieldRegionNo/:operationModel/:online', component: EnvLightPage},
{path: 'waterchannel/:fieldRegionNo/:operationModel', component: EnvWaterchannelPage}, {path: 'waterchannel/:fieldRegionNo/:operationModel/:online', component: EnvWaterchannelPage},
{path: '', redirectTo: 'fan', pathMatch : 'prefix'}, {path: '', redirectTo: 'fan', pathMatch : 'prefix'},
] ]
......
...@@ -132,7 +132,8 @@ export class EnvAlarmPage implements OnInit { ...@@ -132,7 +132,8 @@ export class EnvAlarmPage implements OnInit {
setTimeout(() => { setTimeout(() => {
this.init(); this.init();
event.target.complete(); event.target.complete();
// 通知刷新告警barge
this.eventService.event.emit('refreshAlarmInfo');
}, 1500); }, 1500);
} }
......
...@@ -106,7 +106,7 @@ export class EnvDetailPage implements OnInit { ...@@ -106,7 +106,7 @@ export class EnvDetailPage implements OnInit {
this.setInHouseInfo(data.inHouse); this.setInHouseInfo(data.inHouse);
this.initLayout(environmentConfigJson); this.initLayout(environmentConfigJson);
this.setConfusionModelControll(); this.setInHouseDisable();
} }
}]); }]);
} }
...@@ -129,9 +129,9 @@ export class EnvDetailPage implements OnInit { ...@@ -129,9 +129,9 @@ export class EnvDetailPage implements OnInit {
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 + '/' + this.item.online;
this.lightLink = '/env-detail/light/' + this.fieldRegionNo + '/' + this.item.operationModel; this.lightLink = '/env-detail/light/' + this.fieldRegionNo + '/' + this.item.operationModel + '/' + this.item.online;
this.waterchannelLink = '/env-detail/waterchannel/' + this.fieldRegionNo + '/' + this.item.operationModel; this.waterchannelLink = '/env-detail/waterchannel/' + this.fieldRegionNo + '/' + this.item.operationModel + '/' + this.item.online;
if (this.item) { if (this.item) {
this.item.heatStressColor = this.item.heatStressLevel === 0 ? '#62C7CC' : this.item.heatStressColor = this.item.heatStressLevel === 0 ? '#62C7CC' :
...@@ -256,9 +256,14 @@ export class EnvDetailPage implements OnInit { ...@@ -256,9 +256,14 @@ export class EnvDetailPage implements OnInit {
// }, 2000); // }, 2000);
// } // }
setConfusionModelControll() { setInHouseDisable() {
// 混乱模式 // 以下场合 非活性
if (+this.item.operationModel === Constants.CONTROLL_CONFUSION) { // 1.离线 2.在线&现控 3.在线&混乱
const online = +this.item.online; // 0-离线,1-在线
const operationModel = +this.item.operationModel; // 0-现控,1-远控,4-混乱
if (online === 0 ||
(online === 1 && operationModel === 0) ||
(online === 1 && operationModel === 4)) {
this.inHouseDisabled = true; this.inHouseDisabled = true;
} else { } else {
this.inHouseDisabled = false; this.inHouseDisabled = false;
......
...@@ -20,6 +20,7 @@ export class EnvFanPage implements OnInit { ...@@ -20,6 +20,7 @@ export class EnvFanPage implements OnInit {
// 牧场区域编号 // 牧场区域编号
fieldRegionNo = ''; fieldRegionNo = '';
operationModel = 0; operationModel = 0;
online = 1;
// 牧场设备类型 // 牧场设备类型
fieldDeviceType = ''; fieldDeviceType = '';
// 模式状态 // 模式状态
...@@ -52,8 +53,8 @@ export class EnvFanPage implements OnInit { ...@@ -52,8 +53,8 @@ export class EnvFanPage implements OnInit {
if (data && data.fieldRegionNo !== undefined && data.fieldRegionNo !== null && data.fieldRegionNo !== '') { if (data && data.fieldRegionNo !== undefined && data.fieldRegionNo !== null && data.fieldRegionNo !== '') {
this.fieldRegionNo = data.fieldRegionNo; this.fieldRegionNo = data.fieldRegionNo;
this.operationModel = data.operationModel; this.operationModel = data.operationModel;
this.online = data.online;
} }
}); });
} }
...@@ -120,23 +121,14 @@ export class EnvFanPage implements OnInit { ...@@ -120,23 +121,14 @@ export class EnvFanPage implements OnInit {
}); });
this.enabled = data.enabled; this.enabled = data.enabled;
this.initButtons(); this.initButtonOpen();
this.setConfusionModelControll(); this.initButtonDisable();
this.resetButtons();
} }
this.load.offLoad(); this.load.offLoad();
}]); }]);
} }
initButtons() { initButtonOpen() {
// 各个按钮表示状态
// 一键控制 远控的场合,活性(Disabled = false)
const allDisabled = !(this.controlModel === Constants.CONTROLL_REMOTR);
this.batchSwitch.disabled = allDisabled;
this.devices.forEach((device) => {
device.disabled = allDisabled;
});
// [一键控制]按钮(默认: 开启) // [一键控制]按钮(默认: 开启)
// 当任意子按钮[关闭]的状态下: 关闭 以外:开启 // 当任意子按钮[关闭]的状态下: 关闭 以外:开启
this.batchSwitch.op = true; this.batchSwitch.op = true;
...@@ -147,20 +139,58 @@ export class EnvFanPage implements OnInit { ...@@ -147,20 +139,58 @@ export class EnvFanPage implements OnInit {
}); });
} }
resetButtons() { initButtonDisable() {
console.log('reset buttons'); // 各个按钮表示状态
let batchDisable = false;
let oneDisable = false;
this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => { this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.inHouse) { if (data && data.inHouse) {
const inHouse = data.inHouse.inHouse;
const isInHouse = inHouse === 0; // 离舍-0 在舍-1 const online = +this.online; // 0-离线,1-在线
// 离舍的场合,配置页被勾选: 所有按钮非活性 const operationModel = +this.operationModel; // 0-现控,1-远控,4-混乱
if (isInHouse && this.enabled) { const inHouse = data.inHouse.inHouse ? +data.inHouse.inHouse : 0; // 0-离舍,1-在舍
console.log('离舍时,开关非活性'); const enable = +this.enabled; // 配置页打钩
this.batchSwitch.disabled = isInHouse; const controlModel = this.controlModel;
this.devices.forEach((device) => {
device.disabled = isInHouse; // 1.离线 2.在线&现控 3.在线&混乱
}); if (online === 0 ||
(online === 1 && operationModel === 0) ||
(online === 1 && operationModel === 4)) {
batchDisable = true;
oneDisable = true;
// 在线+远控
} else if (online === 1 && operationModel === 1) {
// 4.在线+远控+离舍+配置页勾选
if (inHouse === 0 && enable === 1) {
batchDisable = true;
oneDisable = true;
} else if (inHouse === 0 && enable === 0) {
// 5.在线+远控+离舍+配置页未勾选+手控
if (controlModel === 1) {
batchDisable = false;
oneDisable = false;
// 6.在线+远控+离舍+配置页未勾选+自控
} else if (controlModel === 2) {
batchDisable = true;
oneDisable = true;
}
} else if (inHouse === 1) {
// 7.在线+远控+在舍+手控
if (controlModel === 1) {
batchDisable = false;
oneDisable = false;
// 8.在线+远控+在舍+自控
} else if (controlModel === 2) {
batchDisable = true;
oneDisable = true;
}
}
} }
this.batchSwitch.disabled = batchDisable;
this.devices.forEach((device) => {
device.disabled = oneDisable;
});
} }
this.loading.closeLoading(); this.loading.closeLoading();
}]); }]);
...@@ -265,14 +295,4 @@ export class EnvFanPage implements OnInit { ...@@ -265,14 +295,4 @@ export class EnvFanPage implements OnInit {
// this.comm.remain = 0; // this.comm.remain = 0;
}]); }]);
} }
setConfusionModelControll() {
// 混乱模式
if (+this.operationModel === Constants.CONTROLL_CONFUSION) {
this.batchSwitch.disabled = true;
this.devices.forEach((device) => {
device.disabled = true;
});
}
}
} }
...@@ -225,7 +225,7 @@ export class EnvHomePage implements OnInit { ...@@ -225,7 +225,7 @@ export class EnvHomePage implements OnInit {
} }
toControl(one) { toControl(one) {
const query = '/env-detail?fieldRegionNo=' + one.fieldRegionNo + '&operationModel=' + one.operationModel; const query = '/env-detail?fieldRegionNo=' + one.fieldRegionNo + '&operationModel=' + one.operationModel + '&online=' + one.online;
this.tf.transfer({ this.tf.transfer({
url: '/' + one.url, url: '/' + one.url,
query: query, query: query,
......
...@@ -18,6 +18,7 @@ export class EnvLightPage implements OnInit { ...@@ -18,6 +18,7 @@ export class EnvLightPage implements OnInit {
// 牧场区域编号 // 牧场区域编号
fieldRegionNo = ''; fieldRegionNo = '';
operationModel = 0; operationModel = 0;
online = 1;
// 牧场设备类型 // 牧场设备类型
fieldDeviceType = ''; fieldDeviceType = '';
// 模式状态 // 模式状态
...@@ -97,7 +98,8 @@ export class EnvLightPage implements OnInit { ...@@ -97,7 +98,8 @@ export class EnvLightPage implements OnInit {
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.online = +params.get('online');
this.getData(0); this.getData(0);
}); });
...@@ -125,43 +127,14 @@ export class EnvLightPage implements OnInit { ...@@ -125,43 +127,14 @@ export class EnvLightPage implements OnInit {
}); });
this.enabled = data.enabled; this.enabled = data.enabled;
this.initButtons(); this.initButtonOpen();
this.setConfusionModelControll(); this.initButtonDisable();
this.resetButtons();
} }
this.load.offLoad(); this.load.offLoad();
}]); }]);
} }
initButtons() { initButtonOpen() {
if (this.controlModel === Constants.CONTROLL_REMOTR) {
// 远控(手控) 的场合
// 一键控制: 活性
this.batchSwitch.disabled = false;
this.devices.forEach((device) => {
device.disabled = false;
});
} else {
// 其他
// 一键控制: 非活性
this.batchSwitch.disabled = true;
}
if (this.controlModel === Constants.CONTROLL_REMOTR) {
// 远控 的场合
// 子按钮: 活性
this.devices.forEach((device) => {
device.disabled = false;
});
} else {
// 其他
// 子按钮: 非活性
this.devices.forEach((device) => {
device.disabled = true;
});
}
// 设置[一键控制]按钮(默认: 开启) // 设置[一键控制]按钮(默认: 开启)
// 当任意子按钮[关闭]的状态下: 关闭 以外:开启 // 当任意子按钮[关闭]的状态下: 关闭 以外:开启
this.batchSwitch.op = true; this.batchSwitch.op = true;
...@@ -172,19 +145,58 @@ export class EnvLightPage implements OnInit { ...@@ -172,19 +145,58 @@ export class EnvLightPage implements OnInit {
}); });
} }
resetButtons() { initButtonDisable() {
// 各个按钮表示状态
let batchDisable = false;
let oneDisable = false;
this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => { this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.inHouse) { if (data && data.inHouse) {
const inHouse = data.inHouse.inHouse;
const isInHouse = inHouse === 0; // 离舍-0 在舍-1 const online = +this.online; // 0-离线,1-在线
// 离舍的场合,配置页被勾选: 所有按钮非活性 const operationModel = +this.operationModel; // 0-现控,1-远控,4-混乱
if (isInHouse && this.enabled) { const inHouse = data.inHouse.inHouse ? +data.inHouse.inHouse : 0; // 0-离舍,1-在舍
console.log('离舍时,开关非活性'); const enable = +this.enabled; // 配置页打钩
this.batchSwitch.disabled = isInHouse; const controlModel = this.controlModel;
this.devices.forEach((device) => {
device.disabled = isInHouse; // 1.离线 2.在线&现控 3.在线&混乱
}); if (online === 0 ||
(online === 1 && operationModel === 0) ||
(online === 1 && operationModel === 4)) {
batchDisable = true;
oneDisable = true;
// 在线+远控
} else if (online === 1 && operationModel === 1) {
// 4.在线+远控+离舍+配置页勾选
if (inHouse === 0 && enable === 1) {
batchDisable = true;
oneDisable = true;
} else if (inHouse === 0 && enable === 0) {
// 5.在线+远控+离舍+配置页未勾选+手控
if (controlModel === 1) {
batchDisable = false;
oneDisable = false;
// 6.在线+远控+离舍+配置页未勾选+自控
} else if (controlModel === 2) {
batchDisable = true;
oneDisable = true;
}
} else if (inHouse === 1) {
// 7.在线+远控+在舍+手控
if (controlModel === 1) {
batchDisable = false;
oneDisable = false;
// 8.在线+远控+在舍+自控
} else if (controlModel === 2) {
batchDisable = true;
oneDisable = true;
}
}
} }
this.batchSwitch.disabled = batchDisable;
this.devices.forEach((device) => {
device.disabled = oneDisable;
});
} }
this.loading.closeLoading(); this.loading.closeLoading();
}]); }]);
...@@ -292,14 +304,4 @@ export class EnvLightPage implements OnInit { ...@@ -292,14 +304,4 @@ export class EnvLightPage implements OnInit {
btn.loading = false; btn.loading = false;
}]); }]);
} }
setConfusionModelControll() {
// 混乱模式
if (+this.operationModel === Constants.CONTROLL_CONFUSION) {
this.batchSwitch.disabled = true;
this.devices.forEach((device) => {
device.disabled = true;
});
}
}
} }
...@@ -28,6 +28,7 @@ export class EnvShowerPage implements OnInit { ...@@ -28,6 +28,7 @@ export class EnvShowerPage implements OnInit {
// 牧场区域编号 // 牧场区域编号
fieldRegionNo = ''; fieldRegionNo = '';
operationModel = 0; operationModel = 0;
online = 1;
// 牧场设备类型 // 牧场设备类型
fieldDeviceType = ''; fieldDeviceType = '';
// 模式状态 // 模式状态
...@@ -119,7 +120,8 @@ export class EnvShowerPage implements OnInit { ...@@ -119,7 +120,8 @@ export class EnvShowerPage implements OnInit {
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.online = +params.get('online');
this.getData(0); this.getData(0);
}); });
} }
...@@ -152,9 +154,7 @@ export class EnvShowerPage implements OnInit { ...@@ -152,9 +154,7 @@ export class EnvShowerPage implements OnInit {
this.enabled = data.enabled; this.enabled = data.enabled;
this.initButtons(); this.initButtonDisable();
this.setConfusionModelControll();
this.resetButtons();
} }
this.load.offLoad(); this.load.offLoad();
}]); }]);
...@@ -167,7 +167,7 @@ export class EnvShowerPage implements OnInit { ...@@ -167,7 +167,7 @@ export class EnvShowerPage implements OnInit {
return param; return param;
} }
initButtons() { initButtonDisable() {
// 自控状态下 设备全部为打开状态 // 自控状态下 设备全部为打开状态
// if (this.controlModel === Constants.CONTROLL_SELF || this.controlModel === Constants.CONTROLL_WISDOM) { // if (this.controlModel === Constants.CONTROLL_SELF || this.controlModel === Constants.CONTROLL_WISDOM) {
// this.param.forEach((device) => { // this.param.forEach((device) => {
...@@ -175,11 +175,34 @@ export class EnvShowerPage implements OnInit { ...@@ -175,11 +175,34 @@ export class EnvShowerPage implements OnInit {
// device.op = true; // device.op = true;
// }); // });
// } // }
// 各个按钮表示状态
let oneDisable = false;
this.api.cowshedApp.getRealDataByFieldRegionNo([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.inHouse) {
this.param.forEach((device) => { const online = +this.online; // 0-离线,1-在线
// 远控的场合 小按钮活性(disabled = false) const operationModel = +this.operationModel; // 0-现控,1-远控,4-混乱
device.disabled = !(this.controlModel === Constants.CONTROLL_REMOTR); const inHouse = data.inHouse.inHouse ? +data.inHouse.inHouse : 0; // 0-离舍,1-在舍
}); const enable = +this.enabled; // 配置页打钩
const controlModel = this.controlModel;
// 5.在线+远控+离舍+配置页未勾选+手控 或者
// 7.在线+远控+在舍+手控 的场合 活性
// 以外 非活性
// 1.离线 2.在线&现控 3.在线&混乱
if ((online === 1 && operationModel === 1 && inHouse === 0 && enable === 0 && controlModel === 1) ||
(online === 1 && operationModel === 1 && inHouse === 1 && controlModel === 1)) {
oneDisable = false;
} else {
oneDisable = true;
}
this.param.forEach((device) => {
// 远控的场合 小按钮活性(disabled = false)
device.disabled = oneDisable;
});
}
this.loading.closeLoading();
}]);
} }
resetButtons() { resetButtons() {
......
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