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