reportform.js
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* 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));
}
};