import { Component, OnInit } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { FrameDetailComponent } from '../../../../frame/core/detail/frame.detail';

declare let laydate; 

@Component({
  selector: 'app-task-dist-cancel',
  templateUrl: './task-dist-cancel.component.html',
  styleUrls: ['./task-dist-cancel.component.scss']
})
export class TaskDistCancelComponent extends FrameDetailComponent implements OnInit {

  exam_date:any;

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
   }

  ngOnInit(): void {
  }

  //取消任务分发
  cancelTask() {
    if(!this.exam_date) {
      this.MsgService.errorToastr('请填写评分日期！');
      return;
    }
    this.MsgService.confirmAlert('确定要取消评分日期为【' + this.exam_date + '】的任务吗？一旦取消，将不可恢复！', () => {
      this.AjaxService.request('ex/task/dist/cancel.htm', {batch_id: this.ResponseEntity.batch_id, exam_date: this.exam_date}, () => {
        this.MsgService.successToastr('任务取消分发成功！');
        this.closeWindow();
      }, {RequestWithLoading: true});
    });
  }

   //初始化时间控件
   getDate() {
    setTimeout(() => {
      laydate.render({
        elem:'#exam_date',
        type:'date',
        theme:'#0c6acf',
        trigger: 'click',
        done:(value, date, endDate)=>{
          this.exam_date = value;
        }
      });
    }, 500);
  }

}
