/**
 * 初始化银行账号变更详情对话框
 */
var TalentBankChangeInfoDlg = {
    talentBankChangeInfoData : {}
};

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


//提交审核
TalentBankChangeInfoDlg.submitCheck = function(){
    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=\"TalentBankChangeInfoDlg.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 + "/talentBankChange/submitCheck", function(data){
                    if(data.code=="200"){
                        Feng.success(data.msg);
                        window.parent.TalentBankChange.table.refresh();
                        TalentBankChangeInfoDlg.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);
        }
    });
}


TalentBankChangeInfoDlg.toggleField = function(){
    var checkState = $("#checkStateNow").val();
    if(checkState==3){
        $("#msg").val("银行账号变更申报审核通过。");
    }else if(checkState==2){
        $("#msg").val("");
    }
}

$(function() {

});
