Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
xiaojuan huang
Ccms
Commits
9094696b
Commit
9094696b
authored
3 years ago
by
wangailin
Browse files
Options
Download
Plain Diff
Merge branch 'dev-treeselect' of
https://gitee.com/jd-platform-opensource/ccms
into v1.2.4
parents
34873287
f597cd1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/formFields/select/common.tsx
+6
-6
src/components/formFields/select/common.tsx
src/components/formFields/treeSelect/index.tsx
+31
-11
src/components/formFields/treeSelect/index.tsx
with
37 additions
and
17 deletions
+37
-17
src/components/formFields/select/common.tsx
+
6
-
6
View file @
9094696b
...
...
@@ -19,7 +19,7 @@ type OptionsConfigDefaultValue =
interface
AutomaticEnumerationOptionsConfig
{
from
:
'
automatic
'
;
defaultValue
?:
OptionsConfigDefaultValue
;
sourceConfig
?:
OptionsConfigDefaultValue
;
format
?:
|
InterfaceEnumerationOptionsKVConfig
|
InterfaceEnumerationOptionsListConfig
;
...
...
@@ -55,9 +55,9 @@ export default class SelectField<C extends SelectFieldConfig, E, T> extends Fiel
}
}
optionsAutomaticValue
=
(
defaultValue
:
OptionsConfigDefaultValue
)
=>
{
if
(
defaultValue
!==
undefined
)
{
return
ParamHelper
(
defaultValue
,
{
record
:
this
.
props
.
record
,
data
:
this
.
props
.
data
,
step
:
this
.
props
.
step
})
optionsAutomaticValue
=
(
sourceConfig
:
OptionsConfigDefaultValue
)
=>
{
if
(
sourceConfig
!==
undefined
)
{
return
ParamHelper
(
sourceConfig
,
{
record
:
this
.
props
.
record
,
data
:
this
.
props
.
data
,
step
:
this
.
props
.
step
})
}
return
undefined
}
...
...
@@ -67,8 +67,8 @@ export default class SelectField<C extends SelectFieldConfig, E, T> extends Fiel
)
=>
{
if
(
config
)
{
if
(
config
.
from
===
'
automatic
'
)
{
if
(
config
.
defaultValue
&&
config
.
defaultValue
.
source
&&
config
.
defaultValue
.
field
)
{
const
data
=
this
.
optionsAutomaticValue
(
config
.
defaultValue
)
if
(
config
.
sourceConfig
&&
config
.
sourceConfig
.
source
&&
config
.
sourceConfig
.
field
)
{
const
data
=
this
.
optionsAutomaticValue
(
config
.
sourceConfig
)
if
(
config
.
format
)
{
if
(
config
.
format
.
type
===
'
kv
'
)
{
return
Object
.
keys
(
data
).
map
((
key
)
=>
({
...
...
This diff is collapsed.
Click to expand it.
src/components/formFields/treeSelect/index.tsx
+
31
-
11
View file @
9094696b
...
...
@@ -10,8 +10,8 @@ export interface TreeSelectFieldConfig extends FieldConfig {
type
:
'
tree_select
'
mode
?:
'
tree
'
|
'
table
'
multiple
?:
true
|
TreeSelectMultipleArrayConfig
|
TreeSelectMultipleSplitConfig
,
titleColumn
:
string
,
treeData
?:
ManualOptionsConfig
|
InterfaceOptionsConfig
|
Default
OptionsConfig
titleColumn
?
:
string
,
treeData
?:
ManualOptionsConfig
|
InterfaceOptionsConfig
|
Automatic
OptionsConfig
}
interface
TreeSelectMultipleArrayConfig
{
...
...
@@ -22,9 +22,9 @@ interface TreeSelectMultipleSplitConfig {
type
:
'
split
'
,
split
?:
string
}
export
interface
Default
OptionsConfig
{
export
interface
Automatic
OptionsConfig
{
from
:
'
automatic
'
defaultValue
?:
OptionsConfigDefaultValue
,
sourceConfig
?:
OptionsConfigDefaultValue
,
format
?:
InterfaceOptionsListConfig
}
...
...
@@ -91,9 +91,9 @@ export default class TreeSelectField extends Field<TreeSelectFieldConfig, ITreeS
}
}
optionsAutomatic
Value
=
(
defaultValue
:
OptionsConfigDefaultValue
)
=>
{
if
(
defaultValue
!==
undefined
)
{
return
ParamHelper
(
defaultValue
,
{
record
:
this
.
props
.
record
,
data
:
this
.
props
.
data
,
step
:
this
.
props
.
step
})
optionsAutomatic
=
(
sourceConfig
:
OptionsConfigDefaultValue
)
=>
{
if
(
sourceConfig
!==
undefined
)
{
return
ParamHelper
(
sourceConfig
,
{
record
:
this
.
props
.
record
,
data
:
this
.
props
.
data
,
step
:
this
.
props
.
step
})
}
return
undefined
}
...
...
@@ -122,7 +122,7 @@ export default class TreeSelectField extends Field<TreeSelectFieldConfig, ITreeS
}
options
=
(
config
:
ManualOptionsConfig
|
InterfaceOptionsConfig
|
Default
OptionsConfig
|
undefined
,
config
:
ManualOptionsConfig
|
InterfaceOptionsConfig
|
Automatic
OptionsConfig
|
undefined
,
datas
:
{
record
?:
object
data
:
object
[]
...
...
@@ -131,8 +131,8 @@ export default class TreeSelectField extends Field<TreeSelectFieldConfig, ITreeS
)
=>
{
if
(
config
)
{
if
(
config
.
from
===
'
automatic
'
)
{
if
(
config
.
defaultValue
&&
config
.
defaultValue
.
source
&&
config
.
defaultValue
.
field
)
{
const
data
=
this
.
optionsAutomatic
Value
(
config
.
defaultValue
)
if
(
config
.
sourceConfig
&&
config
.
sourceConfig
.
source
&&
config
.
sourceConfig
.
field
)
{
const
data
=
this
.
optionsAutomatic
(
config
.
sourceConfig
)
if
(
Array
.
isArray
(
data
))
{
return
this
.
formatTree
(
data
,
...
...
@@ -208,6 +208,15 @@ export default class TreeSelectField extends Field<TreeSelectFieldConfig, ITreeS
return
errors
.
length
?
errors
:
true
}
renderComponent
=
(
props
:
ITreeSelectField
)
=>
{
return
<
React
.
Fragment
>
您当前使用的UI版本没有实现TreeSelectSingleField组件的SelectSingle模式。
<
div
style
=
{
{
display
:
'
none
'
}
}
>
<
button
onClick
=
{
()
=>
props
.
onChange
(
''
)
}
>
onChange
</
button
>
</
div
>
</
React
.
Fragment
>
}
renderTreeComponent
=
(
props
:
ITreeSelectField
)
=>
{
return
<
React
.
Fragment
>
您当前使用的UI版本没有实现TreeSelectField组件的tree模式。
...
...
@@ -255,6 +264,7 @@ export default class TreeSelectField extends Field<TreeSelectFieldConfig, ITreeS
if
(
optionsConfig
&&
(
optionsConfig
.
from
===
'
manual
'
||
optionsConfig
.
from
===
'
automatic
'
))
{
props
.
treeData
=
temp
}
debugger
if
(
multiple
===
true
||
multiple
?.
type
===
'
array
'
)
{
if
(
Array
.
isArray
(
value
))
{
props
.
value
=
(
value
as
Array
<
string
|
number
>
)
...
...
@@ -276,8 +286,18 @@ export default class TreeSelectField extends Field<TreeSelectFieldConfig, ITreeS
if
(
mode
===
'
table
'
)
{
props
.
titleColumn
=
titleColumn
return
this
.
renderTableComponent
(
props
)
}
else
{
}
else
if
(
mode
===
'
tree
'
)
{
return
this
.
renderTreeComponent
(
props
)
}
else
{
return
(
<
React
.
Fragment
>
{
this
.
renderComponent
({
value
,
treeData
:
this
.
state
.
interfaceOptionsData
,
onChange
:
async
(
value
:
string
)
=>
await
this
.
props
.
onValueSet
(
''
,
value
,
await
this
.
validate
(
value
))
})
}
</
React
.
Fragment
>
)
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help