import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { FrameDetailComponent } from 'src/app/routes/frame/core/detail/frame.detail';

@Component({
  selector: 'app-conf-school-subject-detail',
  templateUrl: './conf-school-subject-detail.component.html',
  styleUrls: ['./conf-school-subject-detail.component.scss']
})
export class ConfSchoolSubjectDetailComponent extends  FrameDetailComponent implements OnInit {

  panelArr = []; //评分面板

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'subject_code' : [null, Validators.compose([Validators.required])],
      'subject_name' : [null, Validators.compose([Validators.required])],
      'subject_alias' : [null, Validators.compose([Validators.required])],
      'score_dot' : [null, null],
      'subject_status' : [null, null],
      'panel_id' : [null, null]
    });
   }

  ngOnInit(): void {
   
  }

  initDefautEntity(): void {
    this.requestPanel();
  }

  //评分面板
  requestPanel() {
    this.AjaxService.requestArray('ex/score/panel/list.htm', {school_id: this.currentEntity.school_id}, (array) => {
      this.panelArr = array;
      this.requestDefaultPanel();
    });
  }
  //设置默认面板
  requestDefaultPanel() {
    this.AjaxService.requestEntity('ex/score/panel/subject/find/id.htm', {subject_id: this.currentEntity.subject_id},
     (entity) => {
      this.currentEntity.panel_id = entity;
    })
  }
}
