reportform.js 1.67 KB
/**
 * Created by yoho on 2017/2/23.
 */
$(function () {
    $('#tb').myDatagrid({
        pagination: true,
        singleSelect: true,
        method: 'post',
        autoRowHeight: true,
        striped: false,
        loadFilter: methods.loadFilter,
        pageSize:20,
        checkbox:true,
        singleSelect: false
    });

    $('#searchButton').linkbutton({
        onClick: methods.searchForm
    });

    $('#exportButton').linkbutton({
        onClick: methods.export
    });

    $('#exportAllButton').linkbutton({
        onClick: methods.batchExport
    });

    methods.searchForm();
});

var methods = {
    searchForm: function () {
        $('#tb').datagrid('options').url = url + '?' + $('#searchFm').serialize();
        $('#tb').datagrid('load');
    },
    loadFilter: function (data) {
        return data.data;
    },
    export:function () {
        var rows = $('#tb').datagrid('getChecked');
        if(rows.length < 1){
            alert('没有要导出的数据');
            return;
        }
        var params = {};
        var idArr = new Array();
        $.each(rows,function () {
            idArr.push(this.id);
        });
        params.ids = idArr.join(',');
        window.open(contextPath + "/batch/export.do?type=reportFormExport&queryConf=" + JSON.stringify(params));
    },
    batchExport:function () {
        var searchParams = $('#searchFm').serializeArray();
        var params = {};
        $.each(searchParams,function () {
            params[this.name] = this.value;
        });
        params.formType = $(this).attr('formType');
        window.open(contextPath + "/batch/export.do?type=reportFormExport&queryConf=" + JSON.stringify(params));
    }
};