Commit 10360e70 authored by 麻笑宇's avatar 麻笑宇

1.大屏业务模块详情提交

parent 9925645c
......@@ -333,15 +333,15 @@ public class DPSubServiceImpl {
private JSONArray processShowHideRules(JSONArray children, Object showHideRules, Object apiResult) {
JSONObject result = JSONObject.parseObject(apiResult.toString());
result.put("formType","detail");
result.put("EQU_CATEGORY_CODE","8100");
Map<String,String> relationMap = new HashMap<>();
relationMap.put("and","&&");
relationMap.put("or","||");
if (!ValidationUtil.isEmpty(showHideRules)) {
((JSONArray) showHideRules).stream().forEach(x -> {
JSONObject xObj = (JSONObject) x;
boolean hide = true;
JSONArray conditions = xObj.getJSONArray("condition");
String relation = null;
boolean lastConditionResult = false;
String relation = "";
for (int i = 0; i < conditions.size(); i++) {
JSONObject conditionObj = conditions.getJSONObject(i);
String value = conditionObj.getString("value");
......@@ -349,32 +349,22 @@ public class DPSubServiceImpl {
JSONObject item = this.findByEid(children, JsonValueUtils.getValueByKey(conditionObj, "name", "name.key").toString());
Object fieldvalue = result.get(JsonValueUtils.getValueByKey(item, "visualParams", "visualParams.fieldKey"));
if (ValidationUtil.isEmpty(relation)) {
if (condition.equals("notUndefined") && !ValidationUtil.isEmpty(fieldvalue)) {
lastConditionResult = !ValidationUtil.isEmpty(fieldvalue);
hide = false;
} else if (condition.equals("unequal") && !ValidationUtil.isEmpty(fieldvalue) && !fieldvalue.equals(value)) {
lastConditionResult = !fieldvalue.equals(value);
hide = false;
} else if (condition.equals("equal") && !ValidationUtil.isEmpty(fieldvalue) && fieldvalue.equals(value)) {
lastConditionResult = fieldvalue.equals(value);
hide = false;
}
} else {
if (lastConditionResult && condition.equals("notUndefined") && !ValidationUtil.isEmpty(fieldvalue)) {
lastConditionResult = !ValidationUtil.isEmpty(fieldvalue);
hide = false;
} else if (lastConditionResult && condition.equals("unequal") && !ValidationUtil.isEmpty(fieldvalue) && !fieldvalue.equals(value)) {
lastConditionResult = !fieldvalue.equals(value);
hide = false;
} else if (lastConditionResult && condition.equals("equal") && !ValidationUtil.isEmpty(fieldvalue) && fieldvalue.equals(value)) {
lastConditionResult = fieldvalue.equals(value);
hide = false;
} else {
hide = true;
}
if (condition.equals("notUndefined")) {
relation += !ValidationUtil.isEmpty(fieldvalue);
} else if (condition.equals("unequal")) {
relation += !value.equals(fieldvalue);
} else if (condition.equals("equal")) {
relation += value.equals(fieldvalue);
}
relation = conditionObj.getString("relation");
relation += relationMap.getOrDefault(conditionObj.getString("relation"),"");
}
// 获取 JavaScript 引擎
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
try {
// 将结果转换为布尔值
hide = !(Boolean) engine.eval(relation);
} catch (Exception e) {
hide = true;
}
if (hide) {
......
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