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

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

  constructor(private api: Api, private ac: ActivatedRoute, private load: Load) { }
  item = {fieldRegionNo: ''};

  ngOnInit() {
    this.ac.queryParams.subscribe((data) => {
      this.item.fieldRegionNo = data.no;
    });
    this.getData(0);
  }

  getData(time) {
    if (time) {
      this.load.toLoad('加载中...', false);
    }
    this.api.cowshedApp.getRealDataByFieldRegionNo([{'fieldRegionNo' : this.item.fieldRegionNo}, (data) => {

      if (data) {
        this.item = data;
      }
    }]);
  }

}
