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

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

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'cert_type': [null, Validators.compose([Validators.required])],
      'std_province': [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])],
      'cert_addr': [null],
      'std_nation': [null, Validators.compose([Validators.required])],
      'std_mobile': [null, Validators.compose([Validators.required])]
    });
  }

  ngOnInit() {
  }

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

