瀏覽代碼

页面设计:返回带控件的字段信息

4.0
郑根木 2 年之前
父節點
當前提交
d1d2dcc503
共有 6 個檔案被更改,包括 64 行新增37 行删除
  1. +30
    -20
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  2. +18
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java
  3. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java
  4. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowHelper.java
  5. +6
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java
  6. +6
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java

+ 30
- 20
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java 查看文件

@@ -1,5 +1,6 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.common.AbstractEnum;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
@@ -39,9 +40,9 @@ public class ModelFormHelper {
public static final String OPT_PAGE = "page";



/**
* 获取页面的pageName,格式:module.name
*
* @param form
* @return
*/
@@ -490,37 +491,46 @@ public class ModelFormHelper {
field.put("name", pdf.name);
field.put("label", pdf.label);
field.put("required", pdf.isFieldNotNull());
field.put("widget", 0);
final SwEnum.DataTypeBean dtb = SwEnum.DataType.instance.getByValue(pdf.dataType);
if (dtb != null) {
field.put("maxlength", dtb.dataLength);
field.put("editor", dtb.editor);
if (pdf.link > 0) {
long widget = getFieldCtrl(pdf.link);
if (widget > 0) {
setWidget.add(widget);
field.put("widget", widget);
field.put("widgetText", ModelFormCache.getInstance().getText(widget));
}
}
} else {
field.put("maxlength", 0);
field.put("editor", SwEnum.EditorType.INPUT.value);
}
}
}

