king
2021-09-26 6a0110feb3eb6515447c5a477f20eeaaaabb328b
src/tabviews/zshare/mutilform/mkNumberInput/index.jsx
@@ -20,8 +20,6 @@
    }
  }
  inputNumberRef = React.createRef()
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
@@ -40,26 +38,39 @@
  mkFormHandle = (type, uuid, value) => {
    if (uuid !== this.props.config.uuid) return
    if (type === 'focus') {
      this.inputNumberRef.current.focus()
      let node = document.getElementById(uuid)
      node.select()
    } else if (type === 'input') {
      this.setState({value})
      this.props.onChange(value, true)
    }
  }
  handleChange = (val) => {
    this.props.onChange(val)
    this.setState({value: 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 ref={this.inputNumberRef} 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 ref={this.inputNumberRef} 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} />)
    }
  }
}