/**
 * 初始化子女就学详情对话框
 */
var EducationSchoolInfoDlg = {
    educationSchoolInfoData : {},
};



/**
 * 申报人变更
 * @param content
 */
EducationSchoolInfoDlg.nameChange = function(content){
    var talentId = $(content).val();
    if(Feng.isEmptyStr(talentId)){
        $("#talentId,#pSex,#pIdcard,#talentArrange,#certificateNo,#nativePlace").val("");
        return ;
    }
    var ajax = new $ax(Feng.ctxPath + "/api/talentInfo/detail/"+talentId, function(data){
        $("#pName").val(data.name);
        $("#pSex").val(data.sex);
        $("#pIdcard").val(data.idCard);
        $("#talentArrange").val(data.talentArrange);
        $("#certificateNo").val(data.certificateNO);
        $("#nativePlace").val(data.provinceName+data.cityName+data.countyName);
        $("#address").val(data.streetName);
        $("#phone").val(data.phone);
    },function(data){
        Feng.error("查询失败!" + data.responseJSON.message + "!");
    });
    ajax.start();
}

/**
 * 项目选择变更
 * @param content
 */
EducationSchoolInfoDlg.projectChange = function(content){
    var project = $(content).val();
    if(Feng.isEmptyStr(project)){
        $("#applySchool").val("").parent().css("display","none");
    }
    if(project == CONFIG.education_school){
        $("#applySchool").val("").parent().css("display","block");
    }
    if(project == CONFIG.education_score){
        $("#applySchool").val("").parent().css("display","none");
    }
}


$(function() {
    Feng.initValidatorTip("educationSchoolForm",EducationSchoolInfoDlg.validateFields);
    //批量加载字典表数据
    var arr = [
        {"name":"companyStreet","code":"un_street"},
        {"name":"houseStreet","code":"un_street"},
        {"name":"talentArrange","code":"un_talentLevel"},
        {"name":"cRelation","code":"un_education_relation"},
        {"name":"nowGrade","code":"un_grade"},
        {"name":"project","code":"un_educationSchool_project"},
        {"name":"applySchool","code":"un_school_pool"}];
    Feng.findChildDictBatch(JSON.stringify(arr));
    $("#applySchool").on('chosen:ready', function(e, params) {
        $(".chosen-container-single .chosen-single").css("padding","4px 0px 0px 4px");
    });
    $("#applySchool").chosen({
        search_contains:true,       //关键字模糊搜索。设置为true，只要选项包含搜索词就会显示；设置为false，则要求从选项开头开始匹配
        disable_search: false,
        width:"100%",
        enable_split_word_search: true
    });
    $("select").each(function () {
        $(this).val($(this).attr("value")).trigger("change").trigger("chosen:updated");
    });
    var id = $("#id").val();
    if(Feng.isNotEmptyStr(id)){
        $("#fileLi").removeAttr("style");
        Feng.getCheckLog("logTable",{"type":CONFIG.project_school,"mainId":id,"typeFileId":"","active":1})
    }else{
        $("#fileLi").attr("style","pointer-events: none");
    }
});
