import {Component, OnInit, ViewChild} from '@angular/core';
import {FramePageComponent} from "../../../frame/core/page/frame.page";
import {BsModalService} from "ngx-bootstrap/modal";
import { AjaxService } from '../../../../core/service/ajax.service';
import { MsgService } from '../../../../core/service/msg.service';
import {CfCategoryDetailComponent} from '../category-detail/category-detail.component';
import { FramePager } from '../../../../core/frame/pager/frame-pager/frame-pager';

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

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

  requestData() {
    debugger;
    this.pager.pagerParams["school_id"] = this.query.school_id;
    this.pager.reload();
  }

}
