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-sum-bag-area',
  templateUrl: './kw-sum-bag-area.component.html',
  styleUrls: ['./kw-sum-bag-area.component.scss']
})

export class KwSumBagAreaComponent extends FlexTableComponent implements OnInit {

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

  QUERY_URL = "kw/kwLayoutExamAreaBagSum/page.htm";
  QUERY_ALL_URL = "kw/kwLayoutExamAreaBagSum/allList.htm";
  DELETE_URL = "";
  GET_URL = "kw/kwLayoutExamAreaBagSum/get.htm";
  ADD_URL = "";
  EDIT_URL = "";

  agentArray = []
  examTimeIdArray = []

  list = []

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

    FrameRequest.requestArray('kw/kwExamPoint/listAll.htm', {}, (array) => {
      this.agentArray = array;
    });

    FrameRequest.requestArray('pl/plExamTime/listtime.htm', {}, (array) => {
      this.examTimeIdArray = array;

      // if(this.examTimeIdArray.length > 0){
      //   this.query.exam_time_id = this.examTimeIdArray[0].id;

      // }
    });
  }

  queryAllList(){
    if(!String(this.query.exam_time_id)){
        AppComponent.alert({title:"信息提示",text:"请选择批次!"});
        return;
    }
    FrameRequest.requestArray(this.QUERY_ALL_URL, this.query, (array) => {
      this.list = array;
    });
  }

  exportPdf(){
    FrameRequest.download("kw/kwLayoutExamAreaBagSum/exportPdf.htm",this.query);
  }
 
}
