| | |
| | | import PropTypes from 'prop-types' |
| | | import { Switch } from 'antd' |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | |
| | | class MKSwitch extends Component { |
| | | static propTpyes = { |
| | | config: PropTypes.object, |
| | |
| | | onChange = (val) => { |
| | | const { config } = this.props |
| | | |
| | | let other = {} |
| | | if (config.subFields) { |
| | | let _val = val ? config.openText : config.closeText |
| | | config.subFields.forEach((n, i) => { |
| | | other[n.field] = _val || '' |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkFC', 'input', n.uuid, _val || '') |
| | | }, i * 5) |
| | | }) |
| | | } |
| | | |
| | | if (val) { |
| | | this.props.onChange(config.openVal) |
| | | this.props.onChange(config.openVal, other) |
| | | } else { |
| | | this.props.onChange(config.closeVal) |
| | | this.props.onChange(config.closeVal, other) |
| | | } |
| | | } |
| | | |