优化下拉列表组件,修复若干BUG

This commit is contained in:
2026-03-19 09:50:06 +08:00
parent 9b9ff7f13a
commit abcb9b7b9a
4 changed files with 56 additions and 10 deletions

View File

@@ -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(() => {