import { Component, OnInit } from '@angular/core';
import { CustomValidators } from "ng2-validation";
import { BsModalService } from "ngx-bootstrap/modal";
import { FlexTableComponent } from "../../../../shared/common/FlexTable.component";
import { Validators, FormBuilder } from '@angular/forms';
import 'moment/locale/zh-cn';

import * as moment from 'moment';
declare var $: any;
@Component({
  selector: 'app-std-black-list',
  templateUrl: './std-black-list.component.html',
  styleUrls: ['./std-black-list.component.scss']
})
export class StdBlackListComponent extends FlexTableComponent implements OnInit {

  public query = {
    std_name: "",
    cert_no: "",
    ticket_no: "",
    audit_status: ""
  };

  QUERY_URL = "std/stdBlackList/page.htm";
  DELETE_URL = "std/stdBlackList/delete.htm";
  GET_URL = "std/stdBlackList/get.htm";
  ADD_URL = "std/stdBlackList/add.htm";
  EDIT_URL = "std/stdBlackList/edit.htm";

  constructor(public bsModalService: BsModalService, fb: FormBuilder) {
    super();
    // CustomValidators.rangeLength([1, 6])
    this.formModel = fb.group({
      id: [null],
      std_name: [null, Validators.compose([Validators.required])],
      cert_no: [null, Validators.compose([Validators.required])],
      ticket_no: [null, Validators.compose([Validators.required])],
      audit_status: [null, Validators.compose([Validators.required])],
      limit_starttime: [null, Validators.compose([Validators.required])],
      limit_endtime: [null, Validators.compose([Validators.required])],
      stop_reason: [null, Validators.compose([Validators.required])]
    });
  }

  ngOnInit() {

  }
  stdRegInfoModalConfirm(modal){
    let checkedArray = modal.framePager.getCheckedArray();
    if(checkedArray.length > 0){
      let checkedItem = checkedArray[0];
      this.item.std_name = checkedItem.std_name;
      this.item.cert_no = checkedItem.cert_no;
      this.item.ticket_no = checkedItem.ticket_no;
    }
    modal.hideModal();
  }
  async aftGoEditEvent(){
    //界面渲染之后
    setTimeout(() => {
      // $('input .datepicker').datepicker({
        // $('#limit_starttime').datepicker({
        //   language: "zh-CN",
        //   // minView:2,
        //   autoclose: 1,
        //   // startView:3, 
        //   format:'yyyy-mm-dd'
        // });
        
        // $('#limit_endtime').datepicker({
        //   language: "zh-CN",
        //   // minView:2,
        //   autoclose: 1,
        //   // startView:3, 
        //   format:'yyyy-mm-dd'
        // });
      
    }, 500);
  }
}
