fix: popup record (#1116)

Reviewed-on: daoyoucloud/tachybase#1116
This commit is contained in:
sealday 2024-06-05 11:34:40 +08:00
parent 171d56aaff
commit 72231f8bf1
13 changed files with 211 additions and 75 deletions

View File

@ -270,7 +270,7 @@
"Sub-table": "Sub-table", "Sub-table": "Sub-table",
"Sub-details": "Sub-details", "Sub-details": "Sub-details",
"Sub-form(Popover)": "Sub-form(Popover)", "Sub-form(Popover)": "Sub-form(Popover)",
"Sub-form(Drawer)": "Sub-form(Drawer)", "Subtable: Drawer": "Subtable: Drawer",
"System info": "System info", "System info": "System info",
"Created at": "Created at", "Created at": "Created at",
"Last updated at": "Last updated at", "Last updated at": "Last updated at",
@ -627,6 +627,7 @@
"Current user": "Current user", "Current user": "Current user",
"Current role": "Current role", "Current role": "Current role",
"Current record": "Current record", "Current record": "Current record",
"Current popup record": "Current popup record",
"Associated records": "Associated records", "Associated records": "Associated records",
"Parent record": "Parent record", "Parent record": "Parent record",
"Current time": "Current time", "Current time": "Current time",

View File

@ -334,7 +334,7 @@
"Subtable": "子表格", "Subtable": "子表格",
"Sub-form": "子表单", "Sub-form": "子表单",
"Sub-form(Popover)": "子表单(弹窗)", "Sub-form(Popover)": "子表单(弹窗)",
"Sub-form(Drawer)": "子表单(抽屉)", "Subtable: Drawer": "子表格:抽屉",
"Sub-details": "子详情", "Sub-details": "子详情",
"Record picker": "数据选择器", "Record picker": "数据选择器",
"Toggles the subfield mode": "切换子字段模式", "Toggles the subfield mode": "切换子字段模式",
@ -599,6 +599,7 @@
"Single select and radio fields can be used as the grouping field": "数据表的单选字段可以作为分组字段", "Single select and radio fields can be used as the grouping field": "数据表的单选字段可以作为分组字段",
"Tab name": "标签名称", "Tab name": "标签名称",
"Current record blocks": "当前数据区块", "Current record blocks": "当前数据区块",
"Current popup record": "当前弹窗记录",
"Popup message": "弹窗提示消息", "Popup message": "弹窗提示消息",
"Delete role": "删除角色", "Delete role": "删除角色",
"Role display name": "角色名称", "Role display name": "角色名称",

View File

@ -0,0 +1,29 @@
import React, { createContext } from 'react';
import { Collection } from '../../data-source';
interface DeclareVariableProps {
/* 变量名称 */
name: string;
/** 变量值 */
value: any;
/** 显示给用户的名字 */
title?: string;
/** 变量对应的数据表信息 */
collection?: Collection;
children?: React.ReactNode;
}
export const DeclareVariableContext = createContext<DeclareVariableProps>(null);
/**
*
*/
export const DeclareVariable = (props: DeclareVariableProps) => {
const { name, value, title, collection } = props;
return (
<DeclareVariableContext.Provider value={{ name, value, title, collection }}>
{props.children}
</DeclareVariableContext.Provider>
);
};

View File

@ -0,0 +1,16 @@
import { useContext } from 'react';
import { DeclareVariableContext } from './DeclareVariable';
/**
*
* @param variableName
* @returns
*/
export const useVariable = (variableName: string) => {
const { name, value, title, collection } = useContext(DeclareVariableContext) || {};
if (name === variableName) {
return { value, title, collection };
}
return {};
};

View File

@ -1,9 +1,13 @@
import React, { Fragment, useRef, useState } from 'react'; import React, { Fragment, useRef, useState } from 'react';
import { observer, RecursionField, toArr, useField, useFieldSchema } from '@tachybase/schema'; import { observer, RecursionField, toArr, useField, useFieldSchema } from '@tachybase/schema';
import { useTranslation } from 'react-i18next';
import { useDesignable } from '../../'; import { useDesignable } from '../../';
import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider'; import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider';
import { CollectionProvider_deprecated, useCollectionManager_deprecated } from '../../../collection-manager'; import { CollectionProvider_deprecated, useCollectionManager_deprecated } from '../../../collection-manager';
import { Collection } from '../../../data-source';
import { DeclareVariable } from '../../../modules/variable/DeclareVariable';
import { RecordProvider, useRecord } from '../../../record-provider'; import { RecordProvider, useRecord } from '../../../record-provider';
import { FormProvider } from '../../core'; import { FormProvider } from '../../core';
import { useCompile } from '../../hooks'; import { useCompile } from '../../hooks';
@ -29,6 +33,8 @@ export function isObject(value) {
} }
export const ReadPrettyInternalViewer = observer( export const ReadPrettyInternalViewer = observer(
(props: any) => { (props: any) => {
const { t } = useTranslation();
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const recordCtx = useRecord(); const recordCtx = useRecord();
const { getCollection } = useCollectionManager_deprecated(); const { getCollection } = useCollectionManager_deprecated();
@ -97,18 +103,25 @@ export const ReadPrettyInternalViewer = observer(
); );
}); });
const renderWithoutTableFieldResourceProvider = () => ( const renderWithoutTableFieldResourceProvider = () => (
<WithoutTableFieldResource.Provider value={true}> <DeclareVariable
<FormProvider> name="$nPopupRecord"
<RecursionField title={t('Current popup record')}
schema={fieldSchema} value={record}
onlyRenderProperties collection={targetCollection as Collection}
basePath={field.address} >
filterProperties={(s) => { <WithoutTableFieldResource.Provider value={true}>
return s['x-component'] === 'AssociationField.Viewer'; <FormProvider>
}} <RecursionField
/> schema={fieldSchema}
</FormProvider> onlyRenderProperties
</WithoutTableFieldResource.Provider> basePath={field.address}
filterProperties={(s) => {
return s['x-component'] === 'AssociationField.Viewer';
}}
/>
</FormProvider>
</WithoutTableFieldResource.Provider>
</DeclareVariable>
); );
const renderRecordProvider = () => { const renderRecordProvider = () => {

View File

@ -35,6 +35,7 @@ import {
} from '../../../'; } from '../../../';
import { withDynamicSchemaProps } from '../../../application/hoc/withDynamicSchemaProps'; import { withDynamicSchemaProps } from '../../../application/hoc/withDynamicSchemaProps';
import { isNewRecord, markRecordAsNew } from '../../../data-source/collection-record/isNewRecord'; import { isNewRecord, markRecordAsNew } from '../../../data-source/collection-record/isNewRecord';
import { DeclareVariable } from '../../../modules/variable/DeclareVariable';
import { SubFormProvider } from '../association-field/hooks'; import { SubFormProvider } from '../association-field/hooks';
import { ColumnFieldProvider } from './components/ColumnFieldProvider'; import { ColumnFieldProvider } from './components/ColumnFieldProvider';
import { useStyles } from './Table.styles'; import { useStyles } from './Table.styles';
@ -46,7 +47,7 @@ const useArrayField = (props) => {
}; };
const useTableColumns = (props: { showDel?: boolean; isSubTable?: boolean }) => { const useTableColumns = (props: { showDel?: boolean; isSubTable?: boolean }) => {
const { token } = useToken(); const { t } = useTranslation();
const { styles } = useStyles(); const { styles } = useStyles();
const field = useArrayField(props); const field = useArrayField(props);
const schema = useFieldSchema(); const schema = useFieldSchema();
@ -81,21 +82,28 @@ const useTableColumns = (props: { showDel?: boolean; isSubTable?: boolean }) =>
render: (v, record) => { render: (v, record) => {
const index = field.value?.indexOf(record); const index = field.value?.indexOf(record);
return ( return (
<SubFormProvider value={{ value: record, collection }}> <DeclareVariable
<RecordIndexProvider index={record.__index || index}> name="$nPopupRecord"
<RecordProvider isNew={isNewRecord(record)} record={record} parent={parentRecordData}> title={t('Current popup record')}
<ColumnFieldProvider schema={s} basePath={field.address.concat(record.__index || index)}> value={record}
<span role="button" className={styles.toolbar}> collection={collection}
<RecursionField >
basePath={field.address.concat(record.__index || index)} <SubFormProvider value={{ value: record, collection }}>
schema={s} <RecordIndexProvider index={record.__index || index}>
onlyRenderProperties <RecordProvider isNew={isNewRecord(record)} record={record} parent={parentRecordData}>
/> <ColumnFieldProvider schema={s} basePath={field.address.concat(record.__index || index)}>
</span> <span role="button" className={styles.toolbar}>
</ColumnFieldProvider> <RecursionField
</RecordProvider> basePath={field.address.concat(record.__index || index)}
</RecordIndexProvider> schema={s}
</SubFormProvider> onlyRenderProperties
/>
</span>
</ColumnFieldProvider>
</RecordProvider>
</RecordIndexProvider>
</SubFormProvider>
</DeclareVariable>
); );
}, },
} as TableColumnProps<any>; } as TableColumnProps<any>;

