<div id="datagrid1" url="/inventoryIn.do?method=list" class="mini-datagrid" style="width:100%;height:100%;" pageSize="10" showPageInfo="true" multiSelect="true" >
表明每次load調用 inventoryIn.do?method=list javascript
表明 InventoryInController中的 list方法html
1.開始日期查詢java
<div id="query1" class="mini-form" align="center" style="height:100%"> <table id="table1" class="table" style="height:100%"> <tr> <td> 單據號: </td> <td colspan="4"> <input class="mini-textbox" name="orderNum" id="orderNum"/> </td> <td> 開始日期: </td> <td colspan="4"> <input class="mini-datepicker" id="beginDate" name="beginDate" format="yyyy-MM-dd"/> </td> <td> 結束日期: </td> <td colspan="4"> <input id="endDate" class="mini-datepicker" /> </td> <td> 存儲性質: </td> <td colspan="4"> <input id="typeName" class="mini-textbox" /> </td> <td> 倉庫: </td> <td colspan="4"> <input id="warehouseName" class="mini-textbox" /> </td> <td> <a class="mini-button" onclick="listSearch()"> 查詢 </a> <a class="mini-button" onclick="reset()"> 重置 </a> </td> </tr> </table> </div>
JS查詢部分代碼mysql
function listSearch(){ var form = new mini.Form("#query1"); //獲取到總體查詢條件表單對象 var data = form.getData(); //獲取表單中全部的值 var t= data.beginDate; //獲取表單中日期的值 //如下將 控件中的日期轉化爲 yyyy-MM-dd 格式 var time; if(t!=""){ var y = t.getFullYear(); var m = t.getMonth()+1; m = m < 10 ? '0' + m : m; var d = t.getDate(); d = d < 10 ? ('0' + d) : d; time= y + '-' + m + '-' + d ; } alert(time); grid.load({orderNum:data.orderNum,beginDate:time}); }
grid.load中的第一個 orderNum爲 Java中 InventoryInController list方法內須要從新聲明sql
接收從HTML中的傳入值數據庫
public ModelAndView list(HttpServletRequest request, HttpServletResponse response) { String p = request.getParameter("page"); String limit = request.getParameter("limit"); int toLimit = NumberUtils.toInt(limit, Constants.VALUE_PAGE_SIZE); int toStart = (NumberUtils.toInt(p, 0) - 1) * toLimit; String searchOrderNum = request.getParameter("orderNum"); String searchbeginDate = request.getParameter("beginDate"); //添加 Page page = inventoryInManager.getInventoryInDtoPage(toStart, toLimit, searchOrderNum,searchbeginDate); //添加searchbeginDate
inventoryInManager.getInventoryInDtoPageapp
查看 inventoryInManager.java中的 getInventoryInDtoPage方法ui
public Page getInventoryInDtoPage(int start, int pageSize, String orderNum, String beginDate) { StringBuffer sb = new StringBuffer(); sb.append("select iii.ID,iii.CREATE_TIME,iii.CREATE_USER,iii.II_ARRIVE_DATE,iii.II_ORDER_DATE,iii.II_ORDER_NUM,iii.II_REMARK,"); sb.append(" sp1.SP_NAME as 'STATUS_NAME',sp2.SP_NAME as 'TYPE_NAME',bw.BW_NAME as 'WAREHOUSE_NAME'"); sb.append(" from inv_inventory_in iii,sys_param sp1,sys_param sp2,sys_param sp3,base_warehouse bw"); sb.append(" where iii.II_STATUS_ID=sp1.ID"); sb.append(" and iii.II_TYPE_ID=sp2.ID"); sb.append(" and iii.II_WAREHOUSE_ID=bw.ID"); sb.append(" and bw.BW_STATUS_ID=sp3.ID"); // sb.append(" AND sp1.SP_FLAG='1'"); // sb.append(" AND sp2.SP_FLAG='1'"); // sb.append(" AND sp3.SP_FLAG='1'"); // sb.append(" AND sp3.SP_CODE='1'"); if (orderNum != null && !orderNum.equalsIgnoreCase("")) { sb.append(" AND iii.II_ORDER_NUM='" + orderNum + "'"); } if (beginDate != null && !beginDate.equalsIgnoreCase("")) { sb.append(" AND iii.II_ORDER_DATE>='" + beginDate + "'"); } sb.append(" ORDER BY iii.CREATE_TIME desc");
1.修改形參列表添加 String beginDateurl
2.添加查詢條件spa
if (beginDate != null && !beginDate.equalsIgnoreCase("")) {
sb.append(" AND iii.II_ORDER_DATE>='" + beginDate + "'");
}
在conf下的 jdbc文件中
#druid mysql Ygfsew654JhaL226 datasource.driverClassName=com.mysql.jdbc.Driver datasource.url=jdbc\:mysql\://101.200.180.236\:3308/jiuzaidb?useUnicode=true&characterEncoding=UTF-8 datasource.username=root datasource.password=236Passw0rd #本地文件 #w爲註釋 #datasource.url=jdbc\:mysql\://localhost\:3306/jiuzaidb?useUnicode=true&characterEncoding=UTF-8 #datasource.username=root #datasource.password=1 #datasource.url=jdbc\:mysql\://192.168.10.165\:3306/jgldb_tech?useUnicode=true&characterEncoding=UTF-8 #datasource.username=root #datasource.password=1