/**
 * 硕博人才生活补贴申报管理初始化
 */
var LivingAllowanceInfo = {
    id: "LivingAllowanceInfoTable", //表格id
    seItem: null, //选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
LivingAllowanceInfo.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '申报年度', field: 'year', visible: true, align: 'center', valign: 'middle', width: '80px'},
        {title: '申报补贴年次', field: 'applyCount', visible: true, align: 'center', valign: 'middle', width: '100px',
            formatter: function (value, row, index) {
                if (value == 1) {
                    return "首年";
                }
                if (value == 2) {
                    return "第二年";
                }
                if (value == 3) {
                    return "第三年";
                }
            }
        },
        {title: '申报类型', field: 'declareTypeName', visible: true, align: 'center', valign: 'middle', width: '80px'},
        {title: '引进方式', field: 'introductionMethod', visible: true, align: 'center', valign: 'middle', width: '80px',
            formatter: function (value, row, index) {
                if (value == 1) {
                    return "新引进";
                }
                if (value == 2) {
                    return "其他";
                }
            }
        },
        {
            title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle', width: "100px", 'class': 'uitd_showTip',
            formatter: function (value, row, index) {
                return row.sex == 1 ? value + '<span style="color:#6495ED">【男】</span>' : value + '<span style="color:#FF82AB">【女】</span>';
            }
        },
        // {title: '人才类别', field: 'type', visible: true, align: 'center', valign: 'middle',width:"100px",
        //     formatter : function (value,row,index){
        //         return value == 1?"晋江市优秀人才":"集成电路优秀人才";
        //     }
        // },
        {
            title: '证件号码',
            field: 'idCard',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "150px"
        },
        {
            title: '企业名称',
            field: 'enterpriseName',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '最高学历',
            field: 'highEducation',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '毕业学校',
            field: 'graduateSchool',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '手机号码',
            field: 'phone',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '本单位入职时间',
            field: 'entryTime',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '首次来晋工作时间',
            field: 'firstInJJTime',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px"
        },
        {
            title: '推荐兑现状态',
            field: 'recommendIsPay',
            visible: $("#process").val() == 4,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px",
            formatter: function (value, row, index) {
                if (value == -1) {
                    return "<span style='color: red'>不予兑现</span>"
                }
                if (value == 0) {
                    return "<span style='color: #2401fd'>未知</span>"
                }
                if (value == 1) {
                    return "<span style='color: green'>待兑现</span>"
                }
                if (value == 2) {
                    return "<span style='color: #6d008b'>已兑现</span>"
                }
            }
        },
        {
            title: '推荐兑现金额', field: 'recommendAmount', visible: $("#process").val() == 4, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
        },
        {
            title: '推荐判定描述', field: 'recommendJudgmentDetails', visible: $("#process").val() == 4, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
            // formatter: function (value,row,index) {
            //     if(Feng.isNotEmptyStr(value)){
            //         var arr = value.split(";");
            //         var str = "";
            //         for(var i=0;i<arr.length;i++){
            //             if(Feng.isNotEmptyStr($.trim(arr[i]))){
            //                 str = str + (i+1) + "." + arr[i]
            //             }
            //         }
            //         return str
            //     }
            //     return value;
            // }
        },
        {
            title: '推荐计算描述', field: 'recommendAmountDesc', visible: $("#process").val() == 4, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
            // formatter: function (value,row,index) {
            //     if(Feng.isNotEmptyStr(value)){
            //         var arr = value.split(";");
            //         var str = "";
            //         for(var i=0;i<arr.length;i++){
            //             if(Feng.isNotEmptyStr($.trim(arr[i]))) {
            //                 str = str + (i + 1) + "." + arr[i] +
            //             }
            //         }
            //         return str
            //     }
            //     return value;
            // }
        },
        {
            title: '实际兑现状态',
            field: 'isPay',
            visible: $("#process").val() == 4,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px",
            formatter: function (value, row, index) {
                if (value == -1) {
                    return "<span style='color: red'>不予兑现</span>"
                }
                if (value == 0) {
                    return "<span style='color: #2401fd'>未知</span>"
                }
                if (value == 1) {
                    return "<span style='color: green'>待兑现</span>"
                }
                if (value == 2) {
                    return "<span style='color: #6d008b'>已兑现</span>"
                }
            }
        },
        {
            title: '实际兑现金额', field: 'amount', visible: $("#process").val() == 4, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
        },
        {
            title: '实际判定描述', field: 'judgmentDetails', visible: $("#process").val() == 4, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
            formatter: function (value, row, index) {
                if (Feng.isNotEmptyStr(value)) {
                    var arr = value.split(";");
                    return arr.join("</br>")
                }
                return value;
            }
        },
        {
            title: '实际计算描述', field: 'amountDesc', visible: $("#process").val() == 4, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
            formatter: function (value, row, index) {
                if (Feng.isNotEmptyStr(value)) {
                    var arr = value.split(";");
                    return arr.join("</br>")
                }
                return value;
            }
        },
        {
            title: '审核状态',
            field: 'checkState',
            visible: $("#process").val() == 1,
            align: 'center',
            valign: 'middle',
            width: "100px",
            formatter: function (value, row, index) {
                if (value == -1) {
                    return "<span class='label label-danger'>审核不通过</span>"
                }
                if (value == 1) {
                    return "<span class='label'>待提交</span>"
                }
                if (value == 7) {
                    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 == 20) {
                    if (row.highProcess != null && row.highProcess != '' && row.highProcess >= 1) {
                        return "<span class='label label-danger'>上级驳回</span>"
                    } else {
                        return "<span class='label label-success'>待审核</span>"
                    }
                }
                if (value == 30) {
                    if (row.highProcess != null && row.highProcess != '' && row.highProcess >= 1) {
                        return "<span class='label label-danger'>复核驳回</span>"
                    } else {
                        return "<span class='label label-success'>待审核</span>"
                    }
                }
                if (value == 10) {
                    return "<span class='label label-danger'>已驳回</span>"
                }
                if (value == 15 || value >= 25) {
                    return "<span class='label label-primary'>已通过</span>"
                }
            }
        },
        {
            title: '审核状态',
            field: 'checkState',
            visible: $("#process").val() == 2,
            align: 'center',
            valign: 'middle',
            width: "100px",
            formatter: function (value, row, index) {
                if (value == -1) {
                    return "<span class='label label-danger'>审核不通过</span>"
                } else if (value <= 10 || value == 20) {
                    return "<span class='label label-danger'>已驳回</span>"
                } else if (value == 15) {
                    if (row.highProcess != null && row.highProcess != '' && row.highProcess >= 2) {
                        return "<span class='label label-success'>重新提交</span>"
                    } else {
                        return "<span class='label label-success'>待审核</span>"
                    }
                } else if (value >= 25) {
                    return "<span class='label label-primary'>已通过</span>"
                }

            }
        },
        {
            title: '审核状态',
            field: 'checkState',
            visible: $("#process").val() == 3,
            align: 'center',
            valign: 'middle',
            width: "120px",
            formatter: function (value, row, index) {
                if (value == -1) {
                    return "<span class='label label-danger'>审核不通过</span>"
                }
                if (value == 25) {
                    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 == 30 || value <= 20) {
                    return "<span class='label label-danger'>已驳回</span>"
                }
                if (value >= 35) {
                    return "<span class='label label-primary'>已通过</span>"
                }
            }
        },
        {
            title: '审核状态',
            field: 'checkState',
            visible: $("#process").val() == 4,
            align: 'center',
            valign: 'middle',
            width: "120px",
            formatter: function (value, row, index) {
                if (value == -1) {
                    return "<span class='label label-danger'>审核不通过</span>"
                }
                if (value == 35) {
                    return "<span class='label label-primary'>已通过</span>"
                }
            }
        },
        {
            title: '公示状态',
            field: 'isPublic',
            visible: true,
            align: 'center',
            valign: 'middle',
            'class': 'uitd_showTip',
            width: "100px",
            formatter: function (value, row, index) {
                if (value == 1) {
                    return "<span class='label label-info'>待核查征信</span>"
                }
                if (value == 2) {
                    return "<span class='label label-success'>待公示</span>"
                }
                if (value == 3) {
                    return "<span class='label label-danger'>公示中</span>"
                }
                if (value == 4) {
                    if (row.checkState == -1) {
                        return "<span class='label label-danger'>审核不通过</span>"
                    }
                    return "<span class='label label-primary'>待兑现</span>"
                }
                if (value == 5) {
                    return "<span class='label label-primary'>已兑现</span>"
                }
            }
        },
        {
            title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: '80px',
            formatter: function (value, row, index) {
                return "<span class='label label-success' onclick=\"LivingAllowanceInfo.showLog('" + value + "')\" >" +
                        "<i class=\"fa fa-book\"></i>日志" +
                        "</span>";
            }
        }
    ];
};

