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';

declare let laydate;

@Component({
  selector: 'app-check-in-time-detail',
  templateUrl: './check-in-time-detail.component.html',
  styleUrls: ['./check-in-time-detail.component.scss']
})
export class CheckInTimeDetailComponent extends FrameDetailComponent implements OnInit {

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({
      'ly_agent_id': [null, Validators.compose([Validators.required])],
      'exam_start_time': [null, Validators.compose([Validators.required])],
      'exam_end_time': [null, Validators.compose([Validators.required])]
    });
   }

  ngOnInit() {
    for(const arr of this.ResponseArray) {
      arr.ly_agent_id = arr.agent_id;
    }
    this.getDate();
  }

   //初始化时间控件
   getDate() {
    let _this = this;
    setTimeout(() => {
      laydate.render({
        elem:'#exam_start_time',
        type:'datetime',
        theme:'#0c6acf',
        trigger: 'click',
        done:(value, date, endDate)=>{
          _this.currentEntity.exam_start_time = value;
        }
      });
      laydate.render({
        elem:'#exam_end_time',
        type:'datetime',
        theme:'#0c6acf',
        trigger: 'click',
        done:(value, date, endDate)=>{
          _this.currentEntity.exam_end_time = value;
        }
      });  
    }, 500);
  }

}
