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-admission-page',
  templateUrl: './std-admission-page.component.html',
  styleUrls: ['./std-admission-page.component.scss']
})
export class StdAdmissionPageComponent extends FramePageComponent implements OnInit {
  @ViewChild('uploader', {static: false}) uploader: UploaderComponent;

  PAGE_URL = `std/admission/page.htm`;

  query = {
    query:'',
    region:'',              //省份
    nation:'',              //民族
    department:'',          //系(院)
    major:'',               //专业
    sex:'',                 //性别
    filing_unit:'',         //投档单位名称 
    graduation_type:'',     //毕业类别
    examination_type:'',    //考试类型
    batch:'',               // 批次
    families:'',           //科类
    planning_nature:'',    //计划性质
    isReported:'',     //考生是否报道
  };

  q_valForm: FormGroup
  valForm: FormGroup
  @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] = "";
      }
    } 
  }


  FrameSexArray = [];
  IsReportedArray = [];

  ngOnInit() {
    this.FrameSexArray = FrameService.getFrameDictArray('FrameSex'); //考生性别
    this.IsReportedArray = FrameService.getFrameDictArray('isReported'); //考生是否报道
  }

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

}
