File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react' ;
2+ import { Alert , Input } from 'antd' ;
3+ import { FilterRules } from 'dt-react-component' ;
4+ import { IComponentProps } from 'dt-react-component/filterRules' ;
5+
6+ import { INIT_ROW_VALUES , IRow , MORE_INIT_DATA } from './constants' ;
7+
8+ const MyInput = ( { rowValues : { input } , rowKey, onChange } : IComponentProps < IRow > ) => (
9+ < Input value = { input } onChange = { ( e ) => onChange ?.( rowKey , { input : e . target . value } ) } />
10+ ) ;
11+
12+ export default ( ) => {
13+ const [ data , setData ] = useState ( MORE_INIT_DATA ) ;
14+
15+ return (
16+ < >
17+ < Alert
18+ message = "可以通过操作按钮增加删除数据,切换且或节点内容"
19+ style = { { marginBottom : 16 } }
20+ />
21+ < FilterRules < IRow >
22+ component = { ( props ) => < MyInput { ...props } /> }
23+ value = { data }
24+ onChange = { ( value : any ) => setData ( value ) }
25+ initValues = { INIT_ROW_VALUES }
26+ />
27+ </ >
28+ ) ;
29+ } ;
Original file line number Diff line number Diff line change @@ -12,4 +12,40 @@ export const INIT_DATA = {
1212 } ,
1313} ;
1414
15+ export const MORE_INIT_DATA = {
16+ key : shortid ( ) ,
17+ level : 1 ,
18+ type : 1 ,
19+ children : [
20+ {
21+ rowValues : {
22+ input : '' ,
23+ } ,
24+ key : shortid ( ) ,
25+ level : 1 ,
26+ } ,
27+ {
28+ key : shortid ( ) ,
29+ type : 2 ,
30+ level : 2 ,
31+ children : [
32+ {
33+ key : shortid ( ) ,
34+ level : 2 ,
35+ rowValues : {
36+ input : '' ,
37+ } ,
38+ } ,
39+ {
40+ key : shortid ( ) ,
41+ rowValues : {
42+ input : '' ,
43+ } ,
44+ level : 2 ,
45+ } ,
46+ ] ,
47+ } ,
48+ ] ,
49+ } ;
50+
1551export type IRow = typeof INIT_ROW_VALUES ;
Original file line number Diff line number Diff line change 1717## 示例
1818
1919<code src =" ./demos/basic.tsx " >受控方式使用</code >
20+ <code src =" ./demos/basicMore.tsx " >多条数据的使用</code >
2021<code src =" ./demos/basicUnController.tsx " >非受控方式使用</code >
2122<code src =" ./demos/basicCheck.tsx " >查看数据</code >
2223
You can’t perform that action at this time.
0 commit comments