import { Component, OnInit, ViewChild } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { FrameUpload } from 'src/app/core/frame/upload/frame-upload/frame-upload';
import { ModalService } from 'src/app/core/service/modal.service';
import { FramePageComponent } from 'src/app/routes/frame/core/page/frame.page';

@Component({
  selector: 'app-score-ym-violation',
  templateUrl: './score-ym-violation.component.html',
  styleUrls: ['./score-ym-violation.component.scss']
})
export class ScoreYmViolationComponent extends FramePageComponent implements OnInit {

  @ViewChild('uploader', { static: false }) uploader: FrameUpload;
  constructor(private modalService: BsModalService) {
    super(modalService);
   }

  ngOnInit(): void {
  }

  doUploaFile() {
    ModalService.showUploadWindow(this.bsService, './score/ym/violation/upload.htm', {}, {
      uploadTitle: '违纪考生',
      templateFile:'模版-线上考试违纪考生.xls',
      uploadCallback: this.uploadWithThreadCallback.bind(this),
      autoClose: true
    });
  }

  uploadWithThreadCallback(ajax) {
    this.pager.reload();
  }

   //下载告知书
   downloadNotice(v) {
    window.open(this.FrameService.getParamValue('EnrolMaterialWebPath') + '/' + v.notice_file);
  }

  //生成告知书
  makeStdNotice(v, flag) {
    let msg = '确定要生成该考生的处罚告知书吗！';
    if (flag) {
      msg = '确定要重新生成该考生的处罚告知书吗？';
    }
    this.MsgService.confirmAlert(msg, () => {
      this.FuncService.ajaxDownload('score/ym/make/notice.htm', { cert_id: v.cert_id, aspect_name: v.aspect_name, batch: v.batch });
      setTimeout(() => {
        this.pager.reload();
      }, 1000);
    });
  }


  //下载决定书
  downloadDecision(v) {
    window.open(this.FrameService.getParamValue('EnrolMaterialWebPath') + '/' + v.aspect_image);
  }

  //生成决定书
  makeStdDecision(v, flag) {
    let msg = '确定要生成该考生的处罚决定书吗！';
    if (flag) {
      msg = '确定要重新生成该考生的处罚决定书吗？';
    }
    this.MsgService.confirmAlert(msg, () => {
      this.FuncService.ajaxDownload('score/ym/make/decision.htm', { cert_id: v.cert_id, aspect_name: v.aspect_name, batch: v.batch });
    });
  }

}
