/**
 * 初始化人才基础信息变更详情对话框
 */
var TalentBasicChangeInfoDlg = {
    talentBasicChangeInfoData: {},
};

/**
 * 关闭此对话框
 */
TalentBasicChangeInfoDlg.close = function () {
    parent.layer.close(window.parent.TalentBasicChange.layerIndex);
}

/**
 * 提交审核
 */
TalentBasicChangeInfoDlg.showCheckModal = function () {
    var checkState = $("#checkState").val();
    if(checkState != 1 && checkState != 9){
        Feng.info("不在审核范围内");
        return;
    }
    layer.open({
        type: 1,
        id: "checkModel",
        title: '审核',
        area: ['800px', '450px'], //宽高
        fix: false, //不固定
        shade: 0,
        maxmin: true,
        content: " <form id=\"checkForm\" style='margin: 5px'>\n" +
            "                    <div class=\"form-group\">\n" +
            "                        <label for=\"checkState\" class=\"control-label\">审核状态</label>\n" +
            "                        <select class=\"form-control\" id=\"checkStateNow\" onchange=\"TalentBasicChangeInfoDlg.toggleField()\">\n" +
            "                            <option value=\"\"></option>\n" +
            "                            <option value=\"3\">审核通过</option>\n" +
            "                            <option value=\"2\">审核驳回</option>\n" +
            "                        </select>\n" +
            "                    </div>\n" +
            "                    <div class=\"form-group\">\n" +
            "                        <label for=\"msg\" class=\"control-label\">审核意见</label>\n" +
            "                        <textarea class=\"form-control\" id=\"msg\" rows='6'></textarea>\n" +
            "                    </div>\n" +
            "                </form>",
        btn: ['<i class="fa fa-save"></i>&nbsp;&nbsp;提交', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
        btnAlign: 'c',
        zIndex: layer.zIndex,
        success:function(){
            $("#checkForm")[0].reset();
        },
        yes: function (index, layero) {
            var id = $("#id").val();
            var checkState = $("#checkStateNow").val();
            var msg = $("#msg").val();
            if(checkState==null || checkState==''){
                Feng.error("请选择审核状态");
                return ;
            }
            if(msg==null || msg==''){
                Feng.error("请填写审核意见");
                return ;
            }
            var operation = function(){
                var ajax = new $ax(Feng.ctxPath + "/talentBasicChange/submitCheck", function(data){
                    if(data.code=="200"){
                        Feng.success(data.msg);
                        window.parent.TalentBasicChange.table.refresh();
                        layer.close(index);
                        TalentBasicChangeInfoDlg.close();
                    }else{
                        Feng.error(data.msg);
                    }
                },function(data){
                    Feng.error("提交失败!" + data.responseJSON.message + "!");
                });
                ajax.setData({"id":id,"checkState":checkState,"checkMsg":msg});
                ajax.start();
            }
            Feng.confirm("一旦提交，无法修改，确认提交审核吗?", operation);
        }
    });
}

TalentBasicChangeInfoDlg.toggleField = function(){
    var checkState = $("#checkStateNow").val();
    if(checkState==3){
        $("#msg").val("审核通过。");
    }else if(checkState==2){
        $("#msg").val("");
    }
}

$(function () {
    var id = $("#id").val();
    //批量加载字典表数据
    var arr = [
        {"name": "oldNationality", "code": "un_nationality"},
        {"name": "oldNation", "code": "un_nation"},
        {"name": "oldPolitics", "code": "un_political"},
        {"name": "oldCardType", "code": "un_cardType"},
        {"name": "newNationality", "code": "un_nationality"},
        {"name": "newNation", "code": "un_nation"},
        {"name": "newPolitics", "code": "un_political"},
        {"name": "newCardType", "code": "un_cardType"}
    ];
    Feng.findChildDictBatch(JSON.stringify(arr));
        //select初始化
    $("select").each(function () {
        $(this).val($(this).attr("value")).trigger("change");
    });
    Feng.getCheckLog("logTable", {"type": CONFIG.project_basicchange, "mainId": id, "typeFileId": "", "active": 1})
    $("input,select").attr("style","pointer-events: none;background-color: #eee;");
});
