FieldSwitch.js
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React,{PropTypes} from 'react';
import cx from 'classnames';
import l from './fieldSwitch.les';
import {Switch,Row,Col,Icon,Popconfirm} from 'antd';
import Collapse from 'react-collapse';
class FieldSwitch extends React.Component {
constructor(props) {
super(props);
}
static propTypes = {
editable: PropTypes.bool,
edit:PropTypes.func,
del:PropTypes.func,
onChange:PropTypes.func,
title:PropTypes.string,
defaultChecked:PropTypes.bool,
checked:PropTypes.bool
}
static defaultProps ={
title:'',
onChange:()=>{},
edit:()=>{},
del:()=>{},
editable:true,
defaultChecked:true
}
render(){
const {editable,edit,del,onChange,title,defaultChecked,checked}=this.props;
return (
<div className={cx(l.switch_wrap)}>
<span className={cx(l.left)}>{title}</span>
<span className={cx(l.right)}>
<Switch onChange={onChange} size="small" defaultChecked={true} checked={checked} className={cx(l.switch)} />
</span>
<span className={cx(l.action,l.dis)}>
<i onClick={edit} className={cx('upvi-icon',l.colorE,l.btn)}></i>
<span style={{opacity:'0'}}>1</span>
<Popconfirm title="确认删除吗?" onConfirm={del}>
<i className={cx('upvi-icon',l.colorD,l.btn)} style={{fontSize:'22px'}}></i>
</Popconfirm>
</span>
</div>
)
}
}
export default FieldSwitch;