fix(client): tab pane initializers for create form block

This commit is contained in:
chenos 2022-10-13 19:52:04 +08:00
parent ca2a6fecf0
commit 929a4f848a
3 changed files with 53 additions and 46 deletions

View File

@ -1,8 +1,8 @@
import { useForm } from '@formily/react';
import React from 'react';
import { SchemaComponent, useActionContext, useDesignable } from '../..';
import { SchemaComponent, useActionContext, useDesignable, useRecordIndex } from '../..';
export const TabPaneInitializers = () => {
export const TabPaneInitializers = (props?: any) => {
const { designable, insertBeforeEnd } = useDesignable();
if (!designable) {
return null;
@ -10,6 +10,7 @@ export const TabPaneInitializers = () => {
const useSubmitAction = () => {
const form = useForm();
const ctx = useActionContext();
const index = useRecordIndex();
return {
async run() {
await form.submit();
@ -26,7 +27,8 @@ export const TabPaneInitializers = () => {
grid: {
type: 'void',
'x-component': 'Grid',
'x-initializer': 'RecordBlockInitializers',
'x-initializer':
props.isCreate || index === null ? 'CreateFormBlockInitializers' : 'RecordBlockInitializers',
properties: {},
},
},
@ -111,3 +113,7 @@ export const TabPaneInitializers = () => {
/>
);
};
export const TabPaneInitializersForCreateFormBlock = () => {
return <TabPaneInitializers isCreate />;
};

View File

@ -16,3 +16,4 @@ export * from './TableActionInitializers';
export * from './TableColumnInitializers';
export * from './TableSelectorInitializers';
export * from './TabPaneInitializers';

View File

@ -1,5 +1,5 @@
import React from "react";
import { ActionInitializer } from "./ActionInitializer";
import React from 'react';
import { ActionInitializer } from './ActionInitializer';
export const CreateActionInitializer = (props) => {
const schema = {
@ -26,7 +26,7 @@ export const CreateActionInitializer = (props) => {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {},
'x-initializer': 'TabPaneInitializers',
'x-initializer': 'TabPaneInitializersForCreateFormBlock',
properties: {
tab1: {
type: 'void',