提交 6dba2d1c authored 作者: 姚鑫国's avatar 姚鑫国

新增树多选组件

上级 23d8ba1b
/**
* 姚鑫国
* 2024-07-05 20点37分
* 树多选组件
*/
import { TreeSelect } from 'antd';
import React, { useEffect, useState } from 'react';
const { SHOW_PARENT } = TreeSelect;
export default function TreeSelectDiy(props) {
const { value, onChange, json, disabled, treeData } = props;
const [data, setData] = useState([]);
const onChangeS = v => {
onChange(v);
};
useEffect(() => {
setData(treeData)
}, [treeData]);
return (
<TreeSelect
labelInValue
disabled={disabled}
treeData={data}
value={value}
onChange={onChangeS}
treeCheckable
showCheckedStrategy={SHOW_PARENT}
searchPlaceholder="请选择"
placeholder={json.placeholder}
style={{
width: '100%',
}}
{...json.otherProps}
/>
)
}
......@@ -33,6 +33,7 @@ import MyBlockRenderer from '../App/MyBlockRender';
import { Flex, List as MobileList, Switch as MobileSwitch, List } from 'antd-mobile';
import ReactEcharts from 'echarts-for-react';
import ZdyTable from '../Table/index';
import TreeSelectDiy from '../TreeSelect/index';
import { connect } from 'dva';
import UploadCom from '../libs/UploadCom';
import TableSelect from '../libs/TableSelect';
......@@ -444,7 +445,7 @@ export default class TableCom extends Component {
}
}
dataFilter = ['Select', 'Radio', 'Checkbox', 'Cascader'];
dataFilter = ['Select', 'Radio', 'Checkbox', 'Cascader', 'TreeSelect'];
getData = (json, dataColumn, obj, init) => {
const { formKey, uuid } = this.props;
......@@ -3084,6 +3085,36 @@ ${obj[dataColumn.base52]}
/>,
);
break;
case 'TreeSelect':
if (json?.otherProps) {
otherProps = json?.otherProps;
try {
otherProps = new Function(otherProps)();
} catch (e) {
otherProps = {};
}
}
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue,
rules:
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择' + dataColumn.title,
},
],
})(
<TreeSelectDiy
value={this.props.form.getFieldsValue()[dataColumn.base52]}
treeData={options}
json={json}
disabled={disabled}
data-base52={dataColumn.base52}
/>
);
break;
case 'Select':
if (json?.otherProps) {
otherProps = json?.otherProps;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论