import { FlexTableComponent } from "./../../../../shared/common/FlexTable.component";
import { Component, OnInit } from "@angular/core";
import { FormBuilder, Validators } from "@angular/forms";
import { CustomValidators } from "ng2-validation";
import { BsModalService } from "ngx-bootstrap/modal";
import { AppComponent } from "../../../..";
import { FrameRequest } from "../../../../shared/frame/frame-request";
import * as _ from 'lodash';

@Component({
    selector: "app-std-info-modify-hisquery",
    templateUrl: "./std-info-modify.hisquery.component.html",
    styleUrls: ["./std-info-modify.hisquery.component.scss"]
})
export class StdInfoModifyHisqueryComponent extends FlexTableComponent implements OnInit {
    public query = {
        "std_name": "",
        "cert_no": "",
        "ticket_no": "",
        "is_his":"1"
    };

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

    constructor(public bsModalService: BsModalService, fb: FormBuilder) {
        super();
        this.formModel = fb.group({
            id: [null],
            'std_name': [null],
            'cert_no': [null],
            'ticket_no': [null],
            'modify_content': [null],
            'status': [null],
            'apply_time': [null],
            'modify_remark': [null],
            'verify_person1': [null],
            'verify_time1': [null],
            'verify_remark2': [null],
            'verify_person2': [null],
            'verify_time2': [null],
            'verify_remark1': [null],
        });
    }

    transModifyContent(val) {
        if (val == 1) {
            return "姓名";
        } else if (val == 2) {
            return "身份证号";
        } else if (val == 3) {
            return "照片";
        } else if (val == 4) {
            return "身份证号，照片";
        } else if (val == 5) {
            return "身份证号，姓名";
        }else if (val == 6) {
            return "姓名，照片";
        }
    }

    search(param) {
        let searchCondition = this.query;
        _.assignIn(param,searchCondition);
        param.is_his = 1;

    }

    goVerify(tpl, item?) {
        if(!item){
            let items = this.framePager.getCheckedArray();
            if(items.length == 0){
                AppComponent.alert({title:"信息提示",text:"请选择操作数据!"});
                return;
            }

            if(items.length > 1){
                AppComponent.alert({title:"信息提示",text:"只运行选择单条数据!"});
                return;
            }
        }
        AppComponent.GobalComponent.setLoading(true);
        FrameRequest.requestMap("std/stdInfoModifyApply/toVerify.htm", {apply_id:item.id}, (map) => {
            let url = map.url;
            let apply = map.apply;
            let std = map.std;
            let http_url = map.http_url;

            //apply.old_std_name = std.std_name;
            //apply.old_cert_no = std.cert_no;
            if( apply.face_file_path){
                apply.face_file_path_full = url + apply.face_file_path;
               }

            if(apply.old_photo_path){
            apply.old_face_file_path_full = http_url + apply.old_photo_path;
            }
            apply.cert_file_path_full = url + apply.cert_file_path;

            this.item = apply;
            this.bsModalWin = this.bsModalService.show(tpl, { class: "modal-lg" });
            AppComponent.GobalComponent.setLoading(false);
        });
    }

    downWord(){
        FrameRequest.download("std/stdInfoModifyApply/download.htm",{templateName:"广西自学考试考生基本信息更正申请表.doc"}, ()=>{
            AppComponent.GobalComponent.setLoading(false);
            AppComponent.GobalComponent.successMsg("下载成功");
        });
    }

     
}
