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
shenshaokai
jinfa-platform
Commits
22afb944
Commit
22afb944
authored
Aug 05, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增详情页时需初始化表单数据,修复异步下拉框在异常时的loading状态
parent
14174428
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
useAsyncSelect.ts
src/formSchema/effects/useAsyncSelect.ts
+4
-0
useInitValue.ts
src/formSchema/effects/useInitValue.ts
+21
-0
No files found.
src/formSchema/effects/useAsyncSelect.ts
View file @
22afb944
...
...
@@ -23,6 +23,9 @@ export const useAsyncSelect = (name, service: () => Promise<any[]>) => {
name
,
payload
:
res
})
}).
catch
(
err
=>
{
linkage
.
loaded
(
name
)
linkage
.
enum
(
name
,
[])
})
})
}
\ No newline at end of file
src/formSchema/effects/useInitValue.ts
0 → 100644
View file @
22afb944
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
import
{
useEffect
,
useState
}
from
'react'
/**
* 初始化表单数据, 可传入给NiceForm的initialValues
* @param service 必须保证返回数据中有data属性 并且匹配NiceForm
*/
export
const
useInitValue
=
(
service
)
=>
{
const
{
id
}
=
usePageStatus
()
const
[
state
,
setState
]
=
useState
<
any
>
(
null
)
useEffect
(()
=>
{
if
(
id
)
{
service
({
id
}).
then
(({
data
})
=>
{
setState
(
data
)
})
}
},
[])
return
state
}
\ No newline at end of file
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