import {Component, OnInit} from '@angular/core';
import {FrameDetailComponent} from '../../core/detail/frame.detail';
import {FormBuilder, Validators} from "@angular/forms";
import {AjaxService} from "../../../../core/service/ajax.service";
import {DomSanitizer} from "@angular/platform-browser";
import {mobileValidator} from "../../../../shared/validators/mobile.validator";
import {FrameService} from "../../../../core/service/frame.service";
import {BsModalRef} from "ngx-bootstrap/modal";
import {FrameDeptDetailComponent} from "../../dept/frame-dept-detail/frame-dept-detail.component";

@Component({
  selector: 'app-frame-optr-modify',
  templateUrl: './frame-optr-modify.component.html',
  styleUrls: ['./frame-optr-modify.component.scss']
})
export class FrameOptrModifyComponent extends FrameDetailComponent implements OnInit {

  deptArray = [];

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'optr_name': [null, Validators.compose([Validators.required, Validators.minLength(2), Validators.maxLength(32)])],
      'optr_sex': [null],
      'optr_status': [null],
      'optr_email': [null],
      'optr_mobile': [null, Validators.compose([Validators.required])],
      'optr_tel': [null],
      'optr_fax': [null],
      'optr_addr': [null],
      'optr_post': [null],
      'optr_dept': [null],
      'optr_desc': [null]
    });
  }

  ngOnInit() {
    AjaxService.requestArray('frame/dept/all.htm', {}, (ResponseArray) => {
      this.deptArray = FrameDeptDetailComponent.makeOptrDeptArray(ResponseArray);
    });
    this.currentEntity.optr_image = undefined;
  }


}