View File

@ -1,6 +1,8 @@
import { useField, useFieldSchema, useForm } from '@tachybase/schema';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useField, useFieldSchema, useForm } from '@tachybase/schema';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useCollection_deprecated, useCollectionManager_deprecated } from '../../collection-manager'; import { useCollection_deprecated, useCollectionManager_deprecated } from '../../collection-manager';
export const useFieldModeOptions = (props?) => { export const useFieldModeOptions = (props?) => {
@ -55,7 +57,7 @@ export const useFieldModeOptions = (props?) => {
{ label: t('Cascade Select'), value: 'CascadeSelect' }, { label: t('Cascade Select'), value: 'CascadeSelect' },
!isTableField && { label: t('Sub-form'), value: 'Nester' }, !isTableField && { label: t('Sub-form'), value: 'Nester' },
{ label: t('Sub-form(Popover)'), value: 'PopoverNester' }, { label: t('Sub-form(Popover)'), value: 'PopoverNester' },
{ label: t('Sub-form(Drawer)'), value: 'DrawerSubTable' }, { label: t('Subtable: Drawer'), value: 'DrawerSubTable' },
{ label: t('Cascader'), value: 'Cascader' }, { label: t('Cascader'), value: 'Cascader' },
]; ];
} }
@ -73,7 +75,7 @@ export const useFieldModeOptions = (props?) => {
{ label: t('Record picker'), value: 'Picker' }, { label: t('Record picker'), value: 'Picker' },
!isTableField && { label: t('Sub-form'), value: 'Nester' }, !isTableField && { label: t('Sub-form'), value: 'Nester' },
{ label: t('Sub-form(Popover)'), value: 'PopoverNester' }, { label: t('Sub-form(Popover)'), value: 'PopoverNester' },
{ label: t('Sub-form(Drawer)'), value: 'DrawerSubTable' }, { label: t('Subtable: Drawer'), value: 'DrawerSubTable' },
!isTableField && { label: t('Sub-table'), value: 'SubTable' }, !isTableField && { label: t('Sub-table'), value: 'SubTable' },
]; ];
case 'm2m': case 'm2m':
@ -90,7 +92,7 @@ export const useFieldModeOptions = (props?) => {
!isTableField && { label: t('Sub-table'), value: 'SubTable' }, !isTableField && { label: t('Sub-table'), value: 'SubTable' },
!isTableField && { label: t('Sub-form'), value: 'Nester' }, !isTableField && { label: t('Sub-form'), value: 'Nester' },
{ label: t('Sub-form(Popover)'), value: 'PopoverNester' }, { label: t('Sub-form(Popover)'), value: 'PopoverNester' },
{ label: t('Sub-form(Drawer)'), value: 'DrawerSubTable' }, { label: t('Subtable: Drawer'), value: 'DrawerSubTable' },
]; ];
case 'm2o': case 'm2o':
case 'linkTo': case 'linkTo':
@ -105,7 +107,7 @@ export const useFieldModeOptions = (props?) => {
{ label: t('Record picker'), value: 'Picker' }, { label: t('Record picker'), value: 'Picker' },
!isTableField && { label: t('Sub-form'), value: 'Nester' }, !isTableField && { label: t('Sub-form'), value: 'Nester' },
{ label: t('Sub-form(Popover)'), value: 'PopoverNester' }, { label: t('Sub-form(Popover)'), value: 'PopoverNester' },
{ label: t('Sub-form(Drawer)'), value: 'DrawerSubTable' }, { label: t('Subtable: Drawer'), value: 'DrawerSubTable' },
{ label: t('Cascader'), value: 'Cascader' }, { label: t('Cascader'), value: 'Cascader' },
]; ];
@ -121,7 +123,7 @@ export const useFieldModeOptions = (props?) => {
{ label: t('Record picker'), value: 'Picker' }, { label: t('Record picker'), value: 'Picker' },
!isTableField && { label: t('Sub-form'), value: 'Nester' }, !isTableField && { label: t('Sub-form'), value: 'Nester' },
{ label: t('Sub-form(Popover)'), value: 'PopoverNester' }, { label: t('Sub-form(Popover)'), value: 'PopoverNester' },
{ label: t('Sub-form(Drawer)'), value: 'DrawerSubTable' }, { label: t('Subtable: Drawer'), value: 'DrawerSubTable' },
]; ];
} }
}, [t, collectionField?.interface, label]); }, [t, collectionField?.interface, label]);

