@@ -190,6 +190,7 @@ public class CodeBuildHandler extends AbstractHandler { | |||||
model.put("packageName", packageName); | model.put("packageName", packageName); | ||||
model.put("formTitle", form.getTitle()); | model.put("formTitle", form.getTitle()); | ||||
model.put("service", sName); | model.put("service", sName); | ||||
model.put("eventPath", ModelFormHelper.getEventPath(form)); | |||||
CodeGenerator.getInstance().generateService(model, codeJavaPath + "/" + sName + "Service.java"); | CodeGenerator.getInstance().generateService(model, codeJavaPath + "/" + sName + "Service.java"); | ||||
} | } | ||||
@@ -357,13 +357,21 @@ public class ModelFormHelper { | |||||
* @param opts | * @param opts | ||||
*/ | */ | ||||
public static void buildOptsEx(ModelForm bean, SwMap opts) { | public static void buildOptsEx(ModelForm bean, SwMap opts) { | ||||
String eventPath = getEventPath(bean); | |||||
if (StringUtils.isNotEmpty(eventPath)) { | |||||
opts.put(KEY_EVENT_PATH, eventPath); | |||||
} | |||||
} | |||||
public static String getEventPath(ModelForm bean) { | |||||
String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId()); | String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId()); | ||||
if (StringUtils.isNotEmpty(moduleName)) { | if (StringUtils.isNotEmpty(moduleName)) { | ||||
String ep = moduleName; | String ep = moduleName; | ||||
String cn = ModelCatalogCache.getInstance().getFullName(bean.getMcId()); | String cn = ModelCatalogCache.getInstance().getFullName(bean.getMcId()); | ||||
if (StringUtils.isNotEmpty(cn)) ep = ep + "." + cn; | if (StringUtils.isNotEmpty(cn)) ep = ep + "." + cn; | ||||
opts.put(KEY_EVENT_PATH, ep + "." + bean.getName()); | |||||
return ep + "." + bean.getName(); | |||||
} | } | ||||
return ""; | |||||
} | } | ||||
/** | /** | ||||
@@ -2,7 +2,7 @@ | |||||
* Created by ${user} at ${sysTime} | * Created by ${user} at ${sysTime} | ||||
* 注册事件类【${title}】,参看event.defaultEvent.js | * 注册事件类【${title}】,参看event.defaultEvent.js | ||||
*/ | */ | ||||
window.$swEvent.setup("defaultEvent", { | |||||
window.$swEvent.setup("${eventPath}", { | |||||
setup(page){ | setup(page){ | ||||
const { $params,$refs, $widgets, $model, $utils, $tabRouter, $api } = page; | const { $params,$refs, $widgets, $model, $utils, $tabRouter, $api } = page; | ||||
const { $$message, $$http } = $utils; | const { $$message, $$http } = $utils; | ||||