Commit 1c8137bf authored by 田翔's avatar 田翔

fix: 关联选择排除本身数据源

parent 420bb67f
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "3.0.6", "version": "3.0.7",
"description": "3.0.6: 数值为空时保存为null", "description": "3.0.7: 关联选择排除本身数据源,数值",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -421,9 +421,6 @@ const textWidgets = [ ...@@ -421,9 +421,6 @@ const textWidgets = [
widget: 'VerifyNumberInput', widget: 'VerifyNumberInput',
disabled: disabled, disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'], dependencies: ['tableTypeParent', 'IsSystemField'],
props: {
allowClear: true
},
}, },
presetValue: { presetValue: {
title: '默认值', title: '默认值',
...@@ -1310,7 +1307,7 @@ const selectWidgets = [ ...@@ -1310,7 +1307,7 @@ const selectWidgets = [
title: '默认值', title: '默认值',
type: 'string', type: 'string',
widget: 'CascadeDefault', widget: 'CascadeDefault',
dependencies: ['sourceType'] dependencies: ['sourceType'],
}, },
description: { description: {
title: '字段说明', title: '字段说明',
...@@ -1327,6 +1324,7 @@ const selectWidgets = [ ...@@ -1327,6 +1324,7 @@ const selectWidgets = [
type: 'string', type: 'string',
required: true, required: true,
widget: 'FieldNames', widget: 'FieldNames',
dependencies: ['$id'],
}, },
dictionary: { dictionary: {
title: '数据字典', title: '数据字典',
......
...@@ -10,13 +10,14 @@ const FieldNames = (props) => { ...@@ -10,13 +10,14 @@ const FieldNames = (props) => {
let fields = window.designer || [] let fields = window.designer || []
const { value, onChange, addons, disabled } = props const { value, onChange, addons, disabled } = props
const { tableNameParent, widget } = addons.formData const { tableNameParent, widget, $id } = addons.formData
const isRelevanceFieldParent = widget === 'RelevanceSelect' && addons.dataPath === 'fieldParent'
const [fieldName, setFieldName] = useState([]) const [fieldName, setFieldName] = useState([])
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [radioValue, setRadioValue] = useState(value) const [radioValue, setRadioValue] = useState(value)
const options = useMemo(() => { const options = useMemo(() => {
if (widget === 'RelevanceSelect' && addons.dataPath === 'fieldParent') { if (isRelevanceFieldParent) {
return fieldName return fieldName
} else { } else {
let array = [] let array = []
...@@ -29,7 +30,7 @@ const FieldNames = (props) => { ...@@ -29,7 +30,7 @@ const FieldNames = (props) => {
}, [fieldName, addons]) }, [fieldName, addons])
const plusShow = useMemo(() => { const plusShow = useMemo(() => {
if (widget === 'RelevanceSelect' && addons.dataPath === 'fieldParent') { if (isRelevanceFieldParent) {
return false return false
} }
return true return true
...@@ -54,9 +55,21 @@ const FieldNames = (props) => { ...@@ -54,9 +55,21 @@ const FieldNames = (props) => {
if (!tableNameParent) { if (!tableNameParent) {
return message.info('缺少表名!') return message.info('缺少表名!')
} }
if (isRelevanceFieldParent) {
//防止没有选择数据源情况
if ($id && $id.includes('关联选择_') && $id.length === 11) {
return message.info('请先选择数据源')
}
}
const { data } = await ReloadTableFields({ tableName: tableNameParent }) const { data } = await ReloadTableFields({ tableName: tableNameParent })
if (Array.isArray(data.root)) { if (Array.isArray(data.root)) {
setFieldName(data.root) let array = []
if (isRelevanceFieldParent) {
array = data.root.filter(v => v.name !== $id)
} else {
array = data.root
}
setFieldName(array)
} }
} }
......
import React from 'react' import React from 'react'
import { Input, Dropdown, Menu } from 'antd' import { Input, Dropdown, Menu, Select } from 'antd'
import { PlusOutlined } from '@ant-design/icons' import { PlusOutlined } from '@ant-design/icons'
import styles from './index.less' import styles from './index.less'
const options = [ const options = [
{ label: '整数', key: '${整数}' }, { label: '整数', value: '${整数}' },
{ label: '小数', key: '${小数}' }, { label: '小数', value: '${小数}' },
{ label: '货币', key: '${货币}' }, { label: '货币', value: '${货币}' },
{ label: '百分比', key: '${百分比}' }, { label: '百分比', value: '${百分比}' },
] ]
const Formatting = (props) => { const Formatting = (props) => {
...@@ -19,12 +19,23 @@ const Formatting = (props) => { ...@@ -19,12 +19,23 @@ const Formatting = (props) => {
} }
const menuClick = (item) => { const menuClick = (item) => {
onChange(item.key) onChange(item.value)
}
const selectChange = (value) => {
onChange(value)
} }
return ( return (
<div className={styles.formatting}> <div className={styles.formatting}>
<Input <Select
style={{ width: '100%', color: options.map(v => v.value).includes(value) ? '#4096ff' : '' }}
options={options}
onChange={selectChange}
allowClear
>
</Select>
{/* <Input
style={{ color: options.map(v => v.key).includes(value) ? '#4096ff' : '' }} style={{ color: options.map(v => v.key).includes(value) ? '#4096ff' : '' }}
value={value} value={value}
onChange={inputChange} onChange={inputChange}
...@@ -42,7 +53,7 @@ const Formatting = (props) => { ...@@ -42,7 +53,7 @@ const Formatting = (props) => {
> >
<PlusOutlined /> <PlusOutlined />
</Dropdown> </Dropdown>
</div> </div> */}
</div> </div>
) )
......
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