From e9970fca0bcf2dccbb9393fe45a25b55e33eb10a Mon Sep 17 00:00:00 2001 From: wjh Date: Sat, 8 Jun 2024 04:01:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AD=90=E8=A1=A8=E5=8D=95=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BF=AB=E9=80=9F=E5=88=9B=E5=BB=BA=E7=9A=84=E6=8A=98?= =?UTF-8?q?=E5=8F=A0=E5=8A=9F=E8=83=BD=20(#1143)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1143 Co-authored-by: wjh Co-committed-by: wjh --- .../antd/association-field/SubTable.tsx | 4 +-- ...{InternalTabs.tsx => InternalCollapse.tsx} | 32 ++++++++++++++++--- .../components/antd-mobile/Select/Select.tsx | 2 +- 3 files changed, 30 insertions(+), 8 deletions(-) rename packages/core/client/src/schema-component/antd/association-field/SubTabs/{InternalTabs.tsx => InternalCollapse.tsx} (91%) diff --git a/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx b/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx index 7ec98de78..d91480a0c 100644 --- a/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx @@ -36,7 +36,7 @@ import { ActionContextProvider } from '../action'; import { Table } from '../table-v2/Table'; import { useAssociationFieldContext, useFieldNames } from './hooks'; import { useTableSelectorProps } from './InternalPicker'; -import { InternalTabs } from './SubTabs/InternalTabs'; +import { InternalCollapse } from './SubTabs/InternalCollapse'; import { getLabelFormatValue, useLabelUiSchema } from './util'; const useStyles = createStyles(({ css }) => { @@ -187,7 +187,7 @@ export const SubTable: any = observer( - + { itemParams['childrenTitleField'] = cm.getCollection(itemParams['collectionName']).titleField; itemParams['childrenOptions'] = childrenItem?.data?.data; - if (itemParams['parentOptions']?.length && itemParams['childrenOptions']?.length) { + if ( + itemParams['parentOptions']?.length && + itemParams['childrenOptions']?.length && + quickAddParentField?.value !== 'none' + ) { optionsItem.unshift({ value: 'all', label: t('All'), @@ -134,7 +138,7 @@ export const InternalTabs = observer((props) => { setDefOptions(optionsItem); } } - }, [fieldServiceFilter, fieldSchema, changeForm]); + }, [fieldServiceFilter, tabparams?.filter, changeForm, isQuickAdd, quickAddField, quickAddParentField]); useDeepCompareEffect(() => { if (!defOptions.length) return; @@ -188,7 +192,7 @@ export const InternalTabs = observer((props) => { setFieldValue([...field.value]); }; - return isQuickAdd && quickAddField && quickAddField !== 'none' ? ( + return (
{ ), }))} style={{ maxHeight: '30vh', padding: '10px' }} + defaultActiveKey="all" > ) : null} @@ -241,7 +246,7 @@ export const InternalTabs = observer((props) => { )}
- ) : null; + ); }); const tabsParantFilterOptions = (options, fieldTabs, arrayField) => { @@ -271,3 +276,20 @@ const tabsFilterOptions = (optitons, filterTabs, arrayField) => { }); return filterOptions; }; + +export const InternalCollapse = observer((props) => { + const { t } = useTranslation(); + const fieldSchema = useFieldSchema(); + const isQuickAdd = fieldSchema['parent']['x-component-props']['isQuickAdd']; + const { value: quickAddField } = fieldSchema['parent']['x-component-props']?.['quickAddField'] || {}; + const items: CollapseProps['items'] = [ + { + key: '1', + label: t('Quick create'), + children: , + }, + ]; + return isQuickAdd && quickAddField && quickAddField !== 'none' ? ( + + ) : null; +}); diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx index 6cd76d0f5..9545fc63e 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx @@ -30,7 +30,7 @@ export const MSelect = connect( mapReadPretty((props) => { const { value, fieldNames } = props; const collectionField = useCollectionField(); - const isSlectField = ['multipleSelect', 'select'].includes(collectionField.interface); + const isSlectField = ['multipleSelect', 'select'].includes(collectionField?.interface); const field = useField(); const dataSource = field.dataSource || collectionField?.uiSchema.enum || []; const fieldNamesLabel = fieldNames?.label || 'label';