fix: useParseDefaultValue (#3264)

This commit is contained in:
katherinehhh 2023-12-26 10:43:12 +08:00 committed by GitHub
parent 894e1c8bf8
commit 641ca2dcca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 13 deletions

View File

@ -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;
}

View File

@ -49,7 +49,7 @@ export {
useInheritsTableColumnInitializerFields,
useRecordCollectionDataSourceItems,
useRemoveGridFormItem,
useTableColumnInitializerFields
useTableColumnInitializerFields,
} from './utils';
export class SchemaInitializerPlugin extends Plugin {