diff --git a/packages/api/src/app.ts b/packages/api/src/app.ts index f73ae28dd..f4e664ceb 100644 --- a/packages/api/src/app.ts +++ b/packages/api/src/app.ts @@ -44,7 +44,7 @@ const plugins = [ '@nocobase/plugin-users', '@nocobase/plugin-action-logs', // '@nocobase/plugin-file-manager', - // '@nocobase/plugin-permissions', + '@nocobase/plugin-permissions', // '@nocobase/plugin-automations', // '@nocobase/plugin-china-region', ]; diff --git a/packages/client/src/components/schema-renderer/index.tsx b/packages/client/src/components/schema-renderer/index.tsx index e061e0c94..66efa2e6b 100644 --- a/packages/client/src/components/schema-renderer/index.tsx +++ b/packages/client/src/components/schema-renderer/index.tsx @@ -53,6 +53,7 @@ import { TreeSelect } from '../../schemas/tree-select'; import { Page } from '../../schemas/page'; import { Chart } from '../../schemas/chart'; import { useDesignableSwitchContext } from '../../constate/DesignableSwitch'; +import { action } from '@formily/reactive'; export const BlockContext = createContext({ dragRef: null }); @@ -63,9 +64,20 @@ interface DesignableContextProps { refresh?: any; } +export const useAsyncDataSource = (service: any) => (field: any) => { + field.loading = true; + service(field).then( + action((data: any) => { + field.dataSource = data; + field.loading = false; + }), + ); +}; + export const SchemaField = createSchemaField({ scope: { Table, + useAsyncDataSource, }, components: { Card, diff --git a/packages/client/src/resource.ts b/packages/client/src/resource.ts index 08f14b3d8..4da25cfb5 100644 --- a/packages/client/src/resource.ts +++ b/packages/client/src/resource.ts @@ -50,8 +50,12 @@ export class Resource { list(options: ListOptions = {}) { const { defaultAppends = [], appends = [], defaultFilter, filter, ...others } = options; - const { resourceName } = this.options; - return request(`${resourceName}:list`, { + const { associatedKey, associatedName, resourceName } = this.options; + let url = `${resourceName}:list`; + if (associatedName && associatedKey) { + url = `${associatedName}/${associatedKey}/${resourceName}:list`; + } + return request(url, { method: 'get', params: { filter: decodeURIComponent(JSON.stringify({ and: [defaultFilter, filter].filter(Boolean) })), diff --git a/packages/client/src/schemas/form/index.tsx b/packages/client/src/schemas/form/index.tsx index b5af76faf..5050cc72b 100644 --- a/packages/client/src/schemas/form/index.tsx +++ b/packages/client/src/schemas/form/index.tsx @@ -68,6 +68,7 @@ const FormMain = (props: any) => { }); const path = useSchemaPath(); const scope = useContext(SchemaExpressionScopeContext); + const options = useContext(SchemaOptionsContext); const displayed = useDisplayedMapContext(); const { collection } = useCollectionContext(); useEffect(() => { @@ -81,6 +82,7 @@ const FormMain = (props: any) => { {schema['x-decorator'] === 'Form' ? ( ({} as any); -const TableRowContext = createContext(null); +export const TableRowContext = createContext(null); const CollectionFieldContext = createContext(null); -const useTable = () => { +export const useTable = () => { return useContext(TableContext); }; @@ -364,6 +364,7 @@ const useTableColumns = () => { if ( designable && + schema['x-designable-bar'] && schema['x-designable-bar'] !== 'Table.SimpleDesignableBar' ) { columns.push({