jsp:select月份时本该做成一个日历格式的,但是能力有限,暂时只能做成现在的这个样子,基本功能算是实现了。
function doSearch(){
$('#dg').datagrid('reload',{
test:$('#monthSearch').combobox('getValue'),
username:$('#usernameSearch').textbox('getValue'),
phone:$('#phoneSearch').textbox('getValue'),
dName:$('#departmentSearch').combobox('getText')
})
}
dao:
select r.id,u.username ,r.card_type,d.d_name,r.swipe_time,r.phone
from all_swipe_record r
inner join user u on r.phone=u.phone
inner join department d on u.department_id=d.d_id
and r.phone like "%"#{phone}"%"
and month(swipe_time)=#{test}
and d.d_name like "%"#{dName}"%"
and u.username like "%"#{username}"%"
ORDER BY u.username
limit #{pageBean.start},#{pageBean.pageSize}
/**
* 传入所有要查询的条件作为参数
* @param phone
* @param test
* @return
*/
public List selectSwipeRecordByPage(PageBean pageBean, String dName, String username, String test, String phone) ;
@Override
public List selectSwipeRecordByPage(PageBean pageBean,
String dName, String username, String test, String phone) {
return swipeRecordDao.selectSwipeRecordByPage(pageBean, dName, username, test, phone);
}
controller:
在查询所有的考勤记录时已经将查询条件传进去了。
/**
* 分页
* @param pageNow
* @return
*/
@RequestMapping(value = "/swipeRecordByPage" , method = RequestMethod.POST)
@ResponseBody
public JSONObject swipeRecordByPage(@RequestParam(value="page",required=false)String page,@RequestParam(value="rows",required=false)String rows,String dName, String username, String test, String phone,HttpServletResponse response){
JSONObject result = new JSONObject();
try {
PageBean pageBean=new PageBean(Integer.parseInt(page),Integer.parseInt(rows));
List swipeRecordList = swipeRecordService.selectSwipeRecordByPage(pageBean, dName, username, test, phone);
Long total = swipeRecordService.selectSwipeRecordCount();
result.put("rows", swipeRecordList);
result.put("total", total);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}