mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
Merge pull request #3566 from 2betop/chore-form-item-default-value
chore: 调整表单项默认值的处理, 原来的实现会导致其他场景出问题,换种方式解决 #2674 的问题
This commit is contained in:
commit
009e865e48
@ -23,6 +23,7 @@ import hoistNonReactStatic from 'hoist-non-react-statics';
|
|||||||
import {withRootStore} from '../../WithRootStore';
|
import {withRootStore} from '../../WithRootStore';
|
||||||
import {FormBaseControl, FormItemWrap} from './Item';
|
import {FormBaseControl, FormItemWrap} from './Item';
|
||||||
import {Api} from '../../types';
|
import {Api} from '../../types';
|
||||||
|
import {TableStore} from '../../store/table';
|
||||||
|
|
||||||
export interface ControlOutterProps extends RendererProps {
|
export interface ControlOutterProps extends RendererProps {
|
||||||
formStore?: IFormStore;
|
formStore?: IFormStore;
|
||||||
@ -195,10 +196,13 @@ export function wrapControl<
|
|||||||
|
|
||||||
// 如果没有初始值,通过 onChange 设置过去
|
// 如果没有初始值,通过 onChange 设置过去
|
||||||
if (
|
if (
|
||||||
this.props.data === this.props.scope &&
|
|
||||||
onChange &&
|
onChange &&
|
||||||
typeof propValue === 'undefined' &&
|
typeof propValue === 'undefined' &&
|
||||||
typeof store?.getValueByName(model.name, false) === 'undefined'
|
typeof store?.getValueByName(model.name, false) === 'undefined' &&
|
||||||
|
// todo 后续再优化这个判断,
|
||||||
|
// 目前 input-table 中默认值会给冲掉,所以加上这个判断
|
||||||
|
// 对应 issue 为 https://github.com/baidu/amis/issues/2674
|
||||||
|
store?.storeType !== TableStore.name
|
||||||
) {
|
) {
|
||||||
onChange(model.tmpValue, model.name, false, true);
|
onChange(model.tmpValue, model.name, false, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user