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

微调

parent 9ca886ba
......@@ -24,7 +24,7 @@
<ion-item *ngIf="batchSwitch" lines="full" insert="false">
<ion-label>一键控制</ion-label>
<ion-toggle slot="end" [checked]="batchSwitch.op === 1" [disabled]="batchSwitch.disabled"
[(ngModel)]="batchSwitch.op" (load)="batchSwitch.load" (click)="allCheck(batchSwitch)"></ion-toggle>
(load)="batchSwitch.load" (ionChange)="toggle(batchSwitch)"></ion-toggle>
<!--<v-switch (click)="allCheck(batchSwitch)" [value]="batchSwitch.op" [disabled]="batchSwitch.disabled" [loading]="batchSwitch.load"></v-switch>-->
</ion-item>
<div>
......@@ -36,9 +36,9 @@
<ion-card-content class="cardContent">
<!--<ion-toggle slot="middle" [checked]="device.state"></ion-toggle>-->
<ion-toggle class="btn-switch" *ngIf="device.alarm === 0" [checked]="batchSwitch.op === 1" [disabled]="device.disabled"
[(ngModel)]="device.state" (click)="deviceCheck(device)"></ion-toggle>
(click)="deviceCheck(device)"></ion-toggle>
<ion-toggle class="btn-switch" *ngIf="device.alarm === 1" [checked]="batchSwitch.op === 1" [disabled]="device.disabled" color="danger"
[(ngModel)]="device.state" (click)="deviceCheck(device)"></ion-toggle>
(click)="deviceCheck(device)"></ion-toggle>
<!--<v-switch *ngIf="device.alarm === 0" class="btn-switch" (click)="deviceCheck(device)" [value]="device.state" [disabled]="device.disabled" [loading]="device.load"></v-switch>-->
<!--<v-switch *ngIf="device.alarm === 1" class="btn-switch" color="danger" (click)="deviceCheck(device)" [value]="device.state" [disabled]="device.disabled" [loading]="device.load"></v-switch>-->
</ion-card-content>
......
......@@ -21,7 +21,7 @@ export class EnvFanPage implements OnInit {
// 各设备信息
devices = [];
// 一鍵控制按钮
batchSwitch = {op: undefined, type: undefined, load: undefined, disabled: undefined};
batchSwitch = {op: undefined, type: undefined, load: false, disabled: undefined};
controlModelOptions = [
{modelId: 0, modelValue: '手控模式'},
......@@ -50,14 +50,14 @@ export class EnvFanPage implements OnInit {
this.load.toLoad('加载中...', false);
}
this.api.cowshedApp.getFengJiData([{fieldRegionNo: this.fieldRegionNo}, (data) => {
if (data && data.fieldRegionNo) {
this.fieldRegionNo = data.fieldRegionNo;
this.fieldDeviceType = data.fieldDeviceType;
this.controlModel = data.controlModel;
this.devices = data.param;
this.initButtons();
}
// if (data && data.fieldRegionNo) {
// this.fieldRegionNo = data.fieldRegionNo;
// this.fieldDeviceType = data.fieldDeviceType;
// this.controlModel = data.controlModel;
// this.devices = data.param;
//
// this.initButtons();
// }
// START--------------------------------------------------------------------
// TODO 测试用准备数据
......@@ -75,7 +75,8 @@ export class EnvFanPage implements OnInit {
}
initButtons() {
// [手控(0)]的状态下:活性(false) 以外:非活性(true)
// 各个按钮表示状态
// [手控(0)]的状态:活性(false) 以外:非活性(true)
const allDisabled = this.controlModel === 0 ? false : true;
this.batchSwitch.disabled = allDisabled;
this.devices.forEach((device, i) => {
......@@ -92,6 +93,39 @@ export class EnvFanPage implements OnInit {
});
}
toggle(btn) {
// a.loading = true;
this.opChangeComfirm(btn);
}
async opChangeComfirm(btn) {
const msgHeader = this.fieldDeviceType;
const msgOp = btn.op ? '关闭' : '打开';
const alert = await this.alertControlle.create({
header: '请注意',
// subHeader: '确定要' + msgOp + ' ' + msgHeader + ' 这个泵吗?',
message: '所有' + msgHeader + '即将' + msgOp + ',要继续吗?',
mode: 'ios',
buttons: [
{
text: '取消',
cssClass: 'width: 40%',
handler: () => {
this.batchSwitch.op = btn.op === 0 ? 1 : 0;
}
}, {
text: '确定',
cssClass: 'width: 40%',
handler: () => {
this.allCheck(btn);
}
}
]
});
await alert.present();
}
// 一键控制
allCheck(btn) {
btn.load = true;
......@@ -105,20 +139,17 @@ export class EnvFanPage implements OnInit {
// 一键开启设备
this.api.control.controlCowedBatchSwitch([req, (data) => {
if (data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
// if (data.code === 1) {
// // 子按钮状态
// this.devices.forEach((device, i) => {
// device.state = btn.op ? 0 : 1;
// });
// }
this.api.presentMsgToast(data.message);
this.getData(0);
this.comm.remain = 0;
btn.load = false;
}]);
// 子按钮状态
this.devices.forEach((device, i) => {
device.state = btn.op ? 0 : 1;
});
}
// 单个设备控制
......@@ -132,12 +163,14 @@ export class EnvFanPage implements OnInit {
};
this.comm.remain = 20;
this.api.control.controlCowedSwitch([req, (data) => {
if (data && data.code === 1) {
this.getData(1);
this.api.presentMsgToast(data.message);
} else {
this.api.presentMsgToast(data.message);
}
// if (data && data.code === 1) {
// this.getData(0);
// this.api.presentMsgToast(data.message);
// } else {
// this.api.presentMsgToast(data.message);
// }
this.getData(0);
this.api.presentMsgToast(data.message);
this.comm.remain = 0;
// btn.load = false;
}]);
......
......@@ -47,6 +47,10 @@ export class EnvShowerPage implements OnInit {
constructor(private api: Api, private ac: ActivatedRoute, private load: Load, private route: ActivatedRoute) { }
ngOnInit() {
this.init();
}
init() {
this.route.paramMap.subscribe(params => {this.fieldRegionNo = params.get('fieldRegionNo'); });
this.getData(0);
}
......
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