Merge pull request 'fix: 修改自动补全筛选失效问题' (#394) from fix_multipleSelect into @hera/dev
Reviewed-on: daoyoucloud/tachycode#394 Reviewed-by: sealday <zhanglin@daoyoucloud.com>
This commit is contained in:
commit
ee82c00a64
@ -8,7 +8,6 @@ export const AutoComplete = (props) => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { fieldNames } = fieldSchema['x-component-props'];
|
||||
const fieldFilter = fieldSchema['x-component-props']['params'];
|
||||
const filter = fieldFilter ? JSON.stringify(fieldFilter.filter) : {};
|
||||
const [defultValue, setDefultValue] = useState([]);
|
||||
const api = useAPIClient();
|
||||
const [options, setOptions] = useState([]);
|
||||
@ -24,7 +23,7 @@ export const AutoComplete = (props) => {
|
||||
},
|
||||
});
|
||||
changLable(defultOptions?.data?.data);
|
||||
}, [filter]);
|
||||
}, [fieldFilter?.filter]);
|
||||
|
||||
useEffect(() => {
|
||||
changLable(defultValue);
|
||||
@ -45,7 +44,7 @@ export const AutoComplete = (props) => {
|
||||
}
|
||||
const onSearch = (data) => {
|
||||
if (data) {
|
||||
const searchValue = defultValue.filter((item) => item[fieldNames.label].includes(data));
|
||||
const searchValue = defultValue.filter((item) => item.label.includes(data));
|
||||
if (searchValue.length) {
|
||||
setOptions(searchValue);
|
||||
} else {
|
||||
|
@ -26,7 +26,6 @@ const ObjectSelect = (props: Props) => {
|
||||
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) {
|
||||
@ -39,7 +38,7 @@ const ObjectSelect = (props: Props) => {
|
||||
});
|
||||
setDefOptions(defValue?.data?.data);
|
||||
}
|
||||
}, [filter]);
|
||||
}, [filterField?.filter]);
|
||||
const toValue = (v: any) => {
|
||||
if (isEmptyObject(v)) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user