Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
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-admin
Commits
c863023c
Commit
c863023c
authored
Jan 13, 2022
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: 同步能力中心的代码
parent
012d1d52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
useAsyncInitSelect.ts
src/formSchema/effects/useAsyncInitSelect.ts
+22
-17
No files found.
src/formSchema/effects/useAsyncInitSelect.ts
View file @
c863023c
...
...
@@ -8,26 +8,30 @@ const { onFormInit$ } = FormEffectHooks
* @param service 触发的异步函数, 需返回一个{label: any, value: any}形式的数组
*/
export
const
useAsyncInitSelect
=
(
name
:
string
[],
service
:
()
=>
Promise
<
any
>
)
=>
{
const
{
dispatch
,
setFieldState
}
=
createFormActions
()
const
linkage
=
useLinkageUtils
()
const
{
dispatch
,
setFieldState
}
=
createFormActions
();
const
linkage
=
useLinkageUtils
();
onFormInit$
().
subscribe
(()
=>
{
setFieldState
(
name
,
state
=>
{
FormPath
.
setIn
(
state
,
'props.x-props.hasFeedback'
,
true
)
})
name
.
forEach
(
v
=>
linkage
.
loaded
(
v
))
const
nameStr
:
string
=
name
.
toString
();
const
formPath
:
string
=
`*(
${
nameStr
}
)`
;
setFieldState
(
formPath
,
state
=>
{
FormPath
.
setIn
(
state
,
'props.x-props.hasFeedback'
,
true
);
});
linkage
.
loading
(
formPath
);
service
().
then
(
res
=>
{
name
.
forEach
(
v
=>
{
linkage
.
loaded
(
v
)
linkage
.
enum
(
v
,
res
[
v
])
})
//请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动
dispatch
&&
dispatch
(
'requestAsyncSelect'
,
{
linkage
.
enum
(
v
,
res
[
v
]
||
[]);
});
// 请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动
dispatch
?.(
'requestAsyncSelect'
,
{
name
,
payload
:
res
})
}).
catch
(
err
=>
{
// linkage.loaded(name)
// linkage.enum(name, [])
})
payload
:
res
,
});
}).
finally
(()
=>
{
linkage
.
loaded
(
formPath
);
});
})
}
\ 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