mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
chore: re-org
This commit is contained in:
parent
84d8ccf83b
commit
9f20bc307f
@ -362,7 +362,6 @@ const EventFilterTableDemo: React.FC = (props) => {
|
||||
// 应用 FilterFlow 获取列配置
|
||||
const applyColumnFilter = useCallback(async () => {
|
||||
const context: FilterHandlerContext = {
|
||||
props: {},
|
||||
payload: {
|
||||
hooks: hooks,
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Modal, Form, Input, Select, Switch, InputNumber } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import { EventFlowActionOptions, EventFlowManager } from '../libs/eventflow-manager';
|
||||
import { EventContext } from '../libs/types';
|
||||
import { EventFlowActionOptions } from '@nocobase/client';
|
||||
import { EventContext } from '@nocobase/client';
|
||||
import { SchemaComponent, SchemaComponentProvider } from '@nocobase/client';
|
||||
import { createForm } from '@formily/core';
|
||||
import { ISchema, connect, mapProps, mapReadPretty } from '@formily/react';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Modal, Input } from 'antd';
|
||||
import { EventFlowActionOptions } from '../libs/eventflow-manager';
|
||||
import { EventFlowActionOptions } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { notification, Button, Flex } from 'antd';
|
||||
import { EventFlowActionOptions } from '../libs/eventflow-manager';
|
||||
import { EventFlowActionOptions } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Modal } from 'antd';
|
||||
import { EventFlowActionOptions } from '../libs/eventflow-manager';
|
||||
import { EventFlowActionOptions } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
|
@ -1,50 +0,0 @@
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import { useBlockResource } from '@nocobase/client';
|
||||
import { Spin, Table, Button, Space, Row, Flex } from 'antd';
|
||||
import React, { useMemo } from 'react';
|
||||
import { EventContext } from '../libs/types';
|
||||
import { useAddEventListener, useApplyFilter } from '../libs/hooks';
|
||||
|
||||
const DemoTable = (props) => {
|
||||
const { done, result } = useApplyFilter('core:block:table', { props });
|
||||
const fieldSchema = useFieldSchema();
|
||||
const resource = useBlockResource();
|
||||
|
||||
useAddEventListener('core:block:table:refresh', (ctx: EventContext) => {
|
||||
console.log('core:block:table:refresh', ctx);
|
||||
resource.list();
|
||||
});
|
||||
|
||||
const actionEventContext: EventContext = useMemo(() => {
|
||||
return {
|
||||
source: {
|
||||
uischema: fieldSchema.toJSON(),
|
||||
},
|
||||
};
|
||||
}, [fieldSchema]);
|
||||
|
||||
if (!done) {
|
||||
return <Spin />;
|
||||
}
|
||||
|
||||
const columns = result?.columns || [];
|
||||
const data = result?.data?.data || [];
|
||||
const actions = result?.actions || [];
|
||||
|
||||
return (
|
||||
<Flex vertical style={{ height: result?.height, width: result?.width }}>
|
||||
<Row justify="end" style={{ marginBottom: '16px' }}>
|
||||
<Space>
|
||||
{actions.map((action) => (
|
||||
<Button key={action.label} onClick={async () => await action.handle(actionEventContext)}>
|
||||
{action.label}
|
||||
</Button>
|
||||
))}
|
||||
</Space>
|
||||
</Row>
|
||||
<Table style={{ width: '100%' }} columns={columns} dataSource={data} />
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default DemoTable;
|
@ -1,4 +1,4 @@
|
||||
import { Button, Space, Alert, Card, Divider } from 'antd';
|
||||
import { Button, Space, Card } from 'antd';
|
||||
import { EventBus } from '@nocobase/client';
|
||||
import React, { useState } from 'react';
|
||||
import { openFormDialogAction } from '../actions/open-form-dialog';
|
||||
|
@ -170,7 +170,7 @@ const ConfigurableFilter = () => {
|
||||
try {
|
||||
// 创建FilterFlow上下文
|
||||
const context = {
|
||||
props: {
|
||||
payload: {
|
||||
inputText,
|
||||
},
|
||||
};
|
||||
|
@ -231,7 +231,7 @@ const DataTransformFilterFlow = () => {
|
||||
try {
|
||||
// 创建FilterFlow上下文
|
||||
const context = {
|
||||
props: {},
|
||||
payload: {},
|
||||
};
|
||||
|
||||
// 应用FilterFlow
|
||||
|
@ -130,7 +130,7 @@ const MultiStepFilterFlow = () => {
|
||||
try {
|
||||
// 创建过滤上下文
|
||||
const context = {
|
||||
props: {
|
||||
payload: {
|
||||
inputText,
|
||||
},
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ export interface EventContext<T = any> {
|
||||
event?: string | string[]; // 事件名称, 一个事件是可以触发多个eventflow的,与filterflow不同
|
||||
[key: string]: any;
|
||||
};
|
||||
payload?: T;
|
||||
results?: Record<string, any>;
|
||||
}
|
||||
export interface EventListenerOptions {
|
||||
|
@ -64,14 +64,6 @@ export class FilterFlowStep {
|
||||
return filter?.handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Filter 的 UI Schema
|
||||
*/
|
||||
getUiSchema(): ISchema | undefined {
|
||||
const filter = this.filterFlow.getFilter(this.filterName);
|
||||
return filter?.uiSchema;
|
||||
}
|
||||
|
||||
get(key: string) {
|
||||
return _.get(this.options, key);
|
||||
}
|
||||
@ -91,6 +83,14 @@ export class FilterFlowStep {
|
||||
|
||||
// 可根据需要添加 save 等方法,如果需要持久化步骤配置
|
||||
// async save() { /* ... */ }
|
||||
|
||||
/**
|
||||
* 获取 Filter 的 UI Schema
|
||||
*/
|
||||
private getUiSchema(): ISchema | undefined {
|
||||
const filter = this.filterFlow.getFilter(this.filterName);
|
||||
return filter?.uiSchema;
|
||||
}
|
||||
}
|
||||
|
||||
export class FilterFlow {
|
||||
|
Loading…
x
Reference in New Issue
Block a user