mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
ba89bcd4b4
@ -7,7 +7,7 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useState, useContext } from 'react';
|
import React, { useState, useContext, useEffect } from 'react';
|
||||||
import { RecordPickerProvider, RecordPickerContext } from '../../../schema-component/antd/record-picker';
|
import { RecordPickerProvider, RecordPickerContext } from '../../../schema-component/antd/record-picker';
|
||||||
import {
|
import {
|
||||||
SchemaComponentOptions,
|
SchemaComponentOptions,
|
||||||
@ -41,9 +41,16 @@ const useTableSelectorProps = () => {
|
|||||||
export const AssociateActionProvider = (props) => {
|
export const AssociateActionProvider = (props) => {
|
||||||
const [selectedRows, setSelectedRows] = useState([]);
|
const [selectedRows, setSelectedRows] = useState([]);
|
||||||
const collection = useCollection();
|
const collection = useCollection();
|
||||||
const { resource, service, block, __parent } = useBlockRequestContext();
|
const { resource, block, __parent } = useBlockRequestContext();
|
||||||
const actionCtx = useActionContext();
|
const actionCtx = useActionContext();
|
||||||
const { isMobile } = useOpenModeContext() || {};
|
const { isMobile } = useOpenModeContext() || {};
|
||||||
|
const [associationData, setAssociationData] = useState([]);
|
||||||
|
useEffect(() => {
|
||||||
|
resource?.list?.().then((res) => {
|
||||||
|
setAssociationData(res.data?.data || []);
|
||||||
|
});
|
||||||
|
}, [resource]);
|
||||||
|
|
||||||
const pickerProps = {
|
const pickerProps = {
|
||||||
size: 'small',
|
size: 'small',
|
||||||
onChange: props?.onChange,
|
onChange: props?.onChange,
|
||||||
@ -73,8 +80,8 @@ export const AssociateActionProvider = (props) => {
|
|||||||
};
|
};
|
||||||
const getFilter = () => {
|
const getFilter = () => {
|
||||||
const targetKey = collection?.filterTargetKey || 'id';
|
const targetKey = collection?.filterTargetKey || 'id';
|
||||||
if (service.data?.data) {
|
if (associationData) {
|
||||||
const list = service.data?.data.map((option) => option[targetKey]).filter(Boolean);
|
const list = associationData.map((option) => option[targetKey]).filter(Boolean);
|
||||||
const filter = list.length ? { $and: [{ [`${targetKey}.$ne`]: list }] } : {};
|
const filter = list.length ? { $and: [{ [`${targetKey}.$ne`]: list }] } : {};
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user