import {Component, OnInit} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
import { BsModalService } from 'ngx-bootstrap/modal';
import { FrameService } from '../../../../../core/service/frame.service';
import { MsgService } from '../../../../../core/service/msg.service';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import {LayoutPlanInterviewDetailComponent} from '../layout-plan-interview-detail/layout-plan-interview-detail.component';

@Component({
  selector: 'app-layout-plan-interview',
  templateUrl: './layout-plan-interview.component.html',
  styleUrls: ['./layout-plan-interview.component.scss']
})
export class LayoutPlanInterviewComponent extends FramePageComponent implements OnInit {

  batchNameArray: any;
  searchText: any;
  exam_batch: any;
  showSingleGroup: boolean;

  constructor(private modalService: BsModalService, private san: DomSanitizer) {
    super(modalService, san);
    this.modalComponent = LayoutPlanInterviewDetailComponent;

    const array = [{dict_value: '0', dict_text: '全批次'}];
    for (const v of FrameService.getFrameDictArray('ExamBatchName')) {
      array.push(v);
    }
    this.batchNameArray = array;
  }

  ngOnInit() {

  }

  onModalClose() {
    this.ajax.reload();
  }

  makeGroup() {
    const array = [];
    for (const v of this.ajax.getMap()['SingleArray']) {
      if (v.checked === true) {
        array.push(v);
      }
    }
    if (array.length < 2) {
      MsgService.errorToastr('分组操作至少需要2个科目！');
      return;
    }

    this.showComponentModal(LayoutPlanInterviewDetailComponent, {
      ResponseArray: array
    });
  }

}
