var EpExam = {};
var locked = false;
EpExam.save = function (submit) {
    var id = $("#id").val();
    var checkState = $("#checkState").val();
    var checkMsg = $("#checkMsg").val();
    if (checkState == null || checkState == "") {
        Feng.info("请选择审核状态");
        return;
    }
    if (checkMsg == null || checkMsg == "") {
        Feng.info("请填写审核意见");
        return;
    }
    if (checkState == 5 && $("#field input[type=checkbox]:checked").length == 0) {
        Feng.info("请选择驳回修改的字段或者附件");
        return;
    }
    var fieldCount = $("#field_info input[type=checkbox]:checked").length;
    var fields = new Array();
    for (var i = 0; i < fieldCount; i++) {
        fields.push($("#field_info input[type=checkbox]:checked").eq(i).val());
    }
    var fileCount = $("#field_file input[type=checkbox]:checked").length;
    var files = new Array();
    for (var i = 0; i < fileCount; i++) {
        files.push($("#field_file input[type=checkbox]:checked").eq(i).val());
    }
    var da = {"id": id, "checkState": checkState, "checkMsg": checkMsg, fields: fields, files: files, submit: submit};
    //var operation = function () {
    var ajax = new $ax(Feng.ctxPath + "/enterprise/hospital/doExamine", function (data) {
        if (data.code == 200) {
            if (submit) {
                window.parent.Enterprise.table.refresh();
                parent.layer.closeAll();
            }
        }
        Feng.info(data.msg);
    }, function (data) {
        Feng.error("操作失败!" + data.responseJSON.message + "!");
    });
    ajax.set(da);
    ajax.start();
    //};
    //Feng.confirm("确定提交吗?", operation);
}
EpExam.addSubmit = function () {
    EpExam.save(0);
};
EpExam.submitToCheck = function () {
    EpExam.save(1);
};
EpExam.checkAll = function () {
    $("#field input[type=checkbox]").prop("checked", true);
}
EpExam.unCheckAll = function () {
    $("#field input[type=checkbox]").removeAttr("checked");
}

EpExam.toggleField = function () {
    var type = $("#type").val();
    var checkState = $("#checkState").val();
    var checkMsg = $("#checkMsg").val();
    var typeName = "医院";
    if (checkState == 6) {
        $("#field").css("display", "none");
        if (checkMsg == null || checkMsg == '') {
            $("#checkMsg").val(typeName + "注册审核通过。");
        }
    } else if (checkState == 5) {
        $("#checkMsg").val("");
        $("#field").css("display", "block");
    } else {
        $("#field").css("display", "none");
    }
}