fix: useParseDefaultValue (#3264)
This commit is contained in:
parent
894e1c8bf8
commit
641ca2dcca
@ -115,19 +115,27 @@ const useParseDefaultValue = () => {
|
||||
_run();
|
||||
|
||||
// 实现联动的效果,当依赖的变量变化时(如 `$nForm` 变量),重新解析默认值
|
||||
const dispose = reaction(() => {
|
||||
const obj = { [variableName]: variable?.ctx || {} };
|
||||
const path = getPath(fieldSchema.default);
|
||||
const value = getValuesByPath(obj, path);
|
||||
const dispose = reaction(
|
||||
() => {
|
||||
const obj = { [variableName]: variable?.ctx || {} };
|
||||
const path = getPath(fieldSchema.default);
|
||||
const value = getValuesByPath(obj, path);
|
||||
// fix https://nocobase.height.app/T-2212
|
||||
if (value === undefined) {
|
||||
// 返回一个随机值,确保能触发 run 函数
|
||||
return Math.random();
|
||||
}
|
||||
|
||||
// fix https://nocobase.height.app/T-2212
|
||||
if (value === undefined) {
|
||||
// 返回一个随机值,确保能触发 run 函数
|
||||
return Math.random();
|
||||
}
|
||||
|
||||
return value;
|
||||
}, run);
|
||||
return value;
|
||||
},
|
||||
_run,
|
||||
{
|
||||
equals: (oldValue, newValue) => {
|
||||
field.setValue(newValue);
|
||||
return oldValue === newValue;
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return dispose;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export {
|
||||
useInheritsTableColumnInitializerFields,
|
||||
useRecordCollectionDataSourceItems,
|
||||
useRemoveGridFormItem,
|
||||
useTableColumnInitializerFields
|
||||
useTableColumnInitializerFields,
|
||||
} from './utils';
|
||||
|
||||
export class SchemaInitializerPlugin extends Plugin {
|
||||
|
Loading…
Reference in New Issue
Block a user