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

本文介绍使用EasyUI实现从日期到日期的查询功能。通过前端JavaScript与后端Java配合,实现日期范围内的数据筛选。文章包含前端页面设计、JS交互逻辑及后端处理流程。

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;
    }

 

 

以上代码不是完整,

待续……

转载于:https://www.cnblogs.com/wanghui1316/p/5454380.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值