import {Component, OnInit, ViewChild} from '@angular/core';
import {FramePageComponent} from '../../../frame/core/page/frame.page';
import {BsModalService} from 'ngx-bootstrap/modal';
import { SetOptrComponent } from '../set-optr/set-optr.component';
import {CfInitialOptrDetailComponent} from '../initial-optr-detail/initial-optr-detail.component';

@Component({
  selector: 'app-cf-initial-optr-page',
  templateUrl: './initial-optr-page.component.html',
  styleUrls: ['./initial-optr-page.component.scss']
})
export class CfInitialOptrPageComponent extends FramePageComponent implements OnInit {
  schoolArray = [];
  batchArray = [];
  query = {
    school_id : '',
    batch_id : ''
  };
  constructor(private modalService: BsModalService) {
    super(modalService);
    this.modalComponent = CfInitialOptrDetailComponent;
  }

  ngOnInit() {
    this.AjaxService.requestArray('./cf/school/list.htm', {}, (array) => {
      this.schoolArray = array;
      if (this.schoolArray.length === 1) {
        this.query.school_id = this.schoolArray[0].school_id;
        this.pager.reload();
      }
    });
  }

  setOptrWin(v, type: string) {
    this.onModalClose = () => {
      this.pager.reload();
    };
    v.type=type;
    this.showComponentModal(SetOptrComponent, { ResponseEntity: v }, {class: 'modal-8p'});
  }


}
