Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fill-system
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
fill-system
Commits
8f96813e
Commit
8f96813e
authored
Feb 10, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态表单添加组件
parent
af54ee65
Pipeline
#2882
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
0 deletions
+102
-0
fill-manager/src/main/java/com/mortals/xhx/common/formdesign/component/DesignDynamicTableComponent.java
...mon/formdesign/component/DesignDynamicTableComponent.java
+102
-0
No files found.
fill-manager/src/main/java/com/mortals/xhx/common/formdesign/component/DesignDynamicTableComponent.java
View file @
8f96813e
package
com.mortals.xhx.common.formdesign.component
;
package
com.mortals.xhx.common.formdesign.component
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.mortals.xhx.common.code.ComponentEnum
;
import
com.mortals.xhx.common.code.ComponentEnum
;
import
com.mortals.xhx.common.formdesign.*
;
import
com.mortals.xhx.common.formdesign.*
;
import
com.mortals.xhx.common.pdu.gen.component.ComponentCons
;
import
com.mortals.xhx.common.pdu.gen.component.ComponentCons
;
import
com.mortals.xhx.common.utils.StringUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -131,6 +133,8 @@ public class DesignDynamicTableComponent extends DesignComponent {
...
@@ -131,6 +133,8 @@ public class DesignDynamicTableComponent extends DesignComponent {
columnsItem
.
setLayout
(
"colItem"
);
columnsItem
.
setLayout
(
"colItem"
);
columnsItem
.
setRuleError
(
"该字段不能为空"
);
columnsItem
.
setRuleError
(
"该字段不能为空"
);
columnsItem
.
setRulesType
(
"default"
);
columnsItem
.
setRulesType
(
"default"
);
initDefaultSelectValue
(
item
,
columnsItem
);
}
else
if
(
item
.
getColType
().
equals
(
ComponentEnum
.
RADIO
.
getValue
())){
}
else
if
(
item
.
getColType
().
equals
(
ComponentEnum
.
RADIO
.
getValue
())){
columnsItem
.
setCompType
(
"radio"
);
columnsItem
.
setCompType
(
"radio"
);
columnsItem
.
setCompName
(
item
.
getLabel
());
columnsItem
.
setCompName
(
item
.
getLabel
());
...
@@ -155,6 +159,7 @@ public class DesignDynamicTableComponent extends DesignComponent {
...
@@ -155,6 +159,7 @@ public class DesignDynamicTableComponent extends DesignComponent {
columnsItem
.
setRules
(
Lists
.
newArrayList
());
columnsItem
.
setRules
(
Lists
.
newArrayList
());
columnsItem
.
setLayout
(
"colItem"
);
columnsItem
.
setLayout
(
"colItem"
);
columnsItem
.
setRuleError
(
"该字段不能为空"
);
columnsItem
.
setRuleError
(
"该字段不能为空"
);
initDefaultRadioValue
(
item
,
columnsItem
);
}
else
if
(
item
.
getColType
().
equals
(
ComponentEnum
.
CHECKBOX
.
getValue
())){
}
else
if
(
item
.
getColType
().
equals
(
ComponentEnum
.
CHECKBOX
.
getValue
())){
columnsItem
.
setCompType
(
"checkbox"
);
columnsItem
.
setCompType
(
"checkbox"
);
columnsItem
.
setCompName
(
item
.
getLabel
());
columnsItem
.
setCompName
(
item
.
getLabel
());
...
@@ -184,6 +189,9 @@ public class DesignDynamicTableComponent extends DesignComponent {
...
@@ -184,6 +189,9 @@ public class DesignDynamicTableComponent extends DesignComponent {
columnsItem
.
setLayout
(
"colItem"
);
columnsItem
.
setLayout
(
"colItem"
);
columnsItem
.
setRuleError
(
"该字段不能为空"
);
columnsItem
.
setRuleError
(
"该字段不能为空"
);
columnsItem
.
setRulesType
(
"default"
);
columnsItem
.
setRulesType
(
"default"
);
initDefaultCheckBoxValue
(
item
,
columnsItem
);
}
else
if
(
item
.
getColType
().
equals
(
ComponentEnum
.
IMAGE
.
getValue
())){
}
else
if
(
item
.
getColType
().
equals
(
ComponentEnum
.
IMAGE
.
getValue
())){
columnsItem
.
setCompType
(
"upload"
);
columnsItem
.
setCompType
(
"upload"
);
columnsItem
.
setCompName
(
"附件"
);
columnsItem
.
setCompName
(
"附件"
);
...
@@ -317,6 +325,100 @@ public class DesignDynamicTableComponent extends DesignComponent {
...
@@ -317,6 +325,100 @@ public class DesignDynamicTableComponent extends DesignComponent {
}
}
private
void
initDefaultCheckBoxValue
(
TableColItem
cons
,
ColumnsItem
columnsItem
)
{
if
(
cons
.
getVal
().
indexOf
(
"<"
)
!=
-
1
)
{
String
cks
=
StringUtils
.
substringBetween
(
cons
.
getVal
(),
"<"
,
">"
);
if
(
ObjectUtils
.
isEmpty
(
cks
))
return
;
List
<
OptionsItem
>
optionsItemList
=
StrUtil
.
splitTrim
(
cks
,
"-"
,
-
1
).
stream
().
map
(
option
->
{
OptionsItem
options
=
new
OptionsItem
();
options
.
setLabel
(
option
);
options
.
setValue
(
option
);
return
options
;
}).
collect
(
Collectors
.
toList
());
columnsItem
.
setOptions
(
optionsItemList
);
}
}
private
void
initDefaultRadioValue
(
TableColItem
cons
,
ColumnsItem
columnsItem
)
{
if
(
cons
.
getVal
().
indexOf
(
"<"
)
!=
-
1
)
{
String
cks
=
StringUtils
.
substringBetween
(
cons
.
getVal
(),
"<"
,
">"
);
if
(
ObjectUtils
.
isEmpty
(
cks
))
return
;
List
<
OptionsItem
>
optionsItemList
=
StrUtil
.
splitTrim
(
cks
,
"-"
,
-
1
).
stream
().
map
(
option
->
{
OptionsItem
options
=
new
OptionsItem
();
options
.
setLabel
(
option
);
options
.
setValue
(
option
);
return
options
;
}).
collect
(
Collectors
.
toList
());
columnsItem
.
setOptions
(
optionsItemList
);
}
}
private
void
initDefaultSelectValue
(
TableColItem
cons
,
ColumnsItem
columnsItem
)
{
//判断如果包含年,月,日,选项框 基础化
if
(
cons
.
getVal
().
indexOf
(
"年"
)
!=
-
1
)
{
//初始化10年
List
<
OptionsItem
>
optionsItems
=
initYears
();
columnsItem
.
setOptions
(
optionsItems
);
}
else
if
(
cons
.
getVal
().
indexOf
(
"月"
)
!=
-
1
)
{
List
<
OptionsItem
>
optionsItems
=
initMonths
();
columnsItem
.
setOptions
(
optionsItems
);
}
else
if
(
cons
.
getVal
().
indexOf
(
"日"
)
!=
-
1
)
{
List
<
OptionsItem
>
optionsItems
=
initDays
();
columnsItem
.
setOptions
(
optionsItems
);
}
if
(
cons
.
getVal
().
indexOf
(
"<"
)
!=
-
1
)
{
String
cks
=
StringUtils
.
substringBetween
(
cons
.
getVal
(),
"<"
,
">"
);
if
(
ObjectUtils
.
isEmpty
(
cks
))
return
;
List
<
OptionsItem
>
optionsItemList
=
StrUtil
.
splitTrim
(
cks
,
"-"
,
-
1
).
stream
().
map
(
option
->
{
OptionsItem
options
=
new
OptionsItem
();
options
.
setLabel
(
option
);
options
.
setValue
(
option
);
return
options
;
}).
collect
(
Collectors
.
toList
());
columnsItem
.
setOptions
(
optionsItemList
);
// cons.setVal(cons.getVal().substring(0, cons.getVal().indexOf("[")));
// cons.setLabel(cons.getLabel().substring(0, cons.getLabel().indexOf("[")));
}
}
public
List
<
OptionsItem
>
initYears
()
{
List
<
OptionsItem
>
list
=
new
ArrayList
<>();
for
(
int
i
=
2020
;
i
<
2030
;
i
++)
{
OptionsItem
optionsItem
=
new
OptionsItem
();
optionsItem
.
setLabel
(
i
+
""
);
optionsItem
.
setValue
(
i
+
""
);
list
.
add
(
optionsItem
);
}
return
list
;
}
public
List
<
OptionsItem
>
initMonths
()
{
List
<
OptionsItem
>
list
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<=
12
;
i
++)
{
OptionsItem
optionsItem
=
new
OptionsItem
();
optionsItem
.
setLabel
(
i
+
""
);
optionsItem
.
setValue
(
i
+
""
);
list
.
add
(
optionsItem
);
}
return
list
;
}
public
List
<
OptionsItem
>
initDays
()
{
List
<
OptionsItem
>
list
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<=
31
;
i
++)
{
OptionsItem
optionsItem
=
new
OptionsItem
();
optionsItem
.
setLabel
(
i
+
""
);
optionsItem
.
setValue
(
i
+
""
);
list
.
add
(
optionsItem
);
}
return
list
;
}
@Override
@Override
public
String
getType
()
{
public
String
getType
()
{
return
ComponentEnum
.
DYNAMIC_TABLE
.
getValue
();
return
ComponentEnum
.
DYNAMIC_TABLE
.
getValue
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment