/**
 * 人才认定申报管理初始化
 */
var TalentInfo = {
    id: "TalentInfoTable", //表格id
    seItem: null, //选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
TalentInfo.initColumn = function () {
    var type = $("#type").val();
    var superpriv = $("#superpriv").val();
    var process = $("#process").val();
    var isShowVerifyDept = false;
    isShowVerifyDept = process == 4 && superpriv ? true : false;
    return [
        {field: 'selectItem', checkbox: true},
        {title: '申报年度', field: 'apply_year', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
        {title: '医院名称', field: 'enterprise_name', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px",
            formatter: function (value, row, index) {
                return value + (row.isGeneral == 1 ? "（总院）" : "");
            }
        },
        {title: '医共体', field: 'medicalCommunityName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
        {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
            formatter: function (value, row, index) {
                if (row.sex == 1) {
                    return value + '<span style="color:#6495ED">【男】</span>';
                }
                if (row.sex == 2) {
                    return value + '<span style="color:#FF82AB">【女】</span>';
                }
            }
        },
        {title: '证件号码', field: 'card_number', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
        {title: '认定层次', field: 'talentArrangeName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "80px"},
        {title: '认定条件', field: 'talentConditionName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "150px"},
        {title: '审核部门', field: 'verifyDepts', visible: isShowVerifyDept, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "150px",
            formatter: function (value, row, index) {
                var html = "";
                for (var i in value) {
                    let checkState = "";
                    if (value[i].active == 1) {
                        if (value[i].checkState == 9) {
                            checkState = "<span style='color:#ff0000;'>审核驳回</span>";
                        }
                        if (value[i].checkState == 12) {
                            checkState = "<span style='color:green;'>审核通过</span>";
                        }
                    } else {
                        checkState = "<span style='color:gray;'>待审核</span>";
                    }
                    html += "<p style='margin:0 auto;'>" + value[i].name + "（" + checkState + "）</p>"
                }
                return html
            }
        },
        {title: '首次提交时间', field: 'first_submit_time', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '最新提交时间', field: 'new_submit_time', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '审核状态', field: 'checkState', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
            formatter: function (value, row, index) {
                if (typeof row.deptCheckState != "undefined") {
                    if ((row.deptActive == 0 && row.realState == 10) || !row.deptActive) {
                        if (row.resubmit) {
                            return "<span class='label label-success'>待部门并审（重新提交）</span>";
                        } else {
                            return "<span class='label label-success'>待部门并审（首次提交）</span>";
                        }
                    }
                    if (row.deptActive == 1 && row.newState == 12) {
                        return "<span class='label label-primary'>部门并审通过</span>";
                    }
                    if (row.deptActive == 1 && row.newState == 9) {
                        return "<span class='label label-danger'>部门并审驳回</span>";
                    }
                } else {
                    if (value == 1) {
                        return "<span class='label label-danger'>驳回到分院</span>"
                    }
                    if (value == 2) {
                        if (row.lastState == 4) {
                            return "<span class='label label-success'>待审核（重新提交）</span>"
                        }
                        if (row.realState == 6) {
                            return "<span class='label label-danger'>复审驳回</span>"
                        }
                        if (row.realState == 11) {
                            return "<span class='label label-danger'>驳回到总院</span>"
                        }
                        return "<span class='label label-success'>待审核</span>"
                    }
                    if (value == 3) {
                        return "<span class='label label-success'>待复审</span>"
                    }
                    if (value == 5) {
                        return "<span class='label label-success'>复审通过</span>"
                    }
                    if (value == 10) {
                        if (process == 3) {
                            if (row.pass_dept_check == 1) {
                                return "<span class='label label-success'>初审通过（待复审）</span>"
                            }
                            return "<span class='label label-success'>初审通过（待部门并审）</span>"
                        }
                        if (process == 4) {
                            if (row.resubmit) {
                                return "<span class='label label-success'>待部门并审（重新提交）</span>";
                            } else {
                                return "<span class='label label-success'>待部门并审（首次提交）</span>";
                            }
                        }
                        if (row.resubmit) {
                            return "<span class='label label-success'>待复审（重新提交）</span>";
                        } else {
                            return "<span class='label label-success'>待复审（首次提交）</span>";
                        }
                    }
                    if (value == 8) {
                        if (row.realState == 11) {
                            return "<span class='label label-danger'>初审驳回</span>"
                        } else {
                            return "<span class='label label-success'>保存未提交</span>"
                        }
                    }
                    if (value == 9) {
                        if (row.realState == 13) {
                            if (process == 3) {
                                return "<span class='label label-danger'>待初审（部门并审驳回）</span>";
                            }
                            return "<span class='label label-danger'>部门并审驳回</span>";
                        } else if (row.realState == 15) {
                            if (process == 3) {
                                return "<span class='label label-danger'>待初审（复审驳回）</span>";
                            }
                            return "<span class='label label-danger'>复审驳回</span>";
                        } else {
                            if (row.lastState == 11) {
                                return "<span class='label label-success'>待初审（重新提交）</span>"
                            }
                            return "<span class='label label-success'>待初审（首次提交）</span>"
                        }
                    }
                    if (value == -2) {
                        return "<span class='label label-danger'>初审不通过</span>"
                    }
                    if (value == 16) {
                        return "<span class='label label-danger'>复审不通过</span>"
                    }
                    if (value == -1 || value == 7) {
                        return "<span class='label label-danger'>审核不通过</span>"
                    }
                    if (value == 4) {
                        if (row.highProcess != null && row.highProcess != '' && row.highProcess >= 1) {
                            return "<span class='label label-success'>上级驳回</span>"
                        } else {
                            return "<span class='label label-success'>待审核</span>"
                        }
                    }
                    if (value == 11) {
                        if (row.highProcess != null && row.highProcess != '' && row.highProcess >= 3) {
                            return "<span class='label label-success'>上级驳回</span>"
                        } else {
                            return "<span class='label label-success'>待审核</span>"
                        }
                    }
                    if (value == 12) {
                        if (process == 4) {
                            return "<span class='label label-success'>部门并审通过</span>";
                        }
                        if (process == 3) {
                            return "<span class='label label-success'>待复审（部门并审通过）</span>";
                        }
                        if (row.resubmit) {
                            return "<span class='label label-success'>待复审（重新提交）</span>";
                        } else {
                            return "<span class='label label-success'>待复审（首次提交）</span>";
                        }
                    }
                    if (value == 13) {
                        if (row.highProcess != null && row.highProcess != '' && row.highProcess >= 4) {
                            return "<span class='label label-danger'>上级驳回</span>"
                        } else {
                            return "<span class='label label-success'>待审核</span>"
                        }
                    }
                    if (value == 14) {
                        return "<span class='label label-primary'>复审通过</span>"
                    }
                    if (value == 15) {
                        if (row.highProcess != null && row.highProcess != '' && row.highProcess >= 5) {
                            return "<span class='label label-success'>上级驳回</span>"
                        } else {
                            return "<span class='label label-success'>待审核</span>"
                        }
                    }
                }
            }
        },
        {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "80px",
            formatter: function (value, row, index) {
                return "<span class='label label-success' onclick=\"TalentInfo.showLog('" + value + "')\" >" +
                        "<i class=\"fa fa-book\"></i>日志" +
                        "</span>";
            }
        }
    ];
};
/**
 * 检查是否选中
 */
TalentInfo.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length != 1) {
        Feng.info("请先选中表格中的某一记录！");
        return false;
    } else {
        TalentInfo.seItem = selected[0];
        return true;
    }
};


TalentInfo.openCheckTalentInfo = function () {
    var title = $("#title").val();
    var process = $("#process").val();
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '人才认定' + " - " + title,
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            shade: 0,
            content: '/admin/talent/common_check/id/' + TalentInfo.seItem.id + '/process/' + process,
            btn: ['<i class="fa fa-eye"></i>&nbsp;&nbsp;保存未提交', '<i class="fa fa-save"></i>&nbsp;&nbsp;提交审核', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
            btnAlign: 'c',
            btn1: function (index, layero) {
                var obj = layero.find("iframe")[0].contentWindow;
                obj.TalentInfoInfoDlg.showFirstCheckModal();
            }, btn2: function (index, layero) {
                var obj = layero.find("iframe")[0].contentWindow;
                obj.TalentInfoInfoDlg.submitCheck();
                return false;
            }
        });
        layer.full(index);
        TalentInfo.layerIndex = index;
    }
}


TalentInfo.commonColumns = function () {
    return [
        {field: "selectItem", checkbox: true},
        {title: '申报年度', field: 'apply_year', visible: true, align: 'center', valign: 'middle', width: "10%"},
        {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle', width: "15%"},
        {title: '证件号码', field: 'card_number', visible: true, align: 'center', valign: 'middle', width: "15%"},
        {title: '人才层次', field: 'talentArrangeName', visible: true, align: 'center', valign: 'middle', width: "15%"},
        {title: '医院名称', field: 'enterpriseName', visible: true, align: 'center', valign: 'middle', width: "30%",
            formatter: function (value, row, index) {
                return value + (row.isGeneral == 1 ? "（总院）" : "");
            }
        },
        {title: '所属医共体', field: 'medicalCommunityName', visible: true, align: 'center', valign: 'middle', width: "15%"}
    ];
}

TalentInfo.openBatchCheckModal = function (type) {
    var columns = TalentInfo.commonColumns();
    $('#batchCheckTable').bootstrapTable('destroy');
    $('#batchCheckTable').bootstrapTable({
        url: Feng.ctxPath + "/admin/talent/find_fst_list",
        method: 'POST',
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        search: false, // 是否显示表格搜索，此搜索是客户端搜索，不会进服务端
        showRefresh: false, // 是否显示刷新按钮
        clickToSelect: true, // 是否启用点击选中行
        singleSelect: false, // 设置True 将禁止多选
        striped: true, // 是否显示行间隔色
        pagination: true, // 设置为 true 会在表格底部显示分页条
        paginationHAlign: "left",
        paginationDetailHAlign: "right",
        sidePagination: "client", // 设置在哪里进行分页，可选值为 'client' 或者 'server'
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize: 10, //每页的记录行数（*）
        pageList: [10, 25, 50, 100, 500, 1000, 1500], //可供选择的每页的行数（*）
        maintainSelected: true, //全表全选需要开启
        showColumns: false,
        responseHandler: function (res) {
            $("#batchCheckModal").modal("show");
            return res.obj.rows;
        },
        columns: columns
    });
}

/**
 * 刷新检索
 */
TalentInfo.bcSearch = function () {
    var apply_year = $("#bc_apply_year").val();
    var name = $("#bc_name").val();
    var enterprise_id = $("#bc_enterprise_id").val();
    var medicalCommunityId = $("#medicalCommunityId").val();
    var talent_arrange = $("#bc_talent_arrange").val();
    $('#batchCheckTable').bootstrapTable("refresh", {"query": {"name": name, "enterprise_id": enterprise_id, "talent_arrange": talent_arrange, "apply_year": apply_year, "medicalCommunityId": medicalCommunityId}});
}

/**
 * 重置
 */
TalentInfo.bcReset = function () {
    $("#bc_apply_year").val("");
    $("#bc_name").val("");
    $("#bc_enterprise_id").val("");
    $("#medicalCommunityId").val("");
    $("#bc_talent_arrange").val("");
}

$('#checkAllBatch').click(function () {
    $("#batchCheckTable").bootstrapTable('togglePagination').bootstrapTable('checkAll').bootstrapTable('togglePagination');
})
$('#uncheckAllBatch').click(function () {
    $("#batchCheckTable").bootstrapTable('togglePagination').bootstrapTable('uncheckAll').bootstrapTable('togglePagination')
})


TalentInfo.batchCheck = function () {
    var selected = $('#batchCheckTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = [];
    for (var i = 0; i < selected.length; i++) {
        ids.push(selected[i].id);
    }

    var ajax = new $ax("/admin/talent/findFieldsAndFilesForBatch", function (data) {
        if (data.code == 200) {
            var index = layer.open({
                type: 1,
                title: '审核',
                area: ['800px', '450px'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: TalentInfo.createFirstCheckModal(),
                btn: ['<i class="fa fa-save layui-bg-green"></i>&nbsp;&nbsp;提交审核', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
                btnAlign: 'c',
                success: function (layero, index) {
                    $("#batchCheckModal").modal("hide");
                    //layer.setTop(layero);
                    var html1 = '';
                    if (typeof data.fieldList != "undefined" && data.fieldList.length > 0) {
                        for (var key in data.fieldList) {
                            html1 += '<li style="float:left;margin:0 10px 10px 0;"><input type="checkbox" value="' + data.fieldList[key]["key"] + '"><span>' + data.fieldList[key]["value"] + '</span></li>';
                        }
                    }

                    var html2 = '';
                    for (var key in data.fileList) {
                        html2 = html2 + '<ul><li style="width: 100%"><input type="checkbox" value="' + data.fileList[key].id + '"><span>' + data.fileList[key].name + '</span></li></ul>';
                    }
                    $("#batchcount").html(ids.length + "人");
                    $("#checkMsg").text(data.checkMsg);
                    $("#firstBatchCheckForm #field_info ul").css("overflow", "hidden").html(html1);
                    $("#field_file").css("overflow", "hidden").empty().append(html2);
                },
                yes: function (index, layero) {
                    var checkState = $("#checkStateFirstModal").val();
                    var checkMsg = $("#checkMsgFirst").val();
                    if (checkState == null || checkState == '') {
                        Feng.info("请选择审核状态");
                        return;
                    }
                    if (checkMsg == null || checkMsg == '') {
                        Feng.info("请填写审核意见");
                        return;
                    }
                    var fields = '';
                    var files = '';
                    var companys = '';
                    $("#field_info li input").each(function (index) {
                        if ($(this).is(":checked")) {
                            fields = fields + $(this).val() + ",";
                        }
                    });
                    $("#field_file li input").each(function (index) {
                        if ($(this).is(":checked")) {
                            files = files + $(this).val() + ",";
                        }
                    });
                    if ((checkState == 2 || checkState == 6) && fields == '' && files == '') {
                        Feng.info("请选择可修改的字段或附件！");
                        return;
                    }
                    var ajax = new $ax("/admin/talent/batchCheck", function (data) {
                        if (data.code == 200) {
                            layer.close(i);
                            Feng.success(data.msg);
                        } else {
                            Feng.error(data.msg);
                        }
                        locked = false;
                    }, function (data) {
                        Feng.error("提交审核失败!" + data.responseJSON.message + "!");
                        locked = false;
                    });
                    ajax.setData({"ids": ids.join(","), "checkState": checkState, "checkMsg": checkMsg,
                        "fields": fields, "files": files})
                    ajax.start();
                }
            });
        } else {
            Feng.error(data.msg);
        }
    }, function (data) {
        Feng.error("查询失败!" + data.responseJSON.message + "!");
    });

    ajax.start();
}

/**
 * 打开查看人才认定-初级审核详情
 */
TalentInfo.openTalentInfoDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '人才认定申报详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/talentInfo/talentInfo_toDetail/' + TalentInfo.seItem.id + '/1'
        });
        layer.full(index);
        TalentInfo.layerIndex = index;
    }
};

TalentInfo.cancleThirdCheck = function () {
    if (this.check()) {
        var index = layer.open({
            type: 1,
            title: '撤销复核',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: '<form >\n' +
                    '                    <div class="form-group" style="margin: 10px;">\n' +
                    '                        <label for="checkMsg" class="control-label">撤销原因</label>\n' +
                    '                        <textarea class="form-control" id="msg" rows="6"></textarea>\n' +
                    '                    </div>\n' +
                    '                </form>',
            btn: ['<i class="fa fa-save layui-bg-green"></i>&nbsp;&nbsp;提交', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
            yes: function (index, layero) {
                var cancleMsg = $("#msg").val();
                if (Feng.isEmptyStr(cancleMsg)) {
                    Feng.error("撤销原因不能为空");
                    return;
                }
                var operation = function () {
                    var ajax = new $ax(Feng.ctxPath + "/admin/talent/cancleThirdCheck", function (data) {
                        if (data.code == 200) {
                            Feng.success(data.msg);
                            TalentInfo.table.refresh();
                            layer.close(index);
                        } else {
                            Feng.error(data.msg);
                        }
                        locked = false;
                    }, function (data) {
                        Feng.error("撤销复核失败!" + data.responseJSON.message + "!");
                        locked = false;
                    });
                    ajax.setData({"id": TalentInfo.seItem.id, "checkMsg": cancleMsg})
                    ajax.start();
                };
                Feng.confirm("一旦提交无法修改，确定要撤销吗?", operation);
            }
        });
    }
}


/**
 * 修改驳回的字段及附件
 */
TalentInfo.updateFieldsAndFiles = function () {
    if (this.check()) {
        var ajax = new $ax("/admin/talent/findFieldsAndFiles?id=" + TalentInfo.seItem.id, function (data) {
            if (data.code == 200) {
                layer.open({
                    type: 1,
                    id: "neewFieldFormModel",
                    title: '修改',
                    area: ['800px', '450px'], //宽高
                    fix: false, //不固定
                    shade: 0,
                    maxmin: true,
                    content: TalentInfo.creatFieldCheckModal(),
                    btn: ['<i class="fa fa-save"></i>&nbsp;&nbsp;提交', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
                    btnAlign: 'c',
                    zIndex: layer.zIndex,
                    success: function (layero, index) {

                        var html1 = '';
                        if (typeof data.fieldList != "undefined" && data.fieldList.length > 0) {
                            for (var key in data.fieldList) {
                                html1 += '<li style="float:left;margin:0 10px 10px 0;"><input type="checkbox" value="' + data.fieldList[key]["key"] + '"><span>' + data.fieldList[key]["value"] + '</span></li>';
                            }
                        }

                        var html2 = '';
                        for (var key in data.fileList) {
                            html2 = html2 + '<ul><li style="width: 100%"><input type="checkbox" value="' + data.fileList[key].id + '"><span>' + data.fileList[key].name + '</span></li></ul>';
                        }
                        $("#checkMsg").text(data.checkMsg);
                        $("#firstCheckForm #field_info ul").css("overflow", "hidden").html(html1);
                        $("#field_file").css("overflow", "hidden").empty().append(html2);
                        //$("#field_file").empty().append(html);
                        if (data.select.fields != null && data.select.fields != '') {
                            $("#firstCheckForm #field_info li input").each(function () {
                                if (data.select.fields.indexOf($(this).val()) != -1) {
                                    this.checked = true;
                                }
                            });
                        }
                        if (data.select.files != null && data.select.files != '') {
                            $("#field_file input").each(function () {
                                if (data.select.files.indexOf($(this).val()) != -1) {
                                    this.checked = true;
                                }
                            });
                        }
                    },
                    yes: function (index, layero) {
                        TalentInfo.submitFieldsAndFiles(index, data.id);
                    }
                });
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("查询失败!" + data.responseJSON.message + "!");
        });
        ajax.start();
    }
}

/**
 * 修改提交
 * @param index
 * @param id
 */
TalentInfo.submitFieldsAndFiles = function (index, id) {
    var fields = '';
    var files = '';
    var checkMsg = $("#checkMsg").val();
    $("#firstCheckForm #field_info li input").each(function (index) {
        if ($(this).is(":checked")) {
            fields = fields + $(this).val() + ",";
        }
    });
    $("#field_file li input").each(function (index) {
        if ($(this).is(":checked")) {
            files = files + $(this).val() + ",";
        }
    });
    if (checkMsg.trim() == '') {
        Feng.info("请填写审核意见！");
        return;
    }
    if (fields == '' && files == '') {
        Feng.info("请选择可修改的字段或附件！");
        return;
    }
    var ajax = new $ax("/admin/talent/updateFieldsAndFiles", function (data) {
        if (data.code == 200) {
            layer.close(index);
            Feng.success(data.msg);
        } else {
            Feng.error(data.msg);
        }
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.setData({"id": id, "fields": fields, "files": files, "checkMsg": checkMsg})
    ajax.start();
}

/**
 * 审核不通过
 */
TalentInfo.setNotPass = function () {
    var selecteds = $('#' + this.id).bootstrapTable('getSelections');
    if (selecteds.length == 0) {
        Feng.info("请选择需要设置审核不通过的行");
        return;
    }
    var ids = "";
    for (var key in selecteds) {
        ids = ids + selecteds[key].id + ",";
    }
    ids = ids.substring(0, ids.length - 1);
    layer.open({
        type: 1,
        id: "notPassModal",
        title: '修改',
        area: ['800px', '450px'], //宽高
        fix: false, //不固定
        shade: 0,
        maxmin: true,
        content: '<form id="checkNotPass">\n' +
                '                    <div class="form-group" style="margin: 10px;">\n' +
                '                        <label for="checkMsgNotPass" class="control-label" >审核不通过原因</label>\n' +
                '                        <textarea class="form-control" id="checkMsgNotPass" placeholder="此功能适用于未在申报提交截止时间内提交的数据"  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,
        yes: function (index, layero) {
            var checkMsg = $("#checkMsgNotPass").val();
            if (Feng.isEmptyStr(checkMsg)) {
                Feng.info("请填写审核不通过原因");
                return;
            }
            var operation = function () {
                var ajax = new $ax("/admin/talent/cancel_verify", function (data) {
                    if (data.code == 200) {
                        Feng.success(data.msg);
                        TalentInfo.table.refresh();
                        layer.close(index);
                    } else {
                        Feng.error(data.msg);
                    }
                }, function (data) {
                    Feng.error("设置审核不通过失败!" + data.responseJSON.message + "!");
                });
                ajax.set("ids", ids);
                ajax.set("msg", checkMsg);
                ajax.start();
            }
            Feng.confirm("一旦提交无法修改，确定设置所选数据为审核不通过?", operation);
        }
    });

}

TalentInfo.createFirstCheckModal = function () {
    return '<form id="firstBatchCheckForm">\n' +
            '                    <div class="form-group" style="margin: 10px;">\n' +
            '                        <label for="checkState" class="control-label">审核人数</label>\n' +
            '                        <div class="form-control" id="batchcount">\n' +
            '                        </div>\n' +
            '                    </div>\n' +
            '                    <div class="form-group" style="margin: 10px;">\n' +
            '                        <label for="checkState" class="control-label">审核状态</label>\n' +
            '                        <select class="form-control" id="checkStateFirstModal" onchange="TalentInfo.toggleField()">\n' +
            '                            <option value="">请选择</option>\n' +
            '                            <option value="3">审核通过</option>\n' +
            '                            <option value="2">审核驳回</option>\n' +
            '                            <option value="6">驳回到分院</option>\n' +
            '                        </select>\n' +
            '                    </div>\n' +
            '                    <div class="form-group" style="margin: 10px;">\n' +
            '                        <label for="checkMsg" class="control-label" >审核意见</label>\n' +
            '                        <textarea class="form-control" id="checkMsgFirst" placeholder="审核状态属“审核通过”的，仅代表此步骤已操作完成，不代表用户提交的信息符合认定条件。若不符合认定条件的，请写明不符合原因。" rows="6"></textarea>\n' +
            '                        <div id="company_list" style="padding-top:5px;display:none;">\n' +
            '                            <label for="checkMsg" class="control-label">选择需要再次审核的部门</label>\n' +
            '                            <div id="companys">' +
            '                               <ul style="overflow:hidden;list-style:none;"></ul>' +
            '                            </div>' +
            '                        </div>\n' +
            '                        <div id="modify" style="padding-top: 5px;display: none">\n' +
            '                            <label for="checkMsg" class="control-label">可修改字段</label>\n' +
            '                            <div id="field_info">\n' +
            '                                <ul style="overflow:hidden;list-style:none;">\n' +
            '                                </ul>\n' +
            '                            </div>\n' +
            '                            <label for="checkMsg" class="control-label">可修改附件</label>\n' +
            '                            <div id="field_file">\n' +
            '                            </div>\n' +
            '                            <div class="form-group" style="text-align: center">\n' +
            '                                <button type="button" class="btn btn-primary" onclick="TalentInfo.bcCheckAll(this)">全选</button>\n' +
            '                                <button type="button" class="btn btn-success" onclick="TalentInfo.bcUnCheckAll(this)">反选</button>\n' +
            '                            </div>\n' +
            '                        </div>\n' +
            '                    </div>\n' +
            '                </form>';

}


TalentInfo.bcCheckAll = function (context) {
    $("#modify input[type=checkbox]").prop("checked", "checked");
}
TalentInfo.bcUnCheckAll = function (context) {
    $("#modify input[type=checkbox]").removeAttr("checked");
}

/**
 * 显示字段或者隐藏字段选择
 */
TalentInfo.toggleField = function () {
    var checkState = $("#checkStateFirstModal").val();
    var checkMsgFirst = $("#checkMsgFirst").val();
    $("#company_list").hide();
    if (checkState == 2 || checkState == 6) {
        $("#modify").show();
        $("#checkMsgFirst").val("");
    } else if (checkState == 3 || checkState == 4 || checkState == 5) {
        $("#modify").hide();
        $("#modify").find("input[type=checkbox]").removeAttr("checked");
        if (checkMsgFirst == null || checkMsgFirst == '' || checkMsgFirst == "等待部门审核") {
            $("#checkMsgFirst").val("审核通过");
        }
        if (checkState == 5) {
            $("#company_list").show();
        }
    } else if (checkState == -1) {
        $("#modify").hide();
        $("#checkMsgFirst").val("审核不通过");
    }
}


TalentInfo.creatFieldCheckModal = function () {
    return '<form id="firstCheckForm">\n' +
            '                    <div class="form-group" style="margin: 10px;">\n' +
            '                        <div >\n' +
            '                        <label for="checkMsg" class="control-label" >审核意见</label>\n' +
            '                        <textarea class="form-control" id="checkMsg" placeholder="审核状态属“审核通过”的，仅代表此步骤已操作完成，不代表用户提交的信息符合认定条件。若不符合认定条件的，请写明不符合原因。" rows="6"></textarea>\n' +
            '                            <label for="checkMsg" class="control-label">可修改字段</label>\n' +
            '                            <div id="field_info">\n' +
            '                                <ul>\n' +
            '                                </ul>\n' +
            '                            </div>\n' +
            '                            <label for="checkMsg" class="control-label">可修改附件</label>\n' +
            '                            <div id="field_file">\n' +
            '                            </div>\n' +
            '                            <div class="form-group" style="text-align: center">\n' +
            '                                <button type="button" class="btn btn-primary" onclick="TalentInfo.checkAll()">全选</button>\n' +
            '                                <button type="button" class="btn btn-success" onclick="TalentInfo.unCheckAll()">反选</button>\n' +
            '                            </div>\n' +
            '                        </div>\n' +
            '                    </div>\n' +
            '                </form>';
}

TalentInfo.fieldCheckd = function (context) {
    if ($(context).get(0).checked) {
        $(context).parent().next().children()[0].checked = true;
        $(context).parent().next().children().eq(0).trigger("change");
    }
}

TalentInfo.sourceCheckd = function (context) {
    if ($(context).get(0).checked) {
        $("#talentArrangeCheckBox").attr("checked", true);
        $("#talentArrangeCheckBox").trigger("change");
    }
}

TalentInfo.getPhones = function () {
    var process = $("#process").val();
    var ajax = new $ax("/admin/talent/getPhones/process/" + process, function (data) {
        if (data.code == 200) {
            layer.open({
                type: 1,
                title: "手机号码",
                area: ['830px', '300px'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: "<span style='word-break:break-all'>" + data.obj + "</span>"
            });
        } else {
            Feng.info(data.msg);
        }
    }, function (data) {
        Feng.error("操作失败!");
    });
    ajax.setData(TalentInfo.formParams());
    ajax.start();
}


TalentInfo.getEnterprisePhones = function () {
    var process = $("#process").val();
    var ajax = new $ax("/admin/talent/getEnterprisePhones/process/" + process, function (data) {
        if (data.code == 200) {
            layer.open({
                type: 1,
                title: "手机号码",
                area: ['830px', '300px'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: "<span style='word-break:break-all'>" + data.obj + "</span>"
            });
        } else {
            Feng.info(data.msg);
        }
    }, function (data) {
        Feng.error("操作失败!");
    });
    ajax.setData(TalentInfo.formParams());
    ajax.start();
}

$(function () {
    var defaultColunms = TalentInfo.initColumn();
    var process = $("#process").val();
    var table = new BSTable(TalentInfo.id, "/admin/talent/base_verify_list/process/" + process, defaultColunms);
    table.setPaginationType("server");
    table.setSingleSelect(false);
    table.setOnDblClickRow(function () {
        TalentInfo.openCheckTalentInfo();
    });
    TalentInfo.table = table.init();
    TalentInfo.init();

    // var defaultColunms = TalentInfo.initColumn();
    // var table = new KDTable(TalentInfo.id, "/talentInfo/list/1", defaultColunms);
    // table.setPaginationType("server");
    // TalentInfo.table = table.init();
});
