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

整理按钮活性非活性控制

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