您的位置:首页 > 产品设计 > UI/UE

easyui 日期范围前后台的设置以及实现

2016-05-03 11:37 423 查看
1.页面部分(引入相应的js)

<td class="w40 tl pl10">从日期:</td>
<td>
<input class="easyui-datebox stdfrm-b2" name="mDateBegin" id="mDateBegin" style="width: 158px;" data-options="validType:'date',height:23"></input>
</td>
<td class="w40 tl pl10">到日期:</td>
<td>
<input class="easyui-datebox stdfrm-b2" name="mDateEnd" id="mDateEnd" style="width: 158px;" data-options="validType:'date',height:23"></input>
</td>

<span style="float:left;margin-left:80px;margin-top:12px;"><a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-fi-search'" style="width:80px" onclick="doQuery();">查询</a></span>


2.js

/**
* 查询
*/
function doQuery(){
$('#dg_menu').datagrid('reload',{
'mDateBegin': $('#mDateBegin').datebox('getValue'),
'mDateEnd': $('#mDateEnd').datebox('getValue'),
'code': $('#mealtime').combobox('getValue')
});
}


3.后台

public String queryMenu() throws Exception{
HttpServletRequest request = this.getRequest();
String mDateBegin = request.getParameter("mDateBegin");
String mDateEnd = request.getParameter("mDateEnd");
String type = request.getParameter("code");
if("请选择".equals(type)){
type = null;
}
if(conditions == null){
conditions = new ArrayList();
}
if(mDateBegin != null && !mDateBegin.equals("")){
Condition c1 = new Condition();
c1.setPropertyKey("mDate");
c1.setPropertyExpression(">=");
c1.setPropertyValue(mDateBegin);
conditions.add(c1);
}

if(mDateEnd != null && !mDateEnd.equals("")){
Condition c2 = new Condition();
c2.setPropertyKey("mDate");
c2.setPropertyExpression("<=");
c2.setPropertyValue(mDateEnd);
conditions.add(c2);
}

if(type != null && !type.equals("")){
Condition c3 = new Condition();
c3.setPropertyKey("mealtime");
c3.setPropertyExpression("=");
c3.setPropertyValue(type);
conditions.add(c3);
}
Map map = (Map) this.menuService.queryMenu(conditions, pager, sorter);
jsonConfig.registerJsonValueProcessor(Date.class,new JsonDateValueProcessor());
this.utf8ResponseWriter().write(
JSONObject.fromObject(map, jsonConfig).toString());
return null;
}


以上代码不是完整,

待续……
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: