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-prop-publish-plan',
  templateUrl: './prop-publish-plan.component.html',
  styleUrls: ['./prop-publish-plan.component.scss']
})
export class PropPublishPlanComponent  extends FlexTableComponent implements OnInit {

  public query = {
    query: "",
    year_code: 0
  };
  QUERY_URL = "pl/mergePublishPlan/planPage.htm";
  EXPORT_URL = "pl/mergePublishPlan/propexport.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, {}, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("开考计划导出成功");
    });
  }

}
