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

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

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'batch_code': [null, Validators.compose([Validators.required])],
      'batch_name': [null, Validators.compose([Validators.required])],
      'batch_status': [null, null],
      'show_std_name': [null, null],
      'show_std_height': [null, null],
      'show_std_weight': [null, null],
      'show_std_image': [null, null],
      'show_std_sex': [null, null],
      'show_tracks': [null, null],
      'show_topic': [null, null],
      'show_sign': [null, null],
      'show_remark': [null, null],
      'separate_status': [null, null],
      'exam_echo_status': [null, null],
      'remark': [null, null],
      'show_province': [null, null],
      'show_discipline': [null, null],
      'show_avoid': [null, null],
      'judge_record_need': [null, null],
      'display_screen': [null, null],
      'play_second': [null, null],
      'entry_info': [null, null],
      'checkin_random': [null, null]
    });
  }

  ngOnInit(): void {
  }

  initDefautEntity(): void {
    if(this.detailMode == 'add') {
      this.currentEntity.show_std_name = 'InActive';
      this.currentEntity.show_std_height = 'InActive';
      this.currentEntity.show_std_weight = 'InActive';
      this.currentEntity.show_std_image = 'InActive';
      this.currentEntity.show_std_sex = 'InActive';
      this.currentEntity.show_tracks = 'InActive';
      this.currentEntity.show_topic = 'InActive';
      this.currentEntity.show_sign = 'InActive';
      this.currentEntity.show_remark = 'InActive';
      this.currentEntity.exam_echo_status = 'Active';
      this.currentEntity.separate_status = 'InActive';
      this.currentEntity.show_province = 'InActive';
      this.currentEntity.show_discipline = 'InActive';
      this.currentEntity.show_avoid = 'InActive';
      this.currentEntity.judge_record_need = 'Active';
    }
  }

  addEditBatch() {
    if(this.detailMode == 'add') {
      this.currentEntity.school_id = localStorage.getItem('school_id');
      this.AjaxService.request('./cf/school/batch/add.htm', this.currentEntity, () => {
        MsgService.successToastr('批次添加成功!');
        this.closeWindow();
      });
    }
  }

}
