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

@Component({
  selector: 'app-std-enrol-report',
  templateUrl: './std-enrol-report.component.html',
  styleUrls: ['./std-enrol-report.component.scss']
})
export class StdEnrolReportComponent implements OnInit {

  BM_URL = "std/stdEnrol/exportBm.htm";
  BK_URL = "std/stdEnrol/exportBk.htm";
  KS_URL = "std/stdEnrol/exportKs.htm";
  KJ_URL = "std/stdEnrol/exportKj.htm";
  ENROL_DBF_URL = "std/stdEnrol/exportEnrolDbf.htm";
 
  YEAR_CODE_URL = "pl/plExamTime/list.htm";

  constructor() { }

  public query = {
    exam_time_id: 0
  };

  ngOnInit() {
  }

  exportbm() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.BM_URL, {exam_time_id:this.query.exam_time_id}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("报名情况数据导出成功");
    });
  }

  exportbk() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.BK_URL, {exam_time_id:this.query.exam_time_id}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("报考课程情况数据导出成功");
    });
  }


  exportbmforupdate() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.BM_URL, {exam_time_id:this.query.exam_time_id,is_update:1}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("报名情况数据导出成功");
    });
  }

  exportbkforupdate() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.BK_URL, {exam_time_id:this.query.exam_time_id,is_update:1}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("报考课程情况数据导出成功");
    });
  }

  exportks() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.KS_URL, {exam_time_id:this.query.exam_time_id}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("考试情况数据导出成功");
    });
  }

  buildBkData() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.confirm("确定生成报考数据吗？", () => {
      AppComponent.GobalComponent.setLoading(true);
      FrameRequest.request("std/stdEnrol/buildBkData.htm", {exam_time_id:this.query.exam_time_id}, () => {
        AppComponent.GobalComponent.setLoading(false);
        AppComponent.GobalComponent.successMsg("生成报考数据成功");
      });
    });

    
  }

  buildKsData() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.confirm("确定生成考试情况数据吗？", () => {
      AppComponent.GobalComponent.setLoading(true);
      FrameRequest.request("std/stdEnrol/buildKsData.htm", {exam_time_id:this.query.exam_time_id}, () => {
        AppComponent.GobalComponent.setLoading(false);
        AppComponent.GobalComponent.successMsg("生成考试情况数据成功");
      });
    });

    
  }

  exportkj() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.KJ_URL, {exam_time_id:this.query.exam_time_id}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("考籍档案成绩导出成功");
    });
  }


  exportdbf() {
    if (!this.query.exam_time_id) {
      AppComponent.alert({ title: "信息提示", text: "请选择批次!" })
      return;
    }
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.ENROL_DBF_URL, {exam_time_id:this.query.exam_time_id}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("报考上报数据导出成功");
    });
  }

  

}
