/**
 * 优秀人才津补贴管理初始化
 */
var TalentAllowanceInfo = {
    id: "TalentAllowanceInfoTable", //表格id
    seItem: null, //选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
TalentAllowanceInfo.initColumn = function () {
    var type = $("#type").val();
    return [
        {field: 'selectItem', radio: true},
        {title: '年度', field: 'year', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "60px"},
        {title: '所属镇街', field: 'addressName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '性别', field: 'sex', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "60px",
            formatter(value, row, index) {
                if (value == 1) {
                    return "男";
                }
                if (value == 2) {
                    return "女";
                }
            }
        },
        {title: '证件号码', field: 'idCard', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
        {title: '人才层次', field: 'talentArrangeName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '认定条件', field: 'identifyConditionText', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px"},
        {title: '认定条件证书取得时间', field: 'identifyGetTime', visible: true, align: 'center', valign: 'middle', width: "150px"},
        {title: '认定条件名称', field: 'identifyConditionName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '公布入选月份', field: 'identifyMonth', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '津补贴类型', field: 'allowanceType', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "120px",
            formatter(value, row, index) {
                if (value == null || value == "")
                    return "未判定";
                if (value == 1)
                    return "工作津贴";
                if (value == 2)
                    return "一次性交通补贴";
                if (value == 3)
                    return "不予兑现";
            }
        },
        {title: '兑现月份', field: 'months', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px"},
        {title: '兑现金额', field: 'money', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "80px"},
        {title: '金额说明', field: 'moneyDesc', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "80px"},
        {title: '审核状态', field: 'checkState', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
            formatter(value, row, index) {
                var html = "";
                switch (value) {
                    case 1:
                        html = "<span class='label'>待提交</span>"
                        break;
                    case 3:
                        html = "<span class='label label-success''>待总院审核</span>"
                        break;
                    case 5:
                    case 13:
                    case 15:
                    case 20:
                    case 25:
                    case 35:
                        html = "<span class='label label-success'>审核中</span>";
                        break;
                    case 8:
                        html = "<span class='label label-danger'>总院驳回</span>"
                        break;
                    case 9:
                        html = "<span class='label label-danger'>已驳回</span>"
                        break;
                    case 10:
                        html = "<span class='label label-danger'>已驳回</span>"
                        break;
                    case - 1:
                        if (row.publicState >= 3) {
                            html = "<span class='label label-danger'>审核不通过</span>";
                        } else {
                            html = "<span class='label label-success'>审核中</span>";
                        }
                        break;
                    case 30:
                        if (row.publicState == 1) {
                            html = "<span class='label label-primary'>待核查征信</span>"
                        } else if (row.publicState == 2) {
                            html = "<span class='label label-primary'>待公示</span>"
                        } else if (row.publicState == 3) {
                            html = "<span class='label label-primary'>公示中</span>"
                        } else if (row.publicState == 4) {
                            html = row.allowanceType != 3 ? "<span class='label label-success'>待兑现</span>" : "<span class='label label-danger'>不予兑现</span>";
                        } else if (row.publicState == 5) {
                            html = "<span class='label label-primary'>已兑现</span>"
                        }
                        break;
                }
                return html;
            }
        },
        {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "80px",
            formatter: function (value, row, index) {
                return "<span class='label label-success' onclick=\"TalentAllowanceInfo.showLog('" + value + "')\" >" +
                        "<i class=\"fa fa-book\"></i>日志" +
                        "</span>";
            }
        }
    ];
};

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

/**
 * 点击添加优秀人才津补贴
 */
TalentAllowanceInfo.openAddTalentAllowanceInfo = function () {
    var ajax = new $ax("/common/batch/checkBatchValid", function (data) {
        if (data.code == 200) {
            var index = layer.open({
                type: 2,
                title: '津补贴申报',
                fix: false, //不固定
                maxmin: true,
                content: '/enterprise/talentAllowance/apply?year=' + data.batch,
                btn: ['<i class="fa fa-eye"></i>&nbsp;&nbsp;保存未提交', '<i class="fa fa-check layui-bg-green"></i>&nbsp;&nbsp;提交审核', '<i class="fa fa-calculator"></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.TalentAllowanceInfoDlg.addSubmit();
                }, btn2: function (index, layero) {
                    var obj = layero.find("iframe")[0].contentWindow;
                    obj.TalentAllowanceInfoDlg.submitToCheck();
                    return false;
                }, btn3: function (index, layero) {
                    var obj = layero.find("iframe")[0].contentWindow;
                    obj.TalentAllowanceInfoDlg.calculator();
                    return false;
                }, success: function (layero, index) {
                    layer.tips('添加基本信息并上传附件后点击', '.layui-layer-btn1', {tips: [1, "#78BA32"], time: 0, closeBtn: 2});
                },
                end: function () {
                    layer.closeAll('tips');
                    TalentAllowanceInfo.table.refresh();
                }
            });
            layer.full(index);
            TalentAllowanceInfo.layerIndex = index;
        } else {
            Feng.error(data.msg);
        }
    }, function (data) {
        Feng.error("查询失败!" + data.responseJSON.message + "!");
    });
    ajax.set("type", CONFIG.project_jbt);
    ajax.start();
};

/**
 * 打开查看优秀人才津补贴详情
 */
TalentAllowanceInfo.openTalentAllowanceInfoDetail = function () {
    if (this.check()) {
        var ajax = new $ax("/common/batch/checkBatchValid", function (data) {
            if (data.code == 200) {
                var index = layer.open({
                    type: 2,
                    title: '津补贴申报',
                    fix: false, //不固定
                    maxmin: true,
                    content: Feng.ctxPath + '/enterprise/talentAllowance/apply/id/' + TalentAllowanceInfo.seItem.id,
                    btn: ['<i class="fa fa-eye"></i>&nbsp;&nbsp;保存未提交', '<i class="fa fa-check"></i>&nbsp;&nbsp;提交审核', '<i class="fa fa-calculator"></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.TalentAllowanceInfoDlg.editSubmit();
                    },
                    btn2: function (index, layero) {
                        var obj = layero.find("iframe")[0].contentWindow;
                        obj.TalentAllowanceInfoDlg.submitToCheck();
                        return false;
                    }, btn3: function (index, layero) {
                        var obj = layero.find("iframe")[0].contentWindow;
                        obj.TalentAllowanceInfoDlg.calculator();
                        return false;
                    },
                    success: function (layero, index) {
                        layer.tips('添加基本信息并上传附件后点击', '.layui-layer-btn0', {tips: [1, "#78BA32"], time: 0, closeBtn: 2});
                    },
                    end: function () {
                        layer.closeAll('tips');
                    }
                });
                layer.full(index);
                TalentAllowanceInfo.layerIndex = index;
            } else {
                Feng.info(data.msg);
            }
        }, function (data) {
            Feng.error("校验失败!" + data.responseJSON.message + "!");
        });
        ajax.set("type", CONFIG.project_jbt);
        ajax.set("year", TalentAllowanceInfo.seItem.year);
        ajax.set("first_submit_time", TalentAllowanceInfo.seItem.firstSubmitTime);
        ajax.start();
    }
};

TalentAllowanceInfo.openTalentAllowanceInfoSelect = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '津补贴查看',
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/enterprise/talentAllowance/detail/id/' + TalentAllowanceInfo.seItem.id,
            btn: ['<i class="fa fa-calculator"></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.TalentAllowanceInfoDlg.calculator();
                return false;
            }
        });
        layer.full(index);
        TalentAllowanceInfo.layerIndex = index;
    }
}


