Commit 3b9805c6 authored by 田翔's avatar 田翔

fix: 增加是否初始调用参数

parent f45ed876
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.10.5", "version": "6.10.6",
"description": "6.10.5 解决打印无数据问题", "description": "6.10.6 增加是否初始调用参数",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -21,7 +21,7 @@ const XRender = (props, ref) => { ...@@ -21,7 +21,7 @@ const XRender = (props, ref) => {
} }
)) ))
const { schemaValues, disabledFields, disabled, codes, env } = props const { schemaValues, disabledFields, disabled, codes, env, firstCall } = props
window.pandaXform = { window.pandaXform = {
codes, codes,
env, env,
...@@ -30,7 +30,7 @@ const XRender = (props, ref) => { ...@@ -30,7 +30,7 @@ const XRender = (props, ref) => {
const { formJson, values } = schemaValues const { formJson, values } = schemaValues
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext) const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const pandaXform = getPrefixCls() const pandaXform = getPrefixCls()
const startTime = new Date().getTime() const startTime = firstCall ? 0 : new Date().getTime()
const [initField, setInitField] = useState([]) const [initField, setInitField] = useState([])
const form = useForm() const form = useForm()
......
...@@ -245,7 +245,7 @@ const getFieldValue = (formValue, fieldName) => { ...@@ -245,7 +245,7 @@ const getFieldValue = (formValue, fieldName) => {
} }
//自动计算监听/隐藏条件监听 //自动计算监听/隐藏条件监听
export const getWatch = ({ schema, form, startTime, initField }) => { export const getWatch = ({ schema, form, startTime, initField, firstCall }) => {
let watch = {} let watch = {}
let paths = [] let paths = []
let formValue = form?.getValues() let formValue = form?.getValues()
...@@ -338,6 +338,7 @@ export const getWatch = ({ schema, form, startTime, initField }) => { ...@@ -338,6 +338,7 @@ export const getWatch = ({ schema, form, startTime, initField }) => {
relationForm, relationForm,
schema: schema, schema: schema,
startTime, startTime,
firstCall,
initField, initField,
currentValue, currentValue,
} }
......
...@@ -44,12 +44,6 @@ const NumberInput = (props) => { ...@@ -44,12 +44,6 @@ const NumberInput = (props) => {
} }
} }
const inputChange = (e) => {
let inputValue = e.target.value
inputValue.replace(/[^\d.]/g, '')
onChange(inputValue)
}
const formatterFn = (value) => { const formatterFn = (value) => {
if (value) { if (value) {
if (formatter === '${百分比}') { if (formatter === '${百分比}') {
...@@ -59,7 +53,8 @@ const NumberInput = (props) => { ...@@ -59,7 +53,8 @@ const NumberInput = (props) => {
} else if (formatter === '${整数}') { } else if (formatter === '${整数}') {
return `${parseInt(value)}` return `${parseInt(value)}`
} else if (formatter === '${小数}') { } else if (formatter === '${小数}') {
return Number(value).toFixed(Number(decimalDigits)) return value
// return Number(value).toFixed(Number(decimalDigits))
} else if (formatter === '${科学计数法}') { } else if (formatter === '${科学计数法}') {
return Number(value).toExponential() return Number(value).toExponential()
} else if (formatter) { } else if (formatter) {
...@@ -69,9 +64,12 @@ const NumberInput = (props) => { ...@@ -69,9 +64,12 @@ const NumberInput = (props) => {
return value return value
} }
const obj = formatter === '${小数}' ? { precision: decimalDigits } : { formatter: formatterFn }
return ( return (
<div className={styles.inputNumber} isdisabled={JSON.stringify(disabled)}> <div className={styles.inputNumber} isdisabled={JSON.stringify(disabled)}>
<InputNumber <InputNumber
{...obj}
min={min || Number.MIN_SAFE_INTEGER} min={min || Number.MIN_SAFE_INTEGER}
max={max || Number.MAX_SAFE_INTEGER} max={max || Number.MAX_SAFE_INTEGER}
step={(formatter === '${百分比}' && isStoreFormatter) ? 0.01 : 1} step={(formatter === '${百分比}' && isStoreFormatter) ? 0.01 : 1}
...@@ -81,7 +79,7 @@ const NumberInput = (props) => { ...@@ -81,7 +79,7 @@ const NumberInput = (props) => {
placeholder={disabled ? (placeholder || '') : (placeholder || '请输入内容')} placeholder={disabled ? (placeholder || '') : (placeholder || '请输入内容')}
disabled={disabled} disabled={disabled}
value={value === '' ? null : Number(value)} value={value === '' ? null : Number(value)}
formatter={formatterFn} stringMode={true}
onChange={numberChange} onChange={numberChange}
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