feat: add ActionLogs block

This commit is contained in:
chenos 2021-08-07 23:22:30 +08:00
parent c34d82d180
commit 1ab7d544b3
4 changed files with 187 additions and 12 deletions

View File

@ -41,9 +41,8 @@ const plugins = [
'@nocobase/plugin-collections', '@nocobase/plugin-collections',
'@nocobase/plugin-ui-router', '@nocobase/plugin-ui-router',
'@nocobase/plugin-ui-schema', '@nocobase/plugin-ui-schema',
// '@nocobase/plugin-action-logs',
// '@nocobase/plugin-pages',
'@nocobase/plugin-users', '@nocobase/plugin-users',
'@nocobase/plugin-action-logs',
// '@nocobase/plugin-file-manager', // '@nocobase/plugin-file-manager',
// '@nocobase/plugin-permissions', // '@nocobase/plugin-permissions',
// '@nocobase/plugin-automations', // '@nocobase/plugin-automations',

View File

@ -384,6 +384,150 @@ function generateCardItemSchema(component) {
config: cloneDeep(barChartConfig), config: cloneDeep(barChartConfig),
}, },
}, },
'Ref.ActionLogs': {
type: 'array',
name: 'table',
'x-decorator': 'CardItem',
'x-component': 'Table',
default: [],
'x-component-props': {
useResource: '{{ Table.useActionLogsResource }}',
collectionName: 'action_logs',
rowKey: 'id',
// dragSort: true,
showIndex: true,
refreshRequestOnChange: true,
pagination: {
pageSize: 10,
},
},
properties: {
[uid()]: {
type: 'void',
'x-component': 'Table.ActionBar',
properties: {
[uid()]: {
type: 'void',
title: '筛选',
'x-align': 'left',
'x-component': 'Table.Filter',
'x-component-props': {
fieldNames: [],
},
},
},
},
[uid()]: {
type: 'void',
title: '操作',
'x-component': 'Table.Operation',
'x-component-props': {
className: 'nb-table-operation',
},
properties: {
[uid()]: {
type: 'void',
'x-component': 'Action',
'x-component-props': {
icon: 'EllipsisOutlined',
},
properties: {
[uid()]: {
type: 'void',
'x-component': 'Action.Dropdown',
'x-component-props': {},
properties: {
[uid()]: {
type: 'void',
name: 'action1',
title: '查看',
'x-component': 'Menu.Action',
'x-component-props': {
style: {
minWidth: 150,
},
},
'x-action-type': 'view',
properties: {
[uid()]: {
type: 'void',
title: '查看',
'x-component': 'Action.Drawer',
'x-component-props': {
bodyStyle: {
background: '#f0f2f5',
// paddingTop: 0,
},
},
properties: {
[uid()]: {
type: 'void',
'x-component': 'Tabs',
'x-component-props': {
singleton: true,
},
properties: {
[uid()]: {
type: 'void',
title: '详情',
'x-component': 'Tabs.TabPane',
'x-component-props': {},
properties: {
[uid()]: {
type: 'void',
'x-component': 'Grid',
'x-component-props': {
// addNewComponent: 'AddNew.PaneItem',
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
column1: {
type: 'void',
title: '创建时间',
'x-component': 'Table.Column',
properties: {
created_at: {
type: 'string',
'x-component': 'DatePicker',
'x-read-pretty': true,
'x-component-props': {
format: 'YYYY-MM-DD HH:mm:ss',
},
},
},
},
column2: {
type: 'void',
title: '操作类型',
'x-component': 'Table.Column',
properties: {
type: {
type: 'string',
'x-component': 'Select',
'x-read-pretty': true,
enum: [
{ label: '新增数据', value: 'create' },
{ label: '更新数据', value: 'update' },
{ label: '删除数据', value: 'destroy' },
],
},
},
},
},
},
}; };
return defaults[component]; return defaults[component];
} }
@ -602,12 +746,12 @@ AddNew.CardItem = observer((props: any) => {
</Menu.Item> </Menu.Item>
</Menu.ItemGroup> </Menu.ItemGroup>
<Menu.Divider /> <Menu.Divider />
<Menu.SubMenu disabled key={'Ref'} title={'引用模板'}> <Menu.SubMenu key={'Ref'} title={'引用模板'}>
<Menu.ItemGroup key={'form-select'} title={'选择模板'}> <Menu.ItemGroup key={'form-select'} title={'选择模板'}>
<Menu.Item key={'Ref.name1'}>1</Menu.Item> <Menu.Item key={'Ref.ActionLogs'}></Menu.Item>
</Menu.ItemGroup> </Menu.ItemGroup>
<Menu.Divider></Menu.Divider> <Menu.Divider></Menu.Divider>
<Menu.Item key={'addNewRef'}></Menu.Item> <Menu.Item disabled key={'addNewRef'}></Menu.Item>
</Menu.SubMenu> </Menu.SubMenu>
</Menu> </Menu>
} }
@ -934,12 +1078,34 @@ AddNew.PaneItem = observer((props: any) => {
<Menu.Item <Menu.Item
style={{ minWidth: 150 }} style={{ minWidth: 150 }}
icon={<IconPicker type={'HistoryOutlined'} />} icon={<IconPicker type={'HistoryOutlined'} />}
onClick={async () => {
let data: ISchema = generateCardItemSchema('Ref.ActionLogs');
if (isGridBlock(schema)) {
path.pop();
path.pop();
data = generateGridBlock(data);
} else if (isGrid(schema)) {
data = generateGridBlock(data);
}
if (data) {
let s;
if (isGrid(schema)) {
s = appendChild(data, [...path]);
} else if (defaultAction === 'insertAfter') {
s = insertAfter(data, [...path]);
} else {
s = insertBefore(data, [...path]);
}
await createSchema(s);
}
setVisible(false);
}}
> >
</Menu.Item> </Menu.Item>
<Menu.Item icon={<IconPicker type={'CommentOutlined'} />}> {/* <Menu.Item icon={<IconPicker type={'CommentOutlined'} />}>
</Menu.Item> </Menu.Item> */}
</Menu.ItemGroup> </Menu.ItemGroup>
<Menu.ItemGroup title={'多媒体区块'}> <Menu.ItemGroup title={'多媒体区块'}>
<Menu.Item <Menu.Item

View File

@ -361,7 +361,7 @@ const useTableColumns = () => {
}), }),
); );
if (designable) { if (designable && schema['x-designable-bar']) {
columns.push({ columns.push({
title: <AddColumn />, title: <AddColumn />,
dataIndex: 'addnew', dataIndex: 'addnew',
@ -972,7 +972,7 @@ function AddActionButton() {
const displayed = useDisplayedMapContext(); const displayed = useDisplayedMapContext();
const { appendChild, remove } = useDesignable(); const { appendChild, remove } = useDesignable();
const { schema, designable } = useDesignable(); const { schema, designable } = useDesignable();
if (!designable) { if (!designable || !schema['x-designable-bar']) {
return null; return null;
} }
return ( return (
@ -1385,12 +1385,14 @@ Table.Filter.DesignableBar = () => {
}; };
Table.Operation = observer((props: any) => { Table.Operation = observer((props: any) => {
const { designable } = useDesignable(); const { designable, schema } = useDesignable();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
return ( return (
<div className={'nb-table-column'}> <div className={'nb-table-column'}>
{designable && <Table.Operation.DesignableBar path={props.path} />} {designable && schema['x-designable-bar'] && (
<Table.Operation.DesignableBar path={props.path} />
)}
</div> </div>
); );
}); });
@ -2035,6 +2037,14 @@ Table.useResource = ({ onSuccess }) => {
return { resource, service, initialValues: service.data, ...service }; return { resource, service, initialValues: service.data, ...service };
}; };
const useActionLogsResource = (options: any = {}) => {
const resource = Resource.make('action_logs');
return {
resource,
};
};
Table.useActionLogsResource = useActionLogsResource;
Table.useTableFilterAction = useTableFilterAction; Table.useTableFilterAction = useTableFilterAction;
Table.useTableCreateAction = useTableCreateAction; Table.useTableCreateAction = useTableCreateAction;
Table.useTableUpdateAction = useTableUpdateAction; Table.useTableUpdateAction = useTableUpdateAction;

View File

@ -104,7 +104,7 @@ export const Tabs: any = observer((props: any) => {
{...others} {...others}
className={cls({ singleton })} className={cls({ singleton })}
tabBarExtraContent={ tabBarExtraContent={
designable && ( designable && schema['x-designable-bar'] && (
<Button <Button
type={'dashed'} type={'dashed'}
icon={<PlusOutlined />} icon={<PlusOutlined />}