import {Component, OnInit, ViewChild} from '@angular/core';
import {FramePageComponent} from '../../../../frame/core/FramePageComponent';
import {BsModalService} from 'ngx-bootstrap';
import {StdRegCreateComponent} from '../std-reg-create/std-reg-create.component';
import {ActivatedRoute, Router} from '@angular/router';
import {StdMaterialRefuseComponent} from '../../material/std-material-refuse/std-material-refuse.component';
import {MsgService} from '../../../../../core/msg/msg.service';
import {AjaxService} from '../../../../../core/ajax/ajax.service';
import {FrameService} from '../../../../../core/frame/frame.service';
import {UploaderComponent} from '../../../../../core/uploader/uploader.component';
import { PagerComponent } from '../../../../../core/pager/pager.component';

@Component({
  selector: 'app-std-reg-page',
  templateUrl: './std-reg-page.component.html',
  styleUrls: ['./std-reg-page.component.scss']
})
export class StdRegPageComponent extends FramePageComponent implements OnInit {

  @ViewChild('uploader', {static: false}) uploader: UploaderComponent;
  @ViewChild('pager', {static: false}) pager: PagerComponent;

  constructor(private activateInfo: ActivatedRoute, private router: Router, private modalService: BsModalService) {
    super(modalService);
    this.modalComponent = StdRegCreateComponent;
  }

  ngOnInit() {
  }

  showStdDetail(std) {
    this.router.navigate(['/sk/std/reg/detail',std.std_id], );
  }

  /** 导出考生汇总信息*/
   sumStuDownload() {
    if (this.pager.getRecords().length <= 0) {
      return;
    }
    let entity = {};
      entity = {
                report_name: 'StdRegReport',
                report_title: '考生数据汇总',
                from_school: this.pager.getRecords()[0].from_school
      }
      this.ajaxDownload('frame/report/download.htm', entity);
    }

  validStdPhoto() {
    FrameService;
    MsgService.confirm('确定将所有免冠证件照进行公安验证码？需要消耗较长时间', () => {
      AjaxService.requestEntity('std/reg/NoCrownPhoto/verify.htm', {}, (entity) => {
        MsgService.showThreadRunning(this.modalService, entity, {threadTitle: '正在进行公安验证，请稍候'});
      });
    });
  }

  reloadPage() {
    MsgService.successAlert('批量导入完成，系统将重新加载！', undefined, () => {
      location.reload();
    });
  }

}
