| | |
| | | }, btn.formType === 'count_line' ? 100 : 500) |
| | | } |
| | | |
| | | onChange = (val) => { |
| | | const { btn } = this.props |
| | | |
| | | this.setState({count: val}) |
| | | |
| | | if (btn.formType === 'count_line' && typeof(val) === 'number') { |
| | | clearTimeout(this.timer) |
| | | |
| | | this.timer = setTimeout(() => { |
| | | this.props.onChange(val) |
| | | }, 100) |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { btn, disabled } = this.props |
| | | const { count } = this.state |
| | |
| | | return ( |
| | | <div onClick={(e) => e.stopPropagation()} className={'mk-btn-counter ' + (btn.size || '') + (disabled ? ' mk-disabled' : '')} style={btn.style}> |
| | | <span onClick={this.minus}><MinusOutlined /></span> |
| | | <span><InputNumber value={count} onChange={(val) => this.setState({count: val})} onBlur={this.submit} onPressEnter={this.submit}/></span> |
| | | <span><InputNumber value={count} onChange={this.onChange} onBlur={this.submit} onPressEnter={this.submit}/></span> |
| | | <span onClick={this.plus}><PlusOutlined /></span> |
| | | </div> |
| | | ) |