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/mkSelect/index.jsx | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/tabviews/zshare/mutilform/mkSelect/index.jsx b/src/tabviews/zshare/mutilform/mkSelect/index.jsx index 3e73927..7371348 100644 --- a/src/tabviews/zshare/mutilform/mkSelect/index.jsx +++ b/src/tabviews/zshare/mutilform/mkSelect/index.jsx @@ -17,6 +17,14 @@ } else { value = [] } + } else if (value) { + let option = config.oriOptions[0] + + if (option && typeof(option.value) !== typeof(value)) { + if (typeof(option.value) === 'number' && !isNaN(value)) { + value = +value + } + } } this.state = { @@ -40,7 +48,7 @@ } UNSAFE_componentWillReceiveProps (nextProps) { - const { config } = this.state + const { config, value } = this.state if (!is(fromJS(config.oriOptions), fromJS(nextProps.config.oriOptions))) { this.setState({ @@ -48,10 +56,24 @@ options: fromJS(nextProps.config.options).toJS() }) - if (typeof(config.initval) === 'string' && config.initval.indexOf('$first') > -1) { + let option = nextProps.config.oriOptions[0] + if (config.$first) { this.setState({ value: nextProps.config.initval, }) + if (config.linkFields && nextProps.config.initval) { + config.linkFields.forEach((m, i) => { + setTimeout(() => { + MKEmitter.emit('mkFP', m.uuid, nextProps.config.initval, 0) + }, (i + 1) * 70) + }) + } + } else if (option && typeof(option.value) !== typeof(value)) { + if (typeof(option.value) === 'number' && !isNaN(value)) { + this.setState({ + value: +value + }) + } } } } @@ -64,12 +86,15 @@ MKEmitter.removeListener('mkFC', this.mkFormFocus) } - mkFormFocus = (type, uuid) => { + mkFormFocus = (type, uuid, val, level) => { if (uuid !== this.props.config.uuid) return - if (type !== 'focus') return - - let _div = document.getElementById(uuid) - _div && _div.click && _div.click() + if (type === 'focus') { + let _div = document.getElementById(uuid) + _div && _div.click && _div.click() + } else if (type === 'input' && (!level || level < 10)) { + let _level = level || 1 + this.selectChange(val, _level++) + } } mkFormHandle = (uuid, parentId, level) => { @@ -78,7 +103,7 @@ const { config } = this.state let options = config.oriOptions.filter(option => option.ParentID === parentId || option.value === '') - let _option = options[0] || null + let _option = options[0] && !options[0].$disabled ? options[0] : null let val = _option ? _option.value : '' this.setState({ @@ -108,7 +133,7 @@ } } - selectChange = (val) => { + selectChange = (val, level) => { const { config } = this.state let other = {} @@ -117,7 +142,7 @@ option && config.subFields.forEach((n, i) => { other[n.field] = option[n.field] setTimeout(() => { - MKEmitter.emit('mkFC', 'input', n.uuid, option[n.field]) + MKEmitter.emit('mkFC', 'input', n.uuid, option[n.field], level) }, i * 5) }) } @@ -134,12 +159,13 @@ if (config.enter === 'tab') { MKEmitter.emit('mkFC', 'focus', config.tabUuid) } else if (config.enter === 'sub') { + config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid) if (config.linkFields || config.subFields || config.controlFields) { setTimeout(() => { - this.props.onSubmit() + this.props.onSubmit(config.tabUuid, config.errTabUuid) }, 1000) } else { - this.props.onSubmit() + this.props.onSubmit(config.tabUuid, config.errTabUuid) } } }) @@ -161,7 +187,7 @@ value={value} dropdownMatchSelectWidth={config.dropdown !== 'false'} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onSelect={this.selectChange} + onSelect={(val) => this.selectChange(val)} onChange={(val) => val === undefined && this.selectChange('')} disabled={config.readonly} > @@ -176,6 +202,7 @@ id={config.uuid} mode="multiple" defaultValue={value} + dropdownMatchSelectWidth={config.dropdown !== 'false'} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.mutilselectChange} disabled={config.readonly} -- Gitblit v1.8.0