优化下拉列表组件,修复若干BUG
This commit is contained in:
@@ -232,14 +232,16 @@ const getData = debounce((initValue: valueTypes = '') => {
|
||||
state.params.initValue = initValue
|
||||
getSelectData(props.remoteUrl, state.keyword, state.params)
|
||||
.then((res) => {
|
||||
let opts = res.data.options ? res.data.options : res.data.list
|
||||
const data = res?.data ?? {}
|
||||
let opts = data.options ?? data.list ?? []
|
||||
opts = Array.isArray(opts) ? opts : []
|
||||
if (typeof props.labelFormatter === 'function') {
|
||||
for (const key in opts) {
|
||||
opts[key][props.field] = props.labelFormatter(opts[key], key)
|
||||
}
|
||||
}
|
||||
state.options = opts
|
||||
state.total = res.data.total ?? 0
|
||||
state.total = data.total ?? 0
|
||||
state.optionValidityFlag = state.keyword || (typeof initValue === 'object' ? !isEmpty(initValue) : initValue) ? false : true
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
Reference in New Issue
Block a user