/**
 * 检查是否选中
 */
LivingAllowanceInfo.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录！");
        return false;
    } else {
        LivingAllowanceInfo.seItem = selected[0];
        return true;
    }
};

/**
 * 点击审核硕博人才生活补贴申报
 * @param process
 */
LivingAllowanceInfo.openCheckLivingAllowanceInfo = function (process) {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '硕博人才生活补贴审核',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/admin/living_allowance/detail?id=' + LivingAllowanceInfo.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.LivingAllowanceInfoInfoDlg.showCheckModal(process);
            }, btn2: function (index, layero) {
                var obj = layero.find("iframe")[0].contentWindow;
                obj.LivingAllowanceInfoInfoDlg.submitCheck(process);
                return false;
            }
        });
        layer.full(index);
        LivingAllowanceInfo.layerIndex = index;
    }
};

/**
 * 打开查看硕博人才生活补贴申报详情
 */
LivingAllowanceInfo.openLivingAllowanceInfoDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '硕博人才生活补贴申报详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/livingAllowanceInfo/livingAllowanceInfo_update/' + LivingAllowanceInfo.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 修改驳回的字段及附件
 */
LivingAllowanceInfo.updateFieldsAndFiles = function () {
    if (this.check()) {
        var ajax = new $ax("/admin/living_allowance/findFieldsAndFiles?id=" + LivingAllowanceInfo.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: LivingAllowanceInfo.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 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>';
                        }
                        $("#firstCheckForm #field_info ul").css("overflow", "hidden");
                        $("#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) {
                        LivingAllowanceInfo.submitFieldsAndFiles(index, data.id);
                    }
                });
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("查询失败!" + data.responseJSON.message + "!");
        });
        ajax.start();
    }
}

