Commit e66845d2 authored by 田翔's avatar 田翔

fix: 增加关联选择器

parent cbedc92e
{
"name": "panda-xform",
"version": "1.5.2",
"description": "1.5.2: 台账选择器完成,统一增加说明属性替代强调",
"version": "1.5.3",
"description": "1.5.3: 增加关联选择器",
"keywords": [
"panda-xform"
],
......
......@@ -1173,6 +1173,111 @@ const selectWidgets = [
},
}
},
{
text: '关联选择',
name: '关联选择',
schema: {
title: '关联选择器',
name: '关联选择器',
type: 'string',
widget: 'RelevanceSelect',
require: true,
},
setting: {
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
title: '字段名称',
type: 'string',
widget: 'FieldNames',
required: true,
displayType: 'row',
labelWidth: 80,
},
title: {
title: '标题',
required: true,
type: 'string',
widget: 'htmlInput',
displayType: 'row',
labelWidth: 80,
},
placeholder: {
title: '提示语',
type: 'string',
displayType: 'row',
labelWidth: 80,
default: '请选择内容',
},
presetValue: {
title: '默认值',
type: 'string',
displayType: 'row',
widget: 'CascadeDefault',
labelWidth: 80,
dependencies: ['soruceType']
},
gorupSoruce: {
title: '数据来源',
type: 'object',
properties: {}
},
fieldParent: {
title: '父字段名',
type: 'string',
required: true,
widget: 'FieldNames',
displayType: 'row',
labelWidth: 80,
},
dictionary: {
title: '数据字典',
name: '数据字典',
required: true,
type: 'string',
widget: 'Dictionary',
displayType: 'row',
labelWidth: 80,
},
groupSetting: {
title: '控件设置',
type: 'object',
properties: {}
},
required: {
title: '必填',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
disabled: {
title: '只读',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
hidden: {
title: '隐藏',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
description: {
title: '说明',
type: 'string',
displayType: 'row',
labelWidth: 55,
},
...groupStyle,
}
},
{
text: '级联选择',
name: '级联选择',
......@@ -1297,20 +1402,6 @@ const selectWidgets = [
},
}
},
{
text: '关联选择',
name: '关联选择',
schema: {
title: '关联选择器',
name: '关联选择器',
type: 'string',
widget: 'CascadeSelect',
require: true,
},
setting: {
}
},
{
text: '人员选择器',
name: '人员选择器',
......
......@@ -16,12 +16,8 @@ const XRender = (props, ref) => {
const [listData, setListData] = useState([])
const form = useForm()
const onClick = () => {
console.log('form', form, form.getValues())
}
return (
<div className={prefixCls} onClick={() => onClick()}>
<div className={prefixCls}>
<FormRender
configProvider={{ prefixCls: pandaXform }}
form={form}
......
......@@ -83,7 +83,7 @@ const AccountSelector = (props) => {
setLoading(true)
let param = {
accountName: accountName,
condition: sql,
condition: sql ? window.btoa(encodeURIComponent(condition)) : '',
sortFields: '录入时间',
queryWheres: queryWheres,
...params,
......
// 可编辑值选择器
import React, { useState, useEffect } from 'react';
import { Select } from 'antd';
const { Option } = Select;
const EditSelect = ({ value, onChange, schema }) => {
const { disabled, placeholder } = schema
const children = [];
for (let i = 0; i < schema.enum.length; i++) {
children.push(<Option key={i.toString(36) + i}>{schema.enum[i]}</Option>);
}
const val = value || schema.default;
useEffect(() => {
onChange(val);
}, []);
return (
<Select
disabled={disabled}
showArrow={!disabled}
placeholder={placeholder}
mode={'tags'}
value={value ? value.split(',') : []}
onChange={val => {
onChange(val.join(','))
}}
style={{ width: '100%' }}
>
{children}
</Select>
);
};
export default EditSelect;
import React, { useState } from 'react'
import { Select, message } from 'antd'
import { GetSelectItemList } from '../../../../apis/process'
const { Option } = Select
const RelevanceSelect = (props) => {
const { value, onChange, schema, addons } = props
const { disabled, placeholder, fieldParent, dictionary } = schema
const [options, setOptions] = useState([])
const selectChange = (value) => {
console.log('value', value)
}
const onfocus = async () => {
if (!addons) return
if (!dictionary) {
return message.error('缺少数据字典!')
}
const { code, data, msg } = await GetSelectItemList({ nodeName: dictionary })
if (code === 0) {
if (Array.isArray(data)) {
let filterKey = null
Object.keys(addons.formData).forEach(v => {
if (addons.formData[v]) {
Object.keys(addons.formData[v]).forEach(s => {
if (fieldParent === s) {
filterKey = addons.formData[v][s]
}
})
}
})
console.log('filterKey', data, filterKey, fieldParent)
if (filterKey) {
setOptions(data.filter(v => v.nodeName === filterKey))
} else {
setOptions(data)
}
}
} else {
message.error(msg)
}
console.log('data', data)
}
return (
<Select
onFocus={onfocus}
style={{ width: '100%' }}
onChange={selectChange}
disabled={disabled}
placeholder={!disabled ? placeholder : null}
>
{
options.map((v, i) => <Option value={v.nodeValue} key={i}>{v.nodeValue}</Option>)
}
</Select>
)
}
export default RelevanceSelect
\ No newline at end of file
import React, { useEffect, useMemo } from 'react'
import { Radio, Checkbox } from 'antd'
import './index.less'
const TileSelect = (props) => {
console.log('props', props)
return (
<div className='tileSelect'>
123
</div>
)
}
export default TileSelect
\ No newline at end of file
@import '~antd/es/style/themes/default.less';
.tileSelect {
width: 100%;
min-height: 30px;
&[disabled='true'] {
background: #f8fafc;
}
padding: 0 5px;
.@{ant-prefix}-checkbox-wrapper {
margin-left: 8px;
}
.@{ant-prefix}-radio-wrapper {
margin-top: 5px;
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ import ComboBox from './ComboBox'
import RadioButton from './RadioButton'
import CheckBox from './CheckBox'
import CascadeSelector from './CascadeSelector'
import RelevanceSelect from './RelevanceSelect'
import PersonSelector from './PersonSelector'
import AccountSelector from './AccountSelector'
import DeptSelector from './DeptSelector'
......@@ -10,6 +11,7 @@ const select = {
ComboBox,
RadioButton,
CheckBox,
RelevanceSelect,
PersonSelector,
CascadeSelector,
AccountSelector,
......
......@@ -5,25 +5,19 @@ import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process'
const FieldNames = (props) => {
const { value, onChange, addons } = props
console.log('props', props)
const { tableNameParent } = addons.formData
const [fieldName, setFieldName] = useState([])
// const { tableName } = useContext(GlobalStore)
// console.log('字段名称', props)
const change = (value) => {
onChange(value)
}
const onFocus = async () => {
// if (!tableName) {
// return message.info('请在表单配置中选择表名!')
// }
console.log(addons.getSchemaByPath('tableName'))
const { data } = await ReloadTableFields({ tableName: '事件_测试02' })
console.log('data', data)
if (!tableNameParent) {
return message.info('缺少表名!')
}
const { data } = await ReloadTableFields({ tableName: tableNameParent })
if (Array.isArray(data.root)) {
setFieldName(data.root)
}
......
......@@ -68,10 +68,8 @@ const TextInput = (props) => {
let getValue = async (params) => {
const [rule, value, callback] = params
const { code, data, msg } = await GetFieldValueFromTable(tableName, fieldName, `${fieldName}=${value}`)
if (code === 0) {
if (Array.isArray(data) && data.length) {
callback(new Error(`${title}已重复,请重新输入`));
}
if (Array.isArray(data) && data.length) {
callback(new Error(`${title}已重复,请重新输入`));
} else {
callback()
}
......
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