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-std-enrol-statis',
  templateUrl: './std-enrol-statis.component.html',
  styleUrls: ['./std-enrol-statis.component.scss']
})
export class StdEnrolStatisComponent extends FlexTableComponent implements OnInit {

  public query = {
    query: ""
  };
  QUERY_URL = "std/stdEnrol/stdEnrolStat.htm";

  EXPORT_URL = "std/stdEnrol/stdEnrolStatExport.htm";
  ENROL_NUM_URL = "std/stdEnrol/stdEnrolNum.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";

  stdEnrol: any;
  stdEnrolList = [];
  stdNetEnrolList = [];

  constructor() { 
    super();
  }

  ngOnInit() {
  }

  showEdit(editShowType: any) {
    FrameRequest.requestEntity(this.ENROL_NUM_URL, {}, (entity) => {
      if(entity) {
        this.stdEnrol = entity;
      }
    });
    this.editShowType = editShowType;
  }

  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;
    });
  }


  export() {
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download(this.EXPORT_URL, {query: this.query.query}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("导出成功");
    });
  }

  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("导出成功");
    });
  }
  
}
