Commit 420bb67f authored by 田翔's avatar 田翔

fix: 数值为空时保存为null

parent 46dde126
{
"name": "panda-xform",
"version": "3.0.5",
"description": "3.0.5: 数值形态去掉默认问题,时间组件去掉秒显示,分钟步长改为5",
"version": "3.0.6",
"description": "3.0.6: 数值为空时保存为null",
"keywords": [
"panda-xform"
],
......
......@@ -5,10 +5,18 @@ const NumerDefault = (props) => {
const { value, onChange } = props
const inputChange = (value) => {
if (value !== null) {
onChange(`${value}`)
} else {
onChange('')
}
}
return (
<InputNumber
value={Number(value)}
onChange={value => onChange(value + '')}
value={value === '' ? null : Number(value)}
onChange={inputChange}
/>
)
......
......@@ -21,15 +21,19 @@ const NumberInput = (props) => {
useEffect(() => {
if (addons) {
addons.setValueByPath(addons.dataPath, presetValue || '0')
addons.setValueByPath(addons.dataPath, presetValue)
} else {
onChange(presetValue || '0')
onChange(presetValue)
}
}, [presetValue])
const inputChange = (value) => {
if (addons) {
onChange(`${value}`)
if (value !== null) {
onChange(`${value}`)
} else {
onChange('')
}
}
}
......@@ -60,7 +64,7 @@ const NumberInput = (props) => {
prefix={prefix}
placeholder={placeholder}
disabled={disabled}
value={Number(value)}
value={value === '' ? null : Number(value)}
formatter={formatterFn}
onChange={inputChange}
style={{ width: '100%' }}
......
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