/**
 * 删除优秀人才津补贴
 */
TalentAllowanceInfo.delete = function () {
    if (this.check()) {
        var operation = function () {
            var ajax = new $ax(Feng.ctxPath + "/enterprise/talentAllowance/delete", function (data) {
                if (data.code == 200) {
                    Feng.success(data.msg);
                    TalentAllowanceInfo.table.refresh();
                } else {
                    Feng.info(data.msg);
                }
            }, function (data) {
                Feng.error("删除失败!" + data.responseJSON.message + "!");
            });
            ajax.set("id", TalentAllowanceInfo.seItem.id);
            ajax.start();
        }
        Feng.confirm("删除后无法恢复，确认删除吗?", operation);
    }
};

/**
 * 查询表单提交参数对象
 * @returns {{}}
 */
TalentAllowanceInfo.formParams = function () {
    var queryData = {};
    queryData['year'] = $("#year").val();
    queryData['enterpriseName'] = $("#enterpriseName").val();
    queryData['name'] = $("#name").val();
    queryData['idCard'] = $("#idCard").val();
    queryData['talentType'] = $("#talentType").val();
    queryData['talentArrange'] = $("#talentArrange").val();
    queryData['identifyCondition'] = $("#identifyCondition").val();
    queryData['allowanceType'] = $("#allowanceType").val();
    queryData['address'] = $("#address").val();
    queryData['checkState'] = $("#checkState").val();
    return queryData;
}

/**
 * 查询人才认定申报列表
 */
TalentAllowanceInfo.search = function () {
    TalentAllowanceInfo.table.refresh({query: TalentAllowanceInfo.formParams()});
};

/**
 * 重置
 */
TalentAllowanceInfo.reset = function () {
    $("#year").val("");
    $("#enterpriseName").val("");
    $("#name").val("");
    $("#idCard").val("");
    $("#talentType").val("");
    $("#talentArrange").val("");
    $("#identifyCondition").val("");
    $("#allowance").val("");
    $("#address").val("");
}

