diff --git a/packages/client/src/schemas/add-new/index.tsx b/packages/client/src/schemas/add-new/index.tsx index e462e2344..704b629e6 100644 --- a/packages/client/src/schemas/add-new/index.tsx +++ b/packages/client/src/schemas/add-new/index.tsx @@ -384,6 +384,9 @@ function generateCardItemSchema(component) { type: 'void', title: '创建数据', 'x-decorator': 'Form', + 'x-decorator-props': { + useResource: '{{ Kanban.useCreateResource }}', + }, 'x-component': 'Action.Drawer', 'x-component-props': { useOkAction: '{{ Kanban.useCreateAction }}', diff --git a/packages/client/src/schemas/kanban/index.tsx b/packages/client/src/schemas/kanban/index.tsx index 1fe0c8dd2..35617bb76 100644 --- a/packages/client/src/schemas/kanban/index.tsx +++ b/packages/client/src/schemas/kanban/index.tsx @@ -415,6 +415,27 @@ export const Kanban: any = observer((props: any) => { ); }); +Kanban.useCreateResource = ({ onSuccess }) => { + const { props } = useKanban(); + const column = useContext(KanbanColumnContext); + const { collection } = useCollectionContext(); + const resource = Resource.make({ + resourceName: collection?.name || props.collectionName, + }); + const groupField = props.groupField; + const service = useRequest( + (params?: any) => { + return Promise.resolve({ + [groupField.name]: column.value + }); + }, + { + onSuccess, + }, + ); + return { resource, service, initialValues: service.data, ...service }; +}; + Kanban.useCreateAction = () => { const { service, resource, props } = useKanban(); const column = useContext(KanbanColumnContext);