function imageMaintain() {
$.showModalDialog($$pageContextPath
+ "uepI/imageMaintain.do?servicecode="
+ ajaxform1.getColumnValue("serviceCode"), "上传图片", callback2,
null, 450, 180, 2);
}
第一个参数为action?参数
第二个参数为title
第三个参数是回调函数
第四个参数是回调方法的参数
第五个参数是弹窗宽度
第六个参数是弹窗高度
第七个参数是弹窗的按钮 :
设置值为0:没有按钮;设置值为1:显示确定按钮;设置值为2:显示取消按钮;设置值为3:显示确定、取消按钮,
接下来根据功能介绍
业务一
必须执行保存后,点击添加联系人才能出现弹窗
看点击事件的js方法
function showKeyPerson(cell){
if(unitGrid.isModified()){ //判断当前表格中是否有新添加数据、删除数据、修改数据
$.alert("请先执行保存!");
return;
}
$.showModalDialog($$pageContextPath + "setting/adMaintainperson.do?storeId="+ cell.storeId+"&storeUnitId="+cell.storeUnitId,"联系人信息维护",null,null,910,500,0) ;
}
<%
String storeId = request.getParameter("storeId") == null ? "": request.getParameter("storeId");
String storeUnitId = request.getParameter("storeUnitId")==null ? "": request.getParameter("storeUnitId");//属性标识
%>
<script type="text/javascript">
var storeId = "<%=storeId%>";
var storeUnitId = "<%=storeUnitId%>";
</script>
<script>
function ajax_init(response) {
var dataWrap = response.getAjaxDataWrap("dataWrap");
ajaxgrid.setData(dataWrap);
}
/**
* 查询
*/
function retrieve() {
var data = ajaxgrid.collectData(true, "all");
var dataArr = [];
dataArr.push(data);
$.request({
action : "retrieve",
params : {
"storeId" : storeId,
"storeUnitId" : storeUnitId//这里一定要加参数,要不会报错
},
data : dataArr,
success : ajax_init
});
}
//添加
function add(){
$.request({
action:"add",
params : {
"storeId" : storeId,
"storeUnitId" : storeUnitId
},
success:onaddcomplete
});
}
</script>
对应action
@Override
public void retrieve() {
try {
if (storeId !=null && !storeId.equals("")) {
QueryParamList paramList =new QueryParamList();
paramList.addParam("storeId", storeId);
paramList.addParam("storeUnitId", storeUnitId);
List<MdmCompanyKeyPerson> list=JPAUtil.load(MdmCompanyKeyPerson.class, paramList, dataWrap.getSortOptions(),dataWrap.getPageInfo());
if(list.size()>0){
dataWrap.setDataList(list);
responseData.setAjaxDataWrap("dataWrap", dataWrap);
}
responseData.setParameter("storeId", storeId);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 添加
*/
public void add(){
Long key = PrimarySequenceUtil.genEntitySequenceNo(MdmCompanyKeyPerson.class);
MdmCompanyKeyPerson model=new MdmCompanyKeyPerson ();
model.setKeyPersonId(key);
model.setStoreId(storeId);
model.setStoreUnitId(storeUnitId);
model.setUseFlag("Y");
model.setDefaultMark("N");
dataWrap.setData(model);
responseData.setAjaxDataWrap("dataWrap", dataWrap);
}
业务2
例如 厂商(品牌)这个就是用弹窗来实现的
点击触发事件如下:
function formGongHuo() {
var obj = {};
obj.label = form_gonghuo.getSelectedLabel();
obj.value = form_gonghuo.getSelectedValue();
//$.showModalDialog(""+$$pageContextPath +
// "common/cpm/inputbuttonselectcompany.do?comType=J","供应商选择",showFormGHCallback,obj,720,600,0);
$.showModalDialog("" + $$pageContextPath + "common/getCompany.do?companyType=J", "供应商选择", showFormGHCallback, obj, 720, 600, 0);
}
进入action对应的jsp页面
//确定
function onConf(){
var rec = ajaxgrid.getSelectedRecord();
if (rec==null) {
$.alert("请选择一条记录");
return;
};
$.close(rec);
}
//取消
function onConc(){
$.close("-1");
}
//清空
function onClear(){
$.close("");
回调函数如下:
function showFormGHCallback(retStr, a, b) {// retStr为getCompany动作的返回值, a 为obj开始带入的参数,b为当前操作是否为取消操作,isCancel ==0时,表示是点击取消或点击弹出窗上关闭按钮关闭弹出窗
if (b == 0 || retStr == "-1") {
form_gonghuo.selectItem(a.value, a.label);
} else if (retStr == "") {
// form_gonghuo.selectItem(null, null);
} else {
form_gonghuo.selectItem(retStr.get("companyId"), retStr.get("unitName"));
}
}