mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 11:26:55 +00:00
fix: obo table selector (#613)
Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
parent
2282ec1a2d
commit
ef0d60b683
@ -47,7 +47,7 @@ const recursiveParent = (schema: Schema, component) => {
|
||||
export const TableSelectorProvider = (props) => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const ctx = useFormBlockContext()
|
||||
const { getCollectionJoinField } = useCollectionManager();
|
||||
const { getCollectionJoinField, getCollectionFields } = useCollectionManager();
|
||||
const record = useRecord();
|
||||
|
||||
const collectionFieldSchema = recursiveParent(fieldSchema, 'CollectionField');
|
||||
@ -63,7 +63,6 @@ export const TableSelectorProvider = (props) => {
|
||||
if (appends?.length) {
|
||||
params['appends'] = appends;
|
||||
}
|
||||
console.log('record', record);
|
||||
if (collectionField) {
|
||||
if (['oho', 'o2m'].includes(collectionField.interface)) {
|
||||
if (record?.[collectionField.sourceKey]) {
|
||||
@ -86,8 +85,31 @@ export const TableSelectorProvider = (props) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (['obo'].includes(collectionField.interface)) {
|
||||
// }
|
||||
if (['obo'].includes(collectionField.interface)) {
|
||||
const fields = getCollectionFields(collectionField.target);
|
||||
const targetField = fields.find(f => f.foreignKey && f.foreignKey === collectionField.foreignKey);
|
||||
if (targetField) {
|
||||
if (record?.[collectionField.foreignKey]) {
|
||||
params['filter'] = {
|
||||
$or: [{
|
||||
[`${targetField.name}.${targetField.foreignKey}`]: {
|
||||
$is: null,
|
||||
}
|
||||
}, {
|
||||
[`${targetField.name}.${targetField.foreignKey}`]: {
|
||||
$eq: record?.[collectionField.foreignKey],
|
||||
}
|
||||
}]
|
||||
}
|
||||
} else {
|
||||
params['filter'] = {
|
||||
[`${targetField.name}.${targetField.foreignKey}`]: {
|
||||
$is: null,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<BlockProvider {...props} params={params}>
|
||||
|
@ -37,6 +37,7 @@ const useTableColumns = () => {
|
||||
}
|
||||
}, []);
|
||||
const dataIndex = collectionFields?.length > 0 ? collectionFields[0].name : s.name;
|
||||
|
||||
return {
|
||||
title: <RecursionField name={s.name} schema={s} onlyRenderSelf />,
|
||||
dataIndex,
|
||||
|
Loading…
Reference in New Issue
Block a user