Browse Source

枚举下拉框

(cherry picked from commit c72e6198db)
4.0
lip 2 years ago
parent
commit
03e4ef16b3
1 changed files with 27 additions and 3 deletions
  1. +27
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/dev/EnumComboService.java

+ 27
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/dev/EnumComboService.java View File

@@ -11,6 +11,7 @@ import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.List;
@@ -39,11 +40,34 @@ public class EnumComboService extends DynPageService {
if (PubUtil.isEmpty(cls)) return SwListData.create(new ArrayList(), 0);
List<SwMap> list = new ArrayList<>();
try {
AbstractEnum e;
Class tempClass ;
Class wantClass = null;
try {
e = (AbstractEnum) Class.forName(cls).getDeclaredField("inst").get(null);
tempClass = Class.forName(cls);
wantClass = tempClass;
}catch (Exception e){
e.printStackTrace();
//
int lIndex = cls.lastIndexOf(".");
if (lIndex > 0) {
String outClass = cls.substring(0, lIndex);
String innerClass = outClass + "$" + cls.substring(lIndex+1);
tempClass = Class.forName(outClass);
Class[] declaredClasses = tempClass.getDeclaredClasses();
for (Class declaredClass : declaredClasses) {
if (declaredClass.getName().equals(innerClass)) {
wantClass = declaredClass;
break;
}
}
}
}
Assert.notNull(wantClass,"classNotFound");
AbstractEnum e ;
try {
e = (AbstractEnum) wantClass.getDeclaredField("inst").get(null);
} catch (Exception e1) {
e = (AbstractEnum) Class.forName(cls).getDeclaredField("instance").get(null);
e = (AbstractEnum) wantClass.getDeclaredField("instance").get(null);
}
for (Object v : e.mapAll.values()) {
AbstractEnum.EnumBean bean = (AbstractEnum.EnumBean) v;


Loading…
Cancel
Save