Commit 4441481c authored by 田翔's avatar 田翔

fix: 开关形态默认值不生效问题

parent 11599d21
{
"name": "panda-xform",
"version": "3.0.3",
"description": "3.0.3: 地址坐标初始未赋值问题",
"version": "3.0.4",
"description": "3.0.4: 开关形态默认值不生效问题",
"keywords": [
"panda-xform"
],
......
......@@ -1214,7 +1214,8 @@ const selectWidgets = [
presetValue: {
title: '默认值',
type: 'boolean',
widget: 'BooleanSwitch',
widget: 'SwitchDefault',
dependencies: ['showText'],
},
description: {
title: '字段说明',
......
......@@ -9,9 +9,9 @@ const SwitchSelector = (props) => {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue === text[0] ? text[0]: text[1])
addons.setValue(addons.dataPath, (presetValue === text[0] || presetValue === true) ? text[0] : text[1])
} else {
onChange(presetValue === text[0] ? text[0]: text[1])
onChange((presetValue === text[0] || presetValue === true) ? text[0] : text[1])
}
}, [presetValue])
......
import React, { useEffect } from 'react'
import { Switch } from 'antd'
const SwitchDefault = (props) => {
const { value, onChange, addons } = props
const { showText } = addons?.formData
const text = (showText && showText.includes('/')) ? showText.split('/') : ['开', '关']
const switchChange = (checked) => {
if (addons) {
onChange(checked)
}
}
return (
<Switch
checked={value}
checkedChildren={text[0]}
unCheckedChildren={text[1]}
onChange={switchChange}
>
</Switch>
)
}
export default SwitchDefault
\ No newline at end of file
......@@ -7,6 +7,7 @@ import DateDefault from './DateDefault'
import TimeDefault from './TimeDefault'
import WidgetType from './WidgetType'
import HiddenCondition from './HiddenCondition'
import SwitchDefault from './SwitchDefault'
const groupBase = {
FieldNames,
......@@ -18,6 +19,7 @@ const groupBase = {
TimeDefault,
WidgetType,
HiddenCondition,
SwitchDefault,
}
export default groupBase
\ No newline at end of file
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