/**
 * 获取人才认定
 */
TalentAllowanceInfo.getIdentifyCondition = function () {
    var level = $("#talentArrange").val();
    if (level == null || level == '') {
        $("#identifyCondition").empty();
        $("#identifyCondition").trigger('chosen:updated');
        return;
    }
    Feng.addAjaxSelect({
        "id": "identifyCondition",
        "displayCode": "id",
        "displayName": "name",
        "type": "GET",
        "url": Feng.ctxPath + "/common/api/findIdentifyConditionByLevel?level=" + level
    });
    $("#identifyCondition").trigger('chosen:updated');
}


TalentAllowanceInfo.initCheckFileTable = function () {
    $('#checkFileTable').bootstrapTable('destroy');
    $('#checkFileTable').bootstrapTable({
        url: Feng.ctxPath + "/enterprise/talentAllowance/listCommonFile",
        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()};
        },
        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) {
                            var selector = '<select style="background:#fff;border:1px solid #000;margin-right:2px;" onchange="TalentAllowanceInfo.onCommonTypeChangeAndBind(\'' + row.id + '\',this.value);"><option value="">关联通用附件类型</option>';
                            for (var i = 0; i < row.fileTypes.length; i++) {
                                var selectedStr = row.fileTypes[i].id == row.fileTypeId ? "selected" : "";
                                selector += '<option value="' + row.fileTypes[i].id + '" ' + selectedStr + '>' + row.fileTypes[i].name + '</option>'
                            }
                            selector += '</select>';
                            return selector + "<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=\"TalentAllowanceInfo.deleteCheckFile('" + row.id + "','" + CONFIG.project_jbt + "')\" 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});
        },
    });
}

TalentAllowanceInfo.onCommonTypeChangeAndBind = function (fileId, fileTypeId) {
    var formData = new FormData();
    formData.append('fileId', fileId.toString());
    formData.append('fileTypeId', fileTypeId.toString());
    $.ajax({
        url: Feng.ctxPath + "/enterprise/talentAllowance/bindCommonFileWithFileType",
        type: "POST",
        processData: false,
        contentType: false,
        data: formData,
        success: function (data) {
            Feng.info(data.msg);
        }, error: function (data) {
            Feng.error("关联失败!" + data.responseJSON.message + "!");
        }
    });
}

TalentAllowanceInfo.commonColumns = function () {
    return [
        {field: "selectItem", checkbox: true},
        {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle', width: "30%"},
        {title: '证件号码', field: 'idCard', visible: true, align: 'center', valign: 'middle', width: "40%"},
        {title: '入职时间', field: 'cur_entry_time', visible: true, align: 'center', valign: 'middle', width: "30%"}
    ];
}

TalentAllowanceInfo.openBatchApplyModal = function (type) {
    var columns = TalentAllowanceInfo.commonColumns();
    $('#batchApplyTable').bootstrapTable('destroy');
    $('#batchApplyTable').bootstrapTable({
        url: Feng.ctxPath + "/enterprise/talentAllowance/findTalentAllowance",
        method: 'POST',
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        search: true, // 是否显示表格搜索，此搜索是客户端搜索，不会进服务端
        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) {
            $(".time").each(function () {
                laydate.render({
                    elem: "#" + $(this).attr("id")
                    , type: 'date'
                    , format: 'yyyy年MM月dd日'
                });
            });
            $("#batchApplyModal").modal("show");
            return res.obj.rows;
        },
        columns: columns
    });
}

