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

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

  yearCodeList: any;
  UNRELEASE_URL= "kj/kjUnifiedScoreMain/unrelease.htm";
  RELEASE_URL= "kj/kjUnifiedScoreMain/release.htm";
  YEAR_CODE_URL = "pl/plExamTime/queryExamYear.htm";

  constructor() { }

  public query = {
    year_code: 0
  };

  ngOnInit() {
	FrameRequest.requestArray("pl/plExamTime/list.htm", {}, (array) => {
		this.yearCodeList = array;
	  });
  }

  release() {
    if (!this.query.year_code) {
      AppComponent.alert({ title: "信息提示", text: "请选择年度码!" })
      return;
    }
	AppComponent.confirm("确认发布"+this.query.year_code+"批次的成绩吗",()=>{
		AppComponent.GobalComponent.setLoading(true);
		FrameRequest.requestEntity(this.RELEASE_URL, {year_code:this.query.year_code}, () => {
		  AppComponent.GobalComponent.setLoading(false);
		  AppComponent.GobalComponent.successMsg(this.query.year_code+"成绩发布成功");
		});
	})

  }
  unRelease() {
    if (!this.query.year_code) {
      AppComponent.alert({ title: "信息提示", text: "请选择年度码!" })
      return;
    }
	AppComponent.confirm("确认取消发布"+this.query.year_code+"批次的成绩吗",()=>{
		AppComponent.GobalComponent.setLoading(true);
		FrameRequest.requestEntity(this.UNRELEASE_URL, {year_code:this.query.year_code}, () => {
		  AppComponent.GobalComponent.setLoading(false);
		  AppComponent.GobalComponent.successMsg(this.query.year_code+"成绩发布已取消");
		});
	})
  }


}
