fix: useRecord (#2911)

This commit is contained in:
katherinehhh 2023-10-25 17:27:21 +08:00 committed by GitHub
parent d492471ed5
commit 101e1f8f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -43,7 +43,6 @@ const InternalFormBlockProvider = (props) => {
if (service.loading && Object.keys(form?.initialValues)?.length === 0 && action) { if (service.loading && Object.keys(form?.initialValues)?.length === 0 && action) {
return <Spin />; return <Spin />;
} }
let content = ( let content = (
<div ref={formBlockRef}> <div ref={formBlockRef}>
<RenderChildrenWithDataTemplates form={form} /> <RenderChildrenWithDataTemplates form={form} />
@ -97,7 +96,6 @@ export const FormBlockProvider = (props) => {
if (isDetailBlock) { if (isDetailBlock) {
detailFlag = true; detailFlag = true;
if (!designable && __collection) { if (!designable && __collection) {
console.log(__collection === collection);
detailFlag = __collection === collection; detailFlag = __collection === collection;
} }
} }
@ -127,7 +125,7 @@ export const useFormBlockProps = () => {
if (addChild) { if (addChild) {
ctx.form?.query('parent').take((field) => { ctx.form?.query('parent').take((field) => {
field.disabled = true; field.disabled = true;
field.value = new Proxy({ ...record }, {}); field.value = new Proxy({ ...record?.__parent }, {});
}); });
} }
}); });

View File

@ -205,8 +205,8 @@ export const useCreateActionProps = () => {
// const values = omitBy(formValues, (value) => isEqual(JSON.stringify(value), '[{}]')); // const values = omitBy(formValues, (value) => isEqual(JSON.stringify(value), '[{}]'));
if (addChild) { if (addChild) {
const treeParentField = getTreeParentField(); const treeParentField = getTreeParentField();
values[treeParentField?.name ?? 'parent'] = currentRecord; values[treeParentField?.name ?? 'parent'] = currentRecord?.__parent;
values[treeParentField?.foreignKey ?? 'parentId'] = currentRecord.id; values[treeParentField?.foreignKey ?? 'parentId'] = currentRecord?.__parent?.id;
} }
actionField.data = field.data || {}; actionField.data = field.data || {};
actionField.data.loading = true; actionField.data.loading = true;