TalentAllowanceInfo.batchApply = function () {
    var selected = $('#batchApplyTable').bootstrapTable('getSelections');
    if (!selected || selected.length < 1) {
        Feng.info("请至少选择一行数据!");
        return;
    }
    var ids = "";
    var count = 0;
    for (var i = 0; i < selected.length; i++) {
        count++;
        ids = ids + selected[i].id + ",";
    }
    var operation = function () {
        var index = layer.open({
            type: 1,
            title: '请确认补贴类型',
            area: ['300px', '220px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: '<div class="rowGroup" style="padding:20px;"><label class="control-label spacing"><span style="color: red">*</span>补贴类型</label><br><input type="radio" name="batchAllowanceType" value="1"/><label for="batchAllowanceType">工作津贴</label>&nbsp;&nbsp;<input type="radio" name="batchAllowanceType" value="2"/><label for="batchAllowanceType">一次性交通补贴</label></div>',
            btn: ['<i class="fa fa-save layui-bg-green"></i>&nbsp;&nbsp;确定', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
            btnAlign: 'c',
            success: function () {

            },
            yes: function (index, layero) {
                var allowanceType = $("input[name=batchAllowanceType]:checked").val();
                if (Feng.isEmptyStr(allowanceType) || typeof allowanceType == "undefined") {
                    Feng.info("请选择补贴类型");
                    return;
                }
                layer.close(index);
                var allowanceTypeStr = allowanceType == 1 ? "工作津贴" : "一次性交通补贴";
                Feng.confirm("已选<span style='color:#ff0000;'>" + count + "</span>人，确定要批量申请<span style='color:#ff0000;'>" + allowanceTypeStr + "</span>吗?<br><span style='color:#ff0000;'>*此方法不能撤销，请谨慎操作</span>", function () {
                    var ajax = new $ax("/enterprise/talentAllowance/batchApply", function (data) {
                        if (data.code == 200) {
                            Feng.success(data.msg);
                            TalentInfo.table.refresh();
                            $("#batchApplyModal").modal("hide");
                        } else {
                            Feng.error(data.msg);
                        }
                    }, function (data) {
                        Feng.error("公示失败!" + data.responseJSON.message + "!");
                    });
                    ajax.set("ids", ids);
                    ajax.set("allowanceType", allowanceType);
                    ajax.start();
                });
            }
        });
    }
    Feng.confirm("确定进入下一步选择补贴类型吗?", operation);
}


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

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

/**
 *
 */
TalentAllowanceInfo.importSubmit = function () {
    $("#import-form")[0].submit();
}


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

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


TalentAllowanceInfo.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("batch", batch);
        for (var i = 0; i < $('#upload_file')[0].files.length; i++) {
            formData.append('file', $('#upload_file')[0].files[i]);
        }
        $.ajax({
            url: Feng.ctxPath + "/enterprise/talentAllowance/uploadCommonFile",
            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();
}

TalentAllowanceInfo.deleteCheckFile = function (id, type) {
    var operation = function () {
        var ajax = new $ax(Feng.ctxPath + "/enterprise/talentAllowance/deleteCommonFile", 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);
}


/**
 * 导出基础信息
 */
TalentAllowanceInfo.export = function () {
    var queryData = TalentAllowanceInfo.formParams();
    var url = Feng.setUrlParam(Feng.ctxPath + "/enterprise/talentAllowance/export", queryData);
    window.hiddenIframe.location.href = url;
}

/**
 * 显示审核日志
 */
TalentAllowanceInfo.showLog = function (id) {
    layer.open({
        type: 1,
        title: "日志",
        fixed: false,
        content: '<table id="' + id + '"></table>',
        area: ['80%', '80%'],
        maxmin: true,
        success: function (layero, index) {
            $('#' + id).bootstrapTable({
                url: Feng.ctxPath + "/common/api/getCheckLog",
                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 {"type": CONFIG.project_jbt, "mainId": id, "typeFileId": "", "active": 1}
                },
                rowStyle: function (row, index) {
                    return {
                        css: {
                            "word-break": "break-word",
                            "white-space": "inherit"
                        }
                    }
                },
                columns:
                        [
                            {title: '步骤', field: 'stepName', visible: true, align: 'center', valign: 'middle', width: "10%",
                                formatter: function (value, row, index) {
                                    return "" + value;
                                }
                            },
                            {title: '描述', field: 'description', visible: true, align: 'center', valign: 'middle', width: "65%",
                                formatter: function (value, row, index) {
                                    return '<span data-toggle="tooltip" title="' + value + '">"' + value + '"</span>';
                                }
                            },
                            {title: '操作人', field: 'createUser', visible: false, align: 'center', valign: 'middle', width: "15%"},
                            {title: '操作时间', field: 'createTime', visible: true, align: 'center', valign: 'middle', width: "20%"},
                        ]
                ,
                onPostBody: function () {
                    $('#' + id + "td.uitd_showTip").bind("mouseover", function () {
                        var htm = $(this).html();
                        $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
                    });
                }
            });
        }
    });
}

$(function () {
    var defaultColunms = TalentAllowanceInfo.initColumn();
    var table = new BSTable(TalentAllowanceInfo.id, "/enterprise/talentAllowance/list", defaultColunms);
    table.setPaginationType("server");
    table.setOnDblClickRow(function () {
        TalentAllowanceInfo.openTalentAllowanceInfoDetail();
    });
    TalentAllowanceInfo.table = table.init();
    //批量加载字典表数据
    var arr = [
        {"name": "address", "code": "street"},
        {"name": "talentArrange", "code": "talent_arrange"},
        {"name": "nationality", "code": "nationality"}];
    Feng.findChildDictBatch(JSON.stringify(arr));
    $("#identifyCondition").chosen({
        search_contains: true,       //关键字模糊搜索。设置为true，只要选项包含搜索词就会显示；设置为false，则要求从选项开头开始匹配
        disable_search: false,
        width: "100%",
        enable_split_word_search: true
    });
});
