Commit cca454df authored by 田翔's avatar 田翔

fix: 下拉框编辑支持单选

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