fix: select options (#2101)
This commit is contained in:
parent
bdcbe7392f
commit
480e499f67
@ -1,18 +1,18 @@
|
|||||||
import { LoadingOutlined } from '@ant-design/icons';
|
import { LoadingOutlined } from '@ant-design/icons';
|
||||||
import { connect, mapProps, mapReadPretty, useField, useFieldSchema, useForm } from '@formily/react';
|
import { connect, mapProps, mapReadPretty, useField, useFieldSchema, useForm } from '@formily/react';
|
||||||
import { SelectProps, Tag, Empty, Divider } from 'antd';
|
import { Divider, SelectProps, Tag } from 'antd';
|
||||||
import { uniqBy } from 'lodash';
|
|
||||||
import flat from 'flat';
|
import flat from 'flat';
|
||||||
|
import { uniqBy } from 'lodash';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { ResourceActionOptions, useRequest } from '../../../api-client';
|
import { ResourceActionOptions, useRequest } from '../../../api-client';
|
||||||
|
import { useBlockRequestContext } from '../../../block-provider/BlockProvider';
|
||||||
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
||||||
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
||||||
import { Select, defaultFieldNames } from '../select';
|
|
||||||
import { ReadPretty } from './ReadPretty';
|
|
||||||
import { useBlockRequestContext } from '../../../block-provider/BlockProvider';
|
|
||||||
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
||||||
import { parseVariables, extractFilterfield, generatePattern, extractValuesByPattern } from './utils';
|
import { defaultFieldNames, Select } from '../select';
|
||||||
|
import { ReadPretty } from './ReadPretty';
|
||||||
|
import { extractFilterfield, extractValuesByPattern, generatePattern, parseVariables } from './utils';
|
||||||
const EMPTY = 'N/A';
|
const EMPTY = 'N/A';
|
||||||
|
|
||||||
export type RemoteSelectProps<P = any> = SelectProps<P, any> & {
|
export type RemoteSelectProps<P = any> = SelectProps<P, any> & {
|
||||||
@ -229,8 +229,10 @@ const InternalRemoteSelect = connect(
|
|||||||
if (!data?.data?.length) {
|
if (!data?.data?.length) {
|
||||||
return value != null ? (Array.isArray(value) ? value : [value]) : [];
|
return value != null ? (Array.isArray(value) ? value : [value]) : [];
|
||||||
}
|
}
|
||||||
return uniqBy(data?.data || [], fieldNames.value);
|
const valueOptions = (value != null && (Array.isArray(value) ? value : [value])) || [];
|
||||||
|
return uniqBy(data?.data?.concat(valueOptions) || [], fieldNames.value);
|
||||||
}, [data?.data, value]);
|
}, [data?.data, value]);
|
||||||
|
|
||||||
const onDropdownVisibleChange = (visible) => {
|
const onDropdownVisibleChange = (visible) => {
|
||||||
setOpen(visible);
|
setOpen(visible);
|
||||||
searchData.current = null;
|
searchData.current = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user