mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 15:26:02 +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) => {
|
export const TableSelectorProvider = (props) => {
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const ctx = useFormBlockContext()
|
const ctx = useFormBlockContext()
|
||||||
const { getCollectionJoinField } = useCollectionManager();
|
const { getCollectionJoinField, getCollectionFields } = useCollectionManager();
|
||||||
const record = useRecord();
|
const record = useRecord();
|
||||||
|
|
||||||
const collectionFieldSchema = recursiveParent(fieldSchema, 'CollectionField');
|
const collectionFieldSchema = recursiveParent(fieldSchema, 'CollectionField');
|
||||||
@ -63,7 +63,6 @@ export const TableSelectorProvider = (props) => {
|
|||||||
if (appends?.length) {
|
if (appends?.length) {
|
||||||
params['appends'] = appends;
|
params['appends'] = appends;
|
||||||
}
|
}
|
||||||
console.log('record', record);
|
|
||||||
if (collectionField) {
|
if (collectionField) {
|
||||||
if (['oho', 'o2m'].includes(collectionField.interface)) {
|
if (['oho', 'o2m'].includes(collectionField.interface)) {
|
||||||
if (record?.[collectionField.sourceKey]) {
|
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 (
|
return (
|
||||||
<BlockProvider {...props} params={params}>
|
<BlockProvider {...props} params={params}>
|
||||||
|
@ -37,6 +37,7 @@ const useTableColumns = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
const dataIndex = collectionFields?.length > 0 ? collectionFields[0].name : s.name;
|
const dataIndex = collectionFields?.length > 0 ? collectionFields[0].name : s.name;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: <RecursionField name={s.name} schema={s} onlyRenderSelf />,
|
title: <RecursionField name={s.name} schema={s} onlyRenderSelf />,
|
||||||
dataIndex,
|
dataIndex,
|
||||||
|
Loading…
Reference in New Issue
Block a user