/**
* 计算字段适用控件
*
* @param tableId
* @return
* 页面设计时,返回的字段信息,带控件
* @param table
* @param field
* @param col
*/
public static long getFieldCtrl(long tableId) {
Set<ModelForm> set = ModelFormCache.getInstance().getListByTable(tableId, SwEnum.FormType.WIDGET.value);
if (set == null || set.isEmpty()) return 0L;
public static void buildFieldInfo(ModelTable table, ModelField field, SwMap col) {
col.put("name", field.getName());
col.put("dataType", field.getDataType());
col.put("null", field.getNotNull());
col.put("default", field.getDefaultValue());
col.put("title", field.getTitle());
col.put("link", field.getLink());
col.put("table", table.getId());
col.put("table_text", table.getTitle());

SwEnum.DataTypeBean dtb = SwEnum.DataType.instance.getByValue(field.getDataType());
col.put("editor", dtb != null ? dtb.editor: SwEnum.EditorType.INPUT.value);

if (field.getLink() == 0L) return;

Set<ModelForm> set = ModelFormCache.getInstance().getListByTable(table.getId(), SwEnum.FormType.WIDGET.value);
if (set == null || set.isEmpty()) return;
ModelForm form = set.iterator().next();
return (form != null) ? form.getEntityId(): 0L;
if (form == null) return;
col.put("widget", form.getId());
col.put("widgetText", form.getTitle());
SwMap opts = form.getOpts();
if (opts != null) {
col.put("editor", SwEnum.WidgetType.getEditor(opts.readString("widgetType")));
}
}

/*//js文件的路径


+ 18
- 7
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java 查看文件

@@ -28,6 +28,7 @@ import java.util.List;
@SwService
public class ModelFormService extends AbstractCompService {
private final static String TYPE_CODE = "type_code";

@Override
protected AbstractHandler createHandler(String type) {
switch (type) {
@@ -149,16 +150,11 @@ public class ModelFormService extends AbstractCompService {
col.put("name", colName);
ModelField field = table.findField(colName);
if (field != null) {
col.put("dataType", field.getDataType());
col.put("null", field.getNotNull());
col.put("default", field.getDefaultValue());
col.put("title", field.getTitle());
col.put("link", field.getLink());
col.put("table", table.getId());
col.put("table_text", table.getTitle());
ModelFormHelper.buildFieldInfo(table, field, col);
} else {
SwEnum.DataTypeBean dtb = SwEnum.DataType.getBySqlType(metaData.getColumnType(i), metaData.getPrecision(i), metaData.getScale(i));
col.put("dataType", dtb.value);
col.put("editor", dtb.editor);
}
fields.add(col);
}
@@ -170,6 +166,21 @@ public class ModelFormService extends AbstractCompService {
}
}

public R loadFieldCfg(@SwBody SwMap params, UserSession us) {
long tableId = params.readLong("tableId");
if (tableId <= 0L) return R.error("没有传入的Table!");
ModelTable table = ModelTableCache.getInstance().get(tableId);
if (table == null) return R.error("没有找到表定义信息(table=" + tableId + ")!");

List<SwMap> ret = new ArrayList<>();
for (ModelField field : table.getFields()) {
SwMap col = new SwMap(2);
ModelFormHelper.buildFieldInfo(table, field, col);
ret.add(col);
}
return R.success(ret);
}

//加载模板定义
public R loadTmpls(@SwBody SwMap params, UserSession us) {
return R.success(CodeGenerator.getInstance().getModelTemplates());


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java 查看文件

@@ -152,7 +152,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {

EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(table.getName());
DefaultEntity bean;
if (id <= 0) {
if (id <= 0L) {
bean = dao.createBean();
bean.setIsNew(true);
//暂时不考虑list保存的情况


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowHelper.java 查看文件

@@ -34,13 +34,13 @@ public class FlowHelper {
//是否我的待办任务
public static boolean isMyWaitedTask(long task_id, long user_id) {
return DbEngine.getInstance().isExists("select 1 from " + EntityHelper.getSchemaTableName(Candidate.ENTITY_NAME) +
" where task_id=? and user_id=?", task_id, user_id);
" where cnd_tsk_id=? and cnd_user_id=?", task_id, user_id);
}

public static boolean isMySubmitTask(long task_id, long user_id) {
return DbEngine.getInstance().isExists("select 1 from " + EntityHelper.getSchemaTableName(TaskRel.ENTITY_NAME) +
" r inner join " + EntityHelper.getSchemaTableName(Task.ENTITY_NAME) + " t on t.task_id = r.before_task_bid\n" +
" where r.task_id=? and t.handler=?", task_id, user_id);
" r inner join " + EntityHelper.getSchemaTableName(Task.ENTITY_NAME) + " t on t.tsk_id = r.trl_src_task_id\n" +
" where r.trl_dst_task_id=? and t.tsk_handler=?", task_id, user_id);
}

/**


+ 6
- 6
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java 查看文件

@@ -310,12 +310,12 @@ public class FlowInstance {
*/
public void delete() {
getProcInstDao().deleteEntity(procInst);
getTaskDao().deleteEntity("where bill_id=?", procInst.getId());
getCandidateDao().deleteEntity("where bill_id=?", procInst.getId());
getCareDao().deleteEntity("where bill_id=?", procInst.getId());
getCommentDao().deleteEntity("where bill_id=?", procInst.getId());
getSignDao().deleteEntity("where bill_id=?", procInst.getId());
getTaskRelDao().deleteEntity("where bill_id=?", procInst.getId());
getTaskDao().deleteEntity("where tsk_pri_id=?", procInst.getId());
getCandidateDao().deleteEntity("where cnd_pri_id=?", procInst.getId());
getCareDao().deleteEntity("where cr_pri_id=?", procInst.getId());
getCommentDao().deleteEntity("where cmt_pri_id=?", procInst.getId());
getSignDao().deleteEntity("where sgn_pri_id=?", procInst.getId());
getTaskRelDao().deleteEntity("where trl_pri_id=?", procInst.getId());
}

/**


+ 6
- 0
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java 查看文件

@@ -260,6 +260,12 @@ public interface SwEnum {
public static StrEnumBean COMBOGRID = instance.addEnum("combogrid", "下拉表格");
public static StrEnumBean COMBOTREE = instance.addEnum("combotree", "下拉树");
public static StrEnumBean CUSTOM = instance.addEnum("custom", "自定义");

public static String getEditor(String type) {
if (TREE.value.equals(type) || COMBOTREE.value.equals(type)) return EditorType.TREE.value;
if (COMBOGRID.value.equals(type)) return EditorType.COMBO.value;
return EditorType.INPUT.value;
}
}

/**


Loading…
取消
儲存