diff --git a/packages/client/src/resource.ts b/packages/client/src/resource.ts index 89b28a0d8..33ec627d8 100644 --- a/packages/client/src/resource.ts +++ b/packages/client/src/resource.ts @@ -156,13 +156,13 @@ export class Resource { static make(options: null | string | Resource | ResourceOptions): Resource | null { if (typeof options === 'string') { - return new Resource({ resourceName: options }); + return new this({ resourceName: options }); } if (options instanceof Resource) { return options; } if (typeof options === 'object' && options.resourceName) { - return new Resource(options); + return new this(options); } console.warn('resource 初始化参数错误'); return null; diff --git a/packages/client/src/schemas/add-new/index.tsx b/packages/client/src/schemas/add-new/index.tsx index bbcad2cf7..0d8982d7c 100644 --- a/packages/client/src/schemas/add-new/index.tsx +++ b/packages/client/src/schemas/add-new/index.tsx @@ -697,7 +697,7 @@ function generateCardItemSchema(component) { }, column3: { type: 'void', - title: '选择数据源', + title: '数据表', 'x-component': 'Table.Column', properties: { 'collection.title': { @@ -782,7 +782,7 @@ function generateCardItemSchema(component) { }, 'collection.title': { type: 'string', - title: '选择数据源', + title: '数据表', 'x-decorator': 'FormItem', 'x-component': 'Input', 'x-read-pretty': true, diff --git a/packages/client/src/schemas/table/index.tsx b/packages/client/src/schemas/table/index.tsx index 9d379291c..f8c7c2492 100644 --- a/packages/client/src/schemas/table/index.tsx +++ b/packages/client/src/schemas/table/index.tsx @@ -44,7 +44,7 @@ import { interfaces, options } from '../database-field/interfaces'; import { DraggableBlockContext } from '../../components/drag-and-drop'; import AddNew from '../add-new'; import { isGridRowOrCol } from '../grid'; -import { Resource } from '../../resource'; +import { ListOptions, Resource } from '../../resource'; import { CollectionProvider, DisplayedMapProvider, @@ -432,7 +432,7 @@ function AddColumn() { const { appendChild, remove } = useDesignable(); const { collection, fields, refresh } = useCollectionContext(); const displayed = useDisplayedMapContext(); - + // const { service } = useTable(); return ( ))} @@ -2317,7 +2318,30 @@ Table.useActionLogDetailsResource = ({ onSuccess }) => { }; const useActionLogsResource = (options: any = {}) => { - const resource = Resource.make('action_logs'); + const { props } = useTable(); + const ctx = useContext(TableRowContext); + + class ActionLogoResource extends Resource { + list(options?: ListOptions) { + console.log({ options }); + let defaultFilter = options?.defaultFilter; + if (ctx?.record) { + const extra = { + index: ctx?.record?.id, + collection_name: props.collectionName, + }; + if (defaultFilter) { + defaultFilter = { and: [defaultFilter, extra] }; + } else { + defaultFilter = extra; + } + } + return super.list({ ...options, defaultFilter }); + } + } + + const resource = ActionLogoResource.make('action_logs'); + return { resource, };