import { ChangeDetectorRef } from '@angular/core';
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-modify',
  templateUrl: './std-reg-modify.component.html',
  styleUrls: ['./std-reg-modify.component.scss']
})
export class StdRegModifyComponent extends FrameDetailComponent implements OnInit {

  entity:any;
  constructor(bsModalRef: BsModalRef, fb: FormBuilder, private ref: ChangeDetectorRef) {
    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],
      'exam_id': [null],
      'std_type': [null],
      'std_nation': [null],
      'std_mobile': [null, Validators.compose([Validators.required])],
      'std_school': [null]
    });
  }

  ngOnInit() {
  }

  initDefautEntity() {
    //编辑，需要重新查找数据库
    this.AjaxService.requestMap('std/reg/info.htm', {std_id: this.currentEntity.std_id}, (map) => {
      if (map['StdReg'] === undefined) {
        this.MsgService.errorToastr('获取考生失败！');
        return;
      }
      this.currentEntity = map['StdReg'];
    });
  }

}


