fix: shared form scopes

This commit is contained in:
chenos 2021-01-07 14:58:44 +08:00
parent b878b214d4
commit 07b982960d
4 changed files with 28 additions and 45 deletions

View File

@ -19,6 +19,7 @@ import { useRequest } from 'umi';
import api from '@/api-client';
import { Spin } from '@nocobase/client';
import cleanDeep from 'clean-deep';
import scopes from '@/components/views/Form/scopes';
const actions = createFormActions();
@ -107,20 +108,7 @@ export default forwardRef((props: any, ref) => {
type: 'object',
properties: fields,
}}
expressionScope={{
text(...args: any[]) {
return React.createElement('span', {}, ...args)
},
tooltip(title: string, offset = 3) {
return (
<Tooltip title={title}>
<QuestionCircleOutlined
style={{ margin: '0 3px', cursor: 'default', marginLeft: offset }}
/>
</Tooltip>
);
},
}}
expressionScope={scopes}
>
</SchemaForm>
</Drawer>

View File

@ -23,6 +23,7 @@ import isEqual from 'lodash/isEqual';
import isEmpty from 'lodash/isEmpty';
import get from 'lodash/get';
import cleanDeep from 'clean-deep';
import scopes from './scopes';
const actions = createFormActions();
@ -137,23 +138,8 @@ export const DrawerForm = forwardRef((props: any, ref) => {
type: 'object',
properties,
}}
expressionScope={{
text(...args: any[]) {
return React.createElement('span', {}, ...args)
},
html(html: string) {
return <div dangerouslySetInnerHTML={{__html: html}}></div>
},
tooltip(title: string, offset = 3) {
return (
<Tooltip title={<div dangerouslySetInnerHTML={{__html: title}}></div>}>
<QuestionCircleOutlined
style={{ margin: '0 3px', cursor: 'default', marginLeft: offset }}
/>
</Tooltip>
);
},
}}
autoComplete={'off'}
expressionScope={scopes}
>
</SchemaForm>
)}

View File

@ -13,6 +13,7 @@ import {
setValidationLanguage,
} from '@formily/antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import scopes from './scopes';
export function FilterForm(props: any) {
const actions = createAsyncFormActions();
@ -37,20 +38,7 @@ export function FilterForm(props: any) {
type: 'object',
properties,
}}
expressionScope={{
text(...args: any[]) {
return React.createElement('span', {}, ...args)
},
tooltip(title: string, offset = 3) {
return (
<Tooltip title={title}>
<QuestionCircleOutlined
style={{ margin: '0 3px', cursor: 'default', marginLeft: offset }}
/>
</Tooltip>
);
},
}}
expressionScope={scopes}
>
<FormButtonGroup align={'end'}>
<Reset></Reset>

View File

@ -0,0 +1,21 @@
import React from 'react';
import { Tooltip } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
export default {
text(...args: any[]) {
return React.createElement('span', {}, ...args)
},
html(html: string) {
return <div dangerouslySetInnerHTML={{__html: html}}></div>
},
tooltip(title: string, offset = 3) {
return (
<Tooltip title={<div dangerouslySetInnerHTML={{__html: title}}></div>}>
<QuestionCircleOutlined
style={{ margin: '0 3px', cursor: 'default', marginLeft: offset }}
/>
</Tooltip>
);
},
};