先写输入框:
按钮触发事件及function方法(window.open为打开新的页面具体页面后续):
$("#btnRDSearch").click(reserveDetail.loadReserve);
//搜索关键字
reserveDetail.loadReserve = function(){
var sUrl = "reserveAction_loadReserve";
var objParams = { "hasLoading": false, "cvoParameter.keyWord": $("#txtRDKeyWord").val()};
commonJs.openAjax(sUrl, objParams,function(data){
if (!data.success) {
commonJs.openDialog("error", data.message);
} else {
var lstResult = data.lstResult;
if (typeof(lstResult) =="undefined") {
commonJs.openDialog("error", "无查询结果请重新输入!");
} else {
if (lstResult.length == 1) {
var sId = lstResult[0].id;
var sMrn = lstResult[0].medicalRecordNumber;
var sCn = lstResult[0].clinicNumber;
var sOrderId = lstResult[0].orderId;
var sTargetId = lstResult[0].targetId;
window.open(BASE_PATH + "/spv2/nurse/reserve/reserve_detail.jsp?id="+sId+"&mrn="+sMrn+"&cn="+sCn+"&oid="+sOrderId+"&tid="+sTargetId);
} else if (lstResult.length > 1){
commonJs.openDialog("warning","查询数据条数为"+lstResult.length+",请重新输入!");
return;
}
}
}
});
}
在commonJs中已经封装好openAjax、openDialog方法了:
//打开ajax请求(请求地址, 参数, 成功后回调的函数, 失败后回调的函数)
commonJs.openAjax = function(sUrl, vParams, funSuccess, funError) {
if (sUrl == null || sUrl == '') return false;
// 默认显示加载层,如果不需要,请设置vParams.hasLoading为false
var hasLoading = true;
if (vParams != null && vParams.hasLoading == false) { hasLoading = false; }
if (hasLoading) { commonJs.openLoadDialog(); }
$.ajax({
url: sUrl,
data: vParams,
type: 'POST',
dataType: 'json',// xml,html,script,json,jsonp
timeout: 30 * 60 * 1000,
success: function(data) {
if (hasLoading) { commonJs.closeLoadDialog(); }
if (data != null && data.code == "login"){
commonJs.openDialog("error", data.message, function(){
location.href = BASE_PATH + "/spv2/login.jsp?returnUrl=" + commonJs.enReturnUrl();
});
}else{
funSuccess(data);
}
},
error: funError
});
};
// 打开页面对话框
commonJs.openPageDialog = function(par) {
if (par != null && par.closable == null) { par.closable = false; }
if (par != null && par.lg != null && par.lg == true) {
par.lg = BootstrapDialog.SIZE_WIDE;
} else {
par.lg = BootstrapDialog.SIZE_NORMAL;
}
var dialog = new BootstrapDialog({
id: par.id,// 窗口id
title: par.title,// 标题
size: par.lg,// 是否大窗口
closable: par.closable,// 是否可关闭(默认为不关闭)
closeByKeyboard: par.closable,// 是否可用Esc关闭窗口(与closable一致)
message: function(dialog) {
var $message = $(' 加载中,请稍候...');
setTimeout(function() {
if (par.url == null || par.url == '') return;
if (par.url.indexOf('?') > -1) {
// par.url += '&ran=' + Math.random();
} else {
// par.url += '?ran=' + Math.random();
}
$message.load(par.url, par.data, function() { });
}, 500);
return $message;
},
buttons: par.buttons
}).open();
return dialog;
}
编写action方法:
IReserve funReserve = FunFactory.getReserve();
/**
* 加载预约就诊客户
* @return
*/
@IAccess(competenceNumber = { GlobalCache.UserRole.SPD }, returnFormat = GlobalCache.JSON)
public void loadReserve() {
MessageVo mvoResult = new MessageVo();
CommonVo cvoParams = getCvoParameter();
if ("".equals(cvoParams.getKeyWord()) || cvoParams.getKeyWord() == null) {
mvoResult.setSuccess(false);
mvoResult.setMessage("输入关键字不能为空!");
} else {
mvoResult = funReserve.pageListReserve(cvoParams);
}
this.outJson(mvoResult);
}
commonVo为公共值对象,MessageVo 为返回值对象,立面包含你所要传输的值对象。
funReserve 为FunFactory的获取对象。
pageListReserve方法为:
/**
* 获取预约确认列表
*/
public MessageVo pageListReserve(CommonVo cvoParams) {
String sSql = "";
cvoParams.setIsPay("1");// 已付款
sSql += CommonBean.getRangeCondition(cvoParams.getRange(), "reserve_date", "4");
if (!"".equals(cvoParams.getKeyWord()) && cvoParams.getKeyWord() != null) {
sSql += " and (CLINIC_NUMBER LIKE '%" + cvoParams.getKeyWord() + "%' OR MEDICAL_RECORD_NUMBER LIKE '%" + cvoParams.getKeyWord() + "%' OR TARGET_NAME LIKE '%" + cvoParams.getKeyWord()
+ "%')";
sSql += " and (DOCTOR_ID = '" + cvoParams.getDoctorId() + "' OR DOCTOR_ID IS NULL)";
}
cvoParams.setSql(sSql);
cvoParams.setOrderBy("order by DOCTOR_ID,RESERVE_DATE,QUEUE_ID");
return tdoReserveOrder.getList(cvoParams);
}
封装好的dao包(尽量不要修改这文件):
@Repository("VReserveOrderViewDao")
public class VReserveOrderViewDao extends DaoSupport implements IViewDao {
private static String TABLE_NAME = "VReserveOrder";
public MessageVo getList(CommonVo cvoSelect) {
String sHql = "from " + TABLE_NAME + " where 1=1 ";// 查询语句
String sCount = "select count(*) from " + TABLE_NAME + " where 1=1 ";// 分页语句
MessageVo mvoResult = new MessageVo();
try {
Object[] objParameter = null;
ArrayList