Commit 6771399d authored by 田翔's avatar 田翔

fix: 字段名称防止重复

parent f6b548cb
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "1.5.8", "version": "1.5.9",
"description": "1.5.8: 人员选择器,部门选择器支持ID存储", "description": "1.5.9: 字段名称防止重复",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -633,9 +633,33 @@ const textWidgets = [ ...@@ -633,9 +633,33 @@ const textWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 55, labelWidth: 55,
}, },
...groupStyle, groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
}, },
}, },
{
text: '编码',
name: '编码',
schema: {
title: '编码',
type: 'string',
widget: 'RichText',
},
}
] ]
const selectWidgets = [ const selectWidgets = [
...@@ -1274,9 +1298,6 @@ const selectWidgets = [ ...@@ -1274,9 +1298,6 @@ const selectWidgets = [
...groupStyle, ...groupStyle,
} }
}, },
]
const businessWidgets = [
{ {
text: '级联选择', text: '级联选择',
name: '级联选择', name: '级联选择',
...@@ -1400,6 +1421,9 @@ const businessWidgets = [ ...@@ -1400,6 +1421,9 @@ const businessWidgets = [
}, },
} }
}, },
]
const businessWidgets = [
{ {
text: '人员选择器', text: '人员选择器',
name: '人员选择器', name: '人员选择器',
......
...@@ -5,11 +5,10 @@ import { settings, baseSettings, globalSettings } from './config' ...@@ -5,11 +5,10 @@ import { settings, baseSettings, globalSettings } from './config'
import widgets from '../widgets' import widgets from '../widgets'
import { saveTableConfig, GetTableConfigJson } from '../../apis/process' import { saveTableConfig, GetTableConfigJson } from '../../apis/process'
import FormRender from '../FormRender' import FormRender from '../FormRender'
import { isObject } from '../../utils'
export const GlobalStore = createContext(null) export const GlobalStore = createContext(null)
console.log('defaultSettings', defaultSettings)
const FormDesigner = (props, ref) => { const FormDesigner = (props, ref) => {
const { tableName } = props const { tableName } = props
...@@ -85,9 +84,25 @@ const FormDesigner = (props, ref) => { ...@@ -85,9 +84,25 @@ const FormDesigner = (props, ref) => {
} }
] ]
const fieldRender = (schema, widgetProps, children, originNode) => { const getFields = (schema) => {
console.log(schema, widgetProps, children, originNode) let fields = []
return originNode let parent = schema?.properties
if (isObject(parent)) {
for (let v in parent) {
let child = parent[v]?.properties
if (isObject(child)) {
for (let s in child) {
fields.push(s)
}
}
}
}
return fields
}
const onSchemaChange = (schema) => {
let fields = getFields(schema)
window.sessionStorage.setItem('designerRef', fields)
} }
const testSubmit = async () => { const testSubmit = async () => {
...@@ -113,7 +128,7 @@ const FormDesigner = (props, ref) => { ...@@ -113,7 +128,7 @@ const FormDesigner = (props, ref) => {
settings={settingsParent} settings={settingsParent}
commonSettings={baseSettings} commonSettings={baseSettings}
globalSettings={globalSettings} globalSettings={globalSettings}
// fieldRender={fieldRender} onSchemaChange={onSchemaChange}
/> />
<Modal <Modal
title={tableName} title={tableName}
......
...@@ -353,7 +353,7 @@ const RelationForm = (props) => { ...@@ -353,7 +353,7 @@ const RelationForm = (props) => {
}, []) }, [])
return ( return (
<div className={styles.relationForm} style={{ display: show ? 'block' : 'none' }}> <div className={styles.relationForm} style={{ display: (!addons || show) ? 'block' : 'none' }}>
<div className={styles.header}> <div className={styles.header}>
<span className='account-header-title'>{titleShow}</span> <span className='account-header-title'>{titleShow}</span>
{disabled ? null : <Button className={styles.headerBtn} type='primary' size='middle' icon={<PlusOutlined />} onClick={addClick}>添加</Button>} {disabled ? null : <Button className={styles.headerBtn} type='primary' size='middle' icon={<PlusOutlined />} onClick={addClick}>添加</Button>}
......
...@@ -11,7 +11,9 @@ const RelevanceSelect = (props) => { ...@@ -11,7 +11,9 @@ const RelevanceSelect = (props) => {
const [options, setOptions] = useState([]) const [options, setOptions] = useState([])
const selectChange = (value) => { const selectChange = (value) => {
console.log('value', value) if (addons) {
onChange(value)
}
} }
const onfocus = async () => { const onfocus = async () => {
...@@ -32,7 +34,6 @@ const RelevanceSelect = (props) => { ...@@ -32,7 +34,6 @@ const RelevanceSelect = (props) => {
}) })
} }
}) })
console.log('filterKey', data, filterKey, fieldParent)
if (filterKey) { if (filterKey) {
setOptions(data.filter(v => v.nodeName === filterKey)) setOptions(data.filter(v => v.nodeName === filterKey))
} else { } else {
...@@ -42,7 +43,6 @@ const RelevanceSelect = (props) => { ...@@ -42,7 +43,6 @@ const RelevanceSelect = (props) => {
} else { } else {
message.error(msg) message.error(msg)
} }
console.log('data', data)
} }
return ( return (
......
import React from 'react'
import { Input } from 'antd'
const CascadeField = (props) => {
const { value, onChange } = props
// console.log('关联字段', props)
return (
<Input value={value ? value[0] : ''} onChange={(e) => onChange([e.target.value])} />
)
}
export default CascadeField
\ No newline at end of file
import React, { useMemo, useState } from 'react'
import { Button, Form, Input, Select, Space, Modal } from 'antd'
import { LoadLedgers } from '../../../../apis/process'
const DataSource = (props) => {
const { value, onChange } = props
const { formData } = props.addons
const { widget } = formData
const [visible, setVisible] = useState(false)
const [options, setOptions] = useState({ accountName: [] })
const [form] = Form.useForm()
const formItems = useMemo(() => {
switch (widget) {
case 'RelationForm':
return [
{
name: '台账名称',
label: '台账名称',
rules: [
{
required: true,
message: '请选择台账名称',
}
],
options: options.accountName,
onFocus: () => {
getAccountName()
}
},
]
case '':
return []
default: []
}
return []
}, [widget, options])
const valueShow = useMemo(() => {
return value
}, [value])
const getAccountName = async () => {
const { code, data } = await LoadLedgers()
if (code === 0) {
let accountName = data.root.map(v => {
return {
label: v.name,
value: v.name,
}
})
setOptions({ ...options, accountName })
}
}
const onFocus = () => {
setVisible(true)
}
const inputChange = (e) => {
console.log('e', e)
}
const onOk = () => {
onChange(JSON.stringify(form.getFieldsValue()))
setVisible(false)
}
return (
<>
<Modal
title={`【${formData.$id}】数据来源`}
width='500px'
visible={visible}
onOk={onOk}
onCancel={() => setVisible(false)}
>
<Form
form={form}
>
{
formItems.map((v, i) => {
return (
<Form.Item
name={v.name}
label={v.label}
rules={v.rules}
key={i}
>
<Select onFocus={v.onFocus} options={v.options} />
</Form.Item>
)
})
}
</Form>
</Modal>
<Input value={valueShow} onChange={inputChange} style={{ width: '100%' }} onClick={onFocus} />
</>
)
}
export default DataSource
\ No newline at end of file
import React from 'react'
import { Input } from 'antd'
const EnumOptions = (props) => {
const { value, onChange } = props
return (
<div className=''>
<Input value={value} onChange={e => onChange(e.target.value)} />
</div>
)
}
export default EnumOptions
\ No newline at end of file
...@@ -13,10 +13,6 @@ const InputAddon = (props) => { ...@@ -13,10 +13,6 @@ const InputAddon = (props) => {
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [icon, setIcon] = useState() const [icon, setIcon] = useState()
// const valueShow = useMemo(() => {
// return value ? value : ''
// }, [value])
const inputChange = (e) => { const inputChange = (e) => {
onChange(e.target.value) onChange(e.target.value)
} }
......
import React from 'react'
import { Select } from 'antd'
const MultiSelect = (props) => {
return (
<Select />
)
}
export default MultiSelect
\ No newline at end of file
...@@ -4,11 +4,15 @@ import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process' ...@@ -4,11 +4,15 @@ import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process'
const FieldNames = (props) => { const FieldNames = (props) => {
let fields = window.sessionStorage.getItem('designerRef') || []
const { value, onChange, addons } = props const { value, onChange, addons } = props
const { tableNameParent, name } = addons.formData const { tableNameParent, name } = addons.formData
const [fieldName, setFieldName] = useState([]) const [fieldName, setFieldName] = useState([])
const options = useMemo(() => {
return fieldName.filter(v => !fields.includes(v.name))
}, [fieldName])
const selectChange = (value) => { const selectChange = (value) => {
if (name !== '关联表单') { if (name !== '关联表单') {
addons.setValueByPath('title', value) addons.setValueByPath('title', value)
...@@ -47,10 +51,21 @@ const FieldNames = (props) => { ...@@ -47,10 +51,21 @@ const FieldNames = (props) => {
showSearch showSearch
optionFilterProp='children' optionFilterProp='children'
value={value} value={value}
fieldNames={{ label: 'name', value: 'name' }}
options={options}
> >
{ {/* {
fieldName.map(v => <Select.Option key={v.name} value={v.name}>{v.name}</Select.Option>) options.map(v => {
} return (
<Select.Option key={v.name} value={v.name}>
<div>
<span>{v.name}</span>
<span>{v.check ? '已选': '未选'}</span>
</div>
</Select.Option>
)
})
} */}
</Select> </Select>
) )
} }
......
...@@ -3,10 +3,7 @@ import groupBase from './groupBase' ...@@ -3,10 +3,7 @@ import groupBase from './groupBase'
import groupSource from './groupSource' import groupSource from './groupSource'
import groupVerify from './groupVerify' import groupVerify from './groupVerify'
import BooleanSwitch from './BooleanSwitch' import BooleanSwitch from './BooleanSwitch'
import EnumOptions from './EnumOptions'
import InputAddon from './InputAddon' import InputAddon from './InputAddon'
import CascadeField from './CascadeField'
import DataSource from './DataSource'
const settings = { const settings = {
...form, ...form,
...@@ -14,10 +11,7 @@ const settings = { ...@@ -14,10 +11,7 @@ const settings = {
...groupSource, ...groupSource,
...groupVerify, ...groupVerify,
BooleanSwitch, BooleanSwitch,
EnumOptions,
InputAddon, InputAddon,
CascadeField,
DataSource,
} }
export default settings export default settings
\ No newline at end of file
...@@ -27,19 +27,6 @@ const TextInput = (props) => { ...@@ -27,19 +27,6 @@ const TextInput = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema
const style = useMemo(() => {
let paths = ['【本人姓名】', '【本人部门】']
if (paths.includes(value)) {
if (value === '【本人姓名】') {
onChange(userInfo.fullName)
} else if (value === '【本人部门】') {
onChange(userInfo.depart.name)
}
return { color: 'blue' }
}
return null
}, [value])
const handleChange = (e) => { const handleChange = (e) => {
if (addons) { if (addons) {
onChange(e.target.value) onChange(e.target.value)
...@@ -47,10 +34,19 @@ const TextInput = (props) => { ...@@ -47,10 +34,19 @@ const TextInput = (props) => {
} }
useEffect(() => { useEffect(() => {
let paths = ['【本人姓名】', '【本人部门】']
let value = presetValue
if (paths.includes(value)) {
if (value === '【本人姓名】') {
value = userInfo.fullName
} else if (value === '【本人部门】') {
value = userInfo.depart.name
}
}
if (addons) { if (addons) {
addons.setValue(addons.dataPath, presetValue) addons.setValue(addons.dataPath, value)
} else { } else {
onChange(presetValue) onChange(value)
} }
}, [presetValue]) }, [presetValue])
...@@ -78,7 +74,6 @@ const TextInput = (props) => { ...@@ -78,7 +74,6 @@ const TextInput = (props) => {
return ( return (
<Input <Input
style={style}
disabled={disabled} disabled={disabled}
value={value} value={value}
maxLength={maxLength} maxLength={maxLength}
......
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