import { Component, OnInit } from '@angular/core';
import { AppComponent } from '../../../../..';
import { FrameRequest } from '../../../../../shared/frame/frame-request';

@Component({
  selector: 'app-graduate-statistic',
  templateUrl: './graduate-statistic.component.html',
  styleUrls: ['./graduate-statistic.component.scss']
})
export class GraduateStatisticComponent implements OnInit {

  query = {
    exam_time_id: "",
    status : ""
  }

  LIST_URL = "by/byApply/listgraduate.htm";
  EXPORT_URL = "by/byApply/exportgraduate.htm"; 

  graduateList = [];

  constructor() { }

  ngOnInit() {
    this.search();
  }

  //导出毕业生统计表
  export() {
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.EXPORT_URL, {
      exam_time_id : this.query.exam_time_id === null ? "" : this.query.exam_time_id,
      status: this.query.status
    }, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("毕业生统计表导出成功");
    });
  }

  search() {
    FrameRequest.requestArray(this.LIST_URL, {
      exam_time_id : this.query.exam_time_id === null ? "" : this.query.exam_time_id,
      status: this.query.status
    }, (array) => {
      this.graduateList = array;
    });
  }
}
