Commit a17408a5 authored by 田翔's avatar 田翔

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

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