EditOptions.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package com.kingdee.eas.custom.projectbonus.web.vo;
  2. import com.kingdee.bos.BOSException;
  3. import com.kingdee.bos.Context;
  4. import com.kingdee.shr.base.syssetting.context.SHRContext;
  5. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  6. import com.kingdee.shr.base.syssetting.util.SHRBasicItemUtil;
  7. import com.kingdee.shr.base.syssetting.util.SHREnumUtils;
  8. import com.kingdee.shr.base.syssetting.util.SelectItem;
  9. import com.kingdee.util.StringUtils;
  10. import com.kingdee.util.enums.*;
  11. import com.kingdee.util.enums.Enum;
  12. import java.util.ArrayList;
  13. import java.util.HashMap;
  14. import java.util.List;
  15. import java.util.Map;
  16. /**
  17. * @Description TODO
  18. * @Date 2024/4/28 10:38
  19. * @Created by Heyuan
  20. */
  21. public class EditOptions {
  22. // F7Json对象
  23. private F7Json f7Json;
  24. //枚举对象
  25. private SelectJson selectJson;
  26. //日期
  27. private DatepickerJson datepickerjson;
  28. private Map<String, Object> enumSource;
  29. private String urlSource;
  30. // ValidateJson对象
  31. private ValidateJson validateJson;
  32. public SelectJson getSelectJson() {
  33. if (selectJson == null) {
  34. this.selectJson = new SelectJson();
  35. }
  36. return selectJson;
  37. }
  38. public void setSelectJson(SelectJson selectJson) {
  39. this.selectJson = selectJson;
  40. }
  41. public String getUrlSource() {
  42. return urlSource;
  43. }
  44. public void setUrlSource(String urlSource) throws BOSException, SHRWebException {
  45. this.urlSource = "/shr/selectEnum.do?method=getSelectEnumData&enumSource=" + urlSource;
  46. setEnumSource(urlSource);
  47. }
  48. public F7Json getF7Json() {
  49. if (f7Json == null) {
  50. this.f7Json = new F7Json();
  51. }
  52. return f7Json;
  53. }
  54. public void setF7Json(F7Json f7Json) {
  55. this.f7Json = f7Json;
  56. }
  57. public ValidateJson getValidateJson() {
  58. if (validateJson == null) {
  59. this.validateJson = new ValidateJson();
  60. }
  61. return validateJson;
  62. }
  63. public void setValidateJson(ValidateJson validateJson) {
  64. this.validateJson = validateJson;
  65. }
  66. public DatepickerJson getDatepickerjson() {
  67. if (datepickerjson == null) {
  68. this.datepickerjson = new DatepickerJson();
  69. }
  70. return datepickerjson;
  71. }
  72. public void setDatepickerjson(DatepickerJson datepickerjson) {
  73. this.datepickerjson = datepickerjson;
  74. }
  75. public void setEnumSource(String entityName) throws SHRWebException, BOSException {
  76. if (enumSource == null) {
  77. enumSource = new HashMap<String, Object>();
  78. }
  79. enumSource.put("result", "success");
  80. if (StringUtils.isEmpty(entityName)) {
  81. throw new BOSException("entityName为空!");
  82. }
  83. List<SelectItem> list = new ArrayList();
  84. Context ctx = SHRContext.getInstance().getContext();
  85. SHRBasicItemUtil.getUsePolicySelectItem(entityName, list);
  86. if (null == list || list.size() <= 0) {
  87. if (!StringUtils.isEmpty(entityName)) {
  88. List enumList2 = EnumUtils.getEnumList(entityName);
  89. for (int i = 0; i < enumList2.size(); ++i) {
  90. Enum objEnum = (Enum) enumList2.get(i);
  91. Object value = null;
  92. if (objEnum instanceof StringEnum) {
  93. value = ((StringEnum) objEnum).getValue();
  94. } else if (objEnum instanceof DynamicEnum) {
  95. value = ((DynamicEnum) objEnum).getValue();
  96. } else if (objEnum instanceof LongEnum) {
  97. value = ((LongEnum) objEnum).getValue();
  98. } else if (objEnum instanceof IntEnum) {
  99. value = ((IntEnum) objEnum).getValue();
  100. } else if (objEnum instanceof FloatEnum) {
  101. value = ((FloatEnum) objEnum).getValue();
  102. } else if (objEnum instanceof DoubleEnum) {
  103. value = ((DoubleEnum) objEnum).getValue();
  104. } else {
  105. value = objEnum.getName();
  106. }
  107. String alias = objEnum.getAlias(ctx.getLocale());
  108. if (StringUtils.isEmpty(alias)) {
  109. alias = objEnum.getAlias();
  110. }
  111. SelectItem item = new SelectItem();
  112. item.setValue(value);
  113. item.setAlias(alias);
  114. item.setMultiAlias(SHREnumUtils.getMultiAlias(objEnum));
  115. list.add(item);
  116. }
  117. }
  118. }
  119. enumSource.put("data", list);
  120. }
  121. }