View File

@ -6,7 +6,6 @@ import React, {
useContext, useContext,
useEffect, useEffect,
useMemo, useMemo,
// @ts-ignore
useTransition as useReactTransition, useTransition as useReactTransition,
useState, useState,
} from 'react'; } from 'react';
@ -107,6 +106,8 @@ import {
} from '../filter-provider/utils'; } from '../filter-provider/utils';
import { FlagProvider } from '../flag-provider'; import { FlagProvider } from '../flag-provider';
import { useCollectMenuItem, useCollectMenuItems, useMenuItem } from '../hooks/useMenuItem'; import { useCollectMenuItem, useCollectMenuItems, useMenuItem } from '../hooks/useMenuItem';
import { DeclareVariable } from '../modules/variable/DeclareVariable';
import { useVariable } from '../modules/variable/useVariable';
import { SubFormProvider, useSubFormValue } from '../schema-component/antd/association-field/hooks'; import { SubFormProvider, useSubFormValue } from '../schema-component/antd/association-field/hooks';
import { getTargetKey } from '../schema-component/antd/association-filter/utilts'; import { getTargetKey } from '../schema-component/antd/association-filter/utilts';
import { useSchemaTemplateManager } from '../schema-templates'; import { useSchemaTemplateManager } from '../schema-templates';
@ -1024,6 +1025,8 @@ export const SchemaSettingsModalItem: FC<SchemaSettingsModalItemProps> = (props)
// 解决变量`当前对象`值在弹窗中丢失的问题 // 解决变量`当前对象`值在弹窗中丢失的问题
const { formValue: subFormValue, collection: subFormCollection } = useSubFormValue(); const { formValue: subFormValue, collection: subFormCollection } = useSubFormValue();
// 解决变量`$nPopupRecord`值在弹窗中丢失的问题
const popupRecordVariable = useVariable('$nPopupRecord');
if (hidden) { if (hidden) {
return null; return null;
@ -1039,40 +1042,47 @@ export const SchemaSettingsModalItem: FC<SchemaSettingsModalItemProps> = (props)
{ title: schema.title || title, width }, { title: schema.title || title, width },
() => { () => {
return ( return (
<ApplicationContext.Provider value={app}> <DeclareVariable
<CollectionRecordProvider record={record}> name="$nPopupRecord"
<FormBlockContext.Provider value={formCtx}> title={popupRecordVariable.title}
<SubFormProvider value={{ value: subFormValue, collection: subFormCollection }}> value={popupRecordVariable.value}
<FormActiveFieldsProvider collection={popupRecordVariable.collection}
name="form" >
getActiveFieldsName={upLevelActiveFields?.getActiveFieldsName} <ApplicationContext.Provider value={app}>
> <CollectionRecordProvider record={record}>
<Router location={location} navigator={null}> <FormBlockContext.Provider value={formCtx}>
<BlockRequestContext_deprecated.Provider value={ctx}> <SubFormProvider value={{ value: subFormValue, collection: subFormCollection }}>
<DataSourceApplicationProvider dataSourceManager={dm} dataSource={dataSourceKey}> <FormActiveFieldsProvider
<AssociationOrCollectionProvider name="form"
allowNull getActiveFieldsName={upLevelActiveFields?.getActiveFieldsName}
collection={collection.name} >
association={association} <Router location={location} navigator={null}>
> <BlockRequestContext_deprecated.Provider value={ctx}>
<SchemaComponentOptions scope={options.scope} components={options.components}> <DataSourceApplicationProvider dataSourceManager={dm} dataSource={dataSourceKey}>
<FormLayout layout={'vertical'} className={styles.modal}> <AssociationOrCollectionProvider
<APIClientProvider apiClient={apiClient}> allowNull
<ConfigProvider locale={locale}> collection={collection.name}
<SchemaComponent components={components} scope={scope} schema={schema} /> association={association}
</ConfigProvider> >
</APIClientProvider> <SchemaComponentOptions scope={options.scope} components={options.components}>
</FormLayout> <FormLayout layout={'vertical'} className={styles.modal}>
</SchemaComponentOptions> <APIClientProvider apiClient={apiClient}>
</AssociationOrCollectionProvider> <ConfigProvider locale={locale}>
</DataSourceApplicationProvider> <SchemaComponent components={components} scope={scope} schema={schema} />
</BlockRequestContext_deprecated.Provider> </ConfigProvider>
</Router> </APIClientProvider>
</FormActiveFieldsProvider> </FormLayout>
</SubFormProvider> </SchemaComponentOptions>
</FormBlockContext.Provider> </AssociationOrCollectionProvider>
</CollectionRecordProvider> </DataSourceApplicationProvider>
</ApplicationContext.Provider> </BlockRequestContext_deprecated.Provider>
</Router>
</FormActiveFieldsProvider>
</SubFormProvider>
</FormBlockContext.Provider>
</CollectionRecordProvider>
</ApplicationContext.Provider>
</DeclareVariable>
); );
}, },
theme, theme,

View File

@ -1,8 +1,10 @@
import { Schema } from '@tachybase/schema'; import { Schema } from '@tachybase/schema';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { CollectionFieldOptions_deprecated } from '../../../collection-manager'; import { CollectionFieldOptions_deprecated } from '../../../collection-manager';
import { useParentCollection } from '../../../data-source/collection/AssociationProvider';
import { useCollectionRecord } from '../../../data-source/collection-record/CollectionRecordProvider'; import { useCollectionRecord } from '../../../data-source/collection-record/CollectionRecordProvider';
import { useParentCollection } from '../../../data-source/collection/AssociationProvider';
import { useFlag } from '../../../flag-provider/hooks/useFlag'; import { useFlag } from '../../../flag-provider/hooks/useFlag';
import { useBaseVariable } from './useBaseVariable'; import { useBaseVariable } from './useBaseVariable';

View File

@ -0,0 +1,33 @@
import { useVariable } from '../../../modules/variable/useVariable';
import { useBaseVariable } from './useBaseVariable';
/**
* `Current popup record`
* @param props
* @returns
*/
export const usePopupVariable = (props: any = {}) => {
const { value, title, collection } = useVariable('$nPopupRecord');
const settings = useBaseVariable({
collectionField: props.collectionField,
uiSchema: props.schema,
name: '$nPopupRecord',
title,
collectionName: collection?.name,
noDisabled: props.noDisabled,
targetFieldSchema: props.targetFieldSchema,
dataSource: collection?.dataSource,
});
return {
/** 变量配置 */
settings,
/** 变量值 */
popupRecordCtx: value,
/** 用于判断是否需要显示配置项 */
shouldDisplayPopupRecord: !!value,
/** 当前记录对应的 collection name */
collectionName: collection?.name,
dataSource: collection?.dataSource,
};
};

View File

@ -1,12 +1,13 @@
import { Form } from '@tachybase/schema';
import { ISchema, Schema } from '@tachybase/schema';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { CollectionFieldOptions_deprecated, useCollection_deprecated } from '../../../collection-manager'; import { Form, ISchema, Schema } from '@tachybase/schema';
import { CollectionFieldOptions_deprecated } from '../../../collection-manager';
import { useBlockCollection } from './useBlockCollection'; import { useBlockCollection } from './useBlockCollection';
import { useDatetimeVariable } from './useDateVariable'; import { useDatetimeVariable } from './useDateVariable';
import { useCurrentFormVariable } from './useFormVariable'; import { useCurrentFormVariable } from './useFormVariable';
import { useCurrentObjectVariable } from './useIterationVariable'; import { useCurrentObjectVariable } from './useIterationVariable';
import { useCurrentParentRecordVariable } from './useParentRecordVariable'; import { useCurrentParentRecordVariable } from './useParentRecordVariable';
import { usePopupVariable } from './usePopupVariable';
import { useCurrentRecordVariable } from './useRecordVariable'; import { useCurrentRecordVariable } from './useRecordVariable';
import { useCurrentRoleVariable } from './useRoleVariable'; import { useCurrentRoleVariable } from './useRoleVariable';
import { useCurrentUserVariable } from './useUserVariable'; import { useCurrentUserVariable } from './useUserVariable';
@ -81,6 +82,12 @@ export const useVariableOptions = ({
noDisabled, noDisabled,
targetFieldSchema, targetFieldSchema,
}); });
const { settings: popupRecordSettings, shouldDisplayPopupRecord } = usePopupVariable({
schema: uiSchema,
collectionField,
noDisabled,
targetFieldSchema,
});
const { currentParentRecordSettings, shouldDisplayCurrentParentRecord } = useCurrentParentRecordVariable({ const { currentParentRecordSettings, shouldDisplayCurrentParentRecord } = useCurrentParentRecordVariable({
schema: uiSchema, schema: uiSchema,
collectionName: blockParentCollectionName, collectionName: blockParentCollectionName,
@ -98,6 +105,7 @@ export const useVariableOptions = ({
shouldDisplayCurrentObject && currentObjectSettings, shouldDisplayCurrentObject && currentObjectSettings,
shouldDisplayCurrentRecord && currentRecordSettings, shouldDisplayCurrentRecord && currentRecordSettings,
shouldDisplayCurrentParentRecord && currentParentRecordSettings, shouldDisplayCurrentParentRecord && currentParentRecordSettings,
shouldDisplayPopupRecord && popupRecordSettings,
].filter(Boolean); ].filter(Boolean);
}, [ }, [
currentUserSettings, currentUserSettings,
@ -111,5 +119,7 @@ export const useVariableOptions = ({
currentRecordSettings, currentRecordSettings,
shouldDisplayCurrentParentRecord, shouldDisplayCurrentParentRecord,
currentParentRecordSettings, currentParentRecordSettings,
shouldDisplayPopupRecord,
popupRecordSettings,
]); ]);
}; };

