需求如下
因为系统生成的范围查询,日期没有增加限制,需要结束日期不能高于开始日期,故而重写查询功能,当然也支持下拉框重写,三级联动等,逻辑删除显示功能。
新增,导出按钮都需要重写,后台也需要对应的修改。
代码如下
从下开始到
<div region="center" style="padding:0px;border:0px">
<t:datagrid>
重写查询
将默认查询:query="true"移除,将<t:datagrid name="mdCustomerList" checkbox="true" pagination="true" fitColumns="false" title="客户信息",中的name给替换到下面的位置。
<!-- 操作按钮及查询 -->
<div id="mdCustomerListtb">
<div align="right">
<!-- 查询操作 -->
<table style="width: 100%;border-collapse: collapse;border-bottom: 1.5px solid #E6E6E6;" cellpadding="0"
cellspacing="1" class="formtable">
<table style="width: 100%;" cellpadding="0" cellspacing="1"
class="formtable">
<tr>
<td align="right" style="width:30px;background-color: white;">
<label>
客户类别:
</label>
</td>
<td class="value" style="width:15%;">
<t:dictSelect id="customerCategory" field="customerCategory" type="list"
typeGroupCode="custom" hasLabel="false" title="客户类别"></t:dictSelect>
</td>
<td align="right" style="width:30px;background-color: white;">
<label>
客户名:
</label>
</td>
<td class="value" style="width: 16%">
<input id="name" name="name" type="text" style="width: 90%"
class="inputxt" ignore="ignore"/>
</td>
<td align="right" style="width:30px;background-color: white;">
<label>
系统标题:
</label>
</td>
<td class="value" style="width:15%;">
<input id="systemTitle" name="systemTitle" type="text" style="width: 90%"
class="inputxt" ignore="ignore"/>
</td>
<td align="right" style="width:30px;background-color: white;">
<label>
截止日期:
</label>
</td>
<td class="value" style="width: 20%"><input id="deadlineTime_begin" name="deadlineTime_begin"
type="text" style="width: 45%" class="Wdate"
onClick="WdatePicker({maxDate: $('#deadlineTime_end').val() })"
ignore="ignore"/>
<input id="deadlineTime_end" name="deadlineTime_end"
type="text" style="width: 45%" class="Wdate"
onClick="WdatePicker({minDate: $('#deadlineTime_begin').val() })"
ignore="ignore"/>
</td>
<td class="value" style="width: 5%">
<a href="#" class="easyui-linkbutton" style="width: 100%;" iconCls="icon-search"
onclick="mdCustomerListsearch()">查询</a>
</td>
<td class="value" style="width: 10%">
<a href="#" class="easyui-linkbutton" style="width: 40%;" iconCls="icon-reload"
onclick="resetSearch()">重置</a>
</td>
</tr>
<%--<tr>--%>
<%--<td align="right" style="width:30px;background-color: white;">--%>
<%--<label>--%>
<%--截止日期:--%>
<%--</label>--%>
<%--</td>--%>
<%--<td class="value" style="width: 5%"><input id="deadlineTime_begin" name="deadlineTime_begin"--%>
<%--type="text" style="width: 45%" class="Wdate"--%>
<%--onClick="WdatePicker({maxDate: $('#deadlineTime_end').val() })"--%>
<%--ignore="ignore"/>--%>
<%--<input id="deadlineTime_end" name="deadlineTime_end"--%>
<%--type="text" style="width: 45%" class="Wdate"--%>
<%--onClick="WdatePicker({minDate: $('#deadlineTime_begin').val() })"--%>
<%--ignore="ignore"/>--%>
<%--</td>--%>
<%--</tr>--%>
<tr>
<td class="value" style="width: 5%">
<a href="#" class="easyui-linkbutton" plain="true" icon="icon-add"
onclick="add('新增','mdCustomerController.do?goAdd','mdCustomerList')">新增</a>
</td>
<td class="value" style="width: 10%">
<a href="#" class="easyui-linkbutton" style="width: 40%;" plain="true" icon="icon-putout"
onclick="ExportXls()">导出</a>
</td>
</tr>
</table>
</table>
</div>
</div>
重置按钮
//清空查询条件
function resetSearch() {
searchReset('mdCustomerList');
}
后台查询
@RequestMapping(params = "datagrid")
public void datagrid(MdCustomerEntity mdCustomer, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
//增加模糊查询
if (StringUtils.isNotBlank(mdCustomer.getName())) {
mdCustomer.setName("*" + mdCustomer.getName() + "*");
}
CriteriaQuery cq = new CriteriaQuery(MdCustomerEntity.class, dataGrid);
//查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, mdCustomer, request.getParameterMap());
try {
//自定义追加查询条件
cq.eq("deleteFlag", 0);
String query_deadlineTime_begin = request.getParameter("deadlineTime_begin");
String query_deadlineTime_end = request.getParameter("deadlineTime_end");
if (StringUtil.isNotEmpty(query_deadlineTime_begin)) {
cq.ge("deadlineTime", new SimpleDateFormat("yyyy-MM-dd").parse(query_deadlineTime_begin));
}
if (StringUtil.isNotEmpty(query_deadlineTime_end)) {
cq.le("deadlineTime", new SimpleDateFormat("yyyy-MM-dd").parse(query_deadlineTime_end));
}
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
this.mdCustomerService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}