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

开始日期与结束日期(easyui的日期easyui-datebox)错误

2015-02-03 12:15 561 查看
1.前台页面使用easyui,我演示的是oracle数据库的日期字段,数据库字段:中心结算日期(SETTDATE)NUMBER(8),交易日期(TXNDATE)CHAR(8 BYTE)


中心结算开始日期和中心结算结算日期都是正常写法。

select count(1) from t_XXX  t WHERE t.settdate>=? and t.settdate<=?

 Parameters: 20150113(String), 20150113(String)

<form id="queryfm" method="post">
<div>
<table >
<tr>
<td> 中心结算开始日期:</td><td> <input name="settleDateStart" id="settleDateStart" class="easyui-datebox" /> </td>
<td> 中心结算结束日期:</td><td> <input name="settleDateEnd" id="settleDateEnd" class="easyui-datebox" /> </td>
<tr>
<td>交易开始日期:</td><td> <input name="txnDateStart" id="txnDateStart" class="easyui-datebox" /></td>
<td>交易结束日期:</td><td> <input name="txnDateEnd" id="txnDateEnd" class="easyui-datebox" /></td>
</tr>
</table>
</div>
</form>

2.

提交到后台:路径就隐藏了,

function queryInfo(pageNumber,pageSize,sort, order) {
var submitData = {};
submitData = querypage.initSubmitData(pageNumber,pageSize,sort, order);
submitData = geneSubmitDataFromForm("#queryfm",submitData);
$.messager.progress(COMMONPARAM_PROCESS);
submitData['settleDateStart'] = submitData['settleDateStart'].replace(/-/g, '').trim();
submitData['settleDateEnd'] = submitData['settleDateEnd'].replace(/-/g, '').trim();

submitData['txnDateStart'] = submitData['txnDateStart'].replace(/-/g, '').trim();
submitData['txnDateEnd'] = submitData['txnDateEnd'].replace(/-/g, '').trim();

submitData['adtDateStart'] = submitData['adtDateStart'].replace(/-/g, '').trim();
submitData['adtDateEnd'] = submitData['adtDateEnd'].replace(/-/g, '').trim();

jQueryAjaxForJSON(basePath + '/XXX.do', submitData,
function(sRet) {
querypage.refreshData(sRet.field1,submitData,function(pageNumber, pageSize,sort1,order1){queryInfo(pageNumber, pageSize,sort1,order1);},querypage,tbColumns1);
$.messager.progress('close');
}, function(sRet) {
$.messager.progress('close');
$.messager.alert('提示',sRet.message,'',function(){});
}, function() {
$.messager.progress('close');
alert('通讯异常');

});
}

3.mybatis的执行语句:

<!-- 中心结算日期 -->
<if test="settleDateStart !=null and settleDateStart !='' ">
<![CDATA[and t.settdate>=#{settleDateStart}]]>
</if>
<if test="settleDateEnd !=null and settleDateEnd !='' ">
<![CDATA[and t.settdate<=#{settleDateEnd}]]>
</if>
<!-- 调整日期 -->
<if test="adtDateStart !=null and adtDateStart !='' ">
<![CDATA[ and t.adtdate>=#{adtDateStart} ]]>
</if>
<if test="adtDateEnd != null and adtDateEnd !='' ">
<![CDATA[ and t.adtdate<=#{adtDateEnd} ]]>
</if>
<!-- 交易日期 -->
<if test="txnDateStart !=null and txnDateStart !='' ">
<![CDATA[and t.txndate>=#{txnDateStart}]]>
</if>
<if test="txnDateEnd !=null and txnDateEnd !='' ">
<![CDATA[and t.txndate<=#{txnDateEnd}]]>
</if>
4.见图,

select count(1) from t_XXX t WHERE t.settdate>=? and t.settdate<=?

Parameters: 20150 113(String), 20150113(String)

其实应该是查不到结果才对,其实不是,原因是::中心结算日期(SETTDATE)NUMBER(8),是number类型的,参数的时候多了一个空格。

5.对比:交易日期(TXNDATE)CHAR(8 BYTE),

select count(1) from t_XXX  t WHERE t.txndate>=? and t.txndate<=?

20150120(String), 20150120(String)

 select count(1) from t_dtl_XXX t WHERE t.txndate>=? and t.txndate<=?

Parameters: 20150 120(String), 20150120(String)  参数有空格,依然可以查询。日期中间可以有空格,不会影响查询结果

希望大家在开发中注意,可能是设计表的人大意出的问题。

对于使用number的日期解决方法也很简单,就是用户只能从选择日期,editable="false" 不可编辑
<pre name="code" class="html"> <td> 中心结算开始日期:</td><td> <input name="settleDateStart" id="settleDateStart" class="easyui-datebox" editable="false"/> </td>
<td> 中心结算结束日期:</td><td> <input name="settleDateEnd" id="settleDateEnd" class="easyui-datebox" editable="false"

/> </td>
<tr>
<td>交易开始日期:</td><td> <input name="txnDateStart" id="txnDateStart" class="easyui-datebox" editable="false"

/></td>
<td>交易结束日期:</td><td> <input name="txnDateEnd" id="txnDateEnd" class="easyui-datebox" editable="false"

/></td>


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