首页 > 代码库 > 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 = http://www.mamicode.com/$(this).combobox(‘getValue‘);
      if (value) {  
            parm.paramType = 5;
            parm.paramName = value;
            return true;  
       }  
          return false;  
       },
       onSelect: function(row){    //当用户选择一个列表项时触发。
            //这样赋值便于取值(否则该字段为空)
            document.getElementById("proBidSectionone").value= http://www.mamicode.com/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 实现智能模糊查询(智能检索)