From a1e9b18a4dbfd21e1bf4d5cb60974ac2f0115efd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 30 五月 2025 15:18:44 +0800 Subject: [PATCH] 2025-05-30 --- src/tabviews/zshare/mutilform/mkNumberInput/index.jsx | 28 +++++++++++++++++++++++----- 1 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx b/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx index 4b690c8..b842510 100644 --- a/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx +++ b/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx @@ -37,9 +37,10 @@ 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) @@ -48,7 +49,18 @@ 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 = () => { @@ -59,15 +71,21 @@ MKEmitter.emit('mkFC', 'focus', config.tabUuid) } else { MKEmitter.emit('mkFC', 'focus', config.tabUuid) - this.props.onSubmit() + this.props.onSubmit(config.tabUuid, config.errTabUuid) } } render() { const { config } = this.props const { value, precision } = this.state - - if (precision === null) { + + if (config.format === 'thdSeparator') { + if (precision === null) { + return (<InputNumber id={config.uuid} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} value={value} disabled={config.readonly} onChange={this.handleChange} onPressEnter={this.handleSubmit}/>) + } else { + return (<InputNumber id={config.uuid} formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')} parser={value => value.replace(/,*/g, '')} value={value} precision={precision} disabled={config.readonly} onChange={this.handleChange} onPressEnter={this.handleSubmit} />) + } + } else if (precision === null) { 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={this.handleSubmit} />) -- Gitblit v1.8.0