import { Component, OnInit, Input, ViewChild, Output, EventEmitter, TemplateRef } from "@angular/core";
import { FlexTableComponent } from "../../../../shared/common/FlexTable.component";
import { FormBuilder, Validators } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';
import { BsModalService } from "ngx-bootstrap/modal";
import { FramePagerComponent } from "../../../../core/pager/pager.component";
import { FrameRequest } from "../../../../shared/frame/frame-request";
import { FrameUploaderComponent } from "../../../../core/uploader/uploader.component";
import { AppComponent, InjectorInstance } from "../../../..";
import { FrameValidator } from "../../../../shared/frame/Frame-validator";
import { FrameFunction } from "../../../../shared/frame/frame_function";
import { FlexSelectComponent } from "../../../../shared/components/flexSelect/FlexSelect.component";

import { DomSanitizer } from  '@angular/platform-browser';
import { RequestOptions } from "@angular/http";
import { HttpClient, HttpHeaders } from "@angular/common/http";
import { FrameVariable } from "../../../../shared/frame/frame-variable";
import { FileUploader, FileItem, ParsedResponseHeaders } from "ng2-file-upload";

import * as _ from 'lodash';
declare var webcamInit: any;

@Component({
  selector: "std-reg-key-info",
  templateUrl: "./std-reg-key-info.component.html",
  styleUrls: ["./std-reg-key-info.component.scss"]
})
export class StdRegKeyInfoComponent extends FlexTableComponent implements OnInit {
 
  public query = {
    "std_name": "",
    "cert_no": "",
    "ticket_no": "",
    'exam_time_id': "",
    "major_id": "",
    school_id:"",
    std_source:""
  };

  QUERY_URL = "std/stdRegInfo/page.htm";
  DELETE_URL = "std/stdRegInfo/delete.htm";
  GET_URL = "std/stdRegInfo/get.htm";
  BATCH_GET_URL = "std/stdRegInfo/batchGet.htm";
  ADD_URL = "std/stdRegInfo/add.htm";
  UPLOAD_URL = "std/stdRegInfo/upload.htm";
  DOWNLOAD_URL = "std/stdRegInfo/downloadTpl.htm";
  EDIT_URL = "std/stdRegInfo/editKeyInfo.htm";
  ERROR_DOWNLOAD_URL = "std/stdRegInfo/downloadError.htm";


  VALIDATE_DATE_URL = "std/stdRegInfo/getValidateDataList.htm";

  INIT_PASSWORD_URL = "std/stdRegInfo/initPassword.htm";

  BATCH_QUERY_URL = "std/stdRegInfo/batchList.htm";
  
  BATCH_PAGE_QUERY_URL = "std/stdRegInfo/PageBatchList.htm";

  BATCH_UPLOAD_URL = "std/stdRegInfo/uploadImg.htm";

  UPLOAD_IMGS_URL = "std/stdRegInfo/uploadImgsCheck.htm";

  SCHOOL_URL = "cf/cfOrganization/list.htm?org_type=1&status=1"; //主考学校


  @ViewChild('uploader')
  uploader: FrameUploaderComponent;

  @ViewChild('batchUploader')
  batchUploader: FrameUploaderComponent;

  @ViewChild('batchFramePager')
  batchFramePager:FramePagerComponent;

  @ViewChild('uploaderImgs')
  uploaderImgs:FrameUploaderComponent;

  uploadImageUrlSource = null;

  filePath: any;//错误文件路径
  
  stdSourceArray;
  validateData;

  batchModalWin: any;
  exam_time_info = "";
  //查询条件
  batchQueryCond = "";
  //按批次查询考生信息列表
  batchItems;
  //按批次选中的考生信息
  batchItem;

  selectedBatchId;
  examAreaOrgArray = [];
  // nSocialMajorArray = [];
  // socialMajorArray = [];
  // socialSchoolArray = [];
  majorArray = [];
  schoolArray = [];
  std_source_3_orgArray = [];
  batchTakePhotoModalWin: any;
  batchUploadPhotoModalWin: any;
  batchUploadPhotoModalWin4Edit: any;
  picArray: any;

  file: Array<Object>;
  loading: boolean;
  batchFormModel: any;

  isSFZ = true;//是否身份证
  
  @ViewChild('exam_time_id')  
  exam_time_id:FlexSelectComponent
  
  

  uploadImageUrl = null;
  uploadFile: any;

  batchFileuploader:FileUploader = new FileUploader({
    url: FrameVariable.BASE_URL + this.BATCH_UPLOAD_URL, 
    method: "POST",                                                                     
    itemAlias: "file",     
    isHTML5: true,
    autoUpload: false,
    removeAfterUpload: true,                                            
    });

  fileuploader4Edit:FileUploader = new FileUploader({
    url: FrameVariable.BASE_URL + this.BATCH_UPLOAD_URL, 
    method: "POST",                                                                     
    itemAlias: "file",     
    isHTML5: true,
    autoUpload: false,
    removeAfterUpload: true,                                            
    });
  upload_dir_id: any;
  upload_img_access: any;
  upload_img_passList: any;
  upload_img_failList: any;
  upload_img_failList_size: any;
  upload_img_passListStd: any;

  uploadImgsWin: any;
  school_name: string;
  majorArraySource: any;
  initOptrExamAreaId: any;
  isBatch: boolean;
  

    // uploaderImgs:FileUploader = new FileUploader({
    //   url: FrameVariable.BASE_URL + this.BATCH_UPLOAD_URL, 
    //   method: "POST",                                                                     
    //   itemAlias: "file",     
    //   isHTML5: true,
    //   autoUpload: false,
    //   removeAfterUpload: true,                                            
    //   });
 

