| | |
| | | let val = count - 1 |
| | | |
| | | if (btn.min !== '' && val < btn.min) { |
| | | message.warning(`不可小于${btn.min}!`) |
| | | message.warning(`${window.GLOB.dict['less_limit'] || '不可小于'}${btn.min}!`) |
| | | return |
| | | } else if (btn.max !== '' && val > btn.max) { |
| | | message.warning(`不可大于${btn.max}!`) |
| | | message.warning(`${window.GLOB.dict['max_limit'] || '不可大于'}${btn.max}!`) |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.timer = setTimeout(() => { |
| | | this.props.onChange(val) |
| | | }, 1000) |
| | | }, btn.formType === 'count_line' ? 100 : 500) |
| | | } |
| | | |
| | | plus = () => { |
| | |
| | | let val = count + 1 |
| | | |
| | | if (btn.min !== '' && val < btn.min) { |
| | | message.warning(`不可小于${btn.min}!`) |
| | | message.warning(`${window.GLOB.dict['less_limit'] || '不可小于'}${btn.min}!`) |
| | | return |
| | | } else if (btn.max !== '' && val > btn.max) { |
| | | message.warning(`不可大于${btn.max}!`) |
| | | message.warning(`${window.GLOB.dict['max_limit'] || '不可大于'}${btn.max}!`) |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.timer = setTimeout(() => { |
| | | this.props.onChange(val) |
| | | }, 1000) |
| | | }, btn.formType === 'count_line' ? 100 : 500) |
| | | } |
| | | |
| | | submit = () => { |
| | |
| | | const { count, orival } = this.state |
| | | |
| | | if (count === '') { |
| | | message.warning(`不可为空!`) |
| | | message.warning(window.GLOB.dict['not_empty'] || '不可为空!') |
| | | this.setState({count: 0}) |
| | | return |
| | | } else if (btn.min !== '' && count < btn.min) { |
| | | message.warning(`不可小于${btn.min}!`) |
| | | message.warning(`${window.GLOB.dict['less_limit'] || '不可小于'}${btn.min}!`) |
| | | return |
| | | } else if (btn.max !== '' && count > btn.max) { |
| | | message.warning(`不可大于${btn.max}!`) |
| | | message.warning(`${window.GLOB.dict['max_limit'] || '不可大于'}${btn.max}!`) |
| | | return |
| | | } |
| | | |
| | |
| | | |
| | | this.timer = setTimeout(() => { |
| | | this.props.onChange(count) |
| | | }, 1000) |
| | | }, 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() { |
| | |
| | | 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> |
| | | ) |