@@ -19,19 +19,74 @@ import {
1919 InputNumber ,
2020 CPicker as DatePicker ,
2121 ComplexRadio ,
22- Field
22+ Field ,
23+ TreeSelect
2324} from ' cloud-react' ;
2425
2526const { RangePicker , TimeRangePicker } = DatePicker;
2627
2728const wrapperStyle = { position: ' relative' , top: 2 };
2829
30+ const treeData = [
31+ {
32+ id: 11 ,
33+ name: ' 禁止删除节点' ,
34+ pId: 1 ,
35+ disableRemove: true ,
36+ children: [
37+ {
38+ id: 113 ,
39+ name: ' 删除三个' ,
40+ pId: 11 ,
41+ children: [
42+ {
43+ id: 1131 ,
44+ name: ' 禁止删除节点31' ,
45+ pId: 113 ,
46+ children: []
47+ },
48+ {
49+ id: 1132 ,
50+ name: ' 禁止删除节点32' ,
51+ pId: 113 ,
52+ children: [
53+ {
54+ id: 11321 ,
55+ name: ' 禁止删除节点321' ,
56+ pId: 1132 ,
57+ children: []
58+ }
59+ ]
60+ }
61+ ]
62+ },
63+ {
64+ id: 114 ,
65+ name: ' 禁止删除节点4' ,
66+ pId: 11 ,
67+ children: []
68+ }
69+ ]
70+ },
71+ {
72+ id: 14 ,
73+ name: ' 未分类' ,
74+ pId: 1 ,
75+ disableRemove: true ,
76+ disableAdd: true ,
77+ disableRename: true ,
78+ children: []
79+ }
80+ ];
81+
2982export default function FormHorizontalDemo () {
3083 const field = Field .useField ();
3184 const [size , setSize ] = useState (' default' );
3285 const [labelAlign , setLabelAlign ] = useState (' right' );
3386 const [layout , setLayout ] = useState (' horizontal' );
3487 const [disabled , setDisabled ] = useState (false );
88+ const [singleNodes , setSingleNodes ] = useState ([]);
89+ const [selectedNodes , setSelectedNodes ] = useState ([]);
3590
3691 const [value , setValue ] = useState ();
3792 const radioList = [
@@ -54,20 +109,20 @@ export default function FormHorizontalDemo() {
54109 < Checkbox value= {disabled} checked= {disabled} onChange= {setDisabled}> 禁用表单< / Checkbox>
55110 < / Form .Item >
56111 < Form .Item label= " 设置表单尺寸" wrapperStyle= {wrapperStyle}>
57- < Radio .Group value= {size} onChange= {setSize}>
112+ < Radio .Group value= {size} onChange= {setSize} horizontal >
58113 < Radio value= " large" > large< / Radio>
59114 < Radio value= " default" > default< / Radio>
60115 < Radio value= " small" > small< / Radio>
61116 < / Radio .Group >
62117 < / Form .Item >
63118 < Form .Item label= " 设置对齐方式" wrapperStyle= {wrapperStyle}>
64- < Radio .Group value= {labelAlign} onChange= {setLabelAlign}>
119+ < Radio .Group value= {labelAlign} onChange= {setLabelAlign} horizontal >
65120 < Radio value= " right" > right< / Radio>
66121 < Radio value= " left" > left< / Radio>
67122 < / Radio .Group >
68123 < / Form .Item >
69124 < Form .Item label= " 设置布局方式" wrapperStyle= {wrapperStyle}>
70- < Radio .Group value= {layout} onChange= {setLayout}>
125+ < Radio .Group value= {layout} onChange= {setLayout} horizontal >
71126 < Radio value= " horizontal" > horizontal< / Radio>
72127 < Radio value= " vertical" > vertical< / Radio>
73128 < / Radio .Group >
@@ -109,6 +164,7 @@ export default function FormHorizontalDemo() {
109164
110165 < Form .Item label= " 订单筛选类型" required wrapperStyle= {wrapperStyle}>
111166 < Radio .Group
167+ horizontal
112168 disabled= {disabled}
113169 {... field .init (' type' , {
114170 rules: [{ required: true , message: ' 请选择订单筛选类型' }]
@@ -164,8 +220,10 @@ export default function FormHorizontalDemo() {
164220 / >
165221 < / Form .Item >
166222
167- < Form .Item label= " 所在国家" required>
223+ < Form .Item label= " 所在国家-单选 " required>
168224 < Select
225+ allowClear
226+ searchable
169227 disabled= {disabled}
170228 {... field .init (' country' , {
171229 rules: [{ required: true , message: ' 请选择所在国家' }]
@@ -176,6 +234,52 @@ export default function FormHorizontalDemo() {
176234 < / Select>
177235 < / Form .Item >
178236
237+ < Form .Item label= " 多选" required>
238+ < Select
239+ allowClear
240+ maxTagCount= {1 }
241+ // searchable
242+ multiple
243+ disabled= {disabled}
244+ {... field .init (' country1' , {
245+ rules: [{ required: true , message: ' 请选择' }]
246+ })}>
247+ < Select .Option value= {1 }> A < / Select .Option >
248+ < Select .Option value= {2 }> B < / Select .Option >
249+ < Select .Option value= {3 }> C < / Select .Option >
250+ < / Select>
251+ < / Form .Item >
252+
253+ < Form .Item label= " 树下拉单选" required>
254+ < TreeSelect
255+ searchable
256+ allowClear
257+ type= " single"
258+ isUnfold
259+ containParentNode
260+ placeholder= " 选择一个选项"
261+ style= {{ width: 328 }}
262+ dataSource= {treeData}
263+ value= {singleNodes}
264+ onChange= {(_ , selectedNodes ) => setSingleNodes (selectedNodes)}
265+ / >
266+ < / Form .Item >
267+
268+ < Form .Item label= " 树下拉多选" required>
269+ < TreeSelect
270+ searchable
271+ allowClear
272+ type= " multiple"
273+ isUnfold
274+ containParentNode
275+ placeholder= " 选择一个选项"
276+ style= {{ width: 328 }}
277+ dataSource= {treeData}
278+ value= {selectedNodes}
279+ onChange= {(_ , selectedNodes ) => setSelectedNodes (selectedNodes)}
280+ / >
281+ < / Form .Item >
282+
179283 < Form .Item wrapperCol= {{ offset: 6 }}>
180284 < Button disabled= {disabled} type= " primary" style= {{ marginRight: 10 }} onClick= {() => {
181285 field .validate (err => {
0 commit comments