From f3782baebd7a88fa2d47b62180067371b2abad08 Mon Sep 17 00:00:00 2001 From: wjh Date: Mon, 25 Mar 2024 21:32:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=A1=A8=E8=AE=BE=E7=BD=AE=E6=9D=83=E9=99=90=E6=97=B6=E5=B0=8F?= =?UTF-8?q?=E7=BB=93=E5=87=BA=E4=B8=8D=E6=9D=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/custom-components/CustomComponentDispatcher.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/plugins/@hera/plugin-core/src/client/components/custom-components/CustomComponentDispatcher.tsx b/packages/plugins/@hera/plugin-core/src/client/components/custom-components/CustomComponentDispatcher.tsx index e2c212c6f..deb4bde5c 100644 --- a/packages/plugins/@hera/plugin-core/src/client/components/custom-components/CustomComponentDispatcher.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/components/custom-components/CustomComponentDispatcher.tsx @@ -51,7 +51,9 @@ export const customComponentDispatcherSettings = new SchemaSettings({ ['x-uid']: fieldSchema['x-uid'], }; fieldSchema['x-component-props']['component'] = component; + fieldSchema['x-acl-ignore'] = true; schema['x-component-props'] = fieldSchema['x-component-props']; + schema['x-acl-ignore'] = true; field.componentProps.component = component; dn.emit('patch', { schema, From 4a295a216f23fbb974e2eaa57c4077d216f3a053 Mon Sep 17 00:00:00 2001 From: "bai.jingfeng" Date: Mon, 25 Mar 2024 21:34:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat=EF=BC=9A=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E7=BB=84=E4=BB=B6=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BE=93=E5=85=A5=E8=B7=9F=E8=B8=AA=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E7=AD=9B=E9=80=89=E9=A1=B9=E9=A1=B6=E9=83=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E7=94=A8=E6=88=B7=E7=9A=84=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E8=BE=93=E5=85=A5=20(#491)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachycode/pulls/491 Co-authored-by: bai.jingfeng Co-committed-by: bai.jingfeng --- .../plugins/@hera/plugin-core/package.json | 2 +- .../auto-complete/AutoComplete.tsx | 50 ++++++++++++------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/plugins/@hera/plugin-core/package.json b/packages/plugins/@hera/plugin-core/package.json index c01d46650..e53750b03 100644 --- a/packages/plugins/@hera/plugin-core/package.json +++ b/packages/plugins/@hera/plugin-core/package.json @@ -1,6 +1,6 @@ { "name": "@hera/plugin-core", - "version": "1.6.0", + "version": "1.6.1", "displayName": "Hera platform", "displayName.zh-CN": "赫拉平台", "description": "Hera platform as nocobase plugin.", diff --git a/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx b/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx index de3fa1f19..65fbc413d 100644 --- a/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/schema-components/auto-complete/AutoComplete.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import { AutoComplete as AntdAutoComplete } from 'antd'; import { connect, useFieldSchema } from '@formily/react'; import { useAPIClient } from '@nocobase/client'; @@ -8,42 +8,54 @@ import { fuzzysearch } from '../../utils'; export const AutoComplete = connect((props) => { const { fieldNames, params: fieldFilter } = props; const fieldSchema = useFieldSchema(); - const [defultValue, setDefultValue] = useState([]); + const targetKey = fieldNames.value; const api = useAPIClient(); + const [defultOptions, setDefultOptions] = useState([]); const [options, setOptions] = useState([]); + + const getNoDuplicateTextOptions = (rawOptions) => { + const targetOptions = rawOptions.filter((option, index, self) => { + return self.findIndex((item) => item[targetKey] === option[targetKey]) === index; + }); + return targetOptions; + }; + useAsyncEffect(async () => { - const defultOptions = await api.request({ + const { + data: { data: rawOptions }, + } = await api.request({ url: fieldSchema['collectionName'] + ':list', params: { pageSize: 99999, filter: fieldFilter ? { ...fieldFilter.filter } : {}, }, }); - changLable(defultOptions?.data?.data); + const targetOptions = getNoDuplicateTextOptions(rawOptions); + setDefultOptions(targetOptions); + setOptions(targetOptions); }, [fieldFilter?.filter, fieldSchema['collectionName']]); - useEffect(() => { - changLable(defultValue); - }, [fieldNames?.label]); - - const changLable = (defultOptions) => { - if (defultOptions) { - const items = []; - defultOptions.forEach((item) => { - if (!items.filter((option) => option[fieldNames.value] === item[fieldNames.value]).length) { - items.push(item); - } - }); - setDefultValue(items); - setOptions(items); + const onSearch = (value) => { + // 在筛选项开头跟踪用户的原始输入值 + if (value) { + setOptions([ + { + [targetKey]: value, + }, + ...defultOptions, + ]); + } else { + setOptions(defultOptions); } }; + return ( fuzzysearch(inputValue, option[fieldNames.value].toString())} + filterOption={(inputValue, option) => fuzzysearch(inputValue, option[targetKey].toString())} allowClear + onSearch={onSearch} /> ); });