feat(client): improve sub table
This commit is contained in:
parent
b354313c0e
commit
5785f30075
@ -22,9 +22,9 @@ export const input: IField = {
|
||||
operators: [
|
||||
{ label: '{{t("contains")}}', value: '$includes', selected: true },
|
||||
{ label: '{{t("does not contain")}}', value: '$notIncludes' },
|
||||
{ label: '{{t("is")}}', value: 'eq' },
|
||||
{ label: '{{t("is not")}}', value: 'ne' },
|
||||
{ label: '{{t("is empty")}}', value: '$null', noValue: true },
|
||||
{ label: '{{t("is not empty")}}', value: '$notNull', noValue: true },
|
||||
{ label: '{{t("is")}}', value: '$eq' },
|
||||
{ label: '{{t("is not")}}', value: '$ne' },
|
||||
{ label: '{{t("is empty")}}', value: '$empty', noValue: true },
|
||||
{ label: '{{t("is not empty")}}', value: '$notEmpty', noValue: true },
|
||||
],
|
||||
};
|
||||
|
@ -1,7 +1,15 @@
|
||||
import { observer, useForm } from '@formily/react';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import React, { createContext, useContext, useState } from 'react';
|
||||
import { CollectionOptions, CollectionProvider, useActionContext, useRecord, useRecordIndex, useRequest } from '../';
|
||||
import {
|
||||
CollectionOptions,
|
||||
CollectionProvider,
|
||||
useActionContext,
|
||||
useCollectionManager,
|
||||
useRecord,
|
||||
useRecordIndex,
|
||||
useRequest
|
||||
} from '../';
|
||||
import { useAPIClient } from '../api-client';
|
||||
import { options } from './Configuration/interfaces';
|
||||
|
||||
@ -219,16 +227,20 @@ export const DataSourceProvider = observer((props: any) => {
|
||||
const [dataSource, setDataSource] = useState([]);
|
||||
const record = useRecord();
|
||||
const api = useAPIClient();
|
||||
const { getCollection } = useCollectionManager();
|
||||
const coll = getCollection(collection);
|
||||
const resourceOf = record?.[association.targetKey || 'id'];
|
||||
console.log('record', record);
|
||||
const service = useRequest(
|
||||
() => {
|
||||
if (resourceOf) {
|
||||
return api
|
||||
.request({
|
||||
resource: `${collection}.${association.name}`,
|
||||
resource: `${association.collectionName}.${association.name}`,
|
||||
resourceOf,
|
||||
action: 'list',
|
||||
params: {
|
||||
appends: coll?.fields?.filter((field) => field.target)?.map((field) => field.name),
|
||||
},
|
||||
})
|
||||
.then((res) => res.data);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ export const SubTableFieldInitializer = (props) => {
|
||||
'x-component-props': {
|
||||
collection: item?.field?.target,
|
||||
association: {
|
||||
collectionName: item.field.collectionName,
|
||||
name: item.field.name,
|
||||
sourceKey: item.field.sourceKey,
|
||||
targetKey: item.field.targetKey,
|
||||
|
Loading…
Reference in New Issue
Block a user