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';
import { AjaxService } from '../../../../core/service/ajax.service';
import { FuncService } from '../../../../core/service/func.service';
import { MsgService } from '../../../../core/service/msg.service';

declare let laydate;

@Component({
  selector: 'app-imp-data-detail',
  templateUrl: './imp-data-detail.component.html',
  styleUrls: ['./imp-data-detail.component.scss']
})
export class ImpDataDetailComponent extends FrameDetailComponent implements OnInit {
  query = {
    school_id : '',
    batch_id : ''
  };

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) {
    super(bsModalRef);
    this.detailForm = fb.group({

    });
    this.getDate();
  }

  ngOnInit() {
  
  }

  initDefautEntity() {
    if (this.detailMode === 'add') {
      this.currentEntity.need_face_match = 'Active';
    }
  }

  //初始化时间控件
  getDate() {
    let _this = this;
    setTimeout(() => {
      laydate.render({
        elem:'#startDate',
        type:'date',
        theme:'#0c6acf',
        format: 'yyyy-MM-dd',
        trigger: 'click',
        done:(value, date, startDate)=>{
          _this.currentEntity.start_date = value;
        }
      });
      laydate.render({
        elem:'#endDate',
        type:'date',
        theme:'#0c6acf',
        format: 'yyyy-MM-dd',
        trigger: 'click',
        done:(value, date, endDate)=>{
          _this.currentEntity.end_date = value;
        }
      });        
    }, 500);
  }

  download(contract_id) {
    FuncService.ajaxDownload('conf/contract/contract/download.htm', {contract_id: contract_id});
  }

  uploadCallback(ajax) {
    debugger;
    MsgService.successAlert('This is upload callback!');
  }
}
