import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { Checkbox } from 'antd'
|
|
class MKCheck extends Component {
|
static propTpyes = {
|
config: PropTypes.object,
|
onChange: PropTypes.func
|
}
|
|
state = {
|
defaultChecked: this.props.config.initval === this.props.config.openVal
|
}
|
|
onChange = (e) => {
|
const { config } = this.props
|
|
if (e.target.checked) {
|
this.props.onChange(config.openVal)
|
} else {
|
this.props.onChange(config.closeVal)
|
}
|
}
|
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { config } = this.props
|
const { defaultChecked } = this.state
|
|
return (
|
<Checkbox disabled={config.readonly} defaultChecked={defaultChecked} onChange={this.onChange}>{config.checkTip}</Checkbox>
|
)
|
}
|
}
|
|
export default MKCheck
|