import { Component, OnInit } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { FramePageComponent } from '../../../../frame/core/page/frame.page';
import { OptrSchoolPageDetailComponent } from '../optr-school-page-detail/optr-school-page-detail.component';

@Component({
  selector: 'app-optr-school-page',
  templateUrl: './optr-school-page.component.html',
  styleUrls: ['./optr-school-page.component.scss']
})
export class OptrSchoolPageComponent  extends FramePageComponent  implements OnInit {

  schoolArr = [];
  school_id: any;

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

  ngOnInit(): void {
    this.requestSchool();
  }

  //学校
  requestSchool() {
    this.AjaxService.requestArray('cf/school/list.htm',{}, (array) => {
      this.schoolArr = array;
      if(this.schoolArr.length == 1) {
        this.school_id = this.schoolArr[0].school_id;
        this.reload();
      }
    });
  }

  //重新加载
  reload() {
    this.pager.reload({school_id: this.school_id});
  }

  uploadCallback(ajax) {
    this.MsgService.successAlert('导入成功!');
  }


}