View File

@ -7,6 +7,7 @@ import { useDatetimeVariable } from '../../schema-settings/VariableInput/hooks/u
import { useCurrentFormVariable } from '../../schema-settings/VariableInput/hooks/useFormVariable'; import { useCurrentFormVariable } from '../../schema-settings/VariableInput/hooks/useFormVariable';
import { useCurrentObjectVariable } from '../../schema-settings/VariableInput/hooks/useIterationVariable'; import { useCurrentObjectVariable } from '../../schema-settings/VariableInput/hooks/useIterationVariable';
import { useCurrentParentRecordVariable } from '../../schema-settings/VariableInput/hooks/useParentRecordVariable'; import { useCurrentParentRecordVariable } from '../../schema-settings/VariableInput/hooks/useParentRecordVariable';
import { usePopupVariable } from '../../schema-settings/VariableInput/hooks/usePopupVariable';
import { useCurrentRecordVariable } from '../../schema-settings/VariableInput/hooks/useRecordVariable'; import { useCurrentRecordVariable } from '../../schema-settings/VariableInput/hooks/useRecordVariable';
import { VariableOption } from '../types'; import { VariableOption } from '../types';
@ -18,6 +19,7 @@ interface Props {
const useLocalVariables = (props?: Props) => { const useLocalVariables = (props?: Props) => {
const { currentObjectCtx, shouldDisplayCurrentObject } = useCurrentObjectVariable(); const { currentObjectCtx, shouldDisplayCurrentObject } = useCurrentObjectVariable();
const { currentRecordCtx, collectionName: collectionNameOfRecord } = useCurrentRecordVariable(); const { currentRecordCtx, collectionName: collectionNameOfRecord } = useCurrentRecordVariable();
const { popupRecordCtx, collectionName: collectionNameOfPopupRecord } = usePopupVariable();
const { currentParentRecordCtx, collectionName: collectionNameOfParentRecord } = useCurrentParentRecordVariable(); const { currentParentRecordCtx, collectionName: collectionNameOfParentRecord } = useCurrentParentRecordVariable();
const { datetimeCtx } = useDatetimeVariable(); const { datetimeCtx } = useDatetimeVariable();
const { currentFormCtx } = useCurrentFormVariable({ form: props?.currentForm }); const { currentFormCtx } = useCurrentFormVariable({ form: props?.currentForm });
@ -68,6 +70,11 @@ const useLocalVariables = (props?: Props) => {
ctx: currentParentRecordCtx, ctx: currentParentRecordCtx,
collectionName: collectionNameOfParentRecord, collectionName: collectionNameOfParentRecord,
}, },
{
name: '$nPopupRecord',
ctx: popupRecordCtx,
collectionName: collectionNameOfPopupRecord,
},
{ {
name: '$nForm', name: '$nForm',
ctx: currentFormCtx, ctx: currentFormCtx,
@ -99,6 +106,8 @@ const useLocalVariables = (props?: Props) => {
currentFormCtx, currentFormCtx,
currentParentRecordCtx, currentParentRecordCtx,
collectionNameOfParentRecord, collectionNameOfParentRecord,
popupRecordCtx,
collectionNameOfPopupRecord,
datetimeCtx, datetimeCtx,
shouldDisplayCurrentObject, shouldDisplayCurrentObject,
currentObjectCtx, currentObjectCtx,

View File

@ -78,4 +78,6 @@ export interface VariableOption {
}; };
/** 变量所对应的数据表的名称 */ /** 变量所对应的数据表的名称 */
collectionName?: string; collectionName?: string;
/** 数据表所对应的数据源 */
dataSource?: string;
} }