/**
 * 修改提交
 * @param index
 * @param id
 */
LivingAllowanceInfo.submitFieldsAndFiles = function (index, id) {
    var fields = '';
    var files = '';
    $("#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 (fields == '' && files == '') {
        Feng.info("请选择可修改的字段或附件！");
        return;
    }
    var ajax = new $ax("/admin/living_allowance/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})
    ajax.start();
}

LivingAllowanceInfo.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' +
            '                            <div id="field_info">\n' +
            '                                <ul>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="declareType"><span>申报对象类型</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="introductionMethod"><span>引进方式</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="name"><span>姓名</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="sex"><span>性别</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="birthday"><span>出生日期</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="nationality"><span>国籍/地区</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="provinceCode"onchange="LivingAllowanceInfoInfoDlg.fieldCheckd(this)"><span>籍贯省</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="cityCode" onchange="LivingAllowanceInfoInfoDlg.fieldCheckd(this)"><span>籍贯市</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="countyCode"><span>籍贯县</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="nation"><span>民族</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="politics"><span>政治面貌</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="cardType"><span>证件类型</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="idCard"><span>证件号码</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="firstInJJTime"><span>首次来晋工作时间</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="backJJBusinessTime"><span>返晋创业时间</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="entryTime"><span>本单位入职时间</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="post"><span>职务</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="startTime"><span>工作合同开始时间</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="endTime"><span>工作合同结束时间</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="firstSocialSecurityTime"><span>首次社保缴纳时间</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="highEducation"><span>最高学历</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="graduateSchool"><span>毕业院校</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="studyAbroadTime"><span>学位证书取得时间</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="major"><span>专业</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="title"><span>职称</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="professionalQualifications"><span>国家职业资格</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="studyAbroad"><span>是否有留学经历</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="phone"><span>手机号码</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="email"><span>电子邮箱</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="bank"><span>开户银行</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="bankNetwork"><span>开户银行网点</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="bankNumber"><span>银行行号</span></li>\n' +
            '                                    <li style="width:10%"><input type="checkbox" value="bankAccount"><span>银行账号</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="educationAndResume"><span>教育背景及工作简历</span></li>\n' +
            '                                    <li style="width:22%"><input type="checkbox" value="mainHonours"><span>主要业绩及取得的荣誉</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="socialSecurity"><span>社保缴纳情况</span></li>\n' +
            '                                    <li style="width:20.5%"><input type="checkbox" value="personalTax"><span>个税缴纳情况</span></li>\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="LivingAllowanceInfo.checkAll()">全选</button>\n' +
            '                                <button type="button" class="btn btn-success" onclick="LivingAllowanceInfo.unCheckAll()">反选</button>\n' +
            '                            </div>\n' +
            '                        </div>\n' +
            '                    </div>\n' +
            '                </form>';
}

/**
 * 显示核查征信驳回模态框
 */
LivingAllowanceInfo.showHczxRejectModal = function () {
    if (this.check()) {
        if (LivingAllowanceInfo.seItem.isPublic != 1) {
            Feng.info("当前记录不是待核查征信状态，无法核查");
            return;
        }
        $("#hczxId").val(LivingAllowanceInfo.seItem.id);
        $("#hczxMsg").val("");
        $("#hczxRejectModal").modal("show");
    }
}

/**
 * 核查征信驳回提交
 */
