king
2021-09-28 432b788acf901b0720184b8ee8bc81a2e6fa47e0
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Radio } from 'antd'
 
class MKRadio extends Component {
  static propTpyes = {
    config: PropTypes.object,
    onChange: PropTypes.func
  }
 
  state = {
    defaultValue: this.props.config.initval
  }
 
  onChange = (e) => {
    let value = e.target.value
    this.props.onChange(value)
  }
 
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
 
  render() {
    const { config } = this.props
    const { defaultValue } = this.state
 
    return (
      <Radio.Group defaultValue={defaultValue} disabled={config.readonly} onChange={this.onChange}>
        {config.options.map(option => <Radio key={option.key} disabled={option.$disabled} value={option.value}>{option.label}</Radio>)}
      </Radio.Group>
    )
  }
}
 
export default MKRadio