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

@Component({
  selector: 'app-score-rate-major',
  templateUrl: './score-rate-major.component.html',
  styleUrls: ['./score-rate-major.component.scss']
})
export class ScoreRateMajorComponent extends FlexTableComponent implements OnInit {

  public query = {
    query: "",
    year_code: 0
  };
  QUERY_URL = "kj/kjUnifiedScoreDetail/pageMajorStatic.htm";
  EXPORT_URL = "kj/kjUnifiedScoreDetail/exportMajorStatic.htm";
  YEAR_CODE_URL = "pl/plExamTime/list.htm";
  LATEST_TIME_URL = "pl/plExamTime/getCurrentYearCode.htm";

  constructor() { 
    super();
  }

  ngOnInit() {
    setTimeout(() =>{
      FrameRequest.requestEntity(this.LATEST_TIME_URL, { }, (entity) => {
        if (entity) {
          this.query.year_code = Number.parseInt(entity);
        }
      });
    },200)
  }

  
  export() {
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.EXPORT_URL, {year_code:this.query.year_code}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("专业情况统计导出成功");
    });
  }

}
