| | |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | |
| | | import './index.scss' |
| | | // import './index.scss' |
| | | |
| | | class MKNumberInput extends Component { |
| | | constructor(props) { |
| | |
| | | |
| | | mkFormHandle = (type, uuid, value) => { |
| | | if (uuid !== this.props.config.uuid) return |
| | | |
| | | if (type === 'focus') { |
| | | let node = document.getElementById(uuid) |
| | | node.select() |
| | | node && node.select() |
| | | } else if (type === 'input') { |
| | | this.setState({value}) |
| | | this.props.onChange(value, true) |
| | | } else if (type === 'reset') { |
| | | let _val = this.props.config.initval |
| | | |
| | | this.setState({value: _val}, () => { |
| | | let node = document.getElementById(this.props.config.uuid) |
| | | node && node.select() |
| | | }) |
| | | |
| | | this.props.onChange(_val) |
| | | } |
| | | } |
| | | |
| | | handleChange = (val) => { |
| | | this.setState({value: val}) |
| | | this.props.onChange(val) |
| | | |
| | | let _val = val |
| | | |
| | | if (typeof(_val) !== 'number') { |
| | | _val = parseFloat(_val) |
| | | |
| | | if (isNaN(_val)) { |
| | | _val = '' |
| | | } |
| | | } |
| | | |
| | | this.props.onChange(_val) |
| | | } |
| | | |
| | | handleSubmit = () => { |