jQueryUi自动补全实例myxiao.docx
《jQueryUi自动补全实例myxiao.docx》由会员分享,可在线阅读,更多相关《jQueryUi自动补全实例myxiao.docx(20页珍藏版)》请在冰豆网上搜索。
jQueryUi自动补全实例myxiao
SSH+jqueryUiAutoComplete+多选复选框进行保存
效果图
Dao、service层照常写
Struts.xml文件:
以json的格式返回:
--开发模式-->
主要是Action层
publicclassMZRecipexqActionextendsActionSupport{
privatestaticfinallongserialVersionUID=4172670844909905854L;
//智能提示列表,以JSON数据格式返回
privateListautoSuggests=newArrayList();
//接收药品名称第一个字节长度用来判断是否用简称查询还是用名称进行查询
privateIntegerbytelength;
//药品名字列表
privateListdrugList;
//搜索关键字,药品名称
privateStringdrugName;
//接收处方药品id
privateStringappendValue;
//接收处方药品用法
privateStringappendYongf;
//接收处方药品数量
privateStringappendCiunt;
//接收处方药品天数
privateStringappendTians;
//接收处方药品次数
privateStringappendcishu;
//就收处方挂号编号
privateIntegermzghbianhao;
/**
*门诊药品业务类。
*/
privateMZDrugServicemzDrugService;
/**
*门诊处方业务类。
*/
privateMZRecipeServicemzRecipeSerivce;
/**
*门诊挂号业务类
*/
privateMZGuahaoServicemzGuahaoService;
/**
*智能提示,自动补全功能
*
*@returnString
*/
publicStringautoComplete(){
Stringsql;
//判断字节数根据条件查询
if(this.getBytelength()==1){
Stringdname=this.getDrugName();
sql="fromDrugwherepymlike'%"+dname.toUpperCase()+"%'";
}else{
sql="fromDrugwheredrnamelike'%"+this.getDrugName()+"%'";
}
drugList=mzDrugService.findByListHql(sql);
for(Drugdrug:
drugList){
PunishTableValuee=newPunishTableValue();
e.setLabel(drug.getDrname());
e.setValue(drug.getDrid());
e.setYptype(drug.getDrugcategory().getDcname());
e.setYpprice(drug.getPrice());
e.setYpnorm(drug.getSpecification().getSpvalue());
e.setYpunit(drug.getUnit().getUnvalue());
autoSuggests.add(e);
}
System.out.println("........................."+this.getDrugName());
System.out.println("........................."+drugList.size());
returnSUCCESS;
}
/**
*保存病人处方
*
*@return
*/
publicStringsaveRecipe(){
//挂号编号
ActionContextac=ActionContext.getContext();
Integerghid=(Integer)ac.getSession().get("mzghid");
Guahaoguahao=newGuahao();
//保存挂号编号
guahao.setGhid(ghid);
guahao.setGhstatus
(1);
//当前开处方时间
StringwriteDate=newSimpleDateFormat("yyyy-MM-dd")
.format(newjava.util.Date());
//药品服用天数
Stringmzcfypts[]=this.getAppendTians().split(",");
//药品每一天服用次数
Stringmzcfypcs[]=this.getAppendcishu().split(",");
//药品数量
Stringmzcfypsl[]=this.getAppendCiunt().split(",");
//药品用法
Stringmzcfypyf[]=this.getAppendYongf().split(",");
Listdrlist=newArrayList();
Drugd=newDrug();
Stringmzcfypid[]=this.getAppendValue().split(",");
for(inti=0;id=mzDrugService
.findByHql("fromDrugwheredrid="+mzcfypid[i]);
System.out.println(".............."+d.getDrid());
drlist.add(d);
}
for(inti=0;iReciperecipe=newRecipe();
//药品(外键)
recipe.setDrug(drlist.get(i));
//时间
recipe.setRctime(Date.valueOf(writeDate));
//挂号id(外键)
recipe.setGuahao(guahao);
//药品类型
recipe.setDrugtype(drlist.get(i).getDrugcategory().getDcname());
//规格
recipe.setNorms(drlist.get(i).getSpecification().getSpvalue());
//价格
recipe.setRcprice(drlist.get(i).getPrice());
//单位
recipe.setUnits(drlist.get(i).getUnit().getUnvalue());
//天数
recipe.setFate(Integer.valueOf(mzcfypts[i]));
//次数
recipe.setFrequency(Integer.valueOf(mzcfypcs[i]));
//数量
recipe.setRcnum(Integer.valueOf(mzcfypsl[i]));
//状态
recipe.setStatus(0);
//用法
recipe.setUsage(mzcfypyf[i]);
mzRecipeSerivce.saveOrUpdate(recipe);
}
mzGuahaoService.saveOrUpdate(guahao);
returnNONE;
}
/**
*智能提示列表作为JSON数据返回,设置serialize=true
*/
@JSON(serialize=true)
publicListgetAutoSuggests(){
returnautoSuggests;
}
@JSON(serialize=false)
publicIntegergetBytelength(){
returnbytelength;
}
/**
*搜索结果列表不作为JSON数据返回,设置serialize=false
*/
@JSON(serialize=false)
publicListgetDrugList(){
returndrugList;
}
/**
*搜索关键字不作为JSON数据返回,设置serialize=false
*/
@JSON(serialize=false)
publicStringgetDrugName(){
returndrugName;
}
publicvoidsetAutoSuggests(ListautoSuggests){
this.autoSuggests=autoSuggests;
}
publicvoidsetBytelength(Integerbytelength){
this.bytelength=bytelength;
}
publicvoidsetDrugList(ListdrugList){
this.drugList=drugList;
}
publicvoidsetDrugName(StringdrugName){
this.drugName=drugName;
}
publicvoidsetMzDrugService(MZDrugServicemzD