import { FlexTableComponent } from '../../../../../shared/common/FlexTable.component';
import { Component, OnInit, ViewChild } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal/bs-modal.service';
import { FrameRequest } from '../../../../../shared/frame/frame-request';
import 'ztree';
import * as _ from 'lodash';
import { Validators, FormBuilder } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';
import { AppComponent } from '../../../../../app.component';
declare var $: any;

@Component({
  selector: 'app-kw-layout-monitor',
  templateUrl: './kw-layout-monitor.component.html',
  styleUrls: ['./kw-layout-monitor.component.scss']
})

export class KwLayoutMonitorComponent extends FlexTableComponent implements OnInit {

  public query = {
    exam_time_id: "",
    exam_area_id: "",
    query: "",
  };

  QUERY_URL = "kw/kwLayoutMonitor/page.htm";


  agentArray = [];
  examTimeIdArray = [];
  masterSchoolList=[];

  constructor(
    public bsModalService: BsModalService,
    fb: FormBuilder
  ) {
    super();
    this.formModel = fb.group({
      id: [null],
    });
  }

  ngOnInit() {
    FrameRequest.requestArray('pl/plExamTime/listtime.htm', {}, (array) => {
      this.examTimeIdArray = array;
    });
    //主考学校
    FrameRequest.requestArray("cf/cfOrganization/list.htm?", {org_type: 4,status:1}, (arrary) => {
      this.masterSchoolList = arrary;
    });
    let this_ = this;
    setTimeout(() => {
        FrameRequest.requestMap("kw/kwLayout/initdata.htm", {}, (map)=>{
            if (map["exam_time_id"]) {
                this_.query.exam_time_id = map["exam_time_id"];
                this.framePager.reload();
            }
        });
    }, 800);
  }

  search(param) {
    if (!this.query.exam_time_id) {
      this.query.exam_time_id = "";
    }
    if (!this.query.exam_area_id) {
      this.query.exam_area_id = "";
    }
    param.exam_time_id=this.query.exam_time_id;
    param.exam_area_id=this.query.exam_area_id;
    param.query=this.query.query;
  }

  formatRow(status) {
    if (status == 1) {
      return "已编排";
    } else {
      return "未编排";
    }

  }
}
