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

fix: 数值为空时保存为null

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