import {Component, OnInit, ViewChild} from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { AjaxService } from '../../../../core/service/ajax.service';
import { MsgService } from '../../../../core/service/msg.service';
import { FrameDetailComponent } from '../../../frame/core/detail/frame.detail';

@Component({
  selector: 'app-plan-group-batch-detail',
  templateUrl: './plan-group-batch-detail.component.html',
  styleUrls: ['./plan-group-batch-detail.component.scss']
})
export class PlanGroupBatchDetailComponent extends FrameDetailComponent implements OnInit {

  aspectTotal: any;
  // 分页组件
  // @ViewChild('bPager1', {static: false}) bPager1: PagerComponent;

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


  initDefautEntity() {
    console.log(this.currentEntity);

  }

  ngOnInit() {
  }


  totalQualified(type) {
    this.currentEntity.total_type = type;
    AjaxService.requestEntity('plan/group/province/quailfied/total.htm', this.currentEntity, (entity) => {
      this.aspectTotal = entity;
      console.log(entity);
    });
  }

  saveQualified() {
    debugger
    MsgService.confirmAlert('确定要进行合格判断吗？合格分数为【' + (this.aspectTotal.s01 ? this.aspectTotal.s01 : this.currentEntity.qualified_value) + '】?', () => {
      AjaxService.request('plan/group/province/quailfied/save.htm', {
        pn_province_id: this.currentEntity.pn_province_id,
        cur_batch: this.currentEntity.cur_batch,
        qualified_value: parseInt(this.aspectTotal.s01*100 + '')
      }, () => {
        MsgService.successAlert('分组划线已经保存，并已经进行了合格判断', () => {
          this.closeWindow();
        });
      });
    });
  }

  batchPay(v) {
    MsgService.confirmAlert('确定要人工收费吗？尽可能减少人工收费', () => {
      AjaxService.request('plan/group/province/pay.htm', {
        enrol_id: v.enrol_id
      }, () => {
        //this.bPager1.reload();
        this.pager.reload();
        MsgService.successToastr('已完成人工缴费操作！');
      });
    });
  }

  stdQualified(v) {
    MsgService.confirmAlert(`确定要将该考生【${v.std_name}】重新标记为合格并发布吗？`, () => {
      AjaxService.request('plan/group/province/qualified/std.htm', {
        enrol_id: v.enrol_id,
        pn_province_id:this.currentEntity.pn_province_id
      }, () => {
        //this.bPager1.reload();
        this.pager.reload();
        MsgService.successToastr('已完成操作！');
      });
    });
  }

 

}
