Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
前端-黄佳鑫
jinfa-platform
Commits
7d1553b7
Commit
7d1553b7
authored
Jul 31, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拆分formily逻辑
parent
fd970a17
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
0 deletions
+50
-0
index.ts
src/formSchema/const/index.ts
+2
-0
index.ts
src/formSchema/effects/index.ts
+0
-0
useFilterSearch.ts
src/formSchema/effects/useFilterSearch.ts
+15
-0
usePublicSelect.ts
src/formSchema/effects/usePublicSelect.ts
+15
-0
formEffectUtils.ts
src/utils/formEffectUtils.ts
+18
-0
No files found.
src/formSchema/const/index.ts
0 → 100644
View file @
7d1553b7
export
const
FORM_FILTER_PATH
=
'FORM_FILTER_PATH'
\ No newline at end of file
src/formSchema/effects/index.ts
0 → 100644
View file @
7d1553b7
src/formSchema/effects/useFilterSearch.ts
0 → 100644
View file @
7d1553b7
import
{
useValueLinkageEffect
,
ISchemaFormActions
,
ISchemaFormAsyncActions
}
from
"@formily/antd"
/**
* @param origin 触发联动的字段路径
* @param target 关联的字段路径
*/
export
const
useStateFilterSearchLinkageEffect
=
(
context
,
actions
:
ISchemaFormActions
|
ISchemaFormAsyncActions
,
origin
:
string
,
target
:
string
)
=>
{
const
{
setFieldState
,
reset
}
=
actions
context
(
'onFieldChange'
,
origin
).
subscribe
(
state
=>
{
setFieldState
(
target
,
fieldState
=>
{
fieldState
.
visible
=
state
.
filterSearch
})
})
}
\ No newline at end of file
src/formSchema/effects/usePublicSelect.ts
0 → 100644
View file @
7d1553b7
import
{
createFormActions
,
FormEffectHooks
}
from
'@formily/antd'
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
/**
* 定义表单副作用的集合
*/
const
{
onFieldValueChange$
}
=
FormEffectHooks
export
const
usePublicSelectEffects
=
context
=>
{
const
linkage
=
useLinkageUtils
()
onFieldValueChange$
(
'select'
).
subscribe
(({
value
})
=>
{
linkage
.
visible
(
value
)
})
}
\ No newline at end of file
src/utils/formEffectUtils.ts
0 → 100644
View file @
7d1553b7
import
{
createFormActions
,
FormPath
}
from
'@formily/antd'
export
const
useLinkageUtils
=
()
=>
{
const
{
setFieldState
}
=
createFormActions
()
const
linkage
=
(
key
,
defaultValue
?)
=>
(
path
,
value
?)
=>
setFieldState
(
path
,
state
=>
{
FormPath
.
setIn
(
state
,
key
,
value
!==
undefined
?
value
:
defaultValue
)
})
return
{
hide
:
linkage
(
'visible'
,
false
),
show
:
linkage
(
'visible'
,
true
),
visible
:
linkage
(
'visible'
),
enum
:
linkage
(
'props.enum'
,
[]),
loading
:
linkage
(
'loading'
,
true
),
loaded
:
linkage
(
'loading'
,
false
),
value
:
linkage
(
'value'
)
}
}
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