From d669d0ab505b32234e4eed49e6e2f2f143e52ccd Mon Sep 17 00:00:00 2001 From: konbai <1527468660@qq.com> Date: Thu, 1 Sep 2022 00:19:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=81=E7=A8=8B=E8=A1=A8=E5=8D=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=A1=AB=E5=85=85=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E9=A1=B9=E5=86=85=E5=AE=B9=E6=96=B9=E6=B3=95=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=A1=AB=E5=85=85=E5=AD=90=E8=A1=A8=E5=8D=95=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flowable/utils/ProcessFormUtils.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ProcessFormUtils.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ProcessFormUtils.java index 95f46dac..bd7847d0 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ProcessFormUtils.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/utils/ProcessFormUtils.java @@ -3,6 +3,7 @@ package com.ruoyi.flowable.utils; import cn.hutool.core.convert.Convert; import com.ruoyi.flowable.core.FormConf; +import java.util.List; import java.util.Map; /** @@ -13,6 +14,9 @@ import java.util.Map; */ public class ProcessFormUtils { + private static final String CONFIG = "__config__"; + private static final String MODEL = "__vModel__"; + /** * 填充表单项内容 * @@ -21,13 +25,26 @@ public class ProcessFormUtils { */ public static void fillFormData(FormConf formConf, Map data) { for (Map field : formConf.getFields()) { - String modelKey = Convert.toStr(field.get("__vModel__")); - Object value = data.get(modelKey); - if (value != null) { - @SuppressWarnings("unchecked") - Map configMap = (Map) field.get("__config__"); - configMap.put("defaultValue", value); + recursiveFillField(field, data); + } + } + + @SuppressWarnings("unchecked") + private static void recursiveFillField(final Map field, final Map data) { + if (!field.containsKey(CONFIG)) { + return; + } + Map configMap = (Map) field.get(CONFIG); + if (configMap.containsKey("children")) { + List> childrens = (List>) configMap.get("children"); + for (Map children : childrens) { + recursiveFillField(children, data); } } + String modelKey = Convert.toStr(field.get(MODEL)); + Object value = data.get(modelKey); + if (value != null) { + configMap.put("defaultValue", value); + } } }