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 api from '@/api-client';
import { Spin } from '@nocobase/client'; import { Spin } from '@nocobase/client';
import cleanDeep from 'clean-deep'; import cleanDeep from 'clean-deep';
import scopes from '@/components/views/Form/scopes';
const actions = createFormActions(); const actions = createFormActions();
@ -107,20 +108,7 @@ export default forwardRef((props: any, ref) => {
type: 'object', type: 'object',
properties: fields, properties: fields,
}} }}
expressionScope={{ expressionScope={scopes}
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>
);
},
}}
> >
</SchemaForm> </SchemaForm>
</Drawer> </Drawer>

View File

@ -23,6 +23,7 @@ import isEqual from 'lodash/isEqual';
import isEmpty from 'lodash/isEmpty'; import isEmpty from 'lodash/isEmpty';
import get from 'lodash/get'; import get from 'lodash/get';
import cleanDeep from 'clean-deep'; import cleanDeep from 'clean-deep';
import scopes from './scopes';
const actions = createFormActions(); const actions = createFormActions();
@ -137,23 +138,8 @@ export const DrawerForm = forwardRef((props: any, ref) => {
type: 'object', type: 'object',
properties, properties,
}} }}
expressionScope={{ autoComplete={'off'}
text(...args: any[]) { expressionScope={scopes}
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>
);
},
}}
> >
</SchemaForm> </SchemaForm>
)} )}

View File

@ -13,6 +13,7 @@ import {
setValidationLanguage, setValidationLanguage,
} from '@formily/antd'; } from '@formily/antd';
import { QuestionCircleOutlined } from '@ant-design/icons'; import { QuestionCircleOutlined } from '@ant-design/icons';
import scopes from './scopes';
export function FilterForm(props: any) { export function FilterForm(props: any) {
const actions = createAsyncFormActions(); const actions = createAsyncFormActions();
@ -37,20 +38,7 @@ export function FilterForm(props: any) {
type: 'object', type: 'object',
properties, properties,
}} }}
expressionScope={{ expressionScope={scopes}
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>
);
},
}}
> >
<FormButtonGroup align={'end'}> <FormButtonGroup align={'end'}>
<Reset></Reset> <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>
);
},
};