1. 程式人生 > >Easyui 實現智能模糊查詢(智能檢索)

Easyui 實現智能模糊查詢(智能檢索)

easyui 實現智能模糊查詢

技術分享

技術分享


js代碼:
<input id="proBidSectionone" name="proBidSectionone" value="">
重點:
//工作標段模糊查詢
$("#proBidSectionone").combobox({
valueField: ‘uid‘,
textField: ‘paramName‘,
url: path+‘/admin/dispatcher/searchParam.do‘,
mode: ‘remote‘, //從服務器加載就設置為‘remote‘
hasDownArrow: false, //為true時顯示下拉選項圖標


onBeforeLoad: function (parm) { //在請求加載數據之前觸發,返回 false 則取消加載動作
var value = $(this).combobox(‘getValue‘);
if (value) {
parm.paramType = 5;
parm.paramName = value;
return true;
}
return false;
},
onSelect: function(row){ //當用戶選擇一個列表項時觸發。

//這樣賦值便於取值(否則該字段為空)
document.getElementById("proBidSectionone").value= row.uid;
}
})


後代代碼:
控制層:
@Controller
@RequestMapping("/admin/dispatcher")
public class DispatcherController extends BaseController{
@Resource
private DispatchParamService dispatchParamService;
private Map<String, Object> params;
@RequestMapping("searchParam.do")
@ResponseBody
public List<DispatchParam> paramList(HttpServletRequest req, String paramName, String paramType){
params = new HashMap<>();
params.put("paramType", paramType);
params.put("paramnametest", paramName);
List<DispatchParam> list = dispatchParamService.findByMap(params);
return list;
}
}


model層:
package com.shangyu.entity.dsz;
public class DispatchParam{
private String uid;
private Integer paramType;
private String paramName;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid == null ? null : uid.trim();
}
public Integer getParamType() {
return paramType;
}
public void setParamType(Integer paramType) {
this.paramType = paramType;
}
public String getParamName() {
return paramName;
}
public void setParamName(String paramName) {
this.paramName = paramName == null ? null : paramName.trim();
}
}


mapper.xml:
<select id="findByMap" parameterType="java.util.Map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from yl_pb_dispatch_param
<trim prefix="where" prefixOverrides="and">
<if test="paramType != null">
and param_type = #{paramType}
</if>
<if test="paramnametest != null">
and param_name like concat(‘%‘,#{paramnametest},‘%‘)
</if>
</trim>
</select>





本文出自 “不凡人生——求知者” 博客,請務必保留此出處http://825272560.blog.51cto.com/11004487/1946371

Easyui 實現智能模糊查詢(智能檢索)