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}