  constructor(
    public bsModalService: BsModalService,
    fb: FormBuilder,
    bfb: FormBuilder,
    private sanitizer: DomSanitizer,
  ) {
    super();
    this.file = [];
    this.formModel = fb.group({
      std_name: [null, Validators.compose([Validators.required])],
      cert_no: [null, Validators.compose([Validators.required])],
      std_sex: [null, Validators.compose([Validators.required])],
     
    });
    
  }

  ngOnInit() {
    //自动选择当前批次
    setTimeout(() => {
      FrameRequest.request('pl/plExamTime/getCurrentYearCodeForTicketNo.htm',{}, (resp) => {
        this.exam_time_id.items.forEach((item) => {
          if(item.year_code == resp.entity){
            this.query.exam_time_id = item.id;
          }
          
         });
        }
      )
    }, 1000);

    

    this.initMajorArray();

    this.initOptrExamArea();
  }

  //初始化操作员考区id
  initOptrExamArea(){
    FrameRequest.requestEntity('std/stdRegInfo/getOptrInfo.htm',this.query, (entity) => {
      if(entity)
      this.initOptrExamAreaId = entity;
    })
  }
  //生成准考证号
  genTicketNo(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 0){
      //按查询条件生成

      //验证批次
      if(!String(this.query.exam_time_id)){
        AppComponent.alert({ 'title': '提示', 'text': "请选择批次!" });
        return;
      }else{
        //按查询条件处理
        FrameRequest.request('std/stdRegInfo/batchGenTicketNo.htm',this.query, (resp) => {
           if(resp.success){
             if(resp.errorMsg){
              AppComponent.alert({ 'title': '提示', 'text': resp.errorMsg });
             }else{
              AppComponent.GobalComponent.successMsg('批量生成准考证成功');
             }
            this.framePager.reload();
           }else{
            AppComponent.alert({ 'title': '提示', 'text': resp.errorMsg });
           }
          }
        )
      }
    }else{
      let ids = [];
      for (let index = 0; index < checkedArray.length; index++) {
        const element = checkedArray[index];
        ids.push(element.id);
      }
      //按所选考生处理
      FrameRequest.request('std/stdRegInfo/batchGenTicketNo.htm',{ids:ids.join()}, (resp) => {
          if(resp.success){
            if(resp.errorMsg){
              AppComponent.alert({ 'title': '提示', 'text': resp.errorMsg });
            }else{
              AppComponent.GobalComponent.successMsg('批量生成准考证成功');
            }
            this.framePager.reload();
          }else{
            AppComponent.alert({ 'title': '提示', 'text': resp.errorMsg });
          }
        }
      )

    }
  }

  exportExcel(){
    let reqParam = this.query;
    reqParam['fileName'] = '考生.xlsx';
    reqParam['timeConfigId'] = this.query.exam_time_id;

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.download("std/stdRegInfo/export.htm", reqParam, () => {
      AppComponent.GobalComponent.setLoading(false);
      AppComponent.GobalComponent.successMsg("导出成功");
    });

  }

  std_source_changge(event){
    let std_source = event.currentTarget.value;
    //社会
    if(std_source == 1 && this.std_source_3_orgArray.length >9 ){
      if(String(this.item.major_id)){
        this.initSchoolName(this.item.major_id,this.item);
      }
      return;

    }

    if(std_source == 3){
      this.item.school_id = "";
    } 

    FrameRequest.requestArray("/std/cfOrganization/listOrderBy.htm",{org_type:1,status:1}, async (array) => {
      this.std_source_3_orgArray = array;
    })
  }

  majorChange(event){
    let major_id = event.currentTarget.value;
    
    this.initSchoolName(major_id,null);

  }
  sfzchangeItem(event){
      this.isSFZ = event.currentTarget.checked;
      
      if(this.isSFZ == true && this.item.cert_no && this.item.cert_no.length == 18){
        let  cert_no = this.item.cert_no;
        //生日
        this.item.std_birth  = cert_no.substring(6,10) + "-" + cert_no.substring(10,12) + "-" + cert_no.substring(12,14);
        //性别 
        this.item.std_sex = (parseInt(this.item.cert_no.substring(16,17)) % 2) == 1?"1":"2";
        this.item.cert_no = this.item.cert_no.toUpperCase();
      }
      this.item.cert_type = this.isSFZ==true?1:0;
      
    } 

    certNoBlurItem(event){
      let value = event.currentTarget.value;
      if(this.isSFZ == true && value && value.length == 18){
        let  cert_no = this.item.cert_no;
        //生日
        this.item.std_birth  = cert_no.substring(6,10) + "-" + cert_no.substring(10,12) + "-" + cert_no.substring(12,14);
        //性别 
        this.item.std_sex = (parseInt(this.item.cert_no.substring(16,17)) % 2) == 1?"1":"2";
        this.item.cert_no = this.item.cert_no.toUpperCase();
      }
    }

  sfzchange(event){
      this.isSFZ = event.currentTarget.checked;
      
      if(this.isSFZ == true && this.batchItem.cert_no && this.batchItem.cert_no.length == 18){
        let  cert_no = this.batchItem.cert_no;
        //生日
        this.batchItem.std_birth  = cert_no.substring(6,10) + "-" + cert_no.substring(10,12) + "-" + cert_no.substring(12,14);
        //性别 
        this.batchItem.std_sex = (parseInt(this.batchItem.cert_no.substring(16,17)) % 2) == 1?"1":"2";
        this.batchItem.cert_no = this.batchItem.cert_no.toUpperCase();
      }
      
    } 

  certNoBlur(event){
      let value = event.currentTarget.value;
      if(this.isSFZ == true && value && value.length == 18){
        let  cert_no = this.batchItem.cert_no;
        //生日
        this.batchItem.std_birth  = cert_no.substring(6,10) + "-" + cert_no.substring(10,12) + "-" + cert_no.substring(12,14);
        //性别 
        this.batchItem.std_sex = (parseInt(this.batchItem.cert_no.substring(16,17)) % 2) == 1?"1":"2";
        this.batchItem.cert_no = this.batchItem.cert_no.toUpperCase();
      }

    }


  async preGoEditEvent(entity){
    //新增 证件类型 默认为身份证
    // if(!entity || !String(entity.id)){
    //   entity = {};
    //   entity.cert_type = 1;
    // }

    //新增
    
    this.isBatch = false;
    if(!entity ||!entity.id) {
     
      
      FrameRequest.requestMap("/std/stdRegInfo/examAreaOrgArray.htm",{}, async (resp) => {
        this.examAreaOrgArray = resp.examAreaOrgArray;
        if(this.examAreaOrgArray.length > 0 ){
          // this.examAreaOrgArray
        }
      })
      return true;
    }
    //修改
    else{
        FrameRequest.requestMap(this.BATCH_GET_URL,{id:entity.id}, async (resp) => {
        
          // this.transStdSource(resp);
          if(resp.std_reg_info.photo_url)
          resp.std_reg_info.photo_url_full =  resp.config.url + resp.std_reg_info.photo_url;
          if(resp.std_reg_info){
            entity.photo_url_full = resp.std_reg_info.photo_url_full;
          }
          
          if(this.examAreaOrgArray.length == 0 ){
            this.examAreaOrgArray = resp.examAreaOrgArray;
          }

        let std_major = resp.std_major;

        this.initMajorLevel(std_major.major_level,entity);
        // this.initMajorArray();
        this.initSchoolName(entity.major_id,entity);

          setTimeout(() => {
            AppComponent.GobalComponent.setLoading(false);
          }, 800);
        });
      }

    return true;
  }

  async aftGoEditEvent(){
    if(this.item){
      if(this.item.cert_type == 1){
        this.isSFZ = true;
      }else if(!this.item.id){
        this.item.cert_type = 1
        this.isSFZ = true;
        // document.getElementById("sfz")['checked']=true;
      }else{
        this.isSFZ = false;
      }
    }else{
      this.item.cert_type = 1;
      this.isSFZ = true;
    }

    if(this.initOptrExamAreaId){
      this.item.exam_area_id = this.initOptrExamAreaId;
    }
    
  }
 

  downloadTemplate(){
    FrameRequest.download("std/stdRegInfo/downloadTpl.htm", {fileName: 'group_std_reg.xlsx'});
  }

  upload(){
    if(!String(this.exam_time_id)){
      AppComponent.alert({ 'title': '提示', 'text': '请选择批次' });
      return;
    }
    this.uploader.choooseFileAndUpload({}, ((ajax) => {
      if (ajax.errorCode === -1) {
        this.filePath = ajax.url;
        AppComponent.alert({ 'title': '提示', 'text': '有错误数据，请修正后，在重新上传' });
      } else {
        AppComponent.GobalComponent.successMsg('批量报考成功');
        this.filePath = '';
        this.hideModal();
        this.framePager.reload();
      }
    }).bind(this));
  }

  //错误数据下载
  downloadErrFile() {
    FrameRequest.download(this.ERROR_DOWNLOAD_URL, { filePath: this.filePath });
  }

  showValidateDataListModal(editFormTemplateModal, modalcss?){
    FrameRequest.requestMap(this.VALIDATE_DATE_URL,{}, async (map) => {
      this.validateData = map;
      this.shouModalWin(editFormTemplateModal, modalcss);
    });
  }

  initPassword(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
      FrameRequest.request(this.INIT_PASSWORD_URL,{id:checkedArray[0].id}, async (resp) => {
        if(resp.success){
          AppComponent.alert({ 'title': '提示', 'text': '考生密码初始化成功(考生手机号后6位)!' });
        }else{
          AppComponent.alert({ 'title': '提示', 'text': resp.errorMsg });
        }
      });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
      AppComponent.alert({ 'title': '提示', 'text': '请选择数据!' });

    }
  }

  //处理考生类型下拉数据
  transStdSource(resp){
    this.stdSourceArray = [];
    for (const key in resp.config.stdSourceMap) {
      if (resp.config.stdSourceMap.hasOwnProperty(key)) {
        const element = resp.config.stdSourceMap[key];
        this.stdSourceArray.push({value:element[key],text:key});
      }
    }
  }

  //选中右侧考生列表
  chooseBatchItem(item){
    this.selectedBatchId = item.id;
    AppComponent.GobalComponent.setLoading(true);
   
    FrameRequest.requestMap(this.BATCH_GET_URL,{id:item.id}, async (resp) => {
      // this.transStdSource(resp);
      resp.std_reg_info.photo_url =  resp.config.url + resp.std_reg_info.photo_url;
      if(resp.std_reg_info){
        this.batchItem = resp.std_reg_info;
      }
      if(this.examAreaOrgArray.length == 0 ){
        this.examAreaOrgArray = resp.examAreaOrgArray;
      }
      //初始化社会考生专业
      /*
      if(this.batchItem.std_source == 1){
        this.initSocialMajor();
        //查询主考院校By专业
        if(this.batchItem.major_id)
        this.initSocialSchoolArray(this.batchItem.major_id);

      }
      //非社会考生专业
      else{
        this.initNSocialMajor();
      }
      */
      // this.initMajorArray();
     

      this.initSchoolName(item.major_id,item);
      setTimeout(() => {
        AppComponent.GobalComponent.setLoading(false);
      }, 800);
    });
  }

  chooseBatchItemNew(item){
    this.selectedBatchId = item.id;
    this.batchItem = item;
    AppComponent.GobalComponent.setLoading(true);
   
    FrameRequest.requestMap(this.BATCH_GET_URL,{id:item.id}, async (resp) => {
      // this.transStdSource(resp);
      resp.std_reg_info.photo_url =  resp.config.url + resp.std_reg_info.photo_url;
      if(resp.std_reg_info){
        this.item = resp.std_reg_info;
      }
      if(this.examAreaOrgArray.length == 0 ){
        this.examAreaOrgArray = resp.examAreaOrgArray;
      }
      let std_major = resp.std_major;

      this.initMajorLevel(std_major.major_level,this.item);
      this.initSchoolName(this.item.major_id,this.item);
      setTimeout(() => {
        AppComponent.GobalComponent.setLoading(false);
      }, 800);
    });
  }
  initBatchItemData(){
    AppComponent.GobalComponent.setLoading(true);
    this.item =  {
      std_name: "",
      std_pass1: "",
      std_pass2: "",
      std_source:"",
      std_eng_name: "",
      cert_no: "",
      std_sex: "",
      political_status: "",
      std_nation: "",
      std_family_reg: "",
      school_id: "",
      std_edu: "",
      std_occupation: "",
      std_healthy: "",
      std_birth: "",
      major_id: "",
      major_code: "",
      major_name: "",
      std_mobile: "",
      std_postcode: "",
      std_address: "",
      email: "",
      remark: "",
      // major_id:"",
      // school_id:"",
      exam_area_id:"",
    };
    this.school_name = "";

    //加载 考取数据
    if (this.examAreaOrgArray.length == 0) {
      FrameRequest.requestMap(this.BATCH_GET_URL,{}, async (resp) => {
        this.examAreaOrgArray = resp.examAreaOrgArray;
        setTimeout(() => {
          AppComponent.GobalComponent.setLoading(false);
        }, 300);
      });
    } else {
      setTimeout(() => {
        AppComponent.GobalComponent.setLoading(false);
      }, 300);
    }
    
 
  }
  transStatus(val){
    if(val == 0){
      return "导入";
    }else if(val == 1){
      return "待完善信息";
    }else if(val == 2){
      return "待完善信息";
    }else if(val == 3){
      return "待上传图像";
    }else if(val == 4){
      return "已上报";
    }
  }

  batchSearch(param){
    param['exam_time_id'] = this.query.exam_time_id;
    return param;
  }

  //跳转批量处理页面
  async goBatchItem(templateModal){
    if(!String(this.query.exam_time_id)){
      AppComponent.alert({ 'title': '提示', 'text': "请选中批次数据!" });
      return;
    }

    // debugger
    // let exam_time_info = this.exam_time_info;
    this.exam_time_id.items.forEach((item) => {
      if(this.query.exam_time_id == item.id){
        this.exam_time_info = item.exam_year_month;
      }
      
     });

     this.item = {};
     this.preGoEditEvent(this.item);
     this.aftGoEditEvent();
     this.isBatch = true;


    // this.exam_time_info = "2019四月";
    AppComponent.GobalComponent.setLoading(true);
    // this.batchModalWin = this.bsModalService.show(templateModal, { class: "modal-lg" });
    this.editShowType = "only";
    this.initBatchItemData();
    // FrameRequest.requestArray(this.BATCH_QUERY_URL,{exam_time_id:this.query.exam_time_id,query:this.batchQueryCond}, async (array) => {
    //     this.batchItems = array;
    //     this.batchModalWin = this.bsModalService.show(templateModal, { class: "modal-lg" });
    //     this.initBatchItemData();

    // });
   

  }

  refreshBatchItems(){
    document.getElementById("batchItemsSearchBtn").click();
  }
  
  //考生来源切换
  stdSourceChange(event){
    let val = event.currentTarget.value;
    //社会考生
    /*
    if(val == 1){
      this.initSocialMajor();
    }else{
      this.initNSocialMajor();
    }
    */
  }

  /*
  initSocialMajor(){
    if(this.socialMajorArray.length > 0) return;
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.requestArray("/std/stdRegInfo/getSocialMajorList.htm",{}, async (array) => {
      this.socialMajorArray = array; 
      setTimeout(() => {
        AppComponent.GobalComponent.setLoading(false);
      }, 300);
    });
  }

  initNSocialMajor(){
    if(this.nSocialMajorArray.length > 0) return;
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.requestArray("/std/stdRegInfo/getNSocialMajorList.htm",{}, async (array) => {
      this.nSocialMajorArray = array; 
      setTimeout(() => {
        AppComponent.GobalComponent.setLoading(false);
      }, 300);
    });
  }

  initSocialSchoolArray(major_id){
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.requestArray("/std/stdRegInfo/getOrgBySocialMajor.htm",{major_id:major_id}, async (array) => {
      this.socialSchoolArray = array; 
      setTimeout(() => {
        AppComponent.GobalComponent.setLoading(false);
      }, 300);
    });
  }
  */

  initMajorLevel(major_level,entity){
    entity.major_level = major_level;
 
  }

  initMajorArray(){
    FrameRequest.requestArray('std/stdRegInfo/queryOpenMajorList.htm',{}, (array) => {
      this.majorArray = array;
      }
    )
  }
  initSchoolName(major_id,entity){
    let _this_item = entity;
    if(null == _this_item){
      _this_item = this.item;
    }
 
    if(!major_id) return;
    //助学班 初始化
    if(_this_item.std_source == 3){
      FrameRequest.requestArray("/std/cfOrganization/listOrderBy.htm",{org_type:1,status:1}, async (array) => {
        this.std_source_3_orgArray = array;
      })
      // this.item.school_id = "";
      return;
    }
    FrameRequest.requestArray('cf/cfOrganization/querySchoolListByMajorId.htm',{major_id:major_id}, (array) => {
        this.schoolArray = array;
        if(this.schoolArray.length >0){
          this.school_name = this.schoolArray[0].org_code + "-" + this.schoolArray[0].org_name;
          if(entity){
            entity.school_id = this.schoolArray[0].id;
          }
        }
      }
    )
  }

  //社会专业切换
  /*
  socialMajorChange(event){
    let val = event.currentTarget.value;
    if(!String(val))return;
    this.initSocialSchoolArray(val);
  }
  */


  batchAdd(){
     //验证必填项
    if(this.item.id != undefined && String(this.item.id)){
      //提示数据已经存在 无法新增
      AppComponent.alert({ 'title': '提示', 'text': "当前数据已经存在无法新增!请重置数据后,完善数据后再提交!" });
      return;
    }
    if (!FrameFunction.validForm(this.formModel)) {
      return;
    }
    this.item.exam_time_id = this.query.exam_time_id;

    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.request("std/stdRegInfo/batchAdd.htm", this.item, (ret) => {
      if (ret.success) {
          //提示
          AppComponent.GobalComponent.successMsg('添加数据成功');
          this.initBatchItemData();
          //重新加载列表
          this.refreshBatchItems();
          setTimeout(() => {
            AppComponent.GobalComponent.setLoading(false);
          }, 100);
      }else{
        AppComponent.GobalComponent.errorMsg(ret.errorMsg);
        setTimeout(() => {
          AppComponent.GobalComponent.setLoading(false);
        }, 100);
      }
    });
  }

  batchEdit(){
   
    if (!FrameFunction.validForm(this.formModel)) {
      return;
    }
    //验证必填项
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.request("std/stdRegInfo/batchEdit.htm", this.item, (ret) => {
      if (ret.success) {
          //提示
          AppComponent.GobalComponent.successMsg('更新数据成功');
          //重新加载列表
          this.refreshBatchItems();
          
          setTimeout(() => {
            AppComponent.GobalComponent.setLoading(false);
          }, 100);
      }else{
        AppComponent.GobalComponent.errorMsg(ret.errorMsg);
        setTimeout(() => {
          AppComponent.GobalComponent.setLoading(false);
        }, 100);
      }
    });
  }

  batchDel(){
    if(this.item.id == undefined || !String(this.item.id)){
      //提示数据已经存在 无法新增
      AppComponent.alert({ 'title': '提示', 'text': "请选择有效的考生考生信息删除!" });
      return;
    }
    AppComponent.confirm("确定删除?",()=>{
      AppComponent.GobalComponent.setLoading(true);
      FrameRequest.request("std/stdRegInfo/batchDel.htm", {std_id:this.item.id}, (ret) => {
        if (ret.success) {
            //提示
            AppComponent.GobalComponent.successMsg('删除数据成功');
            //重新加载列表
            this.refreshBatchItems();
            setTimeout(() => {
              AppComponent.GobalComponent.setLoading(false);
            }, 100);
        }else{
          AppComponent.GobalComponent.errorMsg(ret.errorMsg);
          setTimeout(() => {
            AppComponent.GobalComponent.setLoading(false);
          }, 100);
        }
      });
  });
  }

  /*
  batchTakeImg(templateModal){
    if(this.batchItem.id == undefined || !String(this.batchItem.id)){
      //提示数据已经存在 无法新增
      AppComponent.alert({ 'title': '提示', 'text': '考生信息未提交无法现场拍照,请提交后再操作!' });
      return;
    }
    this.batchTakePhotoModalWin = this.bsModalService.show(templateModal, { class: "modal-lg" });
    setTimeout(() => {
      this.initTakePic();
    }, 1000);
  }
  */

  // 弹出上传图片modal
  batchUploadPic(templateModal){
    if(this.item.id == undefined || !String(this.item.id)){
      //提示数据已经存在 无法新增
      AppComponent.alert({ 'title': '提示', 'text': '考生信息未提交无法上传图片,请提交后再操作!' });
      return;
    }
    this.batchUploadPhotoModalWin = this.bsModalService.show(templateModal, { class: "modal-md" });
    this.uploadImageUrl = null;
  }

  //个人信息编辑 弹出上传图片modal
  UploadPic4Edit(templateModal){
    if(this.item.id == undefined || !String(this.item.id)){
      //提示数据已经存在 无法新增
      AppComponent.alert({ 'title': '提示', 'text': '考生信息未提交无法上传图片,请提交后再操作!' });
      return;
    }else{
      // if(this.item.ticket_no){
      //   AppComponent.alert({ 'title': '提示', 'text': '该考生已经存在准考证号无法重新上传图片!' });
      //   return;
      // }
    }
    this.batchUploadPhotoModalWin4Edit = this.bsModalService.show(templateModal, { class: "modal-md" });
    this.uploadImageUrl = null;
  }
 
  //选择上传附件
  img_accept_type = "image/png, image/jpeg, image/gif, image/jpg";
  onChangeSelectFile(event){
    this.batchFileuploader.clearQueue();
    if(event.currentTarget.files.length != 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择单个上传文件!' });
      return;
    }
    const file = event.currentTarget.files[0];   
    this.uploadFile = file;
    //图片格式 大小验证
    if(this.img_accept_type.indexOf(file.type) == -1){
      AppComponent.alert({ 'title': '提示', 'text': '上传图片只支持png jpeg gif jpg格式!' });
      return;
    }
    // 必须 bypassSecurityTrustUrl 转换一下 url ，要不然angular会报，说url不安全错误。   
    this.uploadImageUrlSource =  window.URL.createObjectURL(file);
    this.uploadImageUrl = this.sanitizer.bypassSecurityTrustUrl(this.uploadImageUrlSource); 

    this.batchFileuploader.addToQueue(event.currentTarget.files, event.target.options);
  }

  onChangeSelectFile4Edit(event){
    this.fileuploader4Edit.clearQueue();
    if(event.currentTarget.files.length != 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择单个上传文件!' });
      return;
    }
    const file = event.currentTarget.files[0];   
    this.uploadFile = file;
    //图片格式 大小验证
    if(this.img_accept_type.indexOf(file.type) == -1){
      AppComponent.alert({ 'title': '提示', 'text': '上传图片只支持png jpeg gif jpg格式!' });
      return;
    }
    // 必须 bypassSecurityTrustUrl 转换一下 url ，要不然angular会报，说url不安全错误。   
    this.uploadImageUrlSource =  window.URL.createObjectURL(file);
    this.uploadImageUrl = this.sanitizer.bypassSecurityTrustUrl(this.uploadImageUrlSource); 

    this.fileuploader4Edit.addToQueue(event.currentTarget.files, event.target.options);
  }

  //处理上传文件
  handleUploadFile() {
    // let _this = this;
    this.batchFileuploader.onBuildItemForm  = (fileItem: FileItem, form: any) =>{
      form.append("std_id", this.batchItem.id);
    }
    // this.batchFileuploader.onCompleteItem  = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
    //   AppComponent.GobalComponent.setLoading(false);
    //   debugger
    // }
    this.batchFileuploader.onSuccessItem  = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) =>{
      let respObj = JSON.parse(response);
     
      if(!respObj.success){
        AppComponent.alert({ 'title': '提示', 'text': respObj.errorMsg });
        return;
      }
      // respObj.entity.photo_url = respObj.entity.photo_url + "?" + new Date().getTime();
      let url = respObj.map.url;
      let std = respObj.map.stdRegInfo;
      // std.photo_url = url + std.photo_url + "?" + new Date().getTime();
      this.batchItem.photo_url = null;
      std.photo_url_full = url + std.photo_url;
      
      setTimeout(() => {
        this.batchItem = std;
        this.item = std;
        this.batchUploadPhotoModalWin.hide();
      }, 500);
      AppComponent.GobalComponent.successMsg('图片上传成功');
      
    }
    // this.batchFileuploader.onErrorItem  = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) =>{
    //   debugger
    //   AppComponent.alert({ 'title': '提示', 'text': '图片上传失败!' });
    // }
 
    this.batchFileuploader.queue[0].upload();
  }


  handleUploadFile4Edit(){
    this.fileuploader4Edit.onBuildItemForm  = (fileItem: FileItem, form: any) =>{
      form.append("std_id", this.item.id);
    }
 
    this.fileuploader4Edit.onSuccessItem  = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) =>{
      
      let respObj = JSON.parse(response);
      if(respObj.success){
        let url = respObj.map.url;
        let std = respObj.map.stdRegInfo;
        this.item.photo_url = null;
        std.photo_url_full = url + std.photo_url;
        AppComponent.GobalComponent.successMsg('图片上传成功');
        setTimeout(() => {
          this.item = std;
          this.batchUploadPhotoModalWin4Edit.hide();
        }, 500);
      }else{
        AppComponent.alert({ 'title': '提示', 'text': respObj.errorMsg });
      }
      
    }
 
    this.fileuploader4Edit.queue[0].upload();
  }
  
 



  /*
  initTakePic() {
    AppComponent.GobalComponent.setLoading(true);
    webcamInit();
    setTimeout(() => {
      AppComponent.GobalComponent.setLoading(false);
    }, 800);
  }
  
  batchTakePic(){
    this.picArray.push();
  }
  */

  batchDownConfirmInfo(){
    //状态4 完善所有信息 上传图片
    if(this.batchItem.id == undefined || !String(this.batchItem.id || this.batchItem.status != 4)){
      //提示数据已经存在 无法新增
      AppComponent.alert({ 'title': '提示', 'text': '请完善考生所有信息后再操作(包括上传图像)!' });
      return;
    }
    FrameRequest.download('std/stdRegInfo/batchDownConfirmInfo.htm', {id:this.batchItem.id});

  }

  downConfirmInfo(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length != 1){
      AppComponent.alert({ 'title': '提示', 'text': "请选择一个考生!" });
      return
    }
    FrameRequest.download('std/stdRegInfo/batchDownConfirmInfo.htm', {id:checkedArray[0].id});
  }

  batchUpdateReady(){
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.request("std/stdRegInfo/batchUpdateReady.htm", this.batchItem, (ret) => {
      if (ret.success) {
          if (String(ret.errorCode) && ret.errorCode != 0) {
            AppComponent.GobalComponent.errorMsg(ret.errorMsg);
          } else{
            AppComponent.GobalComponent.successMsg('上报数据成功');
            //重新加载列表
            this.refreshBatchItems();
          }
         
          setTimeout(() => {
            AppComponent.GobalComponent.setLoading(false);
          }, 100);
      }
    });
  }

  //批量打包上传图片
  uploadImgs(tplModal){
  this.uploaderImgs.choooseFileAndUpload({}, ((ajax) => {
    this.upload_dir_id = ajax.map.dirId;
    this.upload_img_access = ajax.map.url;
    this.upload_img_passList = ajax.map.passList;

    this.upload_img_passListStd = ajax.map.passListStd;
    this.upload_img_failList = ajax.map.failList;
    this.upload_img_failList_size = ajax.map.failListSize;

    //上传失败
    // this.uploadImgsWin = this.shouModalWin(tplModal, "modal-lg");
    this.uploadImgsWin = this.bsModalService.show(tplModal, { class: "modal-lg" });
    }).bind(this));
  }

  delUploadImg(){
    FrameRequest.request("std/stdRegInfo/delUploadImgs.htm", {dirId: this.upload_dir_id}, (ret) => {
      if (ret.success) {
        this.uploadImgsWin.hide();

        this.upload_dir_id = null;
        this.upload_img_passList = [];
        this.upload_img_failList = [];
        this.upload_img_passListStd = [];
    
      }
    });

  }

  subimtImgs(){
    if(this.upload_img_failList.length > 0){

      AppComponent.confirm("存在解析失败的照片,确定提交解析成功的照片??",()=>{
        this.subimtImgsReq();
      });
    }else{
      this.subimtImgsReq();
    }


  }
  
  //提交图片请求
  subimtImgsReq(){
    FrameRequest.request("std/stdRegInfo/uploadImgsSubmit.htm", {dirId: this.upload_dir_id,passArray:this.upload_img_passList}, (ret) => {
      if (ret.success) {
        this.uploadImgsWin.hide();

        this.upload_dir_id = null;
        this.upload_img_passList = [];
        this.upload_img_failList = [];
        this.upload_img_passListStd = [];
        AppComponent.GobalComponent.successMsg('批量上传图片成功');
    
      }
    });
  }
 
  majorLevelChange(event){
    let major_level = event.currentTarget.value;
   
    if(!this.majorArraySource){
      FrameRequest.requestArray('std/stdRegInfo/queryOpenMajorList.htm',{}, (array) => {
          this.majorArraySource = array;
          this.majorFilterByLevel(major_level);
        })
    }
    else{
      this.majorFilterByLevel(major_level);
    }
    


  }

  majorFilterByLevel(major_level){
    this.majorArray = _.filter(this.majorArraySource,{'major_level': parseInt(major_level)});
    
  }

  async preSaveEvent(){
    if(this.item.std_source == 3 && !String(this.item.schoole_id)){
      AppComponent.alert({ 'title': '提示', 'text': "助学考生主考学校为必填项!" });
      return false;
    }

    if(this.item.cert_type == 1 && this.item.cert_no && this.item.cert_no.length == 18){
      //性别 
      let cert_no_sex = (parseInt(this.item.cert_no.substring(16,17)) % 2) == 1?"1":"2";
      if(cert_no_sex != this.item.std_sex){
        AppComponent.alert({ 'title': '提示', 'text': "性别与身份证性别不符合,不允许修改!" });
        return false;
      }
    }
    return true;
  }


  uploadPhoto(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定将选中的考生照片迁移到恒生文件服务器吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/uploadPhotoToHs.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('照片迁移提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定将所有未迁移的考生照片迁移到恒生文件服务器吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/uploadPhotoToHs.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('照片迁移提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }

  uploadIdCardPhoto(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定下载选中的考生身份证照片迁移到恒生文件服务器吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/uploadIdCardPhotoToHs.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('照片迁移提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定将所有未迁移的考生身份证照片迁移到恒生文件服务器吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/uploadIdCardPhotoToHs.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('照片迁移提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }

  uploadPhotoModify(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定将选中的考生变更照片迁移到恒生文件服务器吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/uploadPhotoModifyToHs.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('变更照片迁移提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定将所有未迁移的考生变更照片迁移到恒生文件服务器吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/uploadPhotoModifyToHs.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('变更照片迁移提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }
  
  
  uploadPhotoBy(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定将选中的考生毕业照片迁移到恒生文件服务器吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/uploadPhotoByToHs.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('毕业照片迁移提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定将所有未迁移的考生毕业照片迁移到恒生文件服务器吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/uploadPhotoByToHs.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('毕业照片迁移提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }


  uploadPhotoByPaper(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定将选中的考生毕业论文答辩照片迁移到恒生文件服务器吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/uploadPhotoByPaperToHs.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('毕业论文答辩照片迁移提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定将所有未迁移的考生毕业论文答辩照片迁移到恒生文件服务器吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/uploadPhotoByPaperToHs.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('毕业论文答辩照片迁移提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }


  uploadPhotoByCertificate(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("请确保考生照片已经成功上传恒生文件服务器，确定将选中的考生毕业证明书照片迁移到恒生文件服务器吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/uploadPhotoByCertificateToHs.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('毕业证明书照片迁移提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定将所有未迁移的考生毕业证明书照片迁移到恒生文件服务器吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/uploadPhotoByCertificateToHs.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('毕业论证明书照片迁移提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }


  uploadByApplyHis(){
    AppComponent.confirm("确定将所有毕业考生迁移到数据库吗?",()=>{
      AppComponent.GobalComponent.setLoading(true);
      FrameRequest.request("std/stdRegInfo/uploadByApplyHis.htm", {}, (ret) => {
        if (ret.success) {
            //提示
            AppComponent.GobalComponent.successMsg('毕业考生迁移到数据库提交成功，请稍后查看迁移结果。');
            AppComponent.GobalComponent.setLoading(false);
          
        }else{
          AppComponent.GobalComponent.errorMsg(ret.errorMsg);
          AppComponent.GobalComponent.setLoading(false);
        }
      });
  });

  }
 
  photoReview(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定对选中的考生照片进行审核吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/photoReview.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('照片审核提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定对所有考生照片审核吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/photoReview.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('照片审核提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }

  freshPay(){
    
        AppComponent.confirm("确定查询30天内订单并更新报考状态吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/freshPay.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('查询30天内订单并更新报考状态提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    

  }


  getIdPhoto(){
    AppComponent.confirm("确定获取待复核毕业考生的身份证照片吗?",()=>{
      AppComponent.GobalComponent.setLoading(true);
      FrameRequest.request("std/stdRegInfo/getIdPhoto.htm", {}, (ret) => {
        if (ret.success) {
            //提示
            AppComponent.GobalComponent.successMsg('获取待复核毕业考生的身份证照片提交成功，请稍后查看迁移结果。');
            AppComponent.GobalComponent.setLoading(false);
          
        }else{
          AppComponent.GobalComponent.errorMsg(ret.errorMsg);
          AppComponent.GobalComponent.setLoading(false);
        }
      });
  });
}

checkPhoto(){
  AppComponent.confirm("确定对比待复核毕业区内考生照片吗?",()=>{
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.request("std/stdRegInfo/checkPhoto.htm", {}, (ret) => {
      if (ret.success) {
          //提示
          AppComponent.GobalComponent.successMsg('对比待复核毕业区内考生照片提交成功，请稍后查看迁移结果。');
          AppComponent.GobalComponent.setLoading(false);
        
      }else{
        AppComponent.GobalComponent.errorMsg(ret.errorMsg);
        AppComponent.GobalComponent.setLoading(false);
      }
    });
});
}

checkPhotoOut(){
  AppComponent.confirm("确定对比待复核毕业区外考生照片吗?",()=>{
    AppComponent.GobalComponent.setLoading(true);
    FrameRequest.request("std/stdRegInfo/checkPhotoOut.htm", {}, (ret) => {
      if (ret.success) {
          //提示
          AppComponent.GobalComponent.successMsg('对比待复核毕业区外考生照片提交成功，请稍后查看迁移结果。');
          AppComponent.GobalComponent.setLoading(false);
        
      }else{
        AppComponent.GobalComponent.errorMsg(ret.errorMsg);
        AppComponent.GobalComponent.setLoading(false);
      }
    });
});
}


  
  certification(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定对选中的考生进行实名认证吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/certification.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('实名认证提交成功，请稍后查看迁移结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定对所有考生实名认证吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/certification.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('实名认证提交成功，请稍后查看迁移结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }


  identifyCardBatch(){
    let checkedArray = this.framePager.getCheckedArray();
    if(checkedArray.length == 1){
          AppComponent.confirm("确定对选中的考生进行身份证认证吗?",()=>{
            let ids = [];
            ids =  this.framePager.getCheckedArray((item) => item.id);
            
            AppComponent.GobalComponent.setLoading(true);
            FrameRequest.request("std/stdRegInfo/identifyCardBatch.htm", {ids:ids.join()}, (ret) => {
              if (ret.success) {
                  //提示
                  AppComponent.GobalComponent.successMsg('身份证件认证提交成功，请稍后查看认证结果。');
                  AppComponent.GobalComponent.setLoading(false);
                 
              }else{
                AppComponent.GobalComponent.errorMsg(ret.errorMsg);
                AppComponent.GobalComponent.setLoading(false);
              }
            });
        });
    }else if(checkedArray.length > 1){
      AppComponent.alert({ 'title': '提示', 'text': '请选择一条数据!' });

    }else if(checkedArray.length  == 0){
        AppComponent.confirm("确定对所有考生进行身份证认证吗?",()=>{
          AppComponent.GobalComponent.setLoading(true);
          FrameRequest.request("std/stdRegInfo/identifyCardBatch.htm", {}, (ret) => {
            if (ret.success) {
                //提示
                AppComponent.GobalComponent.successMsg('身份证认证提交成功，请稍后查看认证结果。');
                AppComponent.GobalComponent.setLoading(false);
              
            }else{
              AppComponent.GobalComponent.errorMsg(ret.errorMsg);
              AppComponent.GobalComponent.setLoading(false);
            }
          });
      });

    }

  }

  downloadIdCardPhoto(){
    
    let mess = "";
    if(this.item.idcard_photo_path){
      mess = "身份证照片已经存在，确定重新更新身份证照片吗？";
    }else{
      mess = "确定更新身份证照片吗？";
    }

    AppComponent.confirm(mess,()=>{
      FrameRequest.request('std/stdRegInfo/downloadIdCardPhoto.htm',{std_id:this.item.id}, (resp) => {
        if(resp.success){
          if(resp.errorMsg){
            AppComponent.GobalComponent.errorMsg(resp.errorMsg);
        
          }else{
            this.item.idcard_photo_path = resp.entity.idcard_photo_path;
            AppComponent.GobalComponent.successMsg('下载身份证照片成功!');
          }
        }else{
          AppComponent.GobalComponent.errorMsg(resp.errorMsg);
         
        }
       }
     )
     
    });

    
  }

}
