3
3
* 数组组件
4
4
*/
5
5
6
- import React from 'react' ;
6
+ import React , { useState } from 'react' ;
7
7
import listHoc from '../../components/listHoc' ;
8
8
import * as Icons from '@ant-design/icons' ;
9
-
10
- import { Button } from 'antd' ;
9
+ import { isObj } from '../../base/utils' ;
10
+ import { Button , Modal , Drawer } from 'antd' ;
11
11
12
12
function FrButton ( { icon, children, ...rest } ) {
13
13
let iconName ;
@@ -25,12 +25,71 @@ function FrButton({ icon, children, ...rest }) {
25
25
const IconComponent = Icons [ iconName ] ;
26
26
if ( IconComponent ) {
27
27
return (
28
- < Button { ...rest } icon = { < IconComponent /> } >
28
+ < Button { ...rest } size = "small" icon = { < IconComponent /> } >
29
29
{ children }
30
30
</ Button >
31
31
) ;
32
32
}
33
- return < Button { ...rest } > { children } </ Button > ;
33
+ return (
34
+ < Button { ...rest } size = "small" >
35
+ { children }
36
+ </ Button >
37
+ ) ;
34
38
}
35
39
36
- export default listHoc ( FrButton ) ;
40
+ const List = listHoc ( FrButton ) ;
41
+
42
+ const ListWithModal = props => {
43
+ const { options, schema } = props || { } ;
44
+ const [ show , setShow ] = useState ( false ) ;
45
+ const toggle = ( ) => setShow ( o => ! o ) ;
46
+ if ( options && options . modal ) {
47
+ const config = isObj ( options . modal ) ? options . modal : { } ;
48
+ const { text } = config ;
49
+ return (
50
+ < div >
51
+ < a className = "pointer" onClick = { toggle } >
52
+ { text && typeof text === 'string' ? '+ ' + text : '+ 配置' }
53
+ </ a >
54
+ < Modal
55
+ title = { ( schema && schema . title ) || '子配置' }
56
+ visible = { show }
57
+ onCancel = { toggle }
58
+ footer = { null }
59
+ width = "80%"
60
+ { ...config }
61
+ style = { { maxWidth : 800 , ...config . style } }
62
+ >
63
+ < div className = "fr-wrapper" >
64
+ < List { ...props } />
65
+ </ div >
66
+ </ Modal >
67
+ </ div >
68
+ ) ;
69
+ }
70
+ if ( options && options . drawer ) {
71
+ const config = isObj ( options . drawer ) ? options . drawer : { } ;
72
+ const { text } = config ;
73
+ return (
74
+ < div >
75
+ < a className = "pointer" onClick = { toggle } >
76
+ { text && typeof text === 'string' ? '+ ' + text : '+ 配置' }
77
+ </ a >
78
+ < Drawer
79
+ title = { ( schema && schema . title ) || '子配置' }
80
+ visible = { show }
81
+ onClose = { toggle }
82
+ width = "80%"
83
+ { ...config }
84
+ >
85
+ < div className = "fr-wrapper" >
86
+ < List { ...props } />
87
+ </ div >
88
+ </ Drawer >
89
+ </ div >
90
+ ) ;
91
+ }
92
+ return < List { ...props } /> ;
93
+ } ;
94
+
95
+ export default ListWithModal ;
0 commit comments