import { Component, OnInit } from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';
import {DomSanitizer} from '@angular/platform-browser';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { FrameDetailComponent } from '../../../../frame/core/detail/frame.detail';
import { FrameDeptDetailComponent } from '../../../../frame/dept/frame-dept-detail/frame-dept-detail.component';

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

  deptArray = [];
  constructor(bsModalRef: BsModalRef, fb: FormBuilder, sanitizer: DomSanitizer) {
    super(bsModalRef, sanitizer);
    this.detailForm = fb.group({
      'subject_id': [null, Validators.compose([Validators.required, Validators.min(1), Validators.max(9999999)])],
      'subject_name': [null, Validators.compose([Validators.required, Validators.minLength(2), Validators.maxLength(128)])],
      'subject_code': [null, Validators.compose([Validators.required, Validators.maxLength(16)])],
      'subject_type': [null, Validators.required],
      'subject_alias': [null],
      'subject_dept': [null],
      'single_aspect_subject': [null, Validators.required],
      'subject_enrol_explain': [null, Validators.maxLength(2000)],
      'score_dot': [null],
      'score_judge_num': [null],
      'total_score': [null]
    });
  }

  ngOnInit() {
    setTimeout(() => {
      // 设置默认值
      this.deptArray = FrameDeptDetailComponent.makeOptrDeptArray(this.ResponseArray);

    }, 10);
  }

  initDefautEntity() {
    if (this.detailMode === 'add') {
      this.currentEntity.subject_type = 'Interview';
      this.currentEntity.single_aspect_subject = 'Active';
    }
  }
}
