From c544ae80f1ce1fd7fa28a62ccb287fd9c86c0022 Mon Sep 17 00:00:00 2001 From: wjh Date: Fri, 15 Mar 2024 19:06:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schema-components/select/Select.tsx | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/packages/plugins/@hera/plugin-core/src/client/schema-components/select/Select.tsx b/packages/plugins/@hera/plugin-core/src/client/schema-components/select/Select.tsx index 0addb29bd..10afa87b8 100644 --- a/packages/plugins/@hera/plugin-core/src/client/schema-components/select/Select.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/schema-components/select/Select.tsx @@ -21,25 +21,13 @@ type Props = SelectProps & { const isEmptyObject = (val: any) => !isValid(val) || (typeof val === 'object' && Object.keys(val).length === 0); const ObjectSelect = (props: Props) => { - const { - value, - options: defultValue, - onChange, - fieldNames, - mode, - loading, - rawOptions, - defaultValue, - ...others - } = props; - const [options, setOptions] = useState([]); - const [defult, setDefult] = useState(false); + const { value, options, onChange, fieldNames, mode, loading, rawOptions, defaultValue, ...others } = props; + const [defoptions, setDefOptions] = useState(); const fieldSchema = useFieldSchema(); const collectionName = fieldSchema['collectionName']; const filterField = fieldSchema['x-component-props']['params']; const filter = filterField ? JSON.stringify(filterField.filter) : {}; const api = useAPIClient(); - useAsyncEffect(async () => { if (collectionName) { const defValue = await api.request({ @@ -49,10 +37,9 @@ const ObjectSelect = (props: Props) => { filter: filterField ? { ...filterField.filter } : {}, }, }); - setOptions(defValue?.data?.data); + setDefOptions(defValue?.data?.data); } }, [filter]); - const toValue = (v: any) => { if (isEmptyObject(v)) { return; @@ -89,7 +76,7 @@ const ObjectSelect = (props: Props) => { }} labelInValue notFoundContent={loading ? : } - options={options} + options={defoptions || options} fieldNames={fieldNames} showSearch popupMatchSelectWidth={false}