import { Component, OnInit } from '@angular/core';
import { FlexTableComponent } from '../../../../../shared/common/FlexTable.component';
import { AppComponent } from '../../../../..';
import { FrameRequest } from '../../../../../shared/frame/frame-request';

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

  public query = {
    query: "",
    time_config_id: "",
    prov_code: "",
    status:""
  };

  TIME_URL = "by/byTurnTimeConfig/list.htm?turn_type=2";
  QUERY_URL = "by/byTurnOutApply/search.htm";
  PRINT_URL = "by/byTurnOutApply/print.htm";
  PRINT_PAGE_URL = "by/byTurnOutApply/printPage.htm";
  DELETE_URL = "by/byTurnOutApply/delete.htm";

  constructor() {
    super();
  }

  ngOnInit() {
  }

  print() {
    let checkedArray = this.framePager.getCheckedArray((item) => item.id);
    if (checkedArray && (checkedArray.length == 0 || checkedArray.length > 1)) {
      AppComponent.alert({ title: '提示', text: '请选择一条记录' });
      return;
    }
    FrameRequest.download(this.PRINT_URL, { id: checkedArray.join() });
  }

  printPage() {
    let checkedArray = this.framePager.getCheckedArray();
    if (checkedArray && (checkedArray.length == 0 || checkedArray.length > 1)) {
      AppComponent.alert({ title: '提示', text: '请选择一条记录' });
      return ;
    }
    FrameRequest.download(this.PRINT_PAGE_URL, {id: checkedArray[0].id,std_name:checkedArray[0].std_name});
  }
  

  //删除前判断（只能删除转至省外的数据）
  async preDeleteEvent() {
    //let checkArray = this.framePager.getCheckedArray();
   // if (checkArray) {
   //   for (let i = 0; i < checkArray.length; i++) {
   //     if(checkArray[i].status !== 4) {
   //       AppComponent.alert({ 'title': '提示', text: '只能删除转至省外的记录！' });
   //       return false;
   //     }
   //   }
  //  }
    return true
  }

}
