例如:
在流程模板管理页面点击新增按钮,弹出编辑页面:
//编辑流程模板 editFlowModel: function (modelID) { var that = modObj; var title = "编辑流程模板"; var op = "edit"; //设置要传递的数据 xUI.dialog.setParam({ modelID: modelID, op: op }); //显示编辑窗体 xUI.dialog.open('ModelEdit.html', title, 400, 300); },
在编辑页面接收传递过来的参数:
/*初始化组件*/ initUI: function () { var that = this; //获取页面级别的参数 var arg = xUI.dialog.getParam(); if (arg != undefined) { that.dataStore.modelID = arg.modelID; that.dataStore.op = arg.op; if (arg.modelClassCode != undefined && arg.modelClassCode!="root") { that.dataStore.modelClassCode = arg.modelClassCode; } }
为编辑页面添加保存按钮:
/*初始化事件*/ initEvent: function () { var that = this; //绑定保存按钮 xUI.dialog.addButton("保存", function () { return that.saveFlowModel(); }, true, true); },
保存按钮事件:
//保存流程模板
saveFlowModel: function () {
var that = modObj;
var modelName = that.uiStore.txtModelName.getText();
if (modelName == "")
{
alert("模板名称不能为空");
return false;
}
var begDate = that.uiStore.dtbBegDate.getText();
var endDate = that.uiStore.dtbEndDate.getText();
if ( endDate !="" && begDate > endDate )
{
alert("有效终止日期不能小于有效起始日期");
that.uiStore.dtbEndDate.setText("");
return false;
}
//保存流程模板
var param = {
reqType: "SaveFlowModel",
modelID: that.dataStore.modelID,
modelClassCode: that.uiStore.cmbModelClassName.getValue(),
modelName: modelName,
modelDesc: that.uiStore.txtModelDesc.getText(),
modelBody: that.uiStore.txtModelBody.getText(),
begDate: begDate,
endDate: endDate,
enableFlag: that.uiStore.cmbEnableFlag.getValue()
};
that.ajaxDeal(that.dataStore.ajaxUrl, param, function (result) {
if (result.state == "ok") {
alert("保存成功");
xUI.dialog.close();
var modelClassCode = "root";
xUI.dialog.getParentWin().modObj.loadModelListByClass(modelClassCode);
}
else {
alert("保存失败");
}
});
return false;
}
return false;一定要写,否则ajax执行不了成功的回调函数。。。