diff --git a/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java b/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java index a40d66c214c01d84b2317771355c252f6d55b64f..f63e28e82c93803e21ae64224d7653d8a0756174 100644 --- a/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java +++ b/src/main/java/neatlogic/framework/form/constvalue/FormHandler.java @@ -40,7 +40,8 @@ public enum FormHandler implements IFormHandler { FORMRATE("formrate", "评分"), FORMTAB("formtab", "选项卡"), FORMCOLLAPSE("formcollapse", "折叠面板"), - FORMSUBASSEMBLY("formsubassembly", "子表单"); + FORMSUBASSEMBLY("formsubassembly", "子表单"), + FORMCUSTOM("formcustom", "自定义组件"); private final String handler; private final String handlerName; diff --git a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java index f21c786c63187e21ca5453864d434d33d8db4a2f..b052125971a788c1bac773ff396d9be2ea2d17df 100644 --- a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java +++ b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.java @@ -18,6 +18,7 @@ package neatlogic.framework.form.dao.mapper; import neatlogic.framework.common.dto.BasePageVo; import neatlogic.framework.common.dto.ValueTextVo; import neatlogic.framework.form.dto.*; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; import java.util.List; @@ -67,6 +68,8 @@ public interface FormMapper { List getFormAttributeListByFormUuidList(List formUuidList); + List getFormExtendAttributeListByFormUuidAndFormVersionUuid(@Param("formUuid") String formUuid, @Param("formVersionUuid") String formVersionUuid); + int getFormAttributeMatrixCount(); List> getFormAttributeMatrixList(BasePageVo searchVo); @@ -97,8 +100,12 @@ public interface FormMapper { int insertFormAttribute(FormAttributeVo formAttributeVo); + int insertFormExtendAttribute(FormAttributeVo formAttributeVo); + int insertFormAttributeData(AttributeDataVo attributeDataVo); + int insertFormExtendAttributeData(AttributeDataVo attributeDataVo); + int deleteFormAttributeByFormUuid(String formUuid); int deleteFormByUuid(String uuid); @@ -110,4 +117,8 @@ public interface FormMapper { void deleteFormCustomItem(Long id); int deleteFormAttributeDataByIdList(List idList); + + int deleteFormExtendAttributeDataByIdList(List idList); + + int deleteFormExtendAttributeByFormUuidAndFormVersionUuid(@Param("formUuid") String formUuid, @Param("formVersionUuid") String currentVersionUuid); } diff --git a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml index 8d65815182fc046c6b97ca47ef631d66f3054462..e1a623adff053babfad69d99fee479666e4075ba 100644 --- a/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml +++ b/src/main/java/neatlogic/framework/form/dao/mapper/FormMapper.xml @@ -277,7 +277,7 @@ along with this program. If not, see .--> a.`label`, a.`type`, a.`handler`, - a.`config`, + a.`config` AS configStr, a.`data` FROM `form_attribute` a JOIN `form_version` b ON b.`uuid`=a.`formversion_uuid` AND b.`is_active` = 1 @@ -296,7 +296,7 @@ along with this program. If not, see .--> b.`label`, b.`type`, b.`handler`, - b.`config`, + b.`config` AS configStr, b.`data` FROM `form_version` a JOIN `form_attribute` b ON b.`form_uuid` = a.`form_uuid` AND a.`uuid` = b.`formversion_uuid` @@ -307,6 +307,23 @@ along with this program. If not, see .--> + + @@ -500,10 +517,33 @@ along with this program. If not, see .--> #{label}, #{type}, #{handler}, - #{config}, + #{configStr}, #{data}) + + INSERT INTO `form_extend_attribute` (`form_uuid`, + `formversion_uuid`, + `parent_uuid`, + `tag`, + `key`, + `uuid`, + `label`, + `type`, + `handler`, + `config`) + VALUES (#{formUuid}, + #{formVersionUuid}, + #{parentUuid}, + #{tag}, + #{key}, + #{uuid}, + #{label}, + #{type}, + #{handler}, + #{configStr}) + + INSERT INTO `form_attribute_data` ( `id`, @@ -526,6 +566,30 @@ along with this program. If not, see .--> UPDATE `data` = #{data,typeHandler=CompressHandler} + + INSERT INTO `form_extend_attribute_data` ( + `id`, + `form_uuid`, + `handler`, + `tag`, + `attribute_label`, + `attribute_uuid`, + `data` + ) + VALUES + ( + #{id}, + #{formUuid}, + #{handler}, + #{tag}, + #{attributeLabel}, + #{attributeUuid}, + #{data} + ) + ON DUPLICATE KEY + UPDATE `data` = #{data,typeHandler=CompressHandler} + + DELETE FROM `form_attribute` @@ -563,4 +627,18 @@ along with this program. If not, see .--> #{id} + + + DELETE FROM `form_extend_attribute_data` + WHERE `id` IN + + #{id} + + + + + DELETE FROM `form_extend_attribute` + WHERE `form_uuid` = #{formUuid} + AND `formversion_uuid` = #{formVersionUuid} + diff --git a/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java b/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java index fe1f88d54eb8eac9b7250eceaf6e1c251cd97d82..97340a4e7aef79a502e4e4abe6117db6fb638d05 100644 --- a/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java +++ b/src/main/java/neatlogic/framework/form/dto/AttributeDataVo.java @@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils; public class AttributeDataVo implements Comparable { private Long id; private String formUuid; + private String tag; private String attributeUuid; private String attributeLabel; private String handler; @@ -79,6 +80,14 @@ public class AttributeDataVo implements Comparable { this.handler = handler; } + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + public String getData() { return data; } diff --git a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java index 7fbe791a318bc1fcfe72c7e46609bb3fd80a33bb..e420eac30a1bc3d50dfaa2291e93ec5456b71ced 100644 --- a/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java +++ b/src/main/java/neatlogic/framework/form/dto/FormAttributeVo.java @@ -15,7 +15,6 @@ along with this program. If not, see .*/ package neatlogic.framework.form.dto; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.annotation.JSONField; import neatlogic.framework.common.constvalue.ApiParamType; @@ -26,45 +25,47 @@ import neatlogic.framework.form.attribute.core.IFormAttributeHandler; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.restful.annotation.EntityField; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.*; public class FormAttributeVo implements Serializable { private static final long serialVersionUID = 8282018124626035430L; - @EntityField(name = "属性uuid", type = ApiParamType.STRING) + @EntityField(name = "common.uuid", type = ApiParamType.STRING) private String uuid; - @EntityField(name = "表单uuid", type = ApiParamType.STRING) + @EntityField(name = "term.framework.formuuid", type = ApiParamType.STRING) private String formUuid; - @EntityField(name = "表单版本uuid", type = ApiParamType.STRING) + @EntityField(name = "term.framework.formversionuuid", type = ApiParamType.STRING) private String formVersionUuid; - @EntityField(name = "属性标签名", type = ApiParamType.STRING) + @EntityField(name = "common.parentuuid", type = ApiParamType.STRING) + private String parentUuid; + @EntityField(name = "common.tag", type = ApiParamType.STRING) + private String tag; + @EntityField(name = "common.key", type = ApiParamType.STRING) + private String key; + @EntityField(name = "common.name", type = ApiParamType.STRING) private String label; - @EntityField(name = "类型", type = ApiParamType.STRING) + @EntityField(name = "common.type", type = ApiParamType.STRING) private String type; - @EntityField(name = "处理器", type = ApiParamType.STRING) + @EntityField(name = "common.handler", type = ApiParamType.STRING) private String handler; - @EntityField(name = "属性配置", type = ApiParamType.STRING) - private String config; - @EntityField(name = "属性数据", type = ApiParamType.STRING) + @EntityField(name = "common.config", type = ApiParamType.STRING) + private JSONObject config; + @EntityField(name = "common.data", type = ApiParamType.STRING) private String data; - @EntityField(name = "是否必填", type = ApiParamType.BOOLEAN) + @EntityField(name = "common.isrequired", type = ApiParamType.BOOLEAN) private boolean isRequired; - @EntityField(name = "表达式列表", type = ApiParamType.JSONARRAY) + @EntityField(name = "common.expressionlist", type = ApiParamType.JSONARRAY) List expressionList; - @EntityField(name = "默认表达式", type = ApiParamType.JSONOBJECT) + @EntityField(name = "common.defaultexpression", type = ApiParamType.JSONOBJECT) ExpressionVo defaultExpression; - @EntityField(name = "供前端渲染时判断,如果为false则前端页面需使用默认config,true则使用表单管理编辑保存的config", type = ApiParamType.BOOLEAN) + @EntityField(name = "nffd.formattributevo.entityfield.name", type = ApiParamType.BOOLEAN) private boolean isUseFormConfig; - @EntityField(name = "服务uuid,当表单属性作为工单中心搜索条件时需要使用此属性进行对应", type = ApiParamType.STRING) + @EntityField(name = "term.itsm.channeluuid", type = ApiParamType.STRING, help = "当表单属性作为工单中心搜索条件时需要使用此属性进行对应") private String channelUuid; - @EntityField(name = "条件模型") + @EntityField(name = "term.framework.conditionmodel") private FormConditionModel conditionModel = FormConditionModel.CUSTOM; - @JSONField(serialize = false) - private JSONObject configObj; - @JSONField(serialize = false) private Set integrationUuidSet; @@ -76,6 +77,9 @@ public class FormAttributeVo implements Serializable { private FormAttributeParentVo parent; + @JSONField(serialize = false) + private String configStr; + public FormAttributeVo() { } @@ -90,7 +94,7 @@ public class FormAttributeVo implements Serializable { } public FormAttributeVo(String formUuid, String formVersionUuid, String uuid, String label, String type, - String handler, boolean isRequired, String config, String data) { + String handler, boolean isRequired, JSONObject config, String data) { this.uuid = uuid; this.formUuid = formUuid; this.formVersionUuid = formVersionUuid; @@ -158,11 +162,14 @@ public class FormAttributeVo implements Serializable { this.handler = handler; } - public String getConfig() { + public JSONObject getConfig() { + if (config == null && configStr != null) { + config = JSONObject.parseObject(configStr); + } return config; } - public void setConfig(String config) { + public void setConfig(JSONObject config) { this.config = config; } @@ -254,6 +261,9 @@ public class FormAttributeVo implements Serializable { return null; } IFormAttributeHandler formHandler = FormAttributeHandlerFactory.getHandler(handler); + if (formHandler == null) { + return null; + } return formHandler.getHandlerType(conditionModel); } @@ -262,8 +272,7 @@ public class FormAttributeVo implements Serializable { return null; } if ("formselect".equals(handler)) { - JSONObject configObj = JSON.parseObject(config); - return configObj.getBoolean("isMultiple"); + return config.getBoolean("isMultiple"); } if (conditionModel!= null && Objects.equals(conditionModel.getValue(), FormConditionModel.CUSTOM.getValue())) { @@ -284,13 +293,6 @@ public class FormAttributeVo implements Serializable { this.isUseFormConfig = isUseFormConfig; } - public JSONObject getConfigObj() { - if (configObj == null && StringUtils.isNotBlank(config)) { - configObj = JSONObject.parseObject(config); - } - return configObj; - } - public Set getIntegrationUuidSet() { return integrationUuidSet; } @@ -322,4 +324,39 @@ public class FormAttributeVo implements Serializable { public void setParent(FormAttributeParentVo parent) { this.parent = parent; } + + public String getParentUuid() { + return parentUuid; + } + + public void setParentUuid(String parentUuid) { + this.parentUuid = parentUuid; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getConfigStr() { + if (configStr == null && config != null) { + configStr = config.toJSONString(); + } + return configStr; + } + + public void setConfigStr(String configStr) { + this.configStr = configStr; + } } diff --git a/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java b/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java index 576e80f9d7290fafbd947fc3fd4d723001ebbd78..5c0982f9347bb983126e8c5ae30946b0ec5a08b8 100644 --- a/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java +++ b/src/main/java/neatlogic/framework/form/dto/FormVersionVo.java @@ -218,7 +218,7 @@ public class FormVersionVo extends BaseEditorVo { JSONObject controllerObj = controllerList.getJSONObject(i); JSONObject config = controllerObj.getJSONObject("config"); if (MapUtils.isNotEmpty(config)) { - formAttributeList.add(new FormAttributeVo(this.getFormUuid(), this.getUuid(), controllerObj.getString("uuid"), controllerObj.getString("label"), controllerObj.getString("type"), controllerObj.getString("handler"), config.getBooleanValue("isRequired"), controllerObj.getString("config"), config.getString("defaultValueList"))); + formAttributeList.add(new FormAttributeVo(this.getFormUuid(), this.getUuid(), controllerObj.getString("uuid"), controllerObj.getString("label"), controllerObj.getString("type"), controllerObj.getString("handler"), config.getBooleanValue("isRequired"), config, config.getString("defaultValueList"))); } } } @@ -237,7 +237,7 @@ public class FormVersionVo extends BaseEditorVo { String handler = componentObj.getString("handler"); boolean isRequired = config.getBooleanValue("isRequired"); String defaultValue = config.getString("defaultValue"); - return new FormAttributeVo(this.getFormUuid(), this.getUuid(), uuid, label, type, handler, isRequired, componentObj.getString("config"), defaultValue); + return new FormAttributeVo(this.getFormUuid(), this.getUuid(), uuid, label, type, handler, isRequired, config, defaultValue); } return null; } diff --git a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java index 50921b09e00d26bb434a77afc12813913fd01a64..b6f8df4dfb60e49030f3a4f0418f3842fd576ef3 100644 --- a/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java +++ b/src/main/java/neatlogic/framework/form/service/IFormCrossoverService.java @@ -91,4 +91,13 @@ public interface IFormCrossoverService extends ICrossoverService { * @return */ String getFormAttributeHandler(String attributeUuid, String formConfig); + + /** + * 获取表单组件列表 + * @param formUuid 表单UUID + * @param formName 表单名 + * @param tag 标签 + * @return 组件列表 + */ + List getFormAttributeList(String formUuid, String formName, String tag); } diff --git a/src/main/java/neatlogic/framework/restful/annotation/EntityField.java b/src/main/java/neatlogic/framework/restful/annotation/EntityField.java index 905cfc5316a1755631bf9f4f28db6bc485ebbbf3..41021d2b8ae98833f88a41f07b2ca4067d1f6381 100755 --- a/src/main/java/neatlogic/framework/restful/annotation/EntityField.java +++ b/src/main/java/neatlogic/framework/restful/annotation/EntityField.java @@ -1,13 +1,9 @@ package neatlogic.framework.restful.annotation; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - import neatlogic.framework.common.constvalue.ApiParamType; +import java.lang.annotation.*; + @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) @Documented @@ -19,4 +15,6 @@ public @interface EntityField { Class member() default NotDefined.class;// 值成员 + String help() default ""; + } diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java index cba465d66362f74785190efce9a0e5b8583cecdb..a0636115aec5842ec259f660cf3ccde48d338ae0 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CascadeHandler.java @@ -399,7 +399,7 @@ public class CascadeHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java index 78384bae75e97b894d52fbe555faaa836d37ae08..63d42b256263a341fc6dbfea80edc9296cf6afa4 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CheckboxHandler.java @@ -244,7 +244,7 @@ public class CheckboxHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/CustomHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/CustomHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..0d2aa4cadd281e59983d87f10e5248313d49370b --- /dev/null +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/CustomHandler.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.module.framework.form.attribute.handler; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.form.attribute.core.FormHandlerBase; +import neatlogic.framework.form.constvalue.FormConditionModel; +import neatlogic.framework.form.constvalue.FormHandler; +import neatlogic.framework.form.dto.AttributeDataVo; +import neatlogic.framework.form.exception.AttributeValidException; +import org.springframework.stereotype.Component; + +@Component +public class CustomHandler extends FormHandlerBase { + @Override + protected JSONObject getMyDetailedData(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public Object valueConversionText(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public Object dataTransformationForEmail(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public Object textConversionValue(Object text, JSONObject config) { + return null; + } + + @Override + public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) { + return null; + } + + @Override + public int getExcelHeadLength(JSONObject configObj) { + return super.getExcelHeadLength(configObj); + } + + @Override + public int getExcelRowCount(AttributeDataVo attributeDataVo, JSONObject configObj) { + return super.getExcelRowCount(attributeDataVo, configObj); + } + + @Override + public String getHandler() { + return FormHandler.FORMCUSTOM.getHandler(); + } + + @Override + public String getHandlerType(FormConditionModel model) { + return null; + } + + @Override + public ParamType getParamType() { + return null; + } + + @Override + public boolean isAudit() { + return false; + } + + @Override + public boolean isConditionable() { + return false; + } + + @Override + public boolean isProcessTaskBatchSubmissionTemplateParam() { + return false; + } + + @Override + public JSONObject valid(AttributeDataVo attributeDataVo, JSONObject configObj) throws AttributeValidException { + return null; + } + + @Override + public Object conversionDataType(Object source, String attributeLabel) { + if (source == null) { + return null; + } + if (source instanceof String) { + String sourceStr = (String) source; + if (sourceStr.startsWith("{") && sourceStr.endsWith("}")) { + return JSONObject.parse(sourceStr); + } else if (sourceStr.startsWith("[") && sourceStr.endsWith("]")) { + return JSONArray.parseArray(sourceStr); + } + } + return source; + } +} diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java index 5b2fa3c58b41c01d1895dd84c3e0155c40124941..32b9b447c4b24f6a38b65f1d572117fe0ec8cbcb 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/RadioHandler.java @@ -241,7 +241,7 @@ public class RadioHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java index 60781c6f3dec8c0d32446c0183e4a58b9b07d8e4..608bea3cc739cf74a1a8a155702c699fcb05ae8d 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/SelectHandler.java @@ -404,7 +404,7 @@ public class SelectHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java index 9e1677fc837303dab2ade82b14f11aa0f9796dcd..5edaa75bd8215c1063f64edf406c30b5173d919e 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java @@ -690,7 +690,7 @@ public class TableInputerHandler extends FormHandlerBase { public void makeupFormAttribute(FormAttributeVo formAttributeVo) { Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); /** 扩展属性 **/ JSONArray attributeArray = config.getJSONArray("attributeList"); if (CollectionUtils.isNotEmpty(attributeArray)) { diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java index 215e1a342f82f222a1b0d2f31f103b173b998ec4..ce69e9b2272110a426096d15553c43dcd04a9988 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableSelectorHandler.java @@ -539,7 +539,7 @@ public class TableSelectorHandler extends FormHandlerBase { Set integrationUuidSet = new HashSet<>(); Set matrixUuidSet = new HashSet<>(); Map> matrixUuidAttributeUuidSetMap = new HashMap<>(); - JSONObject config = formAttributeVo.getConfigObj(); + JSONObject config = formAttributeVo.getConfig(); String dataSource = config.getString("dataSource"); if ("matrix".equals(dataSource)) { String matrixUuid = config.getString("matrixUuid"); diff --git a/src/main/java/neatlogic/module/framework/form/service/FormService.java b/src/main/java/neatlogic/module/framework/form/service/FormService.java index ac02865c23bc4cd5d32cbce21d9d3a7b8f3cd3a8..985ddd84388c0afaffb13072477380c36370699b 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormService.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormService.java @@ -110,4 +110,13 @@ public interface FormService { * @return */ String getFormAttributeHandler(String attributeUuid, String formConfig); + + /** + * 获取表单组件列表 + * @param formUuid 表单UUID + * @param formName 表单名 + * @param tag 标签 + * @return 组件列表 + */ + List getFormAttributeList(String formUuid, String formName, String tag); } diff --git a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java index 7454a1deaa0a6ce1a5961d7a78dd82a49800c615..90d7d81fbdbc71d7b11e3302f5de30dcd6f1eb50 100644 --- a/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/form/service/FormServiceImpl.java @@ -23,11 +23,13 @@ import neatlogic.framework.dependency.core.DependencyManager; import neatlogic.framework.form.attribute.core.FormAttributeHandlerFactory; import neatlogic.framework.form.attribute.core.IFormAttributeHandler; import neatlogic.framework.form.constvalue.FormHandler; +import neatlogic.framework.form.dao.mapper.FormMapper; import neatlogic.framework.form.dto.AttributeDataVo; import neatlogic.framework.form.dto.FormAttributeParentVo; import neatlogic.framework.form.dto.FormAttributeVo; import neatlogic.framework.form.dto.FormVersionVo; import neatlogic.framework.form.exception.AttributeValidException; +import neatlogic.framework.form.exception.FormActiveVersionNotFoundExcepiton; import neatlogic.framework.form.service.IFormCrossoverService; import neatlogic.framework.matrix.constvalue.SearchExpression; import neatlogic.framework.matrix.core.IMatrixDataSourceHandler; @@ -60,6 +62,9 @@ import java.util.stream.Collectors; public class FormServiceImpl implements FormService, IFormCrossoverService { private static final Logger logger = LoggerFactory.getLogger(FormServiceImpl.class); + @Resource + private FormMapper formMapper; + @Resource private MatrixMapper matrixMapper; @@ -924,9 +929,42 @@ public class FormServiceImpl implements FormService, IFormCrossoverService { formAttributeVo.setRequired(isRequired); String defaultValue = config.getString("defaultValue"); formAttributeVo.setData(defaultValue); - formAttributeVo.setConfig(config.toJSONString()); + formAttributeVo.setConfig(config); } formAttributeVo.setParent(parent); return formAttributeVo; } + + @Override + public List getFormAttributeList(String formUuid, String formName, String tag) { + FormVersionVo formVersion = formMapper.getActionFormVersionByFormUuid(formUuid); + if (formVersion == null) { + throw new FormActiveVersionNotFoundExcepiton(formName); + } + FormAttributeVo searchVo = new FormAttributeVo(); + searchVo.setFormUuid(formUuid); + searchVo.setFormVersionUuid(formVersion.getUuid()); + List formAttributeList = formMapper.getFormAttributeList(searchVo); + if (StringUtils.isBlank(tag)) { + return formAttributeList; + } + List resultList = new ArrayList<>(); + List parentUuidList = new ArrayList<>(); + List formExtendAttributeList = new ArrayList<>(); + List list = formMapper.getFormExtendAttributeListByFormUuidAndFormVersionUuid(formUuid, formVersion.getUuid()); + for (FormAttributeVo formAttributeVo : list) { + if (Objects.equals(formAttributeVo.getTag(), tag)) { + formExtendAttributeList.add(formAttributeVo); + parentUuidList.add(formAttributeVo.getParentUuid()); + } + } + for (FormAttributeVo formAttributeVo : formAttributeList) { + if (parentUuidList.contains(formAttributeVo.getUuid())) { + continue; + } + resultList.add(formAttributeVo); + } + resultList.addAll(formExtendAttributeList); + return resultList; + } }