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

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

  public query = {
    std_name: "",
    ticket_no: "",
    cert_no: "",
    exam_time_id: ""
  };
  centralScore = []; //考生历史成绩
  timeList = [];

  CENTRAL_SCORE_URL = "kj/kjUnifiedScoreDetail/central.htm";
  EXAM_TIME_URL = "pl/plExamTime/list.htm";

  constructor() { }

  ngOnInit() {
    FrameRequest.requestArray(this.EXAM_TIME_URL, {}, (array) => {
      this.timeList = array;
    });
  }

  
  searchStdScore() {
    if(!this.query.std_name && !this.query.ticket_no && !this.query.cert_no) {
      AppComponent.alert({title:'提示', text: '请输入准考证号或身份证号'});
      return;
    }
    FrameRequest.requestArray(this.CENTRAL_SCORE_URL, {
      std_name : this.query.std_name,
      ticket_no : this.query.ticket_no,
      cert_no : this.query.cert_no,
      exam_time_id: (this.query.exam_time_id === undefined || this.query.exam_time_id === null ) ? "" : this.query.exam_time_id
    }, (array) => {
      this.centralScore = array;
    });
  }

  //重置
  reset() {
    this.query.std_name = "";
    this.query.ticket_no= "";
    this.query.cert_no = "";
    this.query.exam_time_id = "";
    this.centralScore = [];
  }

}
