import { Component, OnInit } from '@angular/core';
import {Api} from '../../service/api';

@Component({
  selector: 'v-env-fan',
  templateUrl: './env-fan.page.html',
  styleUrls: ['./env-fan.page.scss'],
})
export class EnvFanPage implements OnInit {

  // 工作模式
  workModeSetting = {  'workMode' : '1',
      'DeviceNo' : '',
      'workModeOld' : '1'};

    // 发送指令延时判断
    comm = {
        remain : 20,
        isLoading : true
    };

    allBtns = [{v:1}];
    fieldRegionNo = '';
    fieldRegionName = '';

    workarea = {
        param: [
        {
            name: '1号风机组',
            runningState:true,  //是否开启
        },
        {
            name: '2号风机组',
            runningState:false,
        }
        ]
    };

    constructor(private api: Api,) { }

    ngOnInit() {
    }

    toggle(a) {
        console.log("123");
    }

    allCheck(a) {
        a.d = true;
        const req = {
            fieldRegionNo: this.fieldRegionNo,
            op: a.v ? 0 : 1,
            type: a.t,
            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.api.presentMsgToast(data.message);
            } else {
                this.api.presentMsgToast(data.message);
            }
            this.comm.remain = 0;
            a.d = false;
        }]);
    }

    getData(a){

    }
}
