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:
parent
4c52c7bca7
commit
a13cbfcc2c
@ -1,5 +1,5 @@
|
|||||||
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
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';
|
import { Spin } from 'antd';
|
||||||
|
|
||||||
@ -11,7 +11,8 @@ import {
|
|||||||
useCollectionRecord,
|
useCollectionRecord,
|
||||||
} from '../data-source';
|
} from '../data-source';
|
||||||
import { RecordProvider, useRecord } from '../record-provider';
|
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 { BlockProvider, useBlockRequestContext } from './BlockProvider';
|
||||||
import { FormActiveFieldsProvider } from './hooks/useFormActiveFields';
|
import { FormActiveFieldsProvider } from './hooks/useFormActiveFields';
|
||||||
|
|
||||||
@ -84,7 +85,9 @@ const InternalFormBlockProvider = (props) => {
|
|||||||
return (
|
return (
|
||||||
<FormBlockContext.Provider value={formBlockValue}>
|
<FormBlockContext.Provider value={formBlockValue}>
|
||||||
<RecordProvider isNew={record?.isNew} parent={record?.parentRecord?.data} record={record?.data}>
|
<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>
|
</RecordProvider>
|
||||||
</FormBlockContext.Provider>
|
</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
|
* @internal
|
||||||
*/
|
*/
|
||||||
export const findFormBlock = (schema: Schema) => {
|
export const findFormBlock = (schema: Schema) => {
|
||||||
|
@ -396,6 +396,10 @@ export class RecordService {
|
|||||||
delete element.record_id;
|
delete element.record_id;
|
||||||
delete element.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 });
|
await this.db.getRepository('records').create({ values: purchaseData, transaction, context });
|
||||||
// 2. 创建租赁出库单
|
// 2. 创建租赁出库单
|
||||||
const leaseData = {
|
const leaseData = {
|
||||||
@ -418,6 +422,10 @@ export class RecordService {
|
|||||||
delete element.record_id;
|
delete element.record_id;
|
||||||
delete element.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 });
|
await this.db.getRepository('records').create({ values: leaseData, transaction, context });
|
||||||
}
|
}
|
||||||
if (values.record_category === RecordTypes.rentDirect && values.category === RecordCategory.lease2lease) {
|
if (values.record_category === RecordTypes.rentDirect && values.category === RecordCategory.lease2lease) {
|
||||||
@ -458,6 +466,11 @@ export class RecordService {
|
|||||||
delete element.record_id;
|
delete element.record_id;
|
||||||
delete element.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 });
|
await this.db.getRepository('records').create({ values: leaseInData, transaction, context });
|
||||||
// 2.创建租赁出库单
|
// 2.创建租赁出库单
|
||||||
const leaseOutData = {
|
const leaseOutData = {
|
||||||
@ -480,6 +493,10 @@ export class RecordService {
|
|||||||
delete element.record_id;
|
delete element.record_id;
|
||||||
delete element.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 });
|
await this.db.getRepository('records').create({ values: leaseOutData, transaction, context });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user