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

@Component({
  selector: 'app-pay-bill-statis',
  templateUrl: './pay-bill-statis.html',
  styleUrls: ['./pay-bill-statis.scss']
})

export class PayBillStatisComponent extends FlexTableComponent implements OnInit {

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

  };

  QUERY_URL = "pay/payBillStatis/page.htm";
  QUERY_ALL_URL = "pay/payBillStatis/allList.htm";
  DELETE_URL = "";
  GET_URL = "pay/payBillStatis/get.htm";
  ADD_URL = "";
  EDIT_URL =  "";

  agentArray = []
  examTimeIdArray = []
  allList = []

  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;

      // }
    });

    FrameRequest.requestArray(this.QUERY_ALL_URL, this.query, (array) => {
        this.allList = array;
      });
    
  }

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

  exportPdf(){
    FrameRequest.download("pay/payBillStatis/exportPdf.htm",this.query);
  }
}
