Commit 2c3e0ebd authored by 前端-许佳敏's avatar 前端-许佳敏

fix:useAsyncSelect

parent c6a733f8
...@@ -17,9 +17,10 @@ export const useAsyncSelect = async (name, service: () => Promise<any[]>, format ...@@ -17,9 +17,10 @@ export const useAsyncSelect = async (name, service: () => Promise<any[]>, format
}) })
linkage.loading(name) linkage.loading(name)
service().then(res => { service().then(res => {
let enums = []
if (format) { if (format) {
const [labelString, valueString] = format const [labelString, valueString] = format
res = res.map(v => ({ enums = res.map(v => ({
label: v[labelString], label: v[labelString],
value: v[valueString] value: v[valueString]
})) }))
...@@ -29,7 +30,7 @@ export const useAsyncSelect = async (name, service: () => Promise<any[]>, format ...@@ -29,7 +30,7 @@ export const useAsyncSelect = async (name, service: () => Promise<any[]>, format
}) })
linkage.loaded(name) linkage.loaded(name)
linkage.enum(name, res) linkage.enum(name, enums)
//请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动 //请求结束可以dispatch一个自定义事件收尾,方便后续针对该事件做联动
dispatch('requestAsyncSelect', { dispatch('requestAsyncSelect', {
name, name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment