import { Component, OnInit } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { FramePageComponent } from 'src/app/routes/frame/core/page/frame.page';
import { StdEnrolBankAuditComponent } from '../std-enrol-bank-audit/std-enrol-bank-audit.component';

@Component({
  selector: 'app-std-enrol-bank',
  templateUrl: './std-enrol-bank.component.html',
  styleUrls: ['./std-enrol-bank.component.scss']
})
export class StdEnrolBankComponent extends FramePageComponent implements OnInit {

  schoolArray = [];
  batchArray = [];
  query = {
    school_id : '',
    batch_id : '',
    audit_flag: 'InActive'
  };
  auditArr = [{name: '请选择', value: ''},{name: '未审核', value: 'InActive'},{name: '已审核', value: 'Active'}]

  constructor(private modalService: BsModalService) {
    super(modalService);
    this.modalComponent = StdEnrolBankAuditComponent;
   }

  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.queryBatchArray();
      } 
    });
  }

  queryBatchArray() {
    this.AjaxService.requestArray("cf/batch/list.htm",{school_id: this.query.school_id},(array)=>{
      this.batchArray = array;
      if (this.batchArray.length == 1) {
        this.query.batch_id = this.batchArray[0].batch_id;
        this.requestData();
      }
    });   
  }

  requestData() {
    this.pager.reload(this.query);
  }
}