LivingAllowanceInfo.hczxReject = function () {
    var id = $("#hczxId").val();
    var msg = $("#hczxMsg").val();
    if (msg == null || msg == '') {
        Feng.info("请填写失信原因");
        return;
    }
    var operation = function () {
        var ajax = new $ax(Feng.ctxPath + "/livingAllowanceInfo/hczxReject", function (data) {
            if (data.code == 200) {
                Feng.success(data.msg);
                LivingAllowanceInfo.table.refresh();
                $("#hczxRejectModal").modal("hide");
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("核查征信失败!" + data.responseJSON.message + "!");
        });
        ajax.setData({"id": id, "outMsg": msg, "creditStatus": 3});
        ajax.start();
    }
    Feng.confirm("一旦提交无法修改，确定提交吗?", operation);
}

LivingAllowanceInfo.showDataCheckModal = function (type) {
    $("#hczxForm").css("display", "none");
    switch (type) {
        case 1:                     //待核查征信名单-导出
            $("#hczxButton").attr("onclick", "LivingAllowanceInfo.checkExport()").text("导出");
            $("#exportCommonModalLabel").text("待核查征信名单");
            break;
        case 2:                     //待核查征信名单-核查征信通过
            $("#hczxButton").attr("onclick", "LivingAllowanceInfo.hczxPass()").text("提交");
            $("#exportCommonModalLabel").text("待核查征信名单");
            break;
        case 3:                     //公示（批量）
            $("#hczxButton").attr("onclick", "LivingAllowanceInfo.public()").text("公示");
            $("#exportCommonModalLabel").text("待公示名单");
            $("#hczxForm").css("display", "block");
            $(".time").each(function () {
                laydate.render({
                    elem: "#" + $(this).attr("id")
                    , type: 'date'
                    , format: 'yyyy年MM月dd日'
                });
            });
            break;
        case 4:                     //公示通过（批量）
            $("#hczxButton").attr("onclick", "LivingAllowanceInfo.publicPass()").text("提交");
            $("#exportCommonModalLabel").text("公示通过名单");
            break;
        case 5:                     //待公布名单
            $("#hczxButton").attr("onclick", "LivingAllowanceInfo.publish()").text("公布");
            $("#exportCommonModalLabel").text("待公布名单");
            break;
        case 6:                     //待发证名单
            $("#hczxButton").attr("onclick", "LivingAllowanceInfo.issue()").text("提交");
            $("#exportCommonModalLabel").text("待发证名单");
            break;
        case 7:                     //公示名单预览
            $("#hczxButton").attr("onclick", "LivingAllowanceInfo.needPublicExport()").text("导出");
            $("#exportCommonModalLabel").text("待公示名单");
            break;
    }
    $('#dataTable').bootstrapTable('destroy');
    $('#dataTable').bootstrapTable({
        url: Feng.ctxPath + "/admin/living_allowance/selectNeedCheckData?type=" + type,
        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) {
            $("#exportCommonModal").modal("show");
            return res.obj.rows;
        },
        columns:
                [
                    {field: "selectItem", checkbox: true},
                    {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle', width: "20%"},
                    {title: '证件号码', field: 'idCard', visible: true, align: 'center', valign: 'middle', width: "30%"},
                    {
                        title: '企业名称',
                        field: 'enterpriseName',
                        visible: true,
                        align: 'center',
                        valign: 'middle',
                        width: "40%"
                    },
                    {
                        title: '审核状态', field: 'checkState', visible: true, align: 'center', valign: 'middle', width: "10%",
                        formatter: function (value, row, index) {
                            if (value == -1) {
                                return "<span style='color: #ed5565;'>审核不通过</span>";
                            }
                            if (value == 35) {
                                return "<span style='color: #1ab394;'>审核通过</span>";
                            }
                        }
                    },
                ]

    });
}


/**
 * 选择导出提交
 */
LivingAllowanceInfo.checkExport = function () {
    var selected = $('#dataTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = "";
    for (var i = 0; i < selected.length; i++) {
        ids = ids + selected[i].id + ",";
    }
    window.location.href = Feng.ctxPath + "/admin/living_allowance/exportHczx?ids=" + ids;
}

LivingAllowanceInfo.actalUpload = function () {
    $("#file,#fileName").val("");
    $("#importModal").modal("show");
}


/**
 *
 */
LivingAllowanceInfo.importSubmit = function () {
    $("#import-form")[0].submit();
    // layer.confirm('您需要导入数据并提交吗?', {
    //     btn: ['仅导入','导入并提交','取消'] //按钮
    // }, function(index){
    //     $("#importType").val(1);
    //     $("#import-form")[0].submit();
    //     layer.close(index);
    // }, function(index){
    //     $("#importType").val(2);
    //     $("#import-form")[0].submit();
    //     layer.close(index);
    // }, function(index){
    //     layer.close(index);
    // });
}


LivingAllowanceInfo.importCallBack = function (data) {
    if (data.code == 200) {
        $("#importModal").modal("hide");
        LivingAllowanceInfo.table.refresh();
        Feng.success(data.msg);
    } else {
        Feng.error(data.msg);
    }
}

LivingAllowanceInfo.initCheckFileTable = function () {
    $('#checkFileTable').bootstrapTable('destroy');
    $('#checkFileTable').bootstrapTable({
        url: Feng.ctxPath + "/common/api/listNonPredefinedFiles",
        method: 'POST',
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        search: false, // 是否显示表格搜索，此搜索是客户端搜索，不会进服务端
        showRefresh: false, // 是否显示刷新按钮
        clickToSelect: true, // 是否启用点击选中行
        singleSelect: true, // 设置True 将禁止多选
        striped: true, // 是否显示行间隔色
        pagination: false, // 设置为 true 会在表格底部显示分页条
        paginationHAlign: "left",
        paginationDetailHAlign: "right",
        sidePagination: "server", // 设置在哪里进行分页，可选值为 'client' 或者 'server'
        showColumns: false,
        queryParams: function (params) {
            return {"batch": $("#batch").val(), "fileTag": "master_living_allowance"};
        },
        rowStyle: function (row, index) {
            return {css: {"word-break": "break-word", "white-space": "inherit"}}
        },
        columns:
                [
                    {title: '附件原名', field: 'originalName', visible: true, align: 'center', valign: 'middle', width: '120px'},
                    {title: '预览', field: 'url', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "80px",
                        formatter: function (value, row, index) {
                            var sn = value.lastIndexOf(".");
                            var suffix = value.substring(sn + 1, value.length);
                            var imgStr = "";
                            if (suffix == "pdf" || suffix == "PDF") {
                                imgStr = "<button type='button'  onclick=\"Feng.showPdf('" + value + "','" + row.id + "','" + row.originalName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-pdf-o\" aria-hidden=\"true\"></i></button>";
                            } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS') {
                                imgStr = "<button type='button'  onclick=\"Feng.showExcel('" + value + "','" + row.id + "','" + row.originalName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-excel-o\" aria-hidden=\"true\"></i></button>";
                            } else {
                                imgStr = '<img class=\"imgUrl\"  src=\"' + value + '\" style=\"width:25px;height:25px;\">';
                            }
                            return imgStr;
                        }
                    },
                    {title: '操作', field: 'url', visible: true, align: 'center', valign: 'middle', width: '80px',
                        formatter: function (value, row, index) {
                            return "<button type='button' onclick=\"downloadFile('" + row.id + "','6')\" class=\"btn btn-xs btn-success\"><i class=\"fa fa-download\" aria-hidden=\"true\"></i>下载</button>" +
                                    "<button type='button' onclick=\"LivingAllowanceInfo.deleteCheckFile('" + row.id + "','" + CONFIG.project_master_living_allowance + "')\" class=\"btn btn-xs btn-danger\">" +
                                    "<i class=\"fa fa-times\"></i>删除" +
                                    "</button>";
                        }
                    },
                ],
        onPostBody: function () {
            $('#checkFileTable' + "td.uitd_showTip").bind("mouseover", function () {
                var htm = $(this).html();
                $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
            });
            $(".imgUrl").viewer({fullscreen: false});
        },
    });
}


/**
 * 核查材料留存上传
 */
LivingAllowanceInfo.showCheckFileModal = function () {
    Feng.addAjaxSelect({
        "id": "batch",
        "displayCode": "id",
        "displayName": "batch",
        "type": "GET",
        "url": Feng.ctxPath + "/admin/batch/listBatchByType?type=" + CONFIG.project_master_living_allowance
    });
    $("#upload_file").val("");
    $("#checkFileModal").modal("show");
}

LivingAllowanceInfo.checkFileUpload = function () {
    var batch = $("#batch").val();
    if (Feng.isEmptyStr(batch)) {
        Feng.info("请选择申报批次后再上传！");
        return;
    }
    $("#upload_file ").unbind("change");
    $("#upload_file ").change(function () {
        var formData = new FormData();
        formData.append("fileTag", "master_living_allowance");
        formData.append("memo", batch);
        for (var i = 0; i < $('#upload_file')[0].files.length; i++) {
            formData.append('file', $('#upload_file')[0].files[i]);
        }
        $.ajax({
            url: Feng.ctxPath + "/admin/talentCommonFile/uploadBatch",
            type: "POST",
            processData: false,
            contentType: false,
            data: formData,
            success: function (data) {
                $("#checkFileTable").bootstrapTable("refresh", {});
                Feng.info(data.msg);
            }, error: function (data) {
                Feng.error("上传失败!" + data.responseJSON.message + "!");
            }
        });
    });
    $('#upload_file').val("");
    $('#upload_file').click();
}

LivingAllowanceInfo.deleteCheckFile = function (id, type) {
    var operation = function () {
        var ajax = new $ax(Feng.ctxPath + "/common/api/deleteNonPredefinedFile", function (data) {
            if (data.code == 200) {
                Feng.success(data.msg);
                $("#checkFileTable").bootstrapTable("refresh", {});
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("id", id);
        ajax.set("type", type);
        ajax.start();
    }
    Feng.confirm("删除后无法恢复，确认删除吗?", operation);
}


/**
 * 审核不通过
 */
LivingAllowanceInfo.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(Feng.ctxPath + "/admin/living_allowance/setNotPass", function (data) {
                    if (data.code == 200) {
                        Feng.success(data.msg);
                        LivingAllowanceInfo.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);
        }
    });

}


/**
 * 批量征信通过
 */
LivingAllowanceInfo.hczxPass = function () {
    var selected = $('#dataTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = "";
    for (var i = 0; i < selected.length; i++) {
        ids = ids + selected[i].id + ",";
    }
    var operation = function () {
        var ajax = new $ax(Feng.ctxPath + "/admin/living_allowance/hczxPass", function (data) {
            if (data.code == 200) {
                Feng.success(data.msg);
                LivingAllowanceInfo.table.refresh();
                $("#exportCommonModal").modal("hide");
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("核查征信失败!" + data.responseJSON.message + "!");
        });
        ajax.set("ids", ids);
        ajax.start();
    }
    Feng.confirm("一旦提交无法修改，确定提交吗?", operation);
}

/**
 * 公示预览
 */
LivingAllowanceInfo.needPublicExport = function () {
    var selected = $('#dataTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = "";
    for (var i = 0; i < selected.length; i++) {
        ids = ids + selected[i].id + ",";
    }
    var operation = function () {
        $("#exportCommonModal").modal("hide");
        window.location.href = encodeURI(encodeURI(Feng.ctxPath + "/admin/living_allowance/exportPublic?ids=" + ids));
    }
    Feng.confirm("确定要公示预览吗?", operation);
}


/**
 * 公示
 */
LivingAllowanceInfo.public = function () {
    var selected = $('#dataTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = "";
    for (var i = 0; i < selected.length; i++) {
        ids = ids + selected[i].id + ",";
    }
    var isMessage = $("input[name='isSend']:checked").val();
    var typeName = $("#typeName").val();
    var address = $("#web").val();
    var publicStartTime = $("#publicStartTime").val();
    var publicEndTime = $("#publicEndTime").val();
    var dep = $("#dep").val();
    var phone = $("#fyphone").val();
    var email = $("#fyemail").val();
    if (isMessage == 1) {
        if (typeName == null || typeName == '') {
            Feng.info("请填写公示类型");
            return;
        }
        if (address == null || address == '') {
            Feng.info("请填写公示平台");
            return;
        }
        if (publicStartTime == null || publicStartTime == '') {
            Feng.info("请填写公示开始时间");
            return;
        }
        if (publicEndTime == null || publicEndTime == '') {
            Feng.info("请填写公示截止时间");
            return;
        }
        if (dep == null || dep == '') {
            Feng.info("请填写反映单位");
            return;
        }
        if (phone == null || phone == '') {
            Feng.info("请填写联系电话");
            return;
        }
        if (email == null || email == '') {
            Feng.info("请填写联系邮箱");
            return;
        }
    }
    var operation = function () {
        var index = layer.open({
            type: 1,
            title: '公示',
            area: ['300px', '220px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: "<input class='form-control' id='publicBatchId' style='width:90%;margin: 10px' placeholder='请输入公示批次'>",
            btn: ['<i class="fa fa-save layui-bg-green"></i>&nbsp;&nbsp;提交', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
            btnAlign: 'c',
            success: function () {
                laydate.render({elem: "#publicBatchId", type: 'month', trigger: 'click', format: "yyyyMM"});
            },
            yes: function (index, layero) {
                var month = $("#publicBatchId").val();
                if (Feng.isEmptyStr(month)) {
                    Feng.info("请填写公示批次");
                    return;
                }
                layer.close(index);
                var ajax = new $ax(Feng.ctxPath + "/admin/living_allowance/publicBatch", function (data) {
                    if (data.code == 200) {
                        Feng.success(data.msg);
                        LivingAllowanceInfo.table.refresh();
                        $("#exportCommonModal").modal("hide");
                    } else {
                        Feng.error(data.msg);
                    }
                }, function (data) {
                    Feng.error("公示失败!" + data.responseJSON.message + "!");
                });
                ajax.set("ids", ids);
                ajax.set("typeName", typeName);
                ajax.set("address", address);
                ajax.set("publicStartTime", publicStartTime);
                ajax.set("publicEndTime", publicEndTime);
                ajax.set("dep", dep);
                ajax.set("phone", phone);
                ajax.set("email", email);
                ajax.set("isMessage", isMessage);
                ajax.set("batch", month);
                ajax.start();
            }
        });
    }
    Feng.confirm("确定要公示吗?", operation);
}

//已公示的数据根据公示批次公示导出
LivingAllowanceInfo.publicExport = function (type) {
    var url = "", dateType = '', format = '';
    if (type == 1) {         //公示导出
        url = Feng.ctxPath + "/admin/living_allowance/publicExport";
        dateType = 'month';
        format = "yyyyMM";
    } else if (type == 2) {     //公布导出
        url = Feng.ctxPath + "/admin/living_allowance/publishExport";
        dateType = 'date';
        format = "yyyy-MM-dd";
    }
    layer.open({
        type: 1,
        title: type == 1 ? '公示导出' : "公布导出",
        area: ['800px', '300px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: "<form id=\"publicExportForm\" action=\"" + url + "\" target=\"hiddenIframe\" class=\"form-horizontal \" style='padding-top: 10px;'>\n" +
                "                    <div class=\"form-group col-sm-12\">\n" +
                "                        <div class=\"row\">\n" +
                "                            <label class=\"col-sm-2 control-label\">开始时间</label>\n" +
                "                            <div class=\"col-sm-4\">\n" +
                "                                <input type=\"text\" id=\"startTime\" name=\"startTime\" time=\"time\" format=\"month\" class=\"form-control\">\n" +
                "                            </div>\n" +
                "                            <label class=\"col-sm-2 control-label\">截止时间</label>\n" +
                "                            <div class=\"col-sm-4\">\n" +
                "                                <input type=\"text\" id=\"endTime\" name=\"endTime\" time=\"time\" format=\"month\" class=\"form-control\">\n" +
                "                            </div>\n" +
                "                        </div>\n" +
                "                    </div>\n" +
                "                </form>",
        btn: ['<i class="fa fa-save layui-bg-green"></i>&nbsp;&nbsp;提交', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
        btnAlign: 'c',
        success: function (index, layero) {
            $("#publicExportForm")[0].reset();
            $("input[time='time']").each(function () {
                laydate.render({
                    elem: "#" + $(this).attr("id")
                    , type: dateType
                    , format: format
                    , trigger: 'click'
                });
            });
        },
        yes: function (index) {
            var startTime = $("#startTime").val();
            var endTime = $("#endTime").val();
            if (startTime == null || startTime == '') {
                Feng.info("请选择开始时间");
                return;
            }
            if (endTime == null || endTime == '') {
                Feng.info("请选择结束时间");
                return;
            }
            $("#publicExportForm")[0].submit();
            layer.close(index)
        }
    });
}

/**
 * 公示再审核
 */
LivingAllowanceInfo.afterCheck = function () {
    if (this.check()) {
        if (LivingAllowanceInfo.seItem.isPublic != 3) {
            Feng.info("当前记录不是公示中状态，无法审核");
            return;
        }
        if (LivingAllowanceInfo.seItem.creditStatus == 3) {
            $("#zxNotice").text("当前申请人核查征信不通过，请谨慎选择审核状态！征信意见为:" + LivingAllowanceInfo.seItem.outMsg);
        }
        if (LivingAllowanceInfo.seItem.checkState == -1) {
            var html = '<option value="">请选择</option>\n' +
                    '       <option value="2">驳回/恢复</option>';
            $("#checkStateAfter").empty().append(html);
        }
        if (LivingAllowanceInfo.seItem.checkState == 35) {
            var html = '<option value="">请选择</option>\n' +
                    '       <option value="-1">审核不通过</option>' +
                    '       <option value="2">驳回</option>';
            $("#checkStateAfter").empty().append(html);
        }
        $("#checkForm")[0].reset();
        $("#mainId").val(LivingAllowanceInfo.seItem.id);
        $("#checkModal").modal("show");
    }
}
/**
 * 公示后审核提交
 */
LivingAllowanceInfo.afterCheckSubmit = function () {
    var checkState = $("#checkStateAfter").val();
    var msg = $("#msg").val();
    if (checkState == null || checkState == '') {
        Feng.info("请选择审核状态");
        return;
    }
    if (msg == null || msg == '') {
        Feng.info("请填写审核意见");
        return;
    }
    var operation = function () {
        var ajax = new $ax(Feng.ctxPath + "/admin/living_allowance/afterCheck", function (data) {
            if (data.code == 200) {
                Feng.success(data.msg);
                LivingAllowanceInfo.table.refresh();
                $("#checkModal").modal("hide");
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("审核失败!" + data.responseJSON.message + "!");
        });
        ajax.setData({"id": $("#mainId").val(), "checkState": $("#checkStateAfter").val(), "checkMsg": msg});
        ajax.start();
    }
    Feng.confirm("一旦提交无法修改，确定提交吗?", operation);
}

/**
 * 批量公示通过
 * @param type
 */
LivingAllowanceInfo.publicPass = function () {
    var selected = $('#dataTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = "";
    for (var i = 0; i < selected.length; i++) {
        ids = ids + selected[i].id + ",";
    }
    var operation = function () {
        var ajax = new $ax(Feng.ctxPath + "/admin/living_allowance/publicPass", function (data) {
            if (data.code == 200) {
                Feng.success(data.msg);
                LivingAllowanceInfo.table.refresh();
                $("#exportCommonModal").modal("hide");
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("公示通过失败!" + data.responseJSON.message + "!");
        });
        ajax.set("ids", ids);
        ajax.start();
    }
    Feng.confirm("一旦提交无法修改，确定公示通过吗?", operation);
}

/**
 * 兑现
 */
LivingAllowanceInfo.issue = function () {
    var selected = $('#dataTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = "";
    for (var i = 0; i < selected.length; i++) {
        ids = ids + selected[i].id + ",";
    }
    var operation = function () {
        var ajax = new $ax(Feng.ctxPath + "/admin/living_allowance/issue", function (data) {
            if (data.code == 200) {
                Feng.success(data.msg);
                LivingAllowanceInfo.table.refresh();
                $("#exportCommonModal").modal("hide");
            } else {
                Feng.error(data.msg);
            }
        }, function (data) {
            Feng.error("兑现失败!" + data.responseJSON.message + "!");
        });
        ajax.set("ids", ids);
        ajax.start();
    }
    Feng.confirm("一旦兑现无法修改,确定要兑现吗?", operation);
}


LivingAllowanceInfo.showExportModal = function () {
    $("#exportForm")[0].reset();
    $("#commonExportModal").modal("show");
}
LivingAllowanceInfo.export = function (process) {
    var operation = function () {
        var names = '';
        var fieldCodes = '';
        $("#field_info li input").each(function (index) {
            if ($(this).is(":checked")) {
                fieldCodes = fieldCodes + $(this).val() + ",";
                names = names + $(this).next().text() + ",";
            }
        });
        var param = LivingAllowanceInfo.formParams();
        param.names = names;
        param.values = fieldCodes;
        param.process = process;
        window.location.href = Feng.setUrlParam(Feng.ctxPath + "/admin/living_allowance/commonExport", param);
        // window.location.href = Feng.ctxPath + "/api/talentInfoExport/export?names=" + names + "&fieldCodes=" + fieldCodes + "&name=" + $("#name").val() + "&idCard=" + $("#idCard").val()
        //     + "&sex=" + $("#sex").val()+ "&nation=" + $("#nation").val()+ "&nationality=" + $("#nationality").val()+ "&talentType=" + $("#talentType").val()+ "&talentArrange=" + $("#talentArrange").val();
    };
    Feng.confirm("确定要导出数据吗？", operation);
}



LivingAllowanceInfo.prepareSearch = function () {
    var sex = $("#pub_sex").val();
    var checkState = $("#pub_checkState").val();
    var name = $("#pub_name").val();
    $('#dataTable').bootstrapTable("refresh", {"query": {"sex": sex, "checkState": checkState, "name": name}});
}

LivingAllowanceInfo.prepareReset = function () {
    $("#pub_sex").val("");
    $("#pub_checkState").val("");
    $("#pub_name").val("");
}

/**
 * 是否发送短信
 */
LivingAllowanceInfo.toggleMessage = function () {
    var isMessage = $("input[name='isSend']:checked").val();
    if (isMessage == 1) {
        $("#messageEdit").css("display", "block");
    } else if (isMessage == 2) {
        $("#messageEdit").css("display", "none");
    }
}

//回调
LivingAllowanceInfo.callBack = function (data) {
    Feng.info(data.msg);
    if (data.code == 200) {
        $("#hczxModal").modal("hide");
        LivingAllowanceInfo.table.refresh();
    }
}

LivingAllowanceInfo.checkAll = function () {
    $("#field_info input").each(function () {
        this.checked = true;
    })
}
/**
 * 反选
 */
LivingAllowanceInfo.unCheckAll = function () {
    $("#field_info input").each(function () {
        if (this.checked) {
            this.checked = false;
        } else {
            this.checked = true;
        }
    })
}


LivingAllowanceInfo.showLog = function (id) {
    layer.open({
        type: 1,
        title: "日志",
        fixed: false,
        content: '<table id="' + id + '"></table>',
        area: ['80%', '80%'],
        maxmin: true,
        success: function (layero, index) {
            Feng.getCheckLog(id, {
                "type": CONFIG.project_master_living_allowance,
                "mainId": id,
                "typeFileId": "",
                "active": 1
            })
        }
    });

}


/**
 * 查询表单提交参数对象
 * @returns {{}}
 */
LivingAllowanceInfo.formParams = function () {
    var queryData = {};
    queryData['name'] = $("#name").val();
    queryData['idCard'] = $("#idCard").val();
    queryData['sex'] = $("#sex").val();
    queryData['nation'] = $("#nation").val();
    queryData['nationality'] = $("#nationality").val();
    queryData['provinceCode'] = $("#provinceCode").val();
    queryData['politics'] = $("#politics").val();
    queryData['enterpriseId'] = $("#enterpriseId").val();
    queryData['industryField'] = $("#industryField").val();
    queryData['introductionMode'] = $("#introductionMode").val();
    queryData['highEducation'] = $("#highEducation").val();
    queryData['major'] = $("#major").val();
    queryData['title'] = $("#title").val();
    queryData['studyAbroad'] = $("#studyAbroad").val();
    queryData['phone'] = $("#phone").val();
    queryData['email'] = $("#email").val();
    queryData['address'] = $("#address").val();
    queryData['checkState'] = $("#checkState").val();
    queryData['isPublic'] = $("#isPublic").val();
    queryData['year'] = $("#year").val();
    queryData['declareType'] = $("#declareType").val();
    queryData['introductionMethod'] = $("#introductionMethod").val();
    return queryData;
}


/**
 * 查询硕博人才生活补贴申报列表
 */
LivingAllowanceInfo.search = function () {
    LivingAllowanceInfo.table.refresh({query: LivingAllowanceInfo.formParams()});
};

/**
 * 重置查询参数
 */
LivingAllowanceInfo.reset = function () {
    $("#name").val("");
    $("#idCard").val("");
    $("#sex").val("");
    $("#nation").val("");
    $("#nationality").val("");
    $("#provinceCode").val("");
    $("#politics").val("");
    $("#enterpriseId").val("").trigger("chosen:updated");
    $("#industryField").val("");
    // $("#introductionMode").val("");
    $("#highEducation").val("");
    $("#major").val("");
    $("#title").val("");
    $("#studyAbroad").val("");
    $("#phone").val("");
    $("#email").val("");
    $("#address").val("");
    $("#checkState").val("");
    $("#isPublic").val("");
    $("#year").val("");
    $("#declareType").val("");
    $("#introductionMethod").val("");
}


$(function () {
    var defaultColunms = LivingAllowanceInfo.initColumn();
    var table = new BSTable(LivingAllowanceInfo.id, "/admin/living_allowance/list?process=" + $("#process").val(), defaultColunms);
    table.setPaginationType("server");
    table.setOnDblClickRow(function () {
        LivingAllowanceInfo.openCheckLivingAllowanceInfo($("#process").val());
    });
    LivingAllowanceInfo.table = table.init();
    //批量加载字典表数据
    var arr = [
        {"name": "nation", "code": "un_nation"},
        {"name": "nationality", "code": "un_nationality"},
        {"name": "politics", "code": "un_political"},
        {"name": "industryField", "code": "un_industryField"},
        {"name": "introductionMode", "code": "un_introduction_mode"},
        {"name": "highEducation", "code": "un_education"},
        {"name": "declareType", "code": "un_master_education"},
        {"name": "address", "code": "un_street"}];
    Feng.findChildDictBatch(JSON.stringify(arr));
    $("#enterpriseId").on('chosen:ready', function (e, params) {
        $(".chosen-container-single .chosen-single").css("padding", "4px 0px 0px 4px");
    });
    $("#enterpriseId").chosen({
        search_contains: true,       //关键字模糊搜索。设置为true，只要选项包含搜索词就会显示；设置为false，则要求从选项开头开始匹配
        disable_search: false,
        width: "100%",
        enable_split_word_search: true
    });
    $('#checkAll').click(function () {
        $("#dataTable").bootstrapTable('togglePagination').bootstrapTable('checkAll').bootstrapTable('togglePagination');
    })
    $('#uncheckAll').click(function () {
        $("#dataTable").bootstrapTable('togglePagination').bootstrapTable('uncheckAll').bootstrapTable('togglePagination')
    })
});
