Commit cca454df authored by 田翔's avatar 田翔

fix: 下拉框编辑支持单选

parent c4d88f85
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "5.6.6", "version": "5.6.7",
"description": "5.6.6 标签颜色修复", "description": "5.6.7 下拉框编辑支持单选",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -953,7 +953,7 @@ const selectWidgets = [ ...@@ -953,7 +953,7 @@ const selectWidgets = [
widget: 'checkbox', widget: 'checkbox',
default: false, default: false,
width: '30%', width: '30%',
hidden: '{{formData.isEdit}}' // hidden: '{{formData.isEdit}}'
}, },
isSearch: { isSearch: {
title: '搜索', title: '搜索',
......
...@@ -9,7 +9,22 @@ const ComboBox = (props) => { ...@@ -9,7 +9,22 @@ const ComboBox = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { placeholder, disabled, sourceType, options, dictionary, tableName, fieldName, presetValue, isMultiple, isEdit, isMySite, isSearch, isStoreID, color } = schema const {
placeholder,
disabled,
sourceType,
options,
dictionary,
tableName,
fieldName,
presetValue,
isMultiple,
isEdit,
isMySite,
isSearch,
isStoreID,
color
} = schema
const [dictionaryList, setDictionaryList] = useState([]) const [dictionaryList, setDictionaryList] = useState([])
const [tableData, setTableData] = useState([]) const [tableData, setTableData] = useState([])
const [site, setSite] = useState([]) const [site, setSite] = useState([])
...@@ -68,16 +83,37 @@ const ComboBox = (props) => { ...@@ -68,16 +83,37 @@ const ComboBox = (props) => {
return children return children
}, [sourceType, enums, isStoreID]) }, [sourceType, enums, isStoreID])
const handleChange = (value) => { //为了支持可编辑形态单选
const handleChange = (value, option) => {
if (addons) { if (addons) {
if (isMultiple || isEdit) { if (isMultiple) {
onChange(value.join(',') || '') onChange(value.join(',') || '')
} else if (!isMultiple && isEdit) {
return
} else { } else {
onChange(value || '') onChange(value || '')
} }
} }
} }
const onSelect = (selectValue) => {
if (!isMultiple && isEdit) {
if (selectValue !== value) {
onChange(selectValue)
}
}
}
const onDeselect = (value) => {
if (!isMultiple && isEdit) {
onChange('')
}
}
const onClear = () => {
onChange('')
}
const getStation = async (presetValue) => { const getStation = async (presetValue) => {
const { code, data, msg } = await getStationIDListByUserID(userID, !isMySite) const { code, data, msg } = await getStationIDListByUserID(userID, !isMySite)
if (code === 0) { if (code === 0) {
...@@ -173,8 +209,10 @@ const ComboBox = (props) => { ...@@ -173,8 +209,10 @@ const ComboBox = (props) => {
value={valueShow} value={valueShow}
placeholder={disabled ? (placeholder || '') : (placeholder || '请选择内容')} placeholder={disabled ? (placeholder || '') : (placeholder || '请选择内容')}
onChange={handleChange} onChange={handleChange}
onSelect={onSelect}
onDeselect={onDeselect}
onClear={onClear}
allowClear allowClear
// getPopupContainer={(targterNode) => targterNode.parentElement || document.body}
{...isTagRender} {...isTagRender}
> >
{children} {children}
......
...@@ -11,16 +11,9 @@ const BooleanSwitch = (props) => { ...@@ -11,16 +11,9 @@ const BooleanSwitch = (props) => {
} }
useEffect(() => { useEffect(() => {
if (widget === 'ComboBox') { // if (widget === 'ComboBox') {
if (value) { // if (value) {
addons.setValue('isMultiple', false) // addons.setValue('isMultiple', false)
}
}
// if (widget === 'TextInput') {
// if (schema.$id === 'isStoreID') {
// if (value) {
// addons.setValue('disabled', true)
// }
// } // }
// } // }
}, [value]) }, [value])
......
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