FieldSwitch.js 1.4 KB
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)}>&#xe637;</i>
					<span style={{opacity:'0'}}>1</span>
					<Popconfirm title="确认删除吗?" onConfirm={del}>
						<i className={cx('upvi-icon',l.colorD,l.btn)} style={{fontSize:'22px'}}>&#xe61c;</i>
					</Popconfirm>
				</span> 
			</div>
    	)
    }
} 

export default FieldSwitch;