fix(LinkageRules): avoid to change observable object (#3538)
This commit is contained in:
parent
65d1b41165
commit
bb46697e71
@ -149,7 +149,7 @@ const WithForm = (props: WithFormProps) => {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
getSubscriber(action, field, rule, form, variables, localVariables),
|
getSubscriber(action, field, rule, variables, localVariables),
|
||||||
{ fireImmediately: true },
|
{ fireImmediately: true },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -229,7 +229,6 @@ function getSubscriber(
|
|||||||
action: any,
|
action: any,
|
||||||
field: any,
|
field: any,
|
||||||
rule: any,
|
rule: any,
|
||||||
form: FormilyForm<any>,
|
|
||||||
variables: VariablesContextType,
|
variables: VariablesContextType,
|
||||||
localVariables: VariableOption[],
|
localVariables: VariableOption[],
|
||||||
): (value: string, oldValue: string) => void {
|
): (value: string, oldValue: string) => void {
|
||||||
@ -240,7 +239,6 @@ function getSubscriber(
|
|||||||
value: action.value,
|
value: action.value,
|
||||||
field,
|
field,
|
||||||
condition: rule.condition,
|
condition: rule.condition,
|
||||||
values: form.values,
|
|
||||||
variables,
|
variables,
|
||||||
localVariables,
|
localVariables,
|
||||||
});
|
});
|
||||||
@ -251,7 +249,7 @@ function getSubscriber(
|
|||||||
const fieldName = getFieldNameByOperator(action.operator);
|
const fieldName = getFieldNameByOperator(action.operator);
|
||||||
|
|
||||||
// 防止重复赋值
|
// 防止重复赋值
|
||||||
if (!field.stateOfLinkageRules[fieldName]) {
|
if (!field.stateOfLinkageRules?.[fieldName]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ interface Props {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
condition;
|
condition;
|
||||||
values;
|
|
||||||
variables: VariablesContextType;
|
variables: VariablesContextType;
|
||||||
localVariables: VariableOption[];
|
localVariables: VariableOption[];
|
||||||
}
|
}
|
||||||
@ -36,7 +35,6 @@ export const collectFieldStateOfLinkageRules = ({
|
|||||||
value,
|
value,
|
||||||
field,
|
field,
|
||||||
condition,
|
condition,
|
||||||
values,
|
|
||||||
variables,
|
variables,
|
||||||
localVariables,
|
localVariables,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { untracked } from '@formily/reactive';
|
import { raw, untracked } from '@formily/reactive';
|
||||||
import { getValuesByPath } from '@nocobase/utils/client';
|
import { getValuesByPath } from '@nocobase/utils/client';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react';
|
import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
@ -124,7 +124,13 @@ const VariablesProvider = ({ children }) => {
|
|||||||
data = await waitForData;
|
data = await waitForData;
|
||||||
clearRequested(url);
|
clearRequested(url);
|
||||||
}
|
}
|
||||||
current[key] = data.data.data;
|
|
||||||
|
// fix https://nocobase.height.app/T-3144,使用 `raw` 方法是为了避免触发 autorun,以修复 T-3144 的错误
|
||||||
|
if (!raw(current)[key]) {
|
||||||
|
// 把接口返回的数据保存起来,避免重复请求
|
||||||
|
raw(current)[key] = data.data.data;
|
||||||
|
}
|
||||||
|
|
||||||
current = getValuesByPath(current, key);
|
current = getValuesByPath(current, key);
|
||||||
} else {
|
} else {
|
||||||
current = getValuesByPath(current, key);
|
current = getValuesByPath(current, key);
|
||||||
|
Loading…
Reference in New Issue
Block a user