Commit d2cf80b1 authored by 赵啸非's avatar 赵啸非

添加级联

parent 536ee4b3
Pipeline #2852 canceled with stages
...@@ -19,7 +19,10 @@ public enum ComponentEnum { ...@@ -19,7 +19,10 @@ public enum ComponentEnum {
AREA("area", "区域选择栏"), AREA("area", "区域选择栏"),
IMAGE("@image", "图片选择"), IMAGE("@image", "图片选择"),
LIST("list", "横向单列表"), LIST("list", "横向单列表"),
DYNAMIC_TABLE("dt", "动态表格"),; DYNAMIC_TABLE("dt", "动态表格"),
CASCADE("csd", "级联选择"),
;
private String value; private String value;
private String desc; private String desc;
......
...@@ -40,6 +40,8 @@ public abstract class DesignComponent { ...@@ -40,6 +40,8 @@ public abstract class DesignComponent {
return new DesignListComponent(type); return new DesignListComponent(type);
} else if (type.equals(ComponentEnum.DYNAMIC_TABLE.getValue())) { } else if (type.equals(ComponentEnum.DYNAMIC_TABLE.getValue())) {
return new DesignDynamicTableComponent(type); return new DesignDynamicTableComponent(type);
} else if (type.equals(ComponentEnum.CASCADE.getValue())) {
return new DesignCascadeComponent(type);
} }
// else if (type.equals(ComponentEnum.AREA.getValue())) { // else if (type.equals(ComponentEnum.AREA.getValue())) {
// return new AreaComponent(type); // return new AreaComponent(type);
......
...@@ -232,7 +232,7 @@ public class ListItem{ ...@@ -232,7 +232,7 @@ public class ListItem{
private String placeholder; private String placeholder;
@JSONField(name="china-area-data") @JSONField(name="china-area-data")
private Boolean chinaAreaData; private String chinaAreaData;
@JSONField(name="color-format") @JSONField(name="color-format")
private String colorFormat; private String colorFormat;
......
package com.mortals.xhx.common.formdesign.component;
import com.mortals.xhx.common.code.ComponentEnum;
import com.mortals.xhx.common.formdesign.*;
import com.mortals.xhx.common.pdu.gen.component.ComponentCons;
import java.util.ArrayList;
import java.util.List;
/**
* 级联选择组件
*
* @author: zxfei
* @date: 2024/11/22 9:24
*/
public class DesignCascadeComponent extends DesignComponent {
public DesignCascadeComponent(String type) {
super(type);
}
@Override
public ListItem buildDefaultComponent(ComponentCons cons) {
ListItem columnsItem = new ListItem();
columnsItem.setId(cons.getVal());
columnsItem.set_id(cons.getVal());
columnsItem.setCompType("cascader");
columnsItem.setEle("el-cascader");
columnsItem.setCompName("级联选择");
columnsItem.setCompIcon("cascader");
columnsItem.setViewType("component");
columnsItem.setType("textarea");
columnsItem.setConfig(true);
columnsItem.setShowLabel(true);
columnsItem.setLabel(cons.getLabel());
columnsItem.setLabelWidth(120);
columnsItem.setPlaceholder("请选择" + cons.getLabel());
columnsItem.setRequired(false);
columnsItem.setGutter(15);
columnsItem.setSpan(24);
columnsItem.setSize("medium");
columnsItem.setDisabled(false);
columnsItem.setDataType("static");
columnsItem.setChinaAreaData("");
//Props 设置
Props props = new Props();
props.setClearable(false);
props.setSeparator("/");
props.setShowAllLevels(false);
props.setFilterable(false);
Props propsChild = new Props();
propsChild.setExpandTrigger("click");
propsChild.setMultiple(false);
propsChild.setCheckStrictly(false);
propsChild.setLabel("lable");
propsChild.setValue("value");
propsChild.setChildren("children");
props.setProps(props);
columnsItem.setProps(props);
//设置options
List<OptionsItem> options = new ArrayList<>();
OptionsItem optionsItem = new OptionsItem();
optionsItem.setValue("zhinan");
optionsItem.setLabel("指南");
List<ChildrenItem> children = new ArrayList<>();
ChildrenItem child = new ChildrenItem();
child.setValue("shejiyuanze");
child.setLabel("设计原则");
children.add(child);
optionsItem.setChildren(children);
List<ChildrenItem> children1 = new ArrayList<>();
ChildrenItem child1 = new ChildrenItem();
child1.setValue("yizhi");
child1.setLabel("一致");
children1.add(child1);
child.setChildren(children1);
columnsItem.setOptions(options);
//设置默认值
columnsItem.setLayout("colItem");
columnsItem.setValue(new ArrayList<>());
return columnsItem;
}
@Override
public String getType() {
return ComponentEnum.TEXTAREA.getValue();
}
}
...@@ -10,7 +10,7 @@ import lombok.Data; ...@@ -10,7 +10,7 @@ import lombok.Data;
* @date: 2021/10/15 10:26 * @date: 2021/10/15 10:26
*/ */
@Data @Data
public class ChildrenItem{ public class ChildrenItem {
@JSONField(name="id") @JSONField(name="id")
private Integer id; private Integer id;
......
package com.mortals.xhx.common.pdu.gen;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
/**
* 配置
*
* @author: zxfei
* @date: 2021/10/15 10:27
*/
@Data
public class Props{
@JSONField(name="props")
private Props props;
@JSONField(name="children")
private String children;
@JSONField(name="multiple")
private Boolean multiple;
@JSONField(name="label")
private String label;
@JSONField(name="value")
private String value;
}
\ No newline at end of file
...@@ -48,6 +48,7 @@ import com.mortals.xhx.module.matter.service.MatterService; ...@@ -48,6 +48,7 @@ import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.pubdatum.model.PubdatumEntity; import com.mortals.xhx.module.pubdatum.model.PubdatumEntity;
import com.mortals.xhx.module.pubdatum.model.PubdatumQuery; import com.mortals.xhx.module.pubdatum.model.PubdatumQuery;
import com.mortals.xhx.module.pubdatum.service.PubdatumService; import com.mortals.xhx.module.pubdatum.service.PubdatumService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
...@@ -77,6 +78,7 @@ import java.util.stream.Collectors; ...@@ -77,6 +78,7 @@ import java.util.stream.Collectors;
* @date 2022-09-27 * @date 2022-09-27
*/ */
@Service("matterDatumService") @Service("matterDatumService")
@Slf4j
public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumDao, MatterDatumEntity, Long> implements MatterDatumService { public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumDao, MatterDatumEntity, Long> implements MatterDatumService {
@Value("${upload.path}") @Value("${upload.path}")
...@@ -371,7 +373,7 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD ...@@ -371,7 +373,7 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
} }
} }
//构建填充复选框值 //构建填充复选框值
if (entry.getKey().indexOf("ck_") != -1 && entry.getKey().indexOf("<") != -1) { if (entry.getKey().indexOf(ComponentEnum.CHECKBOX.getValue()) != -1 && entry.getKey().indexOf("<") != -1) {
//获取复选框选项,并渲染值 //获取复选框选项,并渲染值
String ckStr = StringUtils.substringBetween(entry.getKey(), "<", ">"); String ckStr = StringUtils.substringBetween(entry.getKey(), "<", ">");
//获取所有选项 //获取所有选项
...@@ -396,17 +398,28 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD ...@@ -396,17 +398,28 @@ public class MatterDatumServiceImpl extends AbstractCRUDServiceImpl<MatterDatumD
} }
//TODO 单选 //TODO 单选
//绑定动态表单 //绑定动态表单
if (entry.getKey().indexOf("dt_") != -1) { if (entry.getKey().indexOf(ComponentEnum.DYNAMIC_TABLE.getValue()) != -1) {
builder.bind(entry.getKey(), new MultipleRowTableRenderPolicy()); builder.bind(entry.getKey(), new MultipleRowTableRenderPolicy());
} }
//绑定转换list list_1_身份证 //绑定转换list list_1_身份证
if (entry.getKey().indexOf("list_") != -1) { if (entry.getKey().indexOf(ComponentEnum.LIST.getValue()) != -1) {
String value = entry.getValue().toString(); String value = entry.getValue().toString();
SplitIter splitIter = new SplitIter(value, new LengthFinder(1), -1, false); SplitIter splitIter = new SplitIter(value, new LengthFinder(1), -1, false);
List<String> valueList = splitIter.toList(true); List<String> valueList = splitIter.toList(true);
builder.bind(entry.getKey(), new LoopSingleRowTableRenderPolicy()); builder.bind(entry.getKey(), new LoopSingleRowTableRenderPolicy());
data.put(entry.getKey(), valueList); data.put(entry.getKey(), valueList);
} }
//TODO cascade 级联
if (entry.getKey().indexOf(ComponentEnum.CASCADE.getValue()) != -1) {
List<String> value = (ArrayList) entry.getValue();
log.info("级联数据:{}", JSON.toJSONString(value));
entry.setValue(value.stream().collect(Collectors.joining("")));
}
}); });
if (addMap.size() > 0) { if (addMap.size() > 0) {
data.putAll(addMap); data.putAll(addMap);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment