Commit 12c6e778 authored by 田翔's avatar 田翔

fix: 下拉站点选择器默认选择第一个

parent d7864ca6
......@@ -17,10 +17,13 @@ const ComboBox = (props) => {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue || '')
if (sourceType === '站点') {
getStation(presetValue)
}
} else {
onChange(presetValue || '')
}
}, [presetValue])
}, [presetValue, sourceType, isMultiple])
const valueShow = useMemo(() => {
if (isMultiple || isEdit) {
......@@ -75,6 +78,22 @@ const ComboBox = (props) => {
}
}
const getStation = async (presetValue) => {
const { code, data, msg } = await getStationIDListByUserID(userID, !isMySite)
if (code === 0) {
if (Array.isArray(data)) {
setSite(data)
if (!presetValue) {
onChange(data[0][isStoreID ? 'stationID' : 'stationName'])
}
} else {
setSite([])
}
} else {
message.error(msg)
}
}
const onFocus = async () => {
if (addons) {
if (sourceType === '数据字典') {
......@@ -104,18 +123,6 @@ const ComboBox = (props) => {
message.error(msg)
}
}
if (sourceType === '站点') {
const { code, data, msg } = await getStationIDListByUserID(userID, !isMySite)
if (code === 0) {
if (Array.isArray(data)) {
setSite(data)
} else {
setSite([])
}
} else {
message.error(msg)
}
}
}
}
......@@ -137,8 +144,8 @@ const ComboBox = (props) => {
event.preventDefault()
event.stopPropagation()
}
if(!color) {
if (!color) {
return label
}
......
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