Commit a17408a5 authored by 田翔's avatar 田翔

fix: 下拉框配置联动逻辑修复,前端处理这个问题

parent 5cd150f7
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "1.6.3", "version": "1.6.4",
"description": "1.6.3: 配置表名字段名支持下拉框,下拉框配置数据来源必填信息校验,时间配置改为支持单选,可编辑配置根据数据来源进行控制,下拉框增加搜索选项", "description": "1.6.4: 下拉框配置联动逻辑修复,前端处理这个问题",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -899,35 +899,36 @@ const selectWidgets = [ ...@@ -899,35 +899,36 @@ const selectWidgets = [
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
default: false, default: false,
width: '25%', width: '33%',
}, },
disabled: { disabled: {
title: '只读', title: '只读',
type: 'boolean', type: 'boolean',
widget: 'checkbox', widget: 'checkbox',
default: false, default: false,
width: '25%', width: '33%',
}, },
hidden: { hidden: {
title: '隐藏', title: '隐藏',
type: 'boolean', type: 'boolean',
widget: 'checkbox', widget: 'checkbox',
default: false, default: false,
width: '25%', width: '33%',
}, },
isMultiple: { isMultiple: {
title: '多选', title: '多选',
type: 'boolean', type: 'boolean',
widget: 'checkbox', widget: 'checkbox',
default: false, default: false,
width: '25%', width: '33%',
hidden: '{{formData.isEdit}}'
}, },
isSearch: { isSearch: {
title: '搜索', title: '搜索',
type: 'boolean', type: 'boolean',
widget: 'checkbox', widget: 'checkbox',
default: false, default: false,
width: '25%', width: '33%',
default: true default: true
}, },
isEdit: { isEdit: {
......
...@@ -21,23 +21,27 @@ const FormDesigner = (props, ref) => { ...@@ -21,23 +21,27 @@ const FormDesigner = (props, ref) => {
const designerRef = useRef(null) const designerRef = useRef(null)
const formRenderRef = useRef(null) const formRenderRef = useRef(null)
const settingsParent = useMemo(() => { const getJSON = (json, tableName) => {
let settingsParent = [] let parent = json?.properties
settings.forEach(v => { if (isObject(parent)) {
v.widgets.forEach(s => { for (let v in parent) {
s.schema = { ...s.schema, tableNameParent: tableName } let child = parent[v]?.properties
}) if (isObject(child)) {
settingsParent.push(v) for (let s in child) {
}) child[s].tableNameParent = tableName
return settingsParent }
}, [settings, tableName]) }
}
}
return json
}
const getTableConfig = async (tableName) => { const getTableConfig = async (tableName) => {
const { code, data, msg } = await GetTableConfigJson({ tableName }) const { code, data, msg } = await GetTableConfigJson({ tableName })
if (code === 0) { if (code === 0) {
if (data && typeof data === 'string') { if (data && typeof data === 'string') {
let json = JSON.parse(data) let json = JSON.parse(data)
designerRef?.current?.setValue(json) designerRef?.current?.setValue(getJSON(json, tableName))
setSchema(json) setSchema(json)
} }
} else { } else {
...@@ -151,7 +155,7 @@ const FormDesigner = (props, ref) => { ...@@ -151,7 +155,7 @@ const FormDesigner = (props, ref) => {
ref={designerRef} ref={designerRef}
extraButtons={extraButtons} extraButtons={extraButtons}
widgets={widgets} widgets={widgets}
settings={settingsParent} settings={settings}
commonSettings={baseSettings} commonSettings={baseSettings}
globalSettings={globalSettings} globalSettings={globalSettings}
onSchemaChange={onSchemaChange} onSchemaChange={onSchemaChange}
...@@ -168,7 +172,6 @@ const FormDesigner = (props, ref) => { ...@@ -168,7 +172,6 @@ const FormDesigner = (props, ref) => {
footer={ footer={
<div> <div>
<Button onClick={() => setVisible(false)}>取消</Button> <Button onClick={() => setVisible(false)}>取消</Button>
<Button onClick={() => setVisible(false)}>确定</Button>
<Button onClick={testSubmit}>测试提交</Button> <Button onClick={testSubmit}>测试提交</Button>
</div> </div>
} }
......
...@@ -20,6 +20,12 @@ const XRender = (props, ref) => { ...@@ -20,6 +20,12 @@ const XRender = (props, ref) => {
const pandaXform = getPrefixCls() const pandaXform = getPrefixCls()
const form = useForm() const form = useForm()
const watch = {
'#': (value) => {
console.log('value', value)
}
}
const getValues = async () => { const getValues = async () => {
let { data, errors } = await form.submit() let { data, errors } = await form.submit()
let formValue = [] let formValue = []
...@@ -47,6 +53,7 @@ const XRender = (props, ref) => { ...@@ -47,6 +53,7 @@ const XRender = (props, ref) => {
object: 'Header', object: 'Header',
}} }}
widgets={widgets} widgets={widgets}
watch={watch}
/> />
</div> </div>
) )
......
import React from 'react'
import { InputNumber } from 'antd'
const AutoCalculate = () => {
return (
<div></div>
)
}
export default AutoCalculate
\ No newline at end of file
...@@ -2,8 +2,7 @@ import React, { useMemo, forwardRef, useContext, useImperativeHandle } from 'rea ...@@ -2,8 +2,7 @@ import React, { useMemo, forwardRef, useContext, useImperativeHandle } from 'rea
import { ConfigProvider } from 'antd' import { ConfigProvider } from 'antd'
import FormRender, { useForm } from 'form-render' import FormRender, { useForm } from 'form-render'
import widgets from './widgets' import widgets from './widgets'
import { isObject } from '../../../../../utils'
const isObject = (obj) => typeof obj === 'object'
const BaseForm = (props, ref) => { const BaseForm = (props, ref) => {
......
...@@ -2,6 +2,7 @@ import Header from '../../../Header' ...@@ -2,6 +2,7 @@ import Header from '../../../Header'
import text from '../../../text' import text from '../../../text'
import date from '../../../date' import date from '../../../date'
import select from '../../../select' import select from '../../../select'
import business from '../../../business'
import file from '../../../file' import file from '../../../file'
import Signature from '../../Signature' import Signature from '../../Signature'
...@@ -14,6 +15,7 @@ const widgets = { ...@@ -14,6 +15,7 @@ const widgets = {
...text, ...text,
...date, ...date,
...select, ...select,
...business,
...file, ...file,
...coord, ...coord,
} }
......
import RelationForm from './RelationForm' import RelationForm from './RelationForm'
import Signature from './Signature' import Signature from './Signature'
import AutoCalculate from './AutoCalculate'
const advanced = { const advanced = {
RelationForm, RelationForm,
Signature, Signature,
AutoCalculate,
} }
export default advanced export default advanced
\ No newline at end of file
import AccountSelector from './AccountSelector'
import DeptSelector from './DeptSelector'
import PersonSelector from './PersonSelector'
const business = {
AccountSelector,
DeptSelector,
PersonSelector,
}
export default business
\ No newline at end of file
...@@ -6,13 +6,15 @@ import select from './select' ...@@ -6,13 +6,15 @@ import select from './select'
import file from './file' import file from './file'
import coord from './coord' import coord from './coord'
import advanced from './advanced' import advanced from './advanced'
import business from './business'
const widgets = { const widgets = {
Header, Header,
...setting, ...setting,
...text, ...text,
...date,
...select, ...select,
...business,
...date,
...file, ...file,
...coord, ...coord,
...advanced, ...advanced,
......
...@@ -4,9 +4,6 @@ import CheckBox from './CheckBox' ...@@ -4,9 +4,6 @@ import CheckBox from './CheckBox'
import CascadeSelector from './CascadeSelector' import CascadeSelector from './CascadeSelector'
import RelevanceSelect from './RelevanceSelect' import RelevanceSelect from './RelevanceSelect'
import SwitchSelector from './SwitchSelector' import SwitchSelector from './SwitchSelector'
import PersonSelector from './PersonSelector'
import AccountSelector from './AccountSelector'
import DeptSelector from './DeptSelector'
const select = { const select = {
ComboBox, ComboBox,
...@@ -14,10 +11,7 @@ const select = { ...@@ -14,10 +11,7 @@ const select = {
CheckBox, CheckBox,
SwitchSelector, SwitchSelector,
RelevanceSelect, RelevanceSelect,
PersonSelector,
CascadeSelector, CascadeSelector,
AccountSelector,
DeptSelector,
} }
export default select export default select
\ No newline at end of file
...@@ -13,11 +13,7 @@ const BooleanSwitch = (props) => { ...@@ -13,11 +13,7 @@ const BooleanSwitch = (props) => {
useEffect(() => { useEffect(() => {
if (name === '下拉框') { if (name === '下拉框') {
if (value) { if (value) {
const schemas = addons.getSchemaByPath('isMultiple') addons.setValue('isMultiple', false)
addons.setSchemaByPath('isMultiple', { ...schemas, isMultiple: false, hidden: true })
} else {
const schemas = addons.getSchemaByPath('isMultiple')
addons.setSchemaByPath('isMultiple', { ...schemas, isMultiple: false, hidden: false })
} }
} }
}, [value]) }, [value])
......
import React, { useState } from 'react' import React, { useState } from 'react'
import { Select, message } from 'antd' import { Select, message } from 'antd'
import { LoadTableV2, LoadTableFields } from '../../../../../apis/process' import { LoadTableV2, LoadTableFields, ReloadTableFields } from '../../../../../apis/process'
const FieldName = (props) => { const FieldName = (props) => {
...@@ -12,9 +12,9 @@ const FieldName = (props) => { ...@@ -12,9 +12,9 @@ const FieldName = (props) => {
if (!tableName) { if (!tableName) {
return message.info('请选择表名!') return message.info('请选择表名!')
} }
const { code, data, msg } = await LoadTableFields({ tableName: tableName }) const { code, data, msg } = await ReloadTableFields({ tableName: tableName })
if (code === 0) { if (code === 0) {
let result = data.root.map(v => { return { label: v.fieldName, value: v.fieldName } }) let result = data.root.map(v => { return { label: v.name, value: v.name } })
setOptions(result) setOptions(result)
} else { } else {
message.error(msg) message.error(msg)
......
...@@ -33,7 +33,7 @@ const Fieldshine = (props) => { ...@@ -33,7 +33,7 @@ const Fieldshine = (props) => {
} }
const inputClick = async () => { const inputClick = async () => {
if ($id.includes('台账选择器')) { if ($id.includes('台账选择器') && $id !== '台账选择器') {
return message.info('请选择字段名称') return message.info('请选择字段名称')
} }
if (!accountName) { if (!accountName) {
......
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