<script>
$(function(){
$('#dataFileControl').datagrid({
url: 'audit/sysAuditAction!list.do',
title: '',
width: 'auto',
height: '400',
//fitColumns: true,
//showFooter:true,
nowrap:false,
autoRowHeight: false,
striped: true,
collapsible:true,
sortName: 'sbtsrc',
sortOrder: 'desc',
remoteSort: false,
idField:'sbtsrc',
frozenColumns:[[
{field:'ck',checkbox:true},
{field:'sbtsrc',title:'Source',width:50,sortable:true},
{field:'sbtabk',title:'Area Bank',width:70,sortable:true}
]],
columns:[[
{field:'sbtstn',title:'Station',width:50,sortable:true},
{field:'fileName',title:'File Name',width:180,sortable:true},
{field:'sbtrpd',title:'Reporting Period',width:100,sortable:true},
{field:'count',title:'Count',width:80,sortable:true,align:'right'},
{field:'batchNo',title:'Batch No.',width:150,sortable:true},
{field:'sbtras',title:'Status',width:80,sortable:true},
{field:'loadID',title:'Load ID',width:80,sortable:true},
{field:'loadTime',title:'Load Time',width:120,sortable:true},
{field:'sbtcur',title:'Curr',width:80,sortable:true},
{field:'sbtsra',title:'Ret',width:80,sortable:true}
]],
pagination:true,
rownumbers:true,
toolbar:[{
id:'btnSYSAudit',
text:'SYS Audit',
handler:function(){
var batchNos = [];
var rows = $('#dataFileControl').datagrid('getChecked');
if (rows.length > 0) {
$.messager.confirm('请确认', '您要提交系统审核所选项目?', function(r) {
if (r) {
for(var i=0;i<rows.length;i++){
if(rows[i].sbtras=='L'){
}else{
batchNos.push(rows[i].batchNo);
}
}
//alert(batchNos.join(','));
$.ajax({
url : 'test/testtAction!test.do',
data : {
batchNos : batchNos.join(',')
},
dataType : 'json',
success : function(response) {
$.messager.show({
title : '提示',
msg : '提交成功!'
});
}
});
}
});
} else {
$.messager.alert('提示', '请选择要提交的记录!', 'info');
}
}
},'-',{
id:'btnSchedule',
text:'Schedule',
handler:open1
}
]
});
});
$("#search").click(function (){ var param=serializeObject($('#form1')); $("#dataFileControl").datagrid('load',param); }); }); //格式化表单 serializeObject = function(form) { var o = {}; $.each(form.serializeArray(), function(index) { if (o[this['name']]) { o[this['name']] = o[this['name']] + "," + this['value']; } else { o[this['name']] = this['value']; } }); return o; };
//时间控件
$(function(){
$("#panel_reportingPeriod").datebox({
formatter:formatDate
});
})
//格式化时间
function formatDate(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return y+""+(m<10?"0"+m:m)+""+(d<10?"0"+d:d);//格式:20121002
}
function reset(){
$('#form1').form('clear');
}
</script>
/**
* 分页显示所有未审核的记录
*
* @return
*/
public String list() {
PageModel<Batch> pm = new PageModel<Batch>(getRequest());
Map<String, Object> params = pm.getParams();
String source = getRequest().getParameter("panel_Source");
String areaBank = getRequest().getParameter("panel_AreaBank");
String station = getRequest().getParameter("file_station");
String reportingPeriod = etRequest().getParameter("panel_reportingPeriod");
String batchNo = getRequest().getParameter("panel_batchNo");
String status = getRequest().getParameter("panel_Status");
if (source != null && !"".equals(source)) {
params.put("sbtsrc", "%" + source + "%");
}
if (areaBank != null && !"".equals(areaBank)) {
params.put("sbtabk", "%" + areaBank + "%");
}
if (station != null && !"".equals(station)) {
params.put("sbtstn", station);
}
if (reportingPeriod != null && !"".equals(reportingPeriod)) {
params.put("sbtrpd", "%" + reportingPeriod + "%");
}
if (batchNo != null && !"".equals(batchNo)) {
params.put("batchNo", batchNo);
}
if (status != null && !"".equals(status)) {
params.put("sbtras", status);
}
pm.setParams(params);
pm = sysAuditService.getByCondition(pm);
batchMap.put("total", pm.getTotal());
batchMap.put("rows", pm.getList());
return "list";
}
/*
* 返回按条件查询出来的结果集
* PageModel对象中包含结构集和一些参数
*/
public PageModel<E> getByCondition(PageModel<E> pageModel) {
String queryCondition = prepareQueryString(pageModel.getParams());
return dao.getByCondition(queryCondition, pageModel);
}
/** * 根据条件进行分页查询 * * @param queryString * 查询sql * @param params * 查询条件 * @return */ @SuppressWarnings("unchecked") public PageModel<E> getByCondition(String queryString,PageModel<E> pageModel) { Query query = getEntityManager().createQuery(queryString); // 查询所有数据 Query queryAll = getEntityManager().createQuery(queryString); // 设置参数 Map<String, Object> params = pageModel.getParams(); for (Map.Entry<String, Object> entry : params.entrySet()) { Object value = entry.getValue(); String key = entry.getKey(); if (!key.equals("sort") && !key.equals("order") && value != null && !"".equals(value)) { query.setParameter(key, value); queryAll.setParameter(key, value); } } // 查询所有数据 List<E> list = queryAll.getResultList(); // 设置总数据个数 if (list == null) { pageModel.setTotal(0); } else { pageModel.setTotal(list.size()); } // 分页设置 if (pageModel.getFirstResult() <= 0) { query.setFirstResult(0); } else { int firstresult = pageModel.getTotal() - pageModel.getRows() < 0 ? 0 : pageModel.getTotal() - pageModel.getRows(); query.setFirstResult(pageModel.getFirstResult() >= pageModel .getTotal() ? firstresult : pageModel.getFirstResult()); } query.setMaxResults(pageModel.getRows()); pageModel.setList(query.getResultList()); return pageModel; }
/** * * 分页实体,包含页面所需的参数和查询返回的数据结果 * * @version v1.0 * @author wangxiaopeng * @date 2011-11-30 下午04:12:18 */ public class PageModel<E> implements Serializable { private static final long serialVersionUID = -2778873382939204283L; /** * 当前页面 */ private int page = 1; /** * 显示多少行 */ private int rows = 15; /** * 总记录条数 */ private int total; /** * 记录数据 */ private List<E> list = new ArrayList<E>(); /** * 查询需要的参数 */ private Map<String, Object> params = new HashMap<String, Object>(); public PageModel() { } public PageModel(HttpServletRequest request) { String page = request.getParameter("page"); String rows = request.getParameter("rows"); String sort = request.getParameter("sort"); String order = request.getParameter("order"); if (page != null && rows != null ) { this.page = Integer.valueOf(page); this.rows = Integer.valueOf(rows); } if (sort != null && order != null) { params.put("sort", sort); params.put("order", order); } } public int getPage() { return page; } public void setPage(int page) { this.page = page; } public int getRows() { return rows; } public void setRows(int rows) { this.rows = rows; } /** * 分页需要的第一条记录索引 * * @return */ public int getFirstResult() { return rows * (page - 1); } public int getTotal() { return total; } public void setTotal(int total) { this.total = total; } public List<E> getList() { return list; } public void setList(List<E> list) { this.list = list; } public Map<String, Object> getParams() { return params; } public void setParams(Map<String, Object> params) { this.params = params; } }