兼容多选枚举
This commit is contained in:
@@ -249,12 +249,33 @@ public class EnumMapUtils {
|
||||
if(enumItemId == null) {
|
||||
return null;
|
||||
}
|
||||
Long temp = enumItemId instanceof Long ? (Long)enumItemId : (enumItemId instanceof String ? Long.parseLong((String)enumItemId) : null);
|
||||
if(temp == null) {
|
||||
String str = enumItemId instanceof Long ? String.valueOf(enumItemId) : (enumItemId instanceof String ? (String)enumItemId : null);
|
||||
if(str == null) {
|
||||
return null;
|
||||
}
|
||||
EnumManager enumManagerNew = getEnumManager();
|
||||
CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(temp);
|
||||
// 多选枚举 逗号分隔
|
||||
if(str.contains(",")) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(String id : str.split(",")) {
|
||||
String showValue = getSingleEnumShowValue(id.trim());
|
||||
if(showValue != null) {
|
||||
if(sb.length() > 0) sb.append(",");
|
||||
sb.append(showValue);
|
||||
}
|
||||
}
|
||||
return sb.length() > 0 ? sb.toString() : null;
|
||||
}
|
||||
return getSingleEnumShowValue(str);
|
||||
}
|
||||
|
||||
private static String getSingleEnumShowValue(String enumItemId) throws BusinessException {
|
||||
Long temp;
|
||||
try {
|
||||
temp = Long.parseLong(enumItemId);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
CtpEnumItem ctpEnumItem = getEnumManager().getCtpEnumItem(temp);
|
||||
if(ctpEnumItem == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -339,8 +339,23 @@ public class FormTableExecutor {
|
||||
if (field == null) continue;
|
||||
|
||||
Object value = e.getValue();
|
||||
if (changeEnum && field.isEnumField()) {
|
||||
value = EnumMapUtils.getEnumShowValue(value);
|
||||
if (changeEnum && field.isEnumField() && value != null) {
|
||||
try {
|
||||
if ("multiselect".equals(field.getInputType())) {
|
||||
String str = String.valueOf(value);
|
||||
String[] split = str.split(",");
|
||||
List<String> showValueList = new ArrayList<>();
|
||||
for (String enumId : split) {
|
||||
String sv = EnumMapUtils.getEnumShowValue(enumId.trim());
|
||||
showValueList.add(sv != null ? sv : enumId.trim());
|
||||
}
|
||||
value = showValueList;
|
||||
} else {
|
||||
value = EnumMapUtils.getEnumShowValue(value);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// 多选枚举等无法解析时保留原值
|
||||
}
|
||||
}
|
||||
// 枚举、部门、成员等特殊字段处理
|
||||
// value = handleFieldSpecialType(field, value);
|
||||
|
||||
Reference in New Issue
Block a user