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


@Component({
  selector: 'app-kw-examforecast',
  templateUrl: './kw-examforecast.component.html',
  styleUrls: ['./kw-examforecast.component.scss']
})
export class KwExamforecastComponent extends FlexTableComponent implements OnInit {

   NEED_EXAM_URL = "kw/kwExamUnit/forecast.htm";

   
   SPECIAL_COURSE_URL = "std/stdEnrol/stdEnrolSpecialCourse.htm";
   EXPORT_SPECIAL_COURSE_URL = "std/stdEnrol/stdEnrolSpecialCourseExport.htm";
 
   NET_COURSE_URL = "std/stdEnrol/stdEnrolNetCourse.htm";
   EXPORT_NET_COURSE_URL = "std/stdEnrol/stdEnrolNetCourseExport.htm";

   year: any;
   month: any;
   examNumList = [];

   stdEnrolList = [];
   stdNetEnrolList = [];

  constructor() { 
    super();
  }

  public query = {
    examTimeId: null
  };

  ngOnInit() {
    
  }

  async queryExamNum() {
    if (!this.query.examTimeId) {
      AppComponent.alert({ title: "信息提示", text: "请选择考试批次!" });
      return;
  }

    FrameRequest.requestMap(this.NEED_EXAM_URL, {examTimeId:this.query.examTimeId}, (map) => {
      
      if(map) {
        this.year = map['year'];
        this.month = map['month'];
        this.examNumList = map['exam_num'];
      }
    });

   }

   async resetData(){
     this.query.examTimeId=null;
   }

   showSpecialCourse(editShowType: any) {
    FrameRequest.requestArray(this.SPECIAL_COURSE_URL, {}, (array) => {
      if(array) {
        this.stdEnrolList = array;
      }
      this.editShowType = editShowType;
    });
  }

  showNetCourse(editShowType: any) {
    FrameRequest.requestArray(this.NET_COURSE_URL, {}, (array) => {
      if(array) {
        this.stdNetEnrolList = array;
      }
      this.editShowType = editShowType;
    });
  }


  

  exportSpecialCourse() {
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.EXPORT_SPECIAL_COURSE_URL, {}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("导出成功");
    });
  }

  exportNetCourse() {
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.EXPORT_NET_COURSE_URL, {}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("导出成功");
    });
  }

}
