king
2023-08-17 c7aece35a62b6e91fd98a625bf0e53f64bfbd18d
src/tabviews/zshare/mutilform/mkNumberInput/index.jsx
@@ -4,7 +4,7 @@
import MKEmitter from '@/utils/events.js'
import './index.scss'
// import './index.scss'
class MKNumberInput extends Component {
  constructor(props) {
@@ -37,6 +37,7 @@
  mkFormHandle = (type, uuid, value) => {
    if (uuid !== this.props.config.uuid) return
    if (type === 'focus') {
      let node = document.getElementById(uuid)
      node.select()
@@ -48,17 +49,40 @@
  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 = () => {
    const { config } = this.props
    if (config.enter === 'false') return
    if (config.enter === 'tab') {
      MKEmitter.emit('mkFC', 'focus', config.tabUuid)
    } else {
      MKEmitter.emit('mkFC', 'focus', config.tabUuid)
      this.props.onSubmit()
    }
  }
  render() {
    const { config, onSubmit } = this.props
    const { config } = this.props
    const { value, precision } = this.state
    if (precision === null) {
      return (<InputNumber id={config.uuid} value={value} disabled={config.readonly} onChange={this.handleChange} onPressEnter={onSubmit}/>)
      return (<InputNumber id={config.uuid} value={value} disabled={config.readonly} onChange={this.handleChange} onPressEnter={this.handleSubmit}/>)
    } else {
      return (<InputNumber id={config.uuid} value={value} precision={precision} disabled={config.readonly} onChange={this.handleChange} onPressEnter={onSubmit} />)
      return (<InputNumber id={config.uuid} value={value} precision={precision} disabled={config.readonly} onChange={this.handleChange} onPressEnter={this.handleSubmit} />)
    }
  }
}