fix: 修复表格复制和直发单修改没有分组项 (#1479)

Reviewed-on: daoyoucloud/tachybase#1479
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-08-23 12:04:44 +08:00 committed by sealday
parent 4c52c7bca7
commit a13cbfcc2c
2 changed files with 37 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
import { createForm, Form, Schema, useField } from '@tachybase/schema';
import { createForm, Form, RecursionField, Schema, useField, useFieldSchema } from '@tachybase/schema';
import { Spin } from 'antd';
@ -11,7 +11,8 @@ import {
useCollectionRecord,
} from '../data-source';
import { RecordProvider, useRecord } from '../record-provider';
import { useActionContext } from '../schema-component';
import { useActionContext, useDesignable } from '../schema-component';
import { Templates as DataTemplateSelect } from '../schema-component/antd/form-v2/Templates';
import { BlockProvider, useBlockRequestContext } from './BlockProvider';
import { FormActiveFieldsProvider } from './hooks/useFormActiveFields';
@ -84,7 +85,9 @@ const InternalFormBlockProvider = (props) => {
return (
<FormBlockContext.Provider value={formBlockValue}>
<RecordProvider isNew={record?.isNew} parent={record?.parentRecord?.data} record={record?.data}>
<div ref={formBlockRef}>{props.children}</div>
<div ref={formBlockRef}>
<RenderChildrenWithDataTemplates form={form} />
</div>
</RecordProvider>
</FormBlockContext.Provider>
);
@ -163,7 +166,20 @@ export const useFormBlockProps = (shouldClearInitialValues = false) => {
};
};
/**
const RenderChildrenWithDataTemplates = ({ form }) => {
const FieldSchema = useFieldSchema();
const { findComponent } = useDesignable();
const field = useField();
const Component = findComponent(field.component?.[0]) || React.Fragment;
return (
<Component {...field.componentProps}>
<DataTemplateSelect style={{ marginBottom: 18 }} form={form} />
<RecursionField schema={FieldSchema} onlyRenderProperties />
</Component>
);
};
/**InternalFormBlockProvider
* @internal
*/
export const findFormBlock = (schema: Schema) => {

View File

@ -396,6 +396,10 @@ export class RecordService {
delete element.record_id;
delete element.id;
});
purchaseData.group_weight_items?.forEach((groupItem) => {
delete groupItem.record_id;
delete groupItem.id;
});
await this.db.getRepository('records').create({ values: purchaseData, transaction, context });
// 2. 创建租赁出库单
const leaseData = {
@ -418,6 +422,10 @@ export class RecordService {
delete element.record_id;
delete element.id;
});
leaseData.group_weight_items?.forEach((groupItem) => {
delete groupItem.record_id;
delete groupItem.id;
});
await this.db.getRepository('records').create({ values: leaseData, transaction, context });
}
if (values.record_category === RecordTypes.rentDirect && values.category === RecordCategory.lease2lease) {
@ -458,6 +466,11 @@ export class RecordService {
delete element.record_id;
delete element.id;
});
leaseInData.group_weight_items?.forEach((groupItem) => {
delete groupItem.record_id;
delete groupItem.id;
});
await this.db.getRepository('records').create({ values: leaseInData, transaction, context });
// 2.创建租赁出库单
const leaseOutData = {
@ -480,6 +493,10 @@ export class RecordService {
delete element.record_id;
delete element.id;
});
leaseOutData.group_weight_items?.forEach((groupItem) => {
delete groupItem.record_id;
delete groupItem.id;
});
await this.db.getRepository('records').create({ values: leaseOutData, transaction, context });
}
}