From 07b982960d479e1a683e3585099c80d91c5a2e23 Mon Sep 17 00:00:00 2001 From: chenos Date: Thu, 7 Jan 2021 14:58:44 +0800 Subject: [PATCH] fix: shared form scopes --- .../components/form.fields/sub-table/Form.tsx | 16 ++------------ .../src/components/views/Form/DrawerForm.tsx | 20 +++--------------- .../src/components/views/Form/FilterForm.tsx | 16 ++------------ .../app/src/components/views/Form/scopes.tsx | 21 +++++++++++++++++++ 4 files changed, 28 insertions(+), 45 deletions(-) create mode 100644 packages/app/src/components/views/Form/scopes.tsx diff --git a/packages/app/src/components/form.fields/sub-table/Form.tsx b/packages/app/src/components/form.fields/sub-table/Form.tsx index 505a72f42..b24470e49 100644 --- a/packages/app/src/components/form.fields/sub-table/Form.tsx +++ b/packages/app/src/components/form.fields/sub-table/Form.tsx @@ -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 ( - - - - ); - }, - }} + expressionScope={scopes} > diff --git a/packages/app/src/components/views/Form/DrawerForm.tsx b/packages/app/src/components/views/Form/DrawerForm.tsx index 32c0fe9ef..7f9d9f9e2 100644 --- a/packages/app/src/components/views/Form/DrawerForm.tsx +++ b/packages/app/src/components/views/Form/DrawerForm.tsx @@ -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
- }, - tooltip(title: string, offset = 3) { - return ( - }> - - - ); - }, - }} + autoComplete={'off'} + expressionScope={scopes} > )} diff --git a/packages/app/src/components/views/Form/FilterForm.tsx b/packages/app/src/components/views/Form/FilterForm.tsx index 73f0830c7..625b1427a 100644 --- a/packages/app/src/components/views/Form/FilterForm.tsx +++ b/packages/app/src/components/views/Form/FilterForm.tsx @@ -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 ( - - - - ); - }, - }} + expressionScope={scopes} > 取消 diff --git a/packages/app/src/components/views/Form/scopes.tsx b/packages/app/src/components/views/Form/scopes.tsx new file mode 100644 index 000000000..de5e02e64 --- /dev/null +++ b/packages/app/src/components/views/Form/scopes.tsx @@ -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
+ }, + tooltip(title: string, offset = 3) { + return ( + }> + + + ); + }, +};