import { Component, OnInit } from '@angular/core';
import {FrameEditComponent} from '../../../../frame/core/FrameEditComponent';
import {BsModalRef} from 'ngx-bootstrap';
import {FormBuilder, Validators} from '@angular/forms';

@Component({
  selector: 'app-std-reg-create',
  templateUrl: './std-reg-create.component.html',
  styleUrls: ['./std-reg-create.component.scss']
})
export class StdRegCreateComponent  extends FrameEditComponent implements OnInit {

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.valForm = fb.group({
      'cert_type': [null, Validators.compose([Validators.required])],
      'exam_id': [null, Validators.compose([Validators.required])],
      'cert_id': [null, Validators.compose([Validators.required, Validators.minLength(6), Validators.maxLength(18)])],
      'std_name': [null, Validators.compose([Validators.required])],
      'std_sex': [null, Validators.compose([Validators.required])],
      'std_param3': [null, Validators.compose([Validators.required])],
      'cert_addr': [null],
      'std_nation': [null, Validators.compose([Validators.required])],
      'std_mobile': [null, Validators.compose([Validators.required])]
    });
  }

  ngOnInit() {
  }

  initDefautEntity() {
    if (this.editModel === 'add') {
      this.currentEntity.cert_type = 'IdCard';
    }
  }
}

