import {Component, OnInit, ViewChild} from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import {FramePageComponent} from '../../../../frame/core/FramePageComponent';
import {BsModalService} from 'ngx-bootstrap';
import {ActivatedRoute, Router} from '@angular/router';
import {StdMaterialRefuseComponent} from '../../material/std-material-refuse/std-material-refuse.component';
import {MsgService} from '../../../../../core/msg/msg.service';
import {AjaxService} from '../../../../../core/ajax/ajax.service';
import {FrameService} from '../../../../../core/frame/frame.service';
import {UploaderComponent} from '../../../../../core/uploader/uploader.component';
import { PagerComponent } from '../../../../../core/pager/pager.component';

@Component({
  selector: 'app-std-major-page',
  templateUrl: './std-major-page.component.html',
  styleUrls: ['./std-major-page.component.scss']
})
export class StdMajorPageComponent extends FramePageComponent implements OnInit {
  @ViewChild('uploader', {static: false}) uploader: UploaderComponent;

  PAGE_URL = `std/departmentMajor/majorPage.htm`;

  query = {
    query:'',
    year:'',              //年份
    department:'',              //学院
    major:'',              //专业
  };


  @ViewChild('pager', {static: false}) pager: PagerComponent;

  showSearchCondition = false;

  constructor(private activateInfo: ActivatedRoute, private router: Router, private modalService: BsModalService) {
    super(modalService);
   
  }

  
  search(){
    let params = this.query;
    this.pager.pagerParams  = Object.assign({}, this.pager.pagerParams, params);
    this.pager.reload();
  }
  
  toggleShowSearchCondition(){
    if(this.showSearchCondition == false){
      this.showSearchCondition = true;
    }else{
      this.showSearchCondition = false;
    }
   }

   
  reset(){
    for (let key in this.query) {
      if (this.query.hasOwnProperty(key)) {
        this.query[key] = "";
      }
    } 
  }

  ngOnInit() {

  }

       /** 导出分系分专业分性别录取情况统计表 **/
  majorDownloadReport() {
      if (this.pager.getRecords().length <= 0) {
           return;
      }
      let entity = {};
      entity = {
                report_name: 'StdDepartmentMajorReport',
                report_title: '导出分系分专业分性别录取情况统计表',
                school_id: this.pager.getRecords()[0].from_school
      }
      this.ajaxDownload('frame/report/download.htm', entity);
  }

  reloadPage() {
    MsgService.successAlert('批量导入完成，系统将重新加载！', undefined, () => {
      location.reload();
    });
  }

}
