Commit ed3ea722 authored by 田翔's avatar 田翔

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

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