Commit ed3ea722 authored by 田翔's avatar 田翔

fix: 各个形态组件不做数据类型校验统一使用字符串处理

parent b0e9f174
{
"name": "panda-xform",
"version": "2.2.7",
"description": "2.2.7: 关联表单属性调整",
"version": "2.2.9",
"description": "2.2.9: 各个形态组件不做数据类型校验统一使用字符串处理",
"keywords": [
"panda-xform"
],
......
......@@ -439,7 +439,7 @@ const textWidgets = [
icon: <FieldBinaryOutlined />,
schema: {
title: '数值',
type: 'number',
type: 'string',
widget: 'NumberInput',
presetValue: 0,
},
......@@ -475,7 +475,7 @@ const textWidgets = [
},
presetValue: {
title: '默认值',
type: 'number',
type: 'string',
widget: 'NumerDefault',
displayType: 'row',
labelWidth: 80,
......@@ -1315,8 +1315,9 @@ const selectWidgets = [
schema: {
title: '开关',
name: '开关',
type: 'number',
type: 'string',
widget: 'SwitchSelector',
default: '0',
},
setting: {
groupBase: {
......@@ -2504,6 +2505,19 @@ const mapWidgets = [
labelWidth: 80,
default: '请选择坐标位置'
},
groupSource: {
title: '控件设置',
type: 'object',
properties: {}
},
currentAddress: {
title: '自动获取',
type: 'Boolean',
widget: 'BooleanSwitch',
displayType: 'row',
labelWidth: 100,
description: '是否自动获取当前地址(手持端专用)'
},
groupSetting: {
title: '控件设置',
type: 'object',
......@@ -2832,7 +2846,7 @@ const advancedWidgets = [
labelWidth: 80,
required: true,
default: [],
dependencies: ['accountName'],
dependencies: ['台账名称'],
},
'默认显示': {
title: '默认显示',
......@@ -2877,7 +2891,7 @@ const advancedWidgets = [
name: '自动计算',
schema: {
title: '自动计算',
type: 'number',
type: 'string',
widget: 'AutoCalculate',
},
setting: {
......
......@@ -110,7 +110,7 @@ const automaticComputation = async (params) => {
data.forEach(v => {
let path = getPath(params.schema, v.fieldName)
if (path) {
params.form.setValueByPath(path, v.fieldValue)
params.form.setValueByPath(path, v.fieldValue + '')
}
})
}
......@@ -125,12 +125,6 @@ export const getWatch = (schema, form, startTime) => {
let watch = {}
let { relationForm } = form?.getValues()
const configs = relationForm?.configs || []
// if (Array.isArray(configs)) {
// configs.forEach(v => {
// v['台账名称'] = v.accountName
// v['映射字段'] = v.mappedField
// })
// }
const AutoCalculate = getRules(schema)
if (Array.isArray(AutoCalculate)) {
AutoCalculate.forEach(item => {
......
......@@ -78,7 +78,6 @@ const RelationForm = (props) => {
}
return defaultShow
} catch {
// message.error('字符串规则解析失败')
return defaultShow
}
}
......@@ -92,6 +91,7 @@ const RelationForm = (props) => {
const getFieldValue = (s, formDataObj, codes) => {
return codes ? (codes[s.fromField] || formDataObj[s.fromField]) : formDataObj[s.fromField]
}
console.log('field', field)
field.forEach(v => {
mappedField.forEach(s => {
if (s.toField === v) {
......
......@@ -11,12 +11,10 @@ const UserSelect = (props) => {
const [pullDown, setPullDown] = useState([])
const valueShow = useMemo(() => {
if (value) {
if (isMultiple) {
return value.split(',')
}
if (isMultiple) {
return value ? value.split(',') : []
}
return value
return value || null
}, [value, isMultiple])
const selectFocus = async () => {
......
......@@ -6,15 +6,23 @@ import locale from 'antd/lib/date-picker/locale/zh_CN'
const DateTime = (props) => {
const { value, onChange, schema } = props
const { value, onChange, schema, addons } = props
const { disabled, format, presetValue, placeholder, options, currentDate, defaultCurrent } = schema
const valueShow = useMemo(() => {
if (options === '默认为当前时间') {
return (value || new Date()) ? moment(value || new Date()) : null
}
return (value || presetValue) ? moment(value || presetValue) : null
}, [presetValue, defaultCurrent, value])
return value ? moment(value) : null
}, [defaultCurrent, value])
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
const disabledDate = (current) => {
if (options === '不超过当前时间') {
......
......@@ -12,8 +12,8 @@ const Time = (props) => {
if (options === '默认为当前时间') {
return (value || new Date()) ? moment(value || new Date(), 'HH:mm:ss') : null
}
return (value || presetValue) ? moment(value || presetValue, 'HH:mm:ss') : null
}, [presetValue, value, defaultCurrent])
return value ? moment(value, 'HH:mm:ss') : null
}, [value, defaultCurrent])
const disabledDate = (current) => {
if (options === '不超过当前时间') {
......@@ -27,6 +27,14 @@ const Time = (props) => {
onChange(timeStr)
}
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
return (
<TimePicker
style={{ width: '100%' }}
......
......@@ -9,21 +9,21 @@ const SwitchSelector = (props) => {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, Boolean(presetValue))
addons.setValue(addons.dataPath, presetValue ? '1' : '0')
} else {
onChange(Boolean(presetValue))
onChange(presetValue ? '1' : '0')
}
}, [presetValue])
const switchChange = (checked) => {
if (addons) {
onChange(checked ? 1 : 0)
onChange(checked ? '1' : '0')
}
}
return (
<Switch
checked={Boolean(value)}
checked={Boolean(Number(value))}
disabled={disabled}
checkedChildren={Array.isArray(text) ? text[0] : ''}
unCheckedChildren={Array.isArray(text) ? text[1] : ''}
......
......@@ -8,7 +8,7 @@ const NumerDefault = (props) => {
return (
<InputNumber
value={Number(value)}
onChange={value => onChange(Number(value))}
onChange={value => onChange(value + '')}
/>
)
......
......@@ -10,13 +10,14 @@ const { TreeNode } = TreeSelect
const MappedField = (props) => {
const { value, onChange, schema, addons } = props
const { accountName, tableNameParent } = addons.formData
const { '台账名称': accountName, tableNameParent } = addons.formData
const [form] = Form.useForm()
const [visible, setVisible] = useState(false)
const [fromField, setFromField] = useState([])
const [toField, setToField] = useState([])
const inputClick = async () => {
console.log('addons', addons)
if (!accountName) {
message.info('请选择台账名称')
}
......
......@@ -8,15 +8,15 @@ const NumberInput = (props) => {
useEffect(() => {
if (addons) {
addons.setValueByPath(addons.dataPath, Number(presetValue))
addons.setValueByPath(addons.dataPath, presetValue)
} else {
onChange(Number(presetValue))
onChange(presetValue)
}
}, [presetValue])
const inputChange = (value) => {
if (addons) {
onChange(value)
onChange(value + '')
}
}
......@@ -25,7 +25,7 @@ const NumberInput = (props) => {
prefix={prefix}
placeholder={placeholder}
disabled={disabled}
value={value}
value={Number(value)}
formatter={(value) => value && formatter ? `${value}${formatter}` : value}
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