import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { FormBuilder, Validators } from '@angular/forms';
import { FlexTableComponent } from '../../../../../shared/common/FlexTable.component';
import { FrameUploaderComponent } from '../../../../../core/uploader/uploader.component';
import { AppComponent } from '../../../../../app.component';
import { FrameRequest } from '../../../../../shared/frame/frame-request';
import { FrameFunction } from '../../../../../shared/frame/frame_function';
import { ByFilesPdfViewerModal } from '../../by-files-pdf-viewer/by-files-pdf-viewer-modal';


@Component({
  selector: 'app-by-files-query',
  templateUrl: './by-files-query.component.html',
  styleUrls: ['./by-files-query.component.scss']
})
export class ByFilesQueryComponent  extends FlexTableComponent implements OnInit {

  public query = {
    query : '',
    bysj:"",
    zy:""

  };
  resultList:any;
  FrontFilesList: any;

  /**  暂时无用
   * step:string = 'main';
   * timeList = ['1999年6月','2000年6月','2001年12月','2002年12月']
   */

  QUERY_URL = "by/byFiles/page/query.htm";
  GET_URL= "by/byFiles/get.htm";
  ADD_URL = "by/byFiles/add.htm";
  EDIT_URL = "by/byFiles/add.htm";
  DOWNLOAD_URL = "by/byFiles/std/download.htm";
  UPLOAD_URL="by/byFiles/upload/std/form.htm";

  @ViewChild('uploader')
  uploader: FrameUploaderComponent;
  @ViewChild('byFilesPdfModal') byFilesPdfModal: ByFilesPdfViewerModal;

  constructor(public bsModalService: BsModalService, fb: FormBuilder) {
    super();
    this.formModel = fb.group({
    });
   }

  ngOnInit() {
    //this.listFrontFiles();
  }

  //检索考生档案
  search(param) {
    if(!this.query.query) {
      this.query.query = "";
    }
   
    if(!this.query.bysj) {
      this.query.bysj = "";
    }

    if(!this.query.zy) {
      this.query.zy = "";
    }

    param.query = this.query.query;
    param.bysj = this.query.bysj;
    param.zy = this.query.zy;


  }

  preShow(id){
    FrameRequest.requestEntity("by/byFiles/byFilesIsExists.htm", {id: id,is_preView:true}, (entity) => {
      if (!entity) {
        this.byFilesPdfModal.ids= id;
        this.byFilesPdfModal.show();
      }else{
        AppComponent.alert({title:"信息提示",text:entity});
      }
    });

  }

  listFrontFiles() {
    FrameRequest.requestArray('by/byFiles/query/front.htm', {limit: 6}, (array) => {
      this.FrontFilesList = array;
    });
  }



  /** 暂时无用
  goDetail(type) {
    this.step = type;
  }

  goStep(step) {
    this.step = step;